diff options
Diffstat (limited to 'todo.c')
-rw-r--r-- | todo.c | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -6,14 +6,11 @@ int bbs_todo( term_screen *ts, const char *fname) { int ret=0; - int ret_len; - size_t in_size=0; - char *in_buf=NULL; int quit_loop=0; int menu_input = 0; char menu_cmd = 0; int row = 0; - char *todo_fname = NULL; + const char *todo_fname = NULL; if ( ts == NULL ) return ret; @@ -59,7 +56,7 @@ int bbs_todo( term_screen *ts, const char *fname) { term_clr_scr( ts ); term_cur_set_c( ts, 0 ); - printf("(A)dd,(Q)uit"); fflush( stdout ); + term_printf( ts, "(A)dd,(R)emove,(Q)uit"); //dispaly todo list row = term_get_maxrow( ts ); @@ -71,7 +68,7 @@ int bbs_todo( term_screen *ts, const char *fname) { term_cur_set_c( ts, 0 ); term_cur_set_r( ts, 1+cnt ); - printf( "[%02d] -> %s\n", cnt, (char *)iter->val); + term_printf( ts, "[%02d] -> %s\n", cnt, (char *)iter->val); cnt += 1; iter = iter->next; } @@ -80,7 +77,7 @@ int bbs_todo( term_screen *ts, const char *fname) term_cur_set_c( ts, 0 ); term_cur_set_r( ts, term_get_maxrow( ts ) ); - printf(":"); fflush( stdout ); + term_printf( ts, ":"); menu_input = term_getc( ts ); //if something whent wrong dont know why, need to get some test case @@ -107,15 +104,22 @@ int bbs_todo( term_screen *ts, const char *fname) int cnt = 1; while (iter != NULL) { - printf( "[%02d] -> %s\n", cnt, (char *)iter->val); + term_printf( ts, "[%02d] -> %s\n", cnt, (char *)iter->val); cnt += 1; iter = iter->next; } } break; + case 'r': + case 'R': + { + bbs_todo_remove( ts, todo_list, todo_fname ); + } + break; + default: - printf("Try more\n"); + term_printf( ts, "Try more\n"); } } @@ -140,11 +144,11 @@ int bbs_todo_add( term_screen *ts, List *todo, const char *fname) term_clr_scr( ts ); term_cur_set_c( ts, 0 ); term_cur_set_r( ts, 0 ); - printf("Add new todo task:\n"); fflush( stdout ); + term_printf( ts, "Add new todo task:\n"); memset( buf, 0, buf_size ); term_cur_set_c( ts, 0 ); - fret = term_readline( ts, buf, buf_size, READLINE_ALPHA ); + fret = term_readline( ts, buf, buf_size, READLINE_TEXT ); if ( fret > 0 ) { char *l = malloc( fret+1 ); @@ -177,7 +181,9 @@ int bbs_todo_remove( term_screen *ts, List *todo, const char *fname ) term_clr_scr( ts ); term_cur_set_c( ts, 0 ); term_cur_set_r( ts, 0 ); - printf("Remove entry from todo:\n"); fflush( stdout ); + term_printf( ts, "Remove entry from todo:\n"); + + return ret; |