static int lines_required_for_detailed(void) { if (get_current_item()) return 2 + ((get_current_item()->i_nattrs + 1) / 2); else return INT_MAX; }
void menu_set(menu_t *menu) { menupage_t *page = menu->current_page; menuitem_t *item = get_current_item(page); if (item && item->action) item->action(item); }
void menu_params_rename (menu_t *menu) { menupage_t *page = menu->current_page; menuitem_t *item = get_current_item(page); rename_create(named_temps.names[item->id]); beep(); }
static void draw_detailed(void) { int start_pos, end_pos, i; item_t *intf; int attr_flag = 0; intf = get_current_item(); if (NULL == intf) return; move(row, 39); addch(ACS_TTEE); move(row, 0); NEXT_ROW; start_pos = row; putl(" RX TX " \ " RX TX"); foreach_attr(intf, draw_attr_detail, &attr_flag); end_pos = row; for (i = start_pos; i <= end_pos; i++) { move(i, 39); addch(ACS_VLINE); } move(end_pos, 0); }
static int lines_required_for_graphical(void) { item_t *it; if ((it = get_current_item())) return get_ngraphs() * ((2 * c_graph_height) + 5); else return INT_MAX; }
void menu_repeat_left(menu_t *menu, const int repeating) { menupage_t *page = menu->current_page; menuitem_t *item = get_current_item(page); if (item && !item->readonly && item->dec) { item->dec(item, repeating); if (item->change) item->change(item); menu->changed = true; menu_event_refresh(); } }
static void draw_graphic(void) { int i; for (i = 0; i < get_ngraphs(); i++) { stat_attr_hist_t *a = (stat_attr_hist_t *) current_attr(i); if (!(a->a_flags & ATTR_FLAG_HISTORY)) continue; if (a) __draw_graphic(a, get_current_item()->i_graph_sel == i, get_current_item()->i_unit[i]); if (i < (get_ngraphs() - 1)) { int n; NEXT_ROW; for (n = 1; n < cols-1; n += 2) mvaddch(row, n, ACS_HLINE); } } }
static void fold(void) { item_t *intf = get_current_item(); node_t *node = get_current_node(); int fix = 0; if (NULL == intf || NULL == node) return; if (intf->i_flags & ITEM_FLAG_IS_CHILD) fix = 1; while (intf->i_flags & ITEM_FLAG_IS_CHILD) intf = get_item(node, intf->i_parent); if (intf->i_flags & ITEM_FLAG_FOLDED) intf->i_flags &= ~ITEM_FLAG_FOLDED; else intf->i_flags |= ITEM_FLAG_FOLDED; if (fix) prev_item(); }
int main (int argc, char *argv[]) { vc_component *v = NULL; fpos_t *fpos = NULL; long pos = 0; FILE *fp = NULL; ITEM *it = NULL; int entry_number = 0; bool done = FALSE; int win_state = WINDOW_INDEX; int command = 0; set_defaults (); process_command_line_args (argc, argv); /* * process_environment_variables(); * process_configuration_file(); */ signal (SIGINT, finish); /* catch interrupt for exiting */ signal (SIGWINCH, resize); /* catch interrupt for resizing */ initscr (); keypad (stdscr, TRUE); /* enable keypad for use of arrow keys */ nonl (); /* tell curses not to do NL->CR/NL on output */ cbreak (); /* take input chars immediately */ noecho (); init_index (data_path); set_index_help_fcn (show_index_help); init_view (); set_view_help_fcn (show_view_help); init_edit (); set_edit_help_fcn (show_edit_help); init_help (); while (!done) { switch (win_state) { case WINDOW_INDEX: /*------------------- display the index -------------------*/ display_index (); command = process_index_commands (); switch (command) { case INDEX_COMMAND_VIEW: win_state = WINDOW_VIEW; break; case INDEX_COMMAND_RAW_VIEW: win_state = WINDOW_RAW_VIEW; break; case INDEX_COMMAND_EDIT: win_state = WINDOW_EDIT; break; case INDEX_COMMAND_ADD: win_state = WINDOW_ADD; break; case INDEX_COMMAND_DELETE: win_state = WINDOW_DELETE; break; case INDEX_COMMAND_QUIT: done = TRUE; break; default: break; } break; case WINDOW_RAW_VIEW: /*------------------------------------------------- view the currently selected item with the pager -------------------------------------------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL == it) { v = NULL; } else { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); v = parse_vcard_file (fp); fclose (fp); } if (v != NULL) { raw_view (v); vc_delete_deep (v); v = NULL; } win_state = WINDOW_INDEX; break; case WINDOW_VIEW: /*---------------------------------- view the currently selected item ----------------------------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL == it) { v = NULL; } else { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); v = parse_vcard_file (fp); fclose (fp); } if (v != NULL) { entry_number = get_entry_number (it); view_vcard (entry_number, v); command = process_view_commands (); switch (command) { case VIEW_COMMAND_EDIT: win_state = WINDOW_EDIT; break; case VIEW_COMMAND_INDEX: win_state = WINDOW_INDEX; break; case VIEW_COMMAND_PREVIOUS: select_previous_item (); win_state = WINDOW_VIEW; break; case VIEW_COMMAND_NEXT: select_next_item (); win_state = WINDOW_VIEW; break; default: break; } } else { win_state = WINDOW_INDEX; } vc_delete_deep (v); v = NULL; break; case WINDOW_EDIT: /*-------------- edit a vcard --------------*/ it = get_current_item (); /* only display if there is an item that is selected */ if (NULL != it) { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); pos = ftell (fp); fclose (fp); fp = NULL; if (EDIT_SUCCESSFUL == edit_entry (data_path, pos)) { refresh_index (); } } win_state = WINDOW_INDEX; break; case WINDOW_ADD: if (ADD_SUCCESSFUL == add_entry (data_path)) { refresh_index (); } win_state = WINDOW_INDEX; break; case WINDOW_DELETE: it = get_current_item (); /* only delete if there is an item that is selected */ if (NULL != it) { fpos = (fpos_t *) item_userptr (it); fp = fopen (data_path, "r"); fsetpos (fp, fpos); pos = ftell (fp); fclose (fp); fp = NULL; if (DELETE_SUCCESSFUL == delete_entry (data_path, pos)) { refresh_index (); } } win_state = WINDOW_INDEX; break; default: break; } } finish (0); exit (EXIT_SUCCESS); return (0); }
static int handle_input(int ch) { switch (ch) { case 'q': quit_mode = quit_mode ? 0 : 1; return 1; case 0x1b: quit_mode = 0; print_help = 0; return 1; case 'y': if (quit_mode) exit(0); break; case 'a': next_attr(); return 1; case 'n': if (quit_mode) quit_mode = 0; else new_graph(); return 1; case 'x': del_graph(); return 1; case 'f': fold(); return 1; case 12: case KEY_CLEAR: #ifdef HAVE_REDRAWWIN redrawwin(stdscr); #endif clear(); return 1; case 'c': c_combined_node_list = c_combined_node_list ? 0 : 1; return 1; case 'S': clear(); set_graph_unit(X_SEC); return 1; case 'M': clear(); set_graph_unit(X_MIN); return 1; case 'H': clear(); set_graph_unit(X_HOUR); return 1; case 'D': clear(); set_graph_unit(X_DAY); return 1; case 'R': clear(); set_graph_unit(X_READ); return 1; case '?': clear(); print_help = print_help ? 0 : 1; return 1; case 'g': c_graphical_in_list = c_graphical_in_list ? 0 : 1; return 1; case 'd': c_detailed_in_list = c_detailed_in_list ? 0 : 1; return 1; case 'l': c_list_in_list = c_list_in_list ? 0 : 1; return 1; case KEY_PPAGE: if (print_help) help_page = help_page ? 0 : 1; else prev_node(); return 1; case KEY_NPAGE: if (print_help) help_page = help_page ? 0 : 1; else next_node(); return 1; case KEY_DOWN: if (next_item() == END_OF_LIST) { if (next_node() != END_OF_LIST) first_item(); } return 1; case KEY_UP: if (prev_item() == END_OF_LIST) { if (prev_node() != END_OF_LIST) last_item(); } return 1; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto_item(ch - 48); return 1; case '>': next_graph(); return 1; case '<': prev_graph(); return 1; default: if (get_current_item()) if (handle_bindings(ch, get_current_item()->i_name)) return 1; break; } return 0; }
static void curses_draw(void) { if (NULL == get_current_node()) { first_node(); first_item(); } row = 0; move(0,0); getmaxyx(stdscr, rows, cols); if (cols < 80) { clear(); putl("Screen must be at least 80 columns wide"); refresh(); return; } if (c_use_colors) attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr); else attrset(A_REVERSE); if (get_current_node() && get_current_item()) { putl(" %s on %s", get_current_item()->i_name, get_current_node()->n_name); } move(row, COLS - strlen(PACKAGE_STRING) - 1); putl("%s", PACKAGE_STRING); move(row, 0); if (c_use_colors) attrset(COLOR_PAIR(LAYOUT_DEFAULT) | layout[LAYOUT_DEFAULT].attr); else attroff(A_REVERSE); print_content(); if (quit_mode) print_quit(); else if (print_help) { if (help_page == 0) draw_help(); else draw_help_2(); } for (; row < rows-2;) { move(++row, 0); putl(""); } row = rows-1; move(row, 0); if (c_use_colors) attrset(COLOR_PAIR(LAYOUT_STATUSBAR) | layout[LAYOUT_STATUSBAR].attr); else attrset(A_REVERSE); if (1) { char s[27]; time_t t = time(0); double d; int h, m; asctime_r(localtime(&t), s); s[strlen(s) - 1] = '\0'; d = difftime(time(0), start_time); if (d / 3600) { h = (int) d / 3600; m = (int) d % 3600; m /= 60; } else { h = 0; m = (int) d / 60; } putl(" %s (%dh/%dm)", s, h, m); move(row, COLS - strlen("Press ? for help") - 1); putl("%s", "Press ? for help"); move(row, 0); } attrset(0); refresh(); }