public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Intercept and handle Delete/Home/End keys in the TUI
@ 2015-06-03 23:29 Patrick Palka
  2015-06-03 23:55 ` Patrick Palka
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2015-06-03 23:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

These keys are mapped by wgetch() to special ncurses-specific values and
are otherwise passed through to readline, to no useful effect.

This patch intercepts these keys in the TUI and gives them their
expected function.

gdb/ChangeLog:

	* tui/tui-command.c: Include "readline/readline.h".
	(tui_dispatch_ctrl_char): Handle KEY_DC, KEY_HOME and KEY_END.
---
 gdb/tui/tui-command.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
index 03ec076..84ba2b7 100644
--- a/gdb/tui/tui-command.c
+++ b/gdb/tui/tui-command.c
@@ -27,6 +27,7 @@
 #include "tui/tui-command.h"
 
 #include "gdb_curses.h"
+#include "readline/readline.h"
 /*****************************************
 ** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
 ******************************************/
@@ -76,6 +77,15 @@ tui_dispatch_ctrl_char (unsigned int ch)
     case KEY_LEFT:
       tui_scroll_right (win_info, 1);
       break;
+    case KEY_DC:
+      rl_delete (1, ch);
+      break;
+    case KEY_HOME:
+      rl_point = 0;
+      break;
+    case KEY_END:
+      rl_point = rl_end;
+      break;
     case '\f':
       break;
     default:
-- 
2.4.2.387.gf86f31a.dirty

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

* Re: [PATCH] Intercept and handle Delete/Home/End keys in the TUI
  2015-06-03 23:29 [PATCH] Intercept and handle Delete/Home/End keys in the TUI Patrick Palka
@ 2015-06-03 23:55 ` Patrick Palka
  2015-06-10 15:28   ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Patrick Palka @ 2015-06-03 23:55 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Palka

On Wed, Jun 3, 2015 at 7:28 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> These keys are mapped by wgetch() to special ncurses-specific values and
> are otherwise passed through to readline, to no useful effect.
>
> This patch intercepts these keys in the TUI and gives them their
> expected function.

The commit message is slightly misleading.  These keys work as
expected when the command window is in focus.  But when another window
is in focus, these keys currently have no function.  This patch gives
them their expected function when the command window is not in focus.

Alternatively when the command window is not in focus the Home and
Delete keys could be given the function of scrolling the source/disasm
windows all the way up or down.  Personally I don't think that is very
useful.  I think the traditional binding would probably see more use.

Nonetheless I will reword the commit message to mention the focus aspect.

>
> gdb/ChangeLog:
>
>         * tui/tui-command.c: Include "readline/readline.h".
>         (tui_dispatch_ctrl_char): Handle KEY_DC, KEY_HOME and KEY_END.
> ---
>  gdb/tui/tui-command.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/gdb/tui/tui-command.c b/gdb/tui/tui-command.c
> index 03ec076..84ba2b7 100644
> --- a/gdb/tui/tui-command.c
> +++ b/gdb/tui/tui-command.c
> @@ -27,6 +27,7 @@
>  #include "tui/tui-command.h"
>
>  #include "gdb_curses.h"
> +#include "readline/readline.h"
>  /*****************************************
>  ** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
>  ******************************************/
> @@ -76,6 +77,15 @@ tui_dispatch_ctrl_char (unsigned int ch)
>      case KEY_LEFT:
>        tui_scroll_right (win_info, 1);
>        break;
> +    case KEY_DC:
> +      rl_delete (1, ch);
> +      break;
> +    case KEY_HOME:
> +      rl_point = 0;
> +      break;
> +    case KEY_END:
> +      rl_point = rl_end;
> +      break;
>      case '\f':
>        break;
>      default:
> --
> 2.4.2.387.gf86f31a.dirty
>

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

* Re: [PATCH] Intercept and handle Delete/Home/End keys in the TUI
  2015-06-03 23:55 ` Patrick Palka
@ 2015-06-10 15:28   ` Pedro Alves
  0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2015-06-10 15:28 UTC (permalink / raw)
  To: Patrick Palka, gdb-patches

On 06/04/2015 12:55 AM, Patrick Palka wrote:
> On Wed, Jun 3, 2015 at 7:28 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
>> These keys are mapped by wgetch() to special ncurses-specific values and
>> are otherwise passed through to readline, to no useful effect.
>>
>> This patch intercepts these keys in the TUI and gives them their
>> expected function.
> 
> The commit message is slightly misleading.  These keys work as
> expected when the command window is in focus.  But when another window
> is in focus, these keys currently have no function.  This patch gives
> them their expected function when the command window is not in focus.

I'd think it very natural that given that Up, Down, Left, Right, PageUp/PageDown
all scroll the source window, so should Home/End.  When the console window is
not on focus, we can use ctrl-a / ctrl-e to move to start/end of line,
just like we use ctrl-p/ctrl-n to go "up/down" in history.

> 
> Alternatively when the command window is not in focus the Home and
> Delete keys could be given the function of scrolling the source/disasm
> windows all the way up or down.

Yes, that.

> Personally I don't think that is very useful.  I think the traditional binding
> would probably see more use.

I do not agree.  I know I'd give lots of use to Home jumping to the
start of the file myself.

Thanks,
Pedro Alves

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

end of thread, other threads:[~2015-06-10 15:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-03 23:29 [PATCH] Intercept and handle Delete/Home/End keys in the TUI Patrick Palka
2015-06-03 23:55 ` Patrick Palka
2015-06-10 15:28   ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).