summaryrefslogtreecommitdiff
path: root/libterm/term_io.c
blob: 5ef682b9b7a79afc1c359c1f00e1d052804865b3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "term_io.h"

int term_fprint( screen_mode_e mode, FILE *f )
{
	int ret=-1;
	if (f == NULL)
		return -1;
	
	ERROR("\n");
	switch ( mode )
	{
		case SCREEN_MODE_80x25:
			{
			}
			break;
		default:
			printf("Unknown screen mode\n");
	}
	
	return ret;
}

int term_print( term_screen *ts, const char *s, size_t n)
{
	int ret=0;

	if ( ts == NULL )
		return -1;

	if ( s == NULL )
		return -1;

	if ( n < 1 )
		return -1;

	if ( n > 80*25 )
		return -1;

	ret = write( ts->ofd, s, n );

	return ret;
}

//print data to terminal starting from x,y
int term_print_xy( term_screen *ts, const char *buf, size_t size, 
	int init_column, int init_row )
{
	int ret=-1;
	if ( buf == NULL )
	{
		return -1;
	}

	if ( size <= 0 )
	{
		return -1;
	}

	switch ( ts->mode )
	{
		case SCREEN_MODE_80x25:
			{
				
			}
			break;
		default:
			printf("Unknown mode\n");
	}

	return ret;
}

int term_draw_hline( term_screen *ts, int pc, int pr, const int sz, char ch)
{
	int ret=0;
	char buf[sz]; memset( buf, ch, sz );

	if ( sz > 0)
	{
		term_cur_set_c( ts, pc );
		term_cur_set_r( ts, pr );
		write( ts->ofd, buf, sz );
	} else
	{
		ret = -1;
	}

	return ret;
}

//read one character from stream
int term_getc( term_screen *ts )
{
	int ret=-1;
	int fret=-1;
	char buf;

	fret = read( ts->ifd, &buf, 1 );
	if ( fret == 1 )
		ret = buf;

	return ret;
}