diff options
Diffstat (limited to 'libterm/examples/readline.c')
-rw-r--r-- | libterm/examples/readline.c | 40 |
1 files changed, 40 insertions, 0 deletions
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 |