[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5931] no hard-coded keys in incremental search
From: |
Gavin D. Smith |
Subject: |
[5931] no hard-coded keys in incremental search |
Date: |
Mon, 17 Nov 2014 23:21:33 +0000 |
Revision: 5931
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5931
Author: gavin
Date: 2014-11-17 23:21:30 +0000 (Mon, 17 Nov 2014)
Log Message:
-----------
no hard-coded keys in incremental search
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/session.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2014-11-16 13:48:41 UTC (rev 5930)
+++ trunk/ChangeLog 2014-11-17 23:21:30 UTC (rev 5931)
@@ -1,3 +1,9 @@
+2014-11-17 Gavin Smith <address@hidden>
+
+ * info/session.c (incremental_search): Look up pressed keys in
+ info_keymap and echo_area_keymap. Do not hard-code any keys for
+ particular commands.
+
2014-11-16 Gavin Smith <address@hidden>
* info/session.c (ask_for_search_string): Return 1 for empty
Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c 2014-11-16 13:48:41 UTC (rev 5930)
+++ trunk/info/session.c 2014-11-17 23:21:30 UTC (rev 5931)
@@ -4498,7 +4498,6 @@
{
VFunction *func = NULL;
int quoted = 0;
- char type;
/* Show the search string in the echo area. */
show_isearch_prompt (dir, (unsigned char *) isearch_string,
@@ -4512,11 +4511,68 @@
display_cursor_at_point (active_window);
}
- /* Read a character and dispatch on it. */
- key = get_input_key ();
- window_get_state (window, &mystate);
+ /* Read keys, looking in both keymaps for a recognized key sequence. */
+ {
+ Keymap info_kp, ea_kp;
- if (key == Control ('q'))
+ info_kp = info_keymap;
+ ea_kp = echo_area_keymap;
+
+ key = get_input_key ();
+
+ while (1)
+ {
+ if (key >= 32 && key < 256)
+ break;
+
+ if (info_kp && info_kp[key].type == ISFUNC)
+ {
+ if (info_kp[key].value.function)
+ func = info_kp[key].value.function->func;
+ if (func == &isearch_forward
+ || func == &isearch_backward
+ || func == &info_abort_key)
+ {
+ goto gotfunc;
+ }
+ else
+ {
+ func = 0;
+ info_kp = 0;
+ }
+ }
+ else if (info_kp) /* ISKMAP */
+ info_kp = info_kp[key].value.keymap;
+
+ if (ea_kp && ea_kp[key].type == ISFUNC)
+ {
+ if (ea_kp[key].value.function)
+ func = ea_kp[key].value.function->func;
+ if (func == &ea_abort
+ || func == &ea_quoted_insert
+ || func == &ea_rubout)
+ {
+ func = ea_kp[key].value.function->func;
+ goto gotfunc;
+ }
+ else
+ {
+ func = 0;
+ ea_kp = 0;
+ }
+ }
+ else if (ea_kp) /* ISKMAP */
+ ea_kp = ea_kp[key].value.keymap;
+
+ if (!info_kp && !ea_kp)
+ break;
+
+ key = get_input_key ();
+ }
+ }
+gotfunc:
+
+ if (func == &ea_quoted_insert)
{
/* User wants to insert a character. */
key = get_input_key ();
@@ -4524,18 +4580,23 @@
continue; /* The user pressed a key like an arrow key. */
quoted = 1;
}
- else
+
+ if (quoted || (!func && key >= 32 && key < 256))
{
- /* If this key is not a keymap, get its associated function,
- if any. */
- KEYMAP_ENTRY k = info_keymap[key];
- type = k.type;
- func = type == ISFUNC && k.value.function
- ? k.value.function->func
- : NULL;
+ push_isearch (window, isearch_string_index, dir,
+ search_result, start_off);
+
+ if (isearch_string_index + 2 >= isearch_string_size)
+ isearch_string = xrealloc
+ (isearch_string, isearch_string_size += 100);
+
+ isearch_string[isearch_string_index++] = key;
+ isearch_string[isearch_string_index] = '\0';
+
+ if (search_result != search_success)
+ continue;
}
-
- if (key == DEL || key == Control ('h'))
+ else if (func == &ea_rubout)
{
/* User wants to delete one level of search? */
if (!isearch_states_index)
@@ -4545,6 +4606,7 @@
}
else
{
+ /* TODO: Erase mulit-byte characters correctly. */
pop_isearch (window, &isearch_string_index,
&dir, &search_result, &start_off);
isearch_string[isearch_string_index] = '\0';
@@ -4559,28 +4621,15 @@
}
}
}
- else if (quoted || (key >= 32 && key < 256
- && (isprint (key) || (type == ISFUNC && func == NULL))))
+ else if (func == &isearch_forward || func == &isearch_backward)
{
- push_isearch (window, isearch_string_index, dir, search_result,
start_off);
-
- if (isearch_string_index + 2 >= isearch_string_size)
- isearch_string = xrealloc
- (isearch_string, isearch_string_size += 100);
-
- isearch_string[isearch_string_index++] = key;
- isearch_string[isearch_string_index] = '\0';
- }
- else if (func == (VFunction *) isearch_forward
- || func == (VFunction *) isearch_backward)
- {
/* If this key invokes an incremental search, then this
means that we will either search again in the same
direction, search again in the reverse direction, or
insert the last search string that was accepted through
incremental searching. */
- if ((func == (VFunction *) isearch_forward && dir > 0) ||
- (func == (VFunction *) isearch_backward && dir < 0))
+ if (func == &isearch_forward && dir > 0
+ || func == &isearch_backward && dir < 0)
{
/* If the user has typed no characters, then insert the
last successful search into the current search string. */
@@ -4621,8 +4670,8 @@
dir = -dir;
}
}
- else if (func == (VFunction *) info_abort_key
- && isearch_states_index && (search_result != search_success))
+ else if (func == &info_abort_key
+ && isearch_states_index && search_result != search_success)
{
/* If C-g pressed, and the search is failing, pop the search
stack back to the last unfailed search. */
@@ -4635,17 +4684,17 @@
search_result);
continue;
}
- else
+ else if (func == &info_abort_key || func == &ea_abort || !func)
{
/* The character is not printable, or it has a function which is
non-null. Exit the search, remembering the search string. */
- if (isearch_string_index && func != (VFunction *) info_abort_key)
+ if (isearch_string_index && func != &info_abort_key)
{
free (last_isearch_accepted);
last_isearch_accepted = xstrdup (isearch_string);
}
- if (func == (VFunction *) info_abort_key)
+ if (func == &info_abort_key)
{
if (isearch_states_index)
window_set_state (window, &orig_state);
@@ -4661,7 +4710,7 @@
continue;
}
- /* Search for the contents of isearch_string. */
+ /* Show the new search string in the prompt. */
show_isearch_prompt (dir, (unsigned char *) isearch_string,
search_result);
@@ -4676,6 +4725,8 @@
}
last_search_result = search_result;
+
+ window_get_state (window, &mystate);
search_result = info_search_internal (isearch_string,
window, dir, case_sensitive,
&start_off);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5931] no hard-coded keys in incremental search,
Gavin D. Smith <=