Control characters like Ctrl+A/Ctrl+E/Ctrl+K not working #148

Open
opened 2014-10-07 11:40:09 +02:00 by LenzGr · 6 comments
LenzGr commented 2014-10-07 11:40:09 +02:00 (Migrated from github.com)

First off, this terminal is simply awesome eye candy. Good work!

I noticed one strange behaviour, though - in other terminals I can use control character sequences like Ctrl+A (move to the beginning of the line), Ctrl+E (move to the end of the line) or Ctrl+K (remove the rest of the line starting from the cursor position). There are likely more - in CRT they all result in the characters being printed literally, e.g. pressing "Ctrl+A" prints "^A" instead of moving the cursor. Sure, for cursor navigation I could use "Home" and "End" (which work), but my fingers are hard-coded to these sequences and they do work as expected in other terminal windows :)

Thanks!

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/5132500-control-characters-like-ctrl-a-ctrl-e-ctrl-k-not-working?utm_campaign=plugin&utm_content=tracker%2F479407&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F479407&utm_medium=issues&utm_source=github).
First off, this terminal is simply awesome eye candy. Good work! I noticed one strange behaviour, though - in other terminals I can use control character sequences like Ctrl+A (move to the beginning of the line), Ctrl+E (move to the end of the line) or Ctrl+K (remove the rest of the line starting from the cursor position). There are likely more - in CRT they all result in the characters being printed literally, e.g. pressing "Ctrl+A" prints "^A" instead of moving the cursor. Sure, for cursor navigation I could use "Home" and "End" (which work), but my fingers are hard-coded to these sequences and they do work as expected in other terminal windows :) Thanks! ## <bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/5132500-control-characters-like-ctrl-a-ctrl-e-ctrl-k-not-working?utm_campaign=plugin&utm_content=tracker%2F479407&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F479407&utm_medium=issues&utm_source=github). </bountysource-plugin>
LenzGr commented 2014-10-07 11:41:37 +02:00 (Migrated from github.com)

"Alt+." is another candidate.

"Alt+." is another candidate.
Swordfish90 commented 2014-10-07 21:47:14 +02:00 (Migrated from github.com)

Hi @LenzGr, I'm glad you are enjoying it. Sadly I'm not an expert on the subject @yurikhan kindly made the xterm keytab, and I'd like his thoughts on this request (to see if we should include them as default or not).

In the future we might add a way to add custom keybindings, but at the moment the only solution is to add them to konsole-qml-plugin/assets/kb-layours/xterm.keytab if you want to play with that.

Hi @LenzGr, I'm glad you are enjoying it. Sadly I'm not an expert on the subject @yurikhan kindly made the xterm keytab, and I'd like his thoughts on this request (to see if we should include them as default or not). In the future we might add a way to add custom keybindings, but at the moment the only solution is to add them to konsole-qml-plugin/assets/kb-layours/xterm.keytab if you want to play with that.
yurikhan commented 2014-10-08 08:02:42 +02:00 (Migrated from github.com)

@LenzGr Please write a full-form bug report. Specifically, I think at least the following information is needed for us to help you solve your problem:

  • What is your operating system, OS version and cool-retro-term version?
  • What exact steps reproduce the problem?
    • How do you start cool-retro-term?
    • In what programs do you have the problem?
      • If shell, which shell runs in other terminals and which shell starts in c-r-t?
    • What do you expect to happen?
    • What do you observe?
  • What is the value of the TERM environment variable when you experience the problem?
    • What is its value in other terminals where you do not have the problem?
  • Are you running over SSH?
  • Are you running any terminal multiplexers (such as screen and/or tmux)?
    • If you do, what is the value of $TERM inside them?

For me, under Ubuntu 14.04, c-r-t rev. 9bd0ca7, in bash, with TERM set to xterm-256color, when I type a command line and press Ctrl+A, the cursor moves to the start of the line; when I then press Ctrl+E, it moves to the end of the line; when I move the cursor a few characters to the left by pressing the Left arrow and then press Ctrl+K, the characters under the cursor and to the right of it disappear; and Alt+. inserts at the current position the last argument of the previously executed command.

