Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH]: Provide TUI fast key action with specific readline keymap
@ 2002-08-31  5:34 Stephane Carrez
  2002-08-31  8:30 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Stephane Carrez @ 2002-08-31  5:34 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

Hi!

I've committed this patch to improve the TUI as explained in
http://sources.redhat.com/ml/gdb-patches/2002-08/msg00840.html.

I changed a little bit the patch to simplify and use an enum to represent the
3 key-mode states (command, SingleKey, one-command then SingleKey).

To activate SingleKey, it is bound to C-X S.
To leave it, both C-X S and 'q' work.

Note: In http://sources.redhat.com/ml/gdb-patches/2002-08/msg00907.html
       I proposed to use C-X C-S to activate; but C-S is very bad as it's
       used to stop the terminal output...

	Stephane


2002-08-31  Stephane Carrez  <stcarrez@nerim.fr>

	* tui.c (tui_commands): Table of single key commands.
	(tui_rl_command_key): New function to execute gdb command.
	(tui_rl_command_mode): New function to temporarily leave SingleKey.
	(tui_rl_next_keymap): New function to enter/leave the SingleKey mode.
	(tui_rl_startup_hook): New function to avoid prompt display by
	readline functions.
	(tui_set_key_mode): New function to set the key mode and install
	the readline keymap.
	(tui_initialize_readline): Create TUI SingleKey readline map.
	(tui_enable): Install rl_startup_hook.
	(tui_disable): Remove it.
	* tui.h (enum tui_key_mode): Declare.
	(tui_set_key_mode, tui_current_key_mode): Declare.
	* tuiIO.c (tui_redisplay_readline): Don't display the prompt in
	SingleKey mode.
	* tuiIO.h (tui_redisplay_readline): Declare.

