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
|
#include <stdio.h>
#include <stdlib.h>
#include <term.h>
int main()
{
int c;
int max_r, max_c;
struct term_screen ts; memset( &ts, 0, sizeof(ts) );
if ( term_init( &ts ) == -1 )
printf("Some err when init\n");
term_set_raw_mode( &ts );
term_clr_scr( &ts );
{
char buf[32];
int c;
c = term_get_maxcol( &ts );
snprintf( buf, 32, "MaxCol:%d\n", c );
write( ts.ofd, buf, strlen(buf) );
}
{
char buf[32];
int r;
r = term_get_maxrow( &ts );
snprintf( buf, 32, "MaxRow:%d\n", r );
write( ts.ofd, buf, strlen(buf) );
}
while ( (c = getchar() ) != 'q' )
{
term_clr_scr( &ts );
{
char buf[32];
max_c = term_get_maxcol( &ts );
snprintf( buf, 32, "MaxCol:%d\n", max_c );
write( ts.ofd, buf, strlen(buf) );
}
{
char buf[32];
max_r = term_get_maxrow( &ts );
snprintf( buf, 32, "MaxRow:%d\n", max_r );
write( ts.ofd, buf, strlen(buf) );
}
{
term_cur_set_r( &ts, max_r );
term_cur_set_c( &ts, max_c );
printf("+");
}
}
term_clr_scr( &ts );
term_set_orig_mode( &ts );
return 0;
}
|