Similarly, on the same OS and c-r-t, with tmux running in c-r-t, TERM set to screen-256color, the same steps cause the same reactions.

If I press Ctrl+V Ctrl+A, a ^A sequence appears in the command line, and when I press the Left arrow, the cursor moves left two positions, indicating that it’s a literal SOH control character. (Using Ctrl+V to treat the next key literally is a feature of bash and possibly other shells.)

If I start dash in my c-r-t and press Ctrl+A, a ^A sequence appears. If I press Home, a ^[[H sequence appears. For me, this happens both in c-r-t and other terminals (xterm and xterm+tmux).


@Swordfish90 This all boils down to a simple question: Which terminal do you want to emulate?

In terms of compatibility with applications, it seems best to emulate (a subset of) xterm, because then you don’t have to concern yourself with writing a terminfo file, getting it upstreamed in ncurses, etc.

And an xterm-compatible terminal emulator has to emit by default the same key codes as xterm does, otherwise users will be surprised.

@LenzGr Please write a [full-form bug report](http://www.catb.org/esr/faqs/smart-questions.html). Specifically, I think at least the following information is needed for us to help you solve your problem: - What is your operating system, OS version and cool-retro-term version? - What exact steps reproduce the problem? - How do you start cool-retro-term? - In what programs do you have the problem? - If shell, which shell runs in other terminals and which shell starts in c-r-t? - What do you expect to happen? - What do you observe? - What is the value of the `TERM` environment variable when you experience the problem? - What is its value in other terminals where you do not have the problem? - Are you running over SSH? - Are you running any terminal multiplexers (such as `screen` and/or `tmux`)? - If you do, what is the value of `$TERM` inside them? For me, under Ubuntu 14.04, c-r-t rev. 9bd0ca7, in `bash`, with `TERM` set to `xterm-256color`, when I type a command line and press `Ctrl+A`, the cursor moves to the start of the line; when I then press `Ctrl+E`, it moves to the end of the line; when I move the cursor a few characters to the left by pressing the Left arrow and then press `Ctrl+K`, the characters under the cursor and to the right of it disappear; and `Alt+.` inserts at the current position the last argument of the previously executed command. Similarly, on the same OS and c-r-t, with `tmux` running in c-r-t, `TERM` set to `screen-256color`, the same steps cause the same reactions. If I press `Ctrl+V` `Ctrl+A`, a `^A` sequence appears in the command line, and when I press the Left arrow, the cursor moves left two positions, indicating that it’s a literal `SOH` control character. (Using `Ctrl+V` to treat the next key literally is a feature of `bash` and possibly other shells.) If I start `dash` in my c-r-t and press `Ctrl+A`, a `^A` sequence appears. If I press `Home`, a `^[[H` sequence appears. For me, this happens both in c-r-t and other terminals (`xterm` and `xterm`+`tmux`). --- @Swordfish90 This all boils down to a simple question: Which terminal do you want to emulate? In terms of compatibility with applications, it seems best to emulate (a subset of) xterm, because then you don’t have to concern yourself with writing a terminfo file, getting it upstreamed in ncurses, etc. And an xterm-compatible terminal emulator has to emit by default the same key codes as xterm does, otherwise users will be surprised.
Swordfish90 commented 2014-10-08 15:13:14 +02:00 (Migrated from github.com)

Thank you @yurikhan . I think we should stick with xterm, I thought there were issues with the keycodes but I just tested them carefully and everything works fine for me (Ubuntu 14.04 bash xterm), so let's see the full bug report, but it seems to be a specific problem.

Thank you @yurikhan . I think we should stick with xterm, I thought there were issues with the keycodes but I just tested them carefully and everything works fine for me (Ubuntu 14.04 bash xterm), so let's see the full bug report, but it seems to be a specific problem.
LenzGr commented 2014-10-08 17:09:28 +02:00 (Migrated from github.com)

@yurikhan thanks for the detailed response. I apologize, I should have provided more details to begin with. Here we go:

  • OS: Ubuntu Linux (14.04.1 LTS, x86_64)
  • C-R-T Version: built from git (800bbd3)

I start CRT by calling the resulting binary: ./cool-retro-term
$TERM is set to xterm, $SHELL is /bin/zsh

Pressing common key combinations like Ctrl+A, Ctrl+E do not behave as expected (and how they work in other terminals like guake or gnome-terminal). For example, I expect Ctrl+A to jump to the beginning of the line (similar to what pressing Home does). Instead, the control character ^A is printed to the screen. Interestingly, a gnome-terminal started from c-r-t exposes the same behavior.

This is a plain local shell, no SSH or screen involved.

I compared the differences in the environments of c-r-t and gnome-terminal, here is the diff:

% diff -u export.guake export.crt 
--- export.guake    2014-10-08 16:39:00.444326069 +0200
+++ export.crt  2014-10-08 16:39:13.564326537 +0200
@@ -1,5 +1,7 @@
 BROWSER=chromium-browser
 CLUTTER_IM_MODULE=xim
+COLORFGBG='15;0'
+COLORSCHEMES_DIR=/home/lenz/src/cool-retro-term/imports//org/crt/konsole/color-schemes
 COMPIZ_CONFIG_PROFILE=ubuntu
 DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-eGlDFx6GLH'
 DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
@@ -24,6 +26,7 @@
 IM_CONFIG_PHASE=1
 INSTANCE=''
 JOB=dbus
+KB_LAYOUT_DIR=/home/lenz/src/cool-retro-term/imports//org/crt/konsole/kb-layouts
 LANG=en_US.UTF-8
 LANGUAGE=en_US:en
 LC_ADDRESS=de_DE.UTF-8
@@ -41,13 +44,14 @@
 LOGNAME=lenz
 LS_COLORS='no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;36:mi=04;37:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.bz2=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.pcx=01;35:*.tif=01;35:*.kdelnk=00;36:'
 MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
+OLDPWD=/home/lenz/src/cool-retro-term
 PAGER=less
-PATH=/home/lenz/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/sbin:/sbin:/usr/lib/ccache
+PATH=/home/lenz/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/sbin:/sbin:/usr/lib/ccache:/usr/sbin:/sbin:/usr/lib/ccache
 PS1='[%n@%m %1~]%# '
 PWD=/home/lenz/src/cool-retro-term
 QT4_IM_MODULE=xim
 QT_IM_MODULE=ibus
-QT_QPA_PLATFORMTHEME=appmenu-qt5
+QT_QPA_PLATFORMTHEME=''
 SAVEHIST=10000
 SDL_VIDEO_X11_DGAMOUSE=0
 SELINUX_INIT=YES
@@ -55,6 +59,7 @@
 SESSIONTYPE=gnome-session
 SESSION_MANAGER=local/lenz-ThinkPad-T440:@/tmp/.ICE-unix/3170,unix/lenz-ThinkPad-T440:/tmp/.ICE-unix/3170
 SHELL=/bin/zsh
+SHLVL=2
 SPROMPT='zsh: correct %R to %r ? ([Y]es/[N]o/[E]dit/[A]bort) '
 SSH_AGENT_LAUNCHER=upstart
 SSH_AGENT_PID=3120
@@ -65,6 +70,7 @@
 UBUNTU_MENUPROXY=1
 UPSTART_SESSION='unix:abstract=/com/ubuntu/upstart-session/1000/3064'
 USER=lenz
+WINDOWID=90177548
 XAUTHORITY=/home/lenz/.Xauthority
 XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
 XDG_CURRENT_DESKTOP=Unity
@@ -78,3 +84,4 @@
 XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
 XDG_VTNR=7
 XMODIFIERS='@im=ibus'
+_=export

The only possible offending difference seems to be the KB_LAYOUT_DIR environment. However, unsetting it does not have any noticeable effect.

@yurikhan thanks for the detailed response. I apologize, I should have provided more details to begin with. Here we go: - OS: Ubuntu Linux (14.04.1 LTS, x86_64) - C-R-T Version: built from git (800bbd3) I start CRT by calling the resulting binary: `./cool-retro-term` `$TERM` is set to `xterm`, `$SHELL` is `/bin/zsh` Pressing common key combinations like `Ctrl+A`, `Ctrl+E` do not behave as expected (and how they work in other terminals like `guake` or `gnome-terminal`). For example, I expect `Ctrl+A` to jump to the beginning of the line (similar to what pressing `Home` does). Instead, the control character `^A` is printed to the screen. Interestingly, a gnome-terminal started from c-r-t exposes the same behavior. This is a plain local shell, no SSH or screen involved. I compared the differences in the environments of c-r-t and gnome-terminal, here is the diff: ``` diff % diff -u export.guake export.crt --- export.guake 2014-10-08 16:39:00.444326069 +0200 +++ export.crt 2014-10-08 16:39:13.564326537 +0200 @@ -1,5 +1,7 @@ BROWSER=chromium-browser CLUTTER_IM_MODULE=xim +COLORFGBG='15;0' +COLORSCHEMES_DIR=/home/lenz/src/cool-retro-term/imports//org/crt/konsole/color-schemes COMPIZ_CONFIG_PROFILE=ubuntu DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-eGlDFx6GLH' DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path @@ -24,6 +26,7 @@ IM_CONFIG_PHASE=1 INSTANCE='' JOB=dbus +KB_LAYOUT_DIR=/home/lenz/src/cool-retro-term/imports//org/crt/konsole/kb-layouts LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ADDRESS=de_DE.UTF-8 @@ -41,13 +44,14 @@ LOGNAME=lenz LS_COLORS='no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;36:mi=04;37:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.tar=01;31:*.tgz=01;31:*.bz2=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.pcx=01;35:*.tif=01;35:*.kdelnk=00;36:' MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path +OLDPWD=/home/lenz/src/cool-retro-term PAGER=less -PATH=/home/lenz/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/sbin:/sbin:/usr/lib/ccache +PATH=/home/lenz/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/sbin:/sbin:/usr/lib/ccache:/usr/sbin:/sbin:/usr/lib/ccache PS1='[%n@%m %1~]%# ' PWD=/home/lenz/src/cool-retro-term QT4_IM_MODULE=xim QT_IM_MODULE=ibus -QT_QPA_PLATFORMTHEME=appmenu-qt5 +QT_QPA_PLATFORMTHEME='' SAVEHIST=10000 SDL_VIDEO_X11_DGAMOUSE=0 SELINUX_INIT=YES @@ -55,6 +59,7 @@ SESSIONTYPE=gnome-session SESSION_MANAGER=local/lenz-ThinkPad-T440:@/tmp/.ICE-unix/3170,unix/lenz-ThinkPad-T440:/tmp/.ICE-unix/3170 SHELL=/bin/zsh +SHLVL=2 SPROMPT='zsh: correct %R to %r ? ([Y]es/[N]o/[E]dit/[A]bort) ' SSH_AGENT_LAUNCHER=upstart SSH_AGENT_PID=3120 @@ -65,6 +70,7 @@ UBUNTU_MENUPROXY=1 UPSTART_SESSION='unix:abstract=/com/ubuntu/upstart-session/1000/3064' USER=lenz +WINDOWID=90177548 XAUTHORITY=/home/lenz/.Xauthority XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg XDG_CURRENT_DESKTOP=Unity @@ -78,3 +84,4 @@ XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 XDG_VTNR=7 XMODIFIERS='@im=ibus' +_=export ``` The only possible offending difference seems to be the `KB_LAYOUT_DIR` environment. However, unsetting it does not have any noticeable effect.
Swordfish90 commented 2014-10-11 15:00:14 +02:00 (Migrated from github.com)

KB_LAYOUT_DIR is surely not the reason. It simply indicates where the keytabs files are stored, and is only read by the plugin when it starts.

KB_LAYOUT_DIR is surely not the reason. It simply indicates where the keytabs files are stored, and is only read by the plugin when it starts.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seeseemelk/cool-retro-term#148
No description provided.