diff options
Diffstat (limited to 'libterm/examples')
-rw-r--r-- | libterm/examples/Makefile | 3 | ||||
-rw-r--r-- | libterm/examples/readline.c | 40 |
2 files changed, 42 insertions, 1 deletions
diff --git a/libterm/examples/Makefile b/libterm/examples/Makefile index 00583f8..ffc3d1d 100644 --- a/libterm/examples/Makefile +++ b/libterm/examples/Makefile @@ -1,6 +1,7 @@ CC=gcc CFLAGS=-I../ ../libterm.o -SOURCES=detect_resize.c detect_screen_size.c filtered_input.c invisible_input.c restore_screen.c print_8025.c +SOURCES=detect_resize.c detect_screen_size.c filtered_input.c invisible_input.c \ +readline.c restore_screen.c print_8025.c EXE=$(SOURCES:.c=) BUILD_DIR=. diff --git a/libterm/examples/readline.c b/libterm/examples/readline.c new file mode 100644 index 0000000..cd4467d --- /dev/null +++ b/libterm/examples/readline.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <term.h> +#include <term_io.h> + +int main() +{ + + const int sz = 31; + char name[sz]; + char passsword[sz]; + + 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 ); + + term_cur_set_c( &ts, 0); + term_cur_set_r( &ts, 1 ); + term_readline( &ts, name, sz, READLINE_TEXT ); + + term_cur_set_c( &ts, 0 ); + term_cur_set_r( &ts, 2 ); + term_readline( &ts, passsword, sz, READLINE_HIDDEN ); + + + term_clr_scr( &ts ); + + term_set_orig_mode( &ts ); + + printf("Name:%s\n", name); + printf("passsword:%s\n", passsword ); + + return 0; +}
\ No newline at end of file |