0

I'm using Linux Mint on a MacBook and on its keyboard the equivalent for the INSERT key is the combination Fn + RETURN.

At the moment I can only see the intended behavior of this combination in GNU-Emacs: In there, the overwrite-mode is bound to <insertchar> and <insert>.

For example, in the webbrowser it has no effect. Inside a linux terminal and as well inside any of the terminal emulators I tried (e.g. konsole, xterm) instead of switching to the insert mode, the escape sequence [2~ is printed to the screen.

Since I think its a useful thing to have, I want to get it working. Does anybody know, where to fix this?

By the way: Fn + Backspace, representing "DELETE" works fine in the mentioned applications.

By the way no. 2: I'm using the fish shell. Within the bash shell, the escape sequence is not printed, but the key combination has no effect neither.

1

Terminal emulators cannot edit text on their own, and hence the concept of insert mode vs. overwrite mode doesn't exist on this level.

They just send the keypresses to the running application (via the kernel's tty driver), and receive (again, via the kernel tty driver) and interpret data from the application and update the screen accordingly.

For the Insert key, the proper action is indeed to send the \e[2~ escape sequence.

It's up to the applications (fish/bash/etc. shell, emacs/etc. text editor, etc.) to interpret it and switch between insert and overwrite modes (if they implement the latter).

  • thanks, that was very clear. I was able to figure things out in the bash shell. I'll keep the post open, since I could not yet get it done in the fish shell. – Anton Harald May 22 '16 at 15:52
0

Terminal emulators have control sequences for inserting and deleting characters (and lines) on the screen. But when you are running an application (whether a shell or a text editor), the control sequences you may enter are as a rule not echoed to the terminal. The application reads these special keys and decides what control sequences to send to the terminal. The effect (insertion, deletion — and overstrike) is just a picture of what the application does. The real data is in the application's memory (or data-files).

Most terminals have special keys (such as Insert) which by convention send characters which match a similarly-named control sequence (which would be sent to the terminal). That is because originally, local mode was something that people used.

Any ANSI-compatible terminal can be run in local mode (disregarding as irrelevant a few which have broken this feature). That's called send/receive mode (SRM) in the standard. In older terminals, you might have to take into account another mode for inserting. In the terminfo(5) manual page that is mentioned:

   move_insert_mode          mir    mi   safe to move while
                                         in insert mode

Convention aside, not all terminals make their special keys match the control sequences. For instance,

  • with rxvt, the insert-key might send escape[2~, while the insert-character control sequence is escape[@ and (for multiple characters), insert mode is escape[4m
  • modified special keys (such as controlInsert) may not send characters matching any control sequence. With xterm, they are organized to avoid confusion with existing control sequences, e.g., by adding parameters in places where simplistic programs ignore them.

Further reading:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.