static inline cb_ret_t tree_key (WTree *tree, int key) { int i; for (i = 0; tree_keymap [i].key_code; i++){ if (key == tree_keymap [i].key_code){ if (tree_keymap [i].fn != tree_start_search) tree->searching = 0; (*tree_keymap [i].fn)(tree); show_tree (tree); return MSG_HANDLED; } } /* We do not want to use them if we do not need to */ /* Input line may want to take the motion key event */ if (key == KEY_LEFT) return move_left (tree) ? MSG_HANDLED : MSG_NOT_HANDLED; if (key == KEY_RIGHT) return move_right (tree) ? MSG_HANDLED : MSG_NOT_HANDLED; if (is_abort_char (key)) { if (tree->is_panel) { tree->searching = 0; show_tree (tree); return MSG_HANDLED; /* eat abort char */ } /* modal tree dialog: let upper layer see the abort character and close the dialog */ return MSG_NOT_HANDLED; } /* Do not eat characters not meant for the tree below ' ' (e.g. C-l). */ if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE) { if (tree->searching){ tree_do_search (tree, key); show_tree (tree); return MSG_HANDLED; } if (!command_prompt) { tree_start_search (tree); tree_do_search (tree, key); return MSG_HANDLED; } return tree->is_panel ? MSG_HANDLED : MSG_NOT_HANDLED; } return MSG_NOT_HANDLED; }
static cb_ret_t tree_key (WTree * tree, int key) { size_t i; if (is_abort_char (key)) { if (tree->is_panel) { tree->searching = 0; show_tree (tree); return MSG_HANDLED; /* eat abort char */ } /* modal tree dialog: let upper layer see the abort character and close the dialog */ return MSG_NOT_HANDLED; } if (tree->searching && ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE)) { tree_do_search (tree, key); show_tree (tree); return MSG_HANDLED; } for (i = 0; tree_map[i].key != 0; i++) if (key == tree_map[i].key) switch (tree_map[i].command) { case CK_Left: return tree_move_left (tree) ? MSG_HANDLED : MSG_NOT_HANDLED; case CK_Right: return tree_move_right (tree) ? MSG_HANDLED : MSG_NOT_HANDLED; default: tree_execute_cmd (tree, tree_map[i].command); return MSG_HANDLED; } /* Do not eat characters not meant for the tree below ' ' (e.g. C-l). */ if (!command_prompt && ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE)) { tree_start_search (tree); tree_do_search (tree, key); return MSG_HANDLED; } return MSG_NOT_HANDLED; }
static void tree_start_search (WTree * tree) { gboolean i; if (tree->searching) { if (tree->selected_ptr == tree->store->tree_last) tree_move_to_top (tree); else { /* set navigation mode temporarily to 'Static' because in * dynamic navigation mode tree_move_forward will not move * to a lower sublevel if necessary (sequent searches must * start with the directory followed the last found directory) */ i = tree_navigation_flag; tree_navigation_flag = 0; tree_move_forward (tree, 1); tree_navigation_flag = i; } tree_do_search (tree, 0); } else { tree->searching = 1; tree->search_buffer[0] = 0; } }