#include #include #include int main() { int c; int new_c=0, new_r=0, old_r=0, old_c=0; const int in_size = 32; int counter=0; char in_buf[in_size]; 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 ); new_c = term_get_maxcol( &ts ); new_r = term_get_maxrow( &ts ); old_r = new_r; old_c = new_c; memset( in_buf, 0, in_size ); term_cur_set_c( &ts, 0); term_cur_set_r( &ts, old_r); printf("Your name is?: %s", in_buf); while ( (c = getchar() ) != 13 ) { if ( isalpha(c) ) { if ( counter < in_size-1 ) { in_buf[counter] = c; counter++; } } else if ( c == 127 ) { if ( counter > 0) { in_buf[counter-1] = 0x0; counter--; } } else printf("%d",c); term_clr_scr( &ts ); new_r = term_get_maxrow( &ts ); if ( old_r != new_r ) old_r = new_r; term_cur_set_c( &ts, 0); term_cur_set_r( &ts, old_r); printf("Your name is?: %s", in_buf); } term_clr_scr( &ts ); term_set_orig_mode( &ts ); return 0; }