[-- Attachment #2: tui-readline-2.diffs --]
[-- Type: text/plain, Size: 8387 bytes --]

Index: tui.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.c,v
retrieving revision 1.23
diff -u -p -r1.23 tui.c
--- tui.c	28 Aug 2002 20:33:27 -0000	1.23
+++ tui.c	31 Aug 2002 12:00:44 -0000
@@ -72,7 +72,33 @@
 int tui_active = 0;
 static int tui_finish_init = 1;
 
-/* Switch the output mode between TUI/standard gdb.  */
+enum tui_key_mode tui_current_key_mode = tui_command_mode;
+
+struct tui_char_command
+{
+  unsigned char key;
+  const char* cmd;
+};
+
+/* Key mapping to gdb commands when the TUI is using the single key mode.  */
+static const struct tui_char_command tui_commands[] = {
+  { 'c', "continue" },
+  { 'd', "down" },
+  { 'f', "finish" },
+  { 'n', "next" },
+  { 'r', "run" },
+  { 's', "step" },
+  { 'u', "up" },
+  { 'v', "info locals" },
+  { 'w', "where" },
+  { 0, 0 },
+};
+
+static Keymap tui_keymap;
+static Keymap tui_readline_standard_keymap;
+
+/* TUI readline command.
+   Switch the output mode between TUI/standard gdb.  */
 static int
 tui_rl_switch_mode (void)
 {
@@ -193,19 +219,128 @@ tui_rl_delete_other_windows (void)
   return 0;
 }
 
+/* TUI readline command.
+   Execute the gdb command bound to the specified key.  */
+static int
+tui_rl_command_key (int count, int key)
+{
+  int i;
+
+  reinitialize_more_filter ();
+  for (i = 0; tui_commands[i].cmd; i++)
+    {
+      if (tui_commands[i].key == key)
+        {
+          /* Must save the command because it can be modified
+             by execute_command.  */
+          char* cmd = alloca (strlen (tui_commands[i].cmd) + 1);
+          strcpy (cmd, tui_commands[i].cmd);
+          execute_command (cmd, TRUE);
+          return 0;
+        }
+    }
+  return 0;
+}
+
+/* TUI readline command.
+   Temporarily leave the TUI SingleKey mode to allow editing
+   a gdb command with the normal readline.  Once the command
+   is executed, the TUI SingleKey mode is installed back.  */
+static int
+tui_rl_command_mode (int count, int key)
+{
+  tui_set_key_mode (tui_one_command_mode);
+  return rl_insert (count, key);
+}
+
+/* TUI readline command.
+   Switch between TUI SingleKey mode and gdb readline editing.  */
+static int
+tui_rl_next_keymap (void)
+{
+  tui_set_key_mode (tui_current_key_mode == tui_command_mode
+                    ? tui_single_key_mode : tui_command_mode);
+  return 0;
+}
+
+/* Readline hook to redisplay ourself the gdb prompt.
+   In the SingleKey mode, the prompt is not printed so that
+   the command window is cleaner.  It will be displayed if
+   we temporarily leave the SingleKey mode.  */
+static int
+tui_rl_startup_hook ()
+{
+  rl_already_prompted = (tui_current_key_mode != tui_command_mode);
+  if (rl_already_prompted)
+    {
+      tui_set_key_mode (tui_single_key_mode);
+      tui_redisplay_readline ();
+    }
+  return 0;
+}
+
+/* Change the TUI key mode by installing the appropriate readline keymap.  */
+void
+tui_set_key_mode (enum tui_key_mode mode)
+{
+  tui_current_key_mode = mode;
+  rl_set_keymap (mode == tui_single_key_mode
+                 ? tui_keymap : tui_readline_standard_keymap);
+  tuiShowLocatorContent ();
+}
+
 /* Initialize readline and configure the keymap for the switching
    key shortcut.  */
 void
 tui_initialize_readline ()
 {
+  int i;
+  Keymap tui_ctlx_keymap;
+
   rl_initialize ();
 
   rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
+  rl_add_defun ("gdb-command", tui_rl_command_key, -1);
+  rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
+
+  tui_keymap = rl_make_bare_keymap ();
+  tui_ctlx_keymap = rl_make_bare_keymap ();
+  tui_readline_standard_keymap = rl_get_keymap ();
+
+  for (i = 0; tui_commands[i].cmd; i++)
+    rl_bind_key_in_map (tui_commands[i].key, tui_rl_command_key, tui_keymap);
+
+  rl_generic_bind (ISKMAP, "\\C-x", (char*) tui_ctlx_keymap, tui_keymap);
+
+  /* Bind all other keys to tui_rl_command_mode so that we switch
+     temporarily from SingleKey mode and can enter a gdb command.  */
+  for (i = ' ' + 1; i < 0x7f; i++)
+    {
+      int j;
+
+      for (j = 0; tui_commands[j].cmd; j++)
+        if (tui_commands[j].key == i)
+          break;
+
+      if (tui_commands[j].cmd)
+        continue;
+
+      rl_bind_key_in_map (i, tui_rl_command_mode, tui_keymap);
+    }
+
   rl_bind_key_in_map ('a', tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('a', tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map ('A', tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('A', tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map ('1', tui_rl_delete_other_windows, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('1', tui_rl_delete_other_windows, tui_ctlx_keymap);
   rl_bind_key_in_map ('2', tui_rl_change_windows, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('2', tui_rl_change_windows, tui_ctlx_keymap);
+  rl_bind_key_in_map ('q', tui_rl_next_keymap, tui_keymap);
+  rl_bind_key_in_map ('s', tui_rl_next_keymap, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('s', tui_rl_next_keymap, tui_ctlx_keymap);
 }
 
 /* Enter in the tui mode (curses).
@@ -255,6 +390,7 @@ tui_enable (void)
 
   /* Install the TUI specific hooks.  */
   tui_install_hooks ();
+  rl_startup_hook = tui_rl_startup_hook;
 
   tui_update_variables ();
   
@@ -284,6 +420,8 @@ tui_disable (void)
 
   /* Remove TUI hooks.  */
   tui_remove_hooks ();
+  rl_startup_hook = 0;
+  rl_already_prompted = 0;
 
   /* Leave curses and restore previous gdb terminal setting.  */
   endwin ();
Index: tui.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.h,v
retrieving revision 1.14
diff -u -p -r1.14 tui.h
--- tui.h	25 Aug 2002 19:19:50 -0000	1.14
+++ tui.h	31 Aug 2002 12:00:44 -0000
@@ -102,6 +102,23 @@ extern void tui_enable (void);
 /* Leave the tui mode.  */
 extern void tui_disable (void);
 
+enum tui_key_mode
+{
+  /* Plain command mode to enter gdb commands.  */
+  tui_command_mode,
+
+  /* SingleKey mode with some keys bound to gdb commands.  */
+  tui_single_key_mode,
+
+  /* Read/edit one command and return to SingleKey after it's processed.  */
+  tui_one_command_mode
+};
+
+extern enum tui_key_mode tui_current_key_mode;
+
+/* Change the TUI key mode by installing the appropriate readline keymap.  */
+extern void tui_set_key_mode (enum tui_key_mode mode);
+
 extern void tui_initialize_io (void);
 
 extern void tui_initialize_readline (void);
Index: tuiIO.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.c,v
retrieving revision 1.13
diff -u -p -r1.13 tuiIO.c
--- tuiIO.c	27 Aug 2002 20:58:27 -0000	1.13
+++ tuiIO.c	31 Aug 2002 12:00:44 -0000
@@ -44,6 +44,7 @@
 #include "terminal.h"
 #include "target.h"
 #include "event-loop.h"
+#include "event-top.h"
 #include "command.h"
 #include "top.h"
 #include "readline/readline.h"
@@ -151,7 +152,7 @@ tui_puts (const char *string)
 /* Readline callback.
    Redisplay the command line with its prompt after readline has
    changed the edited text.  */
-static void
+void
 tui_redisplay_readline (void)
 {
   int prev_col;
@@ -164,7 +165,10 @@ tui_redisplay_readline (void)
   char *prompt;
   int start_line;
   
-  prompt = get_prompt ();
+  if (tui_current_key_mode == tui_single_key_mode)
+    prompt = "";
+  else
+    prompt = get_prompt ();
   
   c_pos = -1;
   c_line = -1;
Index: tuiIO.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.h,v
retrieving revision 1.4
diff -u -p -r1.4 tuiIO.h
--- tuiIO.h	21 Jul 2001 19:56:54 -0000	1.4
+++ tuiIO.h	31 Aug 2002 12:00:44 -0000
@@ -1,5 +1,5 @@
 /* TUI support I/O functions.
-   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Hewlett-Packard Company.
 
    This file is part of GDB.
@@ -35,6 +35,11 @@ extern void tui_initialize_io (void);
 
 /* Get a character from the command window.  */
 extern int tui_getc (FILE*);
+
+/* Readline callback.
+   Redisplay the command line with its prompt after readline has
+   changed the edited text.  */
+extern void tui_redisplay_readline (void);
 
 
 #define m_tuiStartNewLine       tuiStartNewLines(1)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH]: Provide TUI fast key action with specific readline keymap
  2002-08-31  5:34 [PATCH]: Provide TUI fast key action with specific readline keymap Stephane Carrez
@ 2002-08-31  8:30 ` Eli Zaretskii
  2002-08-31  9:59   ` Stephane Carrez
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2002-08-31  8:30 UTC (permalink / raw)
  To: stcarrez; +Cc: gdb-patches

> Date: Sat, 31 Aug 2002 16:03:41 +0200
> From: Stephane Carrez <stcarrez@nerim.fr>
> 
> I've committed this patch to improve the TUI as explained in
> http://sources.redhat.com/ml/gdb-patches/2002-08/msg00840.html.
> 
> I changed a little bit the patch to simplify and use an enum to represent the
> 3 key-mode states (command, SingleKey, one-command then SingleKey).
> 
> To activate SingleKey, it is bound to C-X S.
> To leave it, both C-X S and 'q' work.

Thanks for working on this, but you never responded to my request to
change the manual accordingly.  I really don't think we should have
first-class user-level features that are not documented.

TIA


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH]: Provide TUI fast key action with specific readline keymap
  2002-08-31  8:30 ` Eli Zaretskii
@ 2002-08-31  9:59   ` Stephane Carrez
  2002-08-31 22:40     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Stephane Carrez @ 2002-08-31  9:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

Hi!

Eli Zaretskii wrote:
>>Date: Sat, 31 Aug 2002 16:03:41 +0200
>>From: Stephane Carrez <stcarrez@nerim.fr>
>>
>>I've committed this patch to improve the TUI as explained in
>>http://sources.redhat.com/ml/gdb-patches/2002-08/msg00840.html.
>>
>>I changed a little bit the patch to simplify and use an enum to represent the
>>3 key-mode states (command, SingleKey, one-command then SingleKey).
>>
>>To activate SingleKey, it is bound to C-X S.
>>To leave it, both C-X S and 'q' work.
>>
> 
> Thanks for working on this, but you never responded to my request to
> change the manual accordingly.  I really don't think we should have
> first-class user-level features that are not documented.
> 

I agree with you; I responded and I sent the following patch few days ago:

[RFC]: Document TUI breakpoints and SingleKey mode
	http://sources.redhat.com/ml/gdb-patches/2002-08/msg00907.html


	Stephane
-----------------------------------------------------------------------
         Home                               Office
E-mail: stcarrez@nerim.fr                  Stephane.Carrez@solsoft.fr
WWW:    http://stephane.carrez.free.fr     http://www.solsoft.com
         Free the Software!                 Visual Security Policy Management



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH]: Provide TUI fast key action with specific readline keymap
  2002-08-31  9:59   ` Stephane Carrez
@ 2002-08-31 22:40     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2002-08-31 22:40 UTC (permalink / raw)
  To: Stephane Carrez; +Cc: gdb-patches


On Sat, 31 Aug 2002, Stephane Carrez wrote:

> > Thanks for working on this, but you never responded to my request to
> > change the manual accordingly.  I really don't think we should have
> > first-class user-level features that are not documented.
> 
> I agree with you; I responded and I sent the following patch few days ago:
> 
> [RFC]: Document TUI breakpoints and SingleKey mode
> 	http://sources.redhat.com/ml/gdb-patches/2002-08/msg00907.html

Sorry, I somehow missed that.

Those patches are approved with the following comments:

  - "@table @emph" is IMHO not a good idea for markers, since @emph is 
    typeset in a slanted font in the printed manual.  I suggest to use 
    "@table code" instead.

  - In the description of the SingleKey keybindings, please make the 
    index entries indicate that those are SingleKey bindings, like this:

    @kindex c@r{, SingleKey TUI key}

    Otherwise, the user looking at the index will not be able to 
    distinguish between, say, the entry for the normal GDB `c' (continue) 
    command and the SingleKey binding of `c'.

Thanks!


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH]: Provide TUI fast key action with specific readline keymap
  2002-08-25 15:25 Stephane Carrez
@ 2002-08-26  8:55 ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2002-08-26  8:55 UTC (permalink / raw)
  To: Stephane Carrez; +Cc: gdb-patches


On Mon, 26 Aug 2002, Stephane Carrez wrote:

> This patch improves the TUI mode by creating a specific readline keymap
> that can be installed to bind a single key to a gdb command.  The fast key
> mode is entered when CTRL-X CTRL-O is entered.  Then, the keys are bound
> as follows:
> 
>    c  continue
>    d  down
>    f  finish
>    n  next
>    r  run
>    s  step
>    u  up
>    v  info locals
>    w  where
>    x  exit the fast key mode, go back to normal readline+gdb prompt
> 
> Hitting a single key will execute the gdb command.
> Other keys temporarily switch the keymap to use the readline+gdb prompt
> so that a full gdb command can be entered.  Once the command is entered (\n)
> the fast key mode is restored.

Please add something to gdb.texinfo to describe this feature.

TIA


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH]: Provide TUI fast key action with specific readline keymap
@ 2002-08-25 15:25 Stephane Carrez
  2002-08-26  8:55 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Stephane Carrez @ 2002-08-25 15:25 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]

Hi!

This patch improves the TUI mode by creating a specific readline keymap
that can be installed to bind a single key to a gdb command.  The fast key
mode is entered when CTRL-X CTRL-O is entered.  Then, the keys are bound
as follows:

   c  continue
   d  down
   f  finish
   n  next
   r  run
   s  step
   u  up
   v  info locals
   w  where
   x  exit the fast key mode, go back to normal readline+gdb prompt

Hitting a single key will execute the gdb command.
Other keys temporarily switch the keymap to use the readline+gdb prompt
so that a full gdb command can be entered.  Once the command is entered (\n)
the fast key mode is restored.

I'll commit this patch in a few days unless there is some objection.

	Stephane

2002-08-26  Stephane Carrez  <stcarrez@nerim.fr>

	* tui.c (tui_commands): Table of single key commands.
	(tui_rl_command_key): New function to execute gdb command.
	(tui_rl_command_mode): New function to leave fast key mode temporarily.
	(tui_rl_next_keymap): New function to enter/leave the fast key mode.
	(tui_rl_startup_hook): New function to avoid prompt display by
	readline functions.
	(tui_enter_key_mode): New function to enter fast key.
	(tui_leave_key_mode): New function to leave it.
	(tui_initialize_readline): Create TUI fast key readline map.
	(tui_enable): Install rl_startup_hook.
	(tui_disable): Remove it.
	* tui.h (tui_leave_key_mode): Declare.
	(tui_enter_key_mode): Declare.
	(tui_single_key_mode): Declare.
	* tuiIO.c (tui_after_char_processing_restart_key_mode): New function.
	(tui_redisplay_readline): Don't display the prompt in fast key mode.
	(tui_getc): When \n is received, re-enter fast key mode if we left
	it temporarily.

[-- Attachment #2: tui-readline.diffs --]
[-- Type: text/plain, Size: 7368 bytes --]

Index: tui.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.c,v
retrieving revision 1.21
diff -u -p -r1.21 tui.c
--- tui.c	25 Aug 2002 21:44:41 -0000	1.21
+++ tui.c	25 Aug 2002 22:02:55 -0000
@@ -72,7 +72,35 @@
 int tui_active = 0;
 static int tui_finish_init = 1;
 
-/* Switch the output mode between TUI/standard gdb.  */
+int tui_single_key_mode = 0;
+
+struct tui_char_command
+{
+  unsigned char key;
+  char* cmd;
+};
+
+/* Key mapping to gdb commands when the TUI is using the single key mode.  */
+struct tui_char_command tui_commands[] = {
+  { 's', "step" },
+  { 'n', "next" },
+  { 'c', "continue" },
+  { 'u', "up" },
+  { 'd', "down" },
+  { 'f', "finish" },
+  { 'r', "run" },
+  { 'v', "info locals" },
+  { 'w', "where" },
+  { 0, 0 },
+};
+
+static Keymap tui_keymap;
+static Keymap tui_ctlx_keymap;
+static Keymap tui_readline_standard_keymap;
+static Keymap tui_readline_ctrlx_keymap;
+
+/* TUI readline command.
+   Switch the output mode between TUI/standard gdb.  */
 static int
 tui_rl_switch_mode (void)
 {
@@ -193,19 +221,132 @@ tui_rl_delete_other_windows (void)
   return 0;
 }
 
+/* TUI readline command.
+   Execute the gdb command bound to the specified key.  */
+static int
+tui_rl_command_key (int count, int key)
+{
+  int i;
+
+  reinitialize_more_filter ();
+  for (i = 0; tui_commands[i].cmd; i++)
+    {
+      if (tui_commands[i].key == key)
+        {
+          execute_command (tui_commands[i].cmd, TRUE);
+          return 0;
+        }
+    }
+  return 0;
+}
+
+/* TUI readline command.
+   Temporarily leave the TUI fast key mode to allow editing
+   of a gdb command with the normal readline.  Once the command
+   is executed, the TUI fast key mode is installed back.  */
+static int
+tui_rl_command_mode (int count, int key)
+{
+  tui_single_key_mode = 2;
+  rl_set_keymap (tui_readline_standard_keymap);
+  tuiShowLocatorContent ();
+  return rl_insert (count, key);
+}
+
+
+/* TUI readline command.
+   Switch between TUI fast key mode and gdb readline editing.  */
+static int
+tui_rl_next_keymap (void)
+{
+  if (tui_single_key_mode == 0)
+    tui_enter_key_mode ();
+  else
+    tui_leave_key_mode ();
+  tuiShowLocatorContent ();
+  return 0;
+}
+
+int
+tui_rl_startup_hook ()
+{
+  rl_already_prompted = (tui_single_key_mode != 0);
+  if (rl_already_prompted)
+    {
+      tui_single_key_mode = 1;
+      tui_redisplay_readline ();
+    }
+  return 0;
+}
+
+/* Enter in the TUI fast key mode.  */
+void
+tui_enter_key_mode ()
+{
+  tui_single_key_mode = 1;
+  rl_set_keymap (tui_keymap);
+  tuiShowLocatorContent ();
+}
+
+/* Leave the TUI fast key mode to use the gdb plain readline.  */
+void
+tui_leave_key_mode ()
+{
+  tui_single_key_mode = 0;
+  rl_set_keymap (tui_readline_standard_keymap);
+}
+
 /* Initialize readline and configure the keymap for the switching
    key shortcut.  */
 void
 tui_initialize_readline ()
 {
+  int i;
+  
   rl_initialize ();
 
   rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1);
+  rl_add_defun ("gdb-command", tui_rl_command_key, -1);
+  rl_add_defun ("next-keymap", tui_rl_next_keymap, -1);
+
+  tui_keymap = rl_make_bare_keymap ();
+  tui_ctlx_keymap = rl_make_bare_keymap ();
+  
+  for (i = 0; tui_commands[i].cmd; i++)
+    rl_bind_key_in_map (tui_commands[i].key, tui_rl_command_key, tui_keymap);
+
+  rl_generic_bind (ISKMAP, "\\C-x", (char*) tui_ctlx_keymap, tui_keymap);
+
+  for (i = ' ' + 1; i < 0x7f; i++)
+    {
+      int j;
+
+      for (j = 0; tui_commands[j].cmd; j++)
+        if (tui_commands[j].key == i)
+          break;
+
+      if (tui_commands[j].cmd)
+        continue;
+
+      rl_bind_key_in_map (i, tui_rl_command_mode, tui_keymap);
+    }
+
   rl_bind_key_in_map ('a', tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('a', tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map ('A', tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('A', tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, emacs_ctlx_keymap);
+  rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, tui_ctlx_keymap);
   rl_bind_key_in_map ('1', tui_rl_delete_other_windows, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('1', tui_rl_delete_other_windows, tui_ctlx_keymap);
   rl_bind_key_in_map ('2', tui_rl_change_windows, emacs_ctlx_keymap);
+  rl_bind_key_in_map ('2', tui_rl_change_windows, tui_ctlx_keymap);
+
+  tui_readline_standard_keymap = rl_get_keymap ();
+  tui_readline_ctrlx_keymap = rl_make_bare_keymap ();
+
+  rl_bind_key_in_map ('x', tui_rl_next_keymap, tui_keymap);
+  rl_bind_key_in_map (CTRL ('O'), tui_rl_next_keymap, emacs_ctlx_keymap);
 }
 
 /* Enter in the tui mode (curses).
@@ -255,6 +396,7 @@ tui_enable (void)
 
   /* Install the TUI specific hooks.  */
   tui_install_hooks ();
+  rl_startup_hook = tui_rl_startup_hook;
 
   tui_update_variables ();
   
@@ -281,6 +423,8 @@ tui_disable (void)
 
   /* Remove TUI hooks.  */
   tui_remove_hooks ();
+  rl_startup_hook = 0;
+  rl_already_prompted = 0;
 
   /* Leave curses and restore previous gdb terminal setting.  */
   endwin ();
Index: tui.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui.h,v
retrieving revision 1.14
diff -u -p -r1.14 tui.h
--- tui.h	25 Aug 2002 19:19:50 -0000	1.14
+++ tui.h	25 Aug 2002 22:02:55 -0000
@@ -84,6 +84,8 @@ TuiWinType, *TuiWinTypePtr;
        }
 TuiPoint, *TuiPointPtr;
 
+extern int tui_single_key_mode;
+
 /* GENERAL TUI FUNCTIONS */
 /* tui.c */
 extern void tuiFree (char *);
@@ -101,6 +103,12 @@ extern void tui_enable (void);
 
 /* Leave the tui mode.  */
 extern void tui_disable (void);
+
+/* Leave the TUI fast key mode to use the gdb plain readline.  */
+extern void tui_leave_key_mode (void);
+
+/* Enter in the TUI fast key mode.  */
+extern void tui_enter_key_mode (void);
 
 extern void tui_initialize_io (void);
 
Index: tuiIO.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tuiIO.c,v
retrieving revision 1.12
diff -u -p -r1.12 tuiIO.c
--- tuiIO.c	1 Mar 2002 06:19:28 -0000	1.12
+++ tuiIO.c	25 Aug 2002 22:02:55 -0000
@@ -55,6 +55,7 @@
 #include "tuiGeneralWin.h"
 #include "tui-file.h"
 #include "ui-out.h"
+#include "event-top.h"
 #include "cli-out.h"
 #include <fcntl.h>
 #include <signal.h>
@@ -144,10 +145,17 @@ tui_puts (const char *string)
   fflush (stdout);
 }
 
+static void
+tui_after_char_processing_restart_key_mode (void)
+{
+  after_char_processing_hook = 0;
+  tui_enter_key_mode ();
+}
+
 /* Readline callback.
    Redisplay the command line with its prompt after readline has
    changed the edited text.  */
-static void
+void
 tui_redisplay_readline (void)
 {
   int prev_col;
@@ -160,7 +168,10 @@ tui_redisplay_readline (void)
   char *prompt;
   int start_line;
   
-  prompt = get_prompt ();
+  if (tui_single_key_mode == 1)
+     prompt = "";
+  else
+     prompt = get_prompt ();
   
   c_pos = -1;
   c_line = -1;
@@ -432,7 +443,10 @@ tui_getc (FILE *fp)
     {				/* Handle prev/next/up/down here */
       ch = tuiDispatchCtrlChar (ch);
     }
-  
+
+  if (ch == '\n' && tui_single_key_mode == 2)
+     after_char_processing_hook = tui_after_char_processing_restart_key_mode;
+
   if (ch == '\n' || ch == '\r' || ch == '\f')
     cmdWin->detail.commandInfo.curch = 0;
 #if 0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-09-01  5:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-31  5:34 [PATCH]: Provide TUI fast key action with specific readline keymap Stephane Carrez
2002-08-31  8:30 ` Eli Zaretskii
2002-08-31  9:59   ` Stephane Carrez
2002-08-31 22:40     ` Eli Zaretskii
  -- strict thread matches above, loose matches on Subject: below --
2002-08-25 15:25 Stephane Carrez
2002-08-26  8:55 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox