static void resize_abook() { #ifdef TIOCGWINSZ struct winsize winsz; ioctl(0, TIOCGWINSZ, &winsz); #ifdef DEBUG if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) { fprintf(stderr, "Warning: COLS=%d, LINES=%d\n", winsz.ws_col, winsz.ws_row); } #endif if(winsz.ws_col >= MIN_COLS && winsz.ws_row >= MIN_LINES) { #ifdef HAVE_RESIZETERM resizeterm(winsz.ws_row, winsz.ws_col); #else COLS = winsz.ws_col; LINES = winsz.ws_row; #endif } should_resize = FALSE; close_list(); /* we need to recreate windows */ init_list(); free_windows(); init_windows(); refresh_screen(); refresh(); #endif /* TIOCGWINSZ */ }
void close_list(node* list) { if(list->next) close_list(list->next); free(list); return; }
void close_ui() { close_list(); free_windows(); clear(); refresh(); endwin(); ui_initialized = FALSE; }
int main (void) { node* init=NULL; node* a[16]; init=create_node("",""); a[0]=create_node("aaa","あああ"); a[1]=create_node("bbb","いいい"); concat_list(a[0],init); concat_list(a[1],init); printf("%-16s\t%-8s\t%-8s\t%-16s\n", "アドレス","eng","jpn","next"); print_list(init); close_list(init); return 0; }
int main () { char line[40], *str, cmd, last_cmd = 0; if (!(ld = open_list ())) { fprintf (stderr, "Error opening List\n"); exit (1); } printf ("Type \'-?\' or \'-h\' for Help contents\n"); while (1) { printf ("list> "); fgets (line, 40, stdin); for (str = line; *str == ' ' || *str == '\t'; str++) ; str[strchr (str, '\n') - str] = '\0'; switch (*str) { case '\0' : continue; default : append (ld, str); break; case '.' : cmd = last_cmd; case '-' : if (*str != '.') cmd = last_cmd = *++str; switch (cmd) { default : fprintf (stderr, "Invalid Command\n"); continue; case '?' : case 'h' : case 'H' : printf ("Type any name to add to list\n" "-r<name> to remove from list\n" "\'-d\' to display all list items\n" "\'-f\' to print the first item in list\n" "\'-l\' to print the last item in list\n" "\'-n\' to print the next list item\n" "\'-p\' to print the previous list item\n" "\'.\' to repeat last command\n" //"\'-s\' to sort list items\n" "\'-e\' to exit\n"); break; case 'd' : case 'D' : print_list (ld); break; case 'f' : case 'F' : if (read_first (ld, str)) PRINT_MSG case 'l' : case 'L' : if (read_last (ld, str)) PRINT_MSG case 'n' : case 'N' : if (read_next (ld, str)) PRINT_MSG case 'p' : case 'P' : if (read_prev (ld, str)) PRINT_MSG case 'r' : case 'R' : if (delete (ld, ++str)) { fprintf (stderr, "%s not on list\n", str); continue; } else printf ("%s removed\n", str); break; case 'e' : case 'E' : print_list (ld); close_list (ld); printf ("===> End of App <===\n"); exit (0); } } } }