static void cmd_L(key_info_t key_info, keys_info_t *keys_info) { int top; int off; if(menu->key_handler != NULL) { if(pass_combination_to_khandler(L"L")) { return; } } off = MAX(cfg.scroll_off, 0); if(off > menu->win_rows/2) return; if(menu->top + menu->win_rows < menu->len - 1) top = menu->top + menu->win_rows - off; else top = menu->top + menu->win_rows; clean_menu_position(menu); move_to_menu_pos(top - 3, menu); wrefresh(menu_win); }
static int goto_cmd(const cmd_info_t *cmd_info) { if(cmd_info->end == NOT_DEF) return 0; clean_menu_position(menu); move_to_menu_pos(cmd_info->end, menu); wrefresh(menu_win); return 0; }
static void cmd_gg(key_info_t key_info, keys_info_t *keys_info) { if(key_info.count == NO_COUNT_GIVEN) key_info.count = 1; clean_menu_position(menu); move_to_menu_pos(key_info.count - 1, menu); wrefresh(menu_win); }
static void cmd_ctrl_d(key_info_t key_info, keys_info_t *keys_info) { const int s = get_effective_menu_scroll_offset(menu); clean_menu_position(menu); menu->top += DIV_ROUND_UP(menu->win_rows - 3, 2); menu->pos += DIV_ROUND_UP(menu->win_rows - 3, 2); if(cfg.scroll_off > 0 && menu->pos - menu->top < s) menu->pos += s - (menu->pos - menu->top); update_menu(); }
static int search_menu_backwards(menu_info *m, int start_pos) { int match_up = -1; int match_down = -1; int x; for(x = m->len - 1; x > -1; x--) { if(!m->matches[x]) continue; if(match_up < 0) { if(x <= start_pos) match_up = x; } if(match_down < 0) { if(x > start_pos) match_down = x; } } if(match_up > -1 || match_down > -1) { int pos; if(!cfg.wrap_scan && match_up <= -1) { status_bar_errorf("Search hit TOP without match for: %s", m->regexp); return 1; } pos = (match_up > -1) ? match_up : match_down; clean_menu_position(m); move_to_menu_pos(pos, m); status_bar_messagef("%d %s", m->matching_entries, (m->matching_entries == 1) ? "match" : "matches"); } else { move_to_menu_pos(m->pos, m); if(!cfg.wrap_scan) status_bar_errorf("Search hit TOP without match for: %s", m->regexp); else status_bar_errorf("No matches for: %s", m->regexp); return 1; } return 0; }
static void cmd_k(key_info_t key_info, keys_info_t *keys_info) { if(menu->pos == 0) return; if(key_info.count == NO_COUNT_GIVEN) key_info.count = 1; clean_menu_position(menu); menu->pos -= key_info.count; move_to_menu_pos(menu->pos, menu); wrefresh(menu_win); }
/* Moves cursor to the middle of the window. */ static void cmd_M(key_info_t key_info, keys_info_t *keys_info) { int new_pos; if(menu->len < menu->win_rows) new_pos = DIV_ROUND_UP(menu->len, 2); else new_pos = menu->top + DIV_ROUND_UP(menu->win_rows - 3, 2); clean_menu_position(menu); move_to_menu_pos(MAX(0, new_pos - 1), menu); wrefresh(menu_win); }
static void cmd_M(key_info_t key_info, keys_info_t *keys_info) { int new_pos; if(menu->len < menu->win_rows) new_pos = menu->len/2; else new_pos = menu->top + (menu->win_rows - 3)/2; clean_menu_position(menu); move_to_menu_pos(new_pos, menu); wrefresh(menu_win); }
static void cmd_H(key_info_t key_info, keys_info_t *keys_info) { int top; int off = MAX(cfg.scroll_off, 0); if(off > menu->win_rows/2) return; if(menu->top == 0) top = 0; else top = menu->top + off; clean_menu_position(menu); move_to_menu_pos(top, menu); wrefresh(menu_win); }
void remove_current_item(menu_info *m) { clean_menu_position(m); remove_from_string_array(m->items, m->len, m->pos); if(m->matches != NULL) { if(m->matches[m->pos]) m->matching_entries--; memmove(m->matches + m->pos, m->matches + m->pos + 1, sizeof(int)*((m->len - 1) - m->pos)); } m->len--; draw_menu(m); move_to_menu_pos(m->pos, m); }