diff options
author | FreeArtMan <dos21h@gmail.com> | 2015-01-07 21:00:59 +0900 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2015-01-07 21:00:59 +0900 |
commit | 03e459e7dff84c44644b1eccc0e00b73d846fe2a (patch) | |
tree | 00269e56bdf53906396199e22dcabe8bbee9592f /libterm/examples/detect_resize.c | |
parent | 0ab31d63699467d72f09327171b735ed2152bf2c (diff) | |
download | microbbs-03e459e7dff84c44644b1eccc0e00b73d846fe2a.tar.gz microbbs-03e459e7dff84c44644b1eccc0e00b73d846fe2a.zip |
Small fixes about loging and libterm
Diffstat (limited to 'libterm/examples/detect_resize.c')
-rw-r--r-- | libterm/examples/detect_resize.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/libterm/examples/detect_resize.c b/libterm/examples/detect_resize.c new file mode 100644 index 0000000..27c88c6 --- /dev/null +++ b/libterm/examples/detect_resize.c @@ -0,0 +1,63 @@ +#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_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; +}
\ No newline at end of file |