0

Can I, through a trick or a module, make the Micro editor behave in a separate TTY as if I had started it directly from a console/terminal emulator in my desktop environment?

Setup: Debian 12, Bash, KDE/Gnome

The core feature I'm searching for:

I just want to mark text/ part of a text using the arrow keys + Shift.

Is this possible, or is it fundamentally impossible because the Linux kernel console (e.g., tty1) does not support this?

Results I discovered:

The kernel console (TTY) does not support extended modifier sequences like Shift+arrow keys, which means it is not possible to select text using Shift+arrow keys in the Micro editor when running in the TTY.

According to the official man page console_codes(4), the Linux console implements only a subset of the VT102 and ECMA-48/ISO 6429/ANSI X3.64 terminal controls.

In particular, it lacks support for extended input sequences that are handled by modern terminal emulators like xterm. This means the console does not send escape sequences for combined keys such as Shift+arrow keys.

The loadkeys keymaps use tricks to assign different sequences to function keys (F1–F12) combined with modifiers like Alt or Ctrl.

But that probably works because the kernel has explicit support for it but it looks like not for Shift+Arrow.

From @Gilles 'SO- stop being evil' answer:

Terminals don't send key up events. (Your use case doesn't require them, though, according to your description.)

Unless you can afford to require a specific terminal emulator (e.g. recent-ish xterm), don't rely on the user being able to type Shift+Up. Support an alternate method, such as a “start multiple selection” key followed by plain Up/Down

1
  • with "a separate TTY", you mean the virtual TTYs you get by switching to the framebuffer consoles (e.g. Alt+F3 or whatever?) The behaviour you describe seems to have little to do with the TTY, but with the program running in it! Commented May 30 at 17:11

2 Answers 2

1

The Linux kernel console does not support this directly. Its arrow key handling in drivers/tty/vt/keyboard.c -> k_cur() -> applkey() does not implement outputting the xterm-style modifier sequences.

You could maybe make a custom keymap using loadkeys, where Shift+arrows were defined to send a custom string, e.g. \e[1;2D for Shift+Left. See /usr/share/kbd/keymaps/.

2
  • Unfortunately, this doesn’t work. I’ll leave the upvote because the first part is correct. I’ll try some other things in the next days. Commented May 31 at 8:48
  • What were the results? I saw the default keymaps use this same method for function keys (F1..F12). Does only micro not recognize the sequence or does the mapping not work in general? Commented May 31 at 8:50
1

It seems it's not possible for the Micro editor, so there is no solution, because the Linux kernel console TTY does not support extended key sequences like Shift+Arrow keys.

I have linked to specific posts in the question, with further explanations.

This appears to be a hardware/kernel-level limitation, not a software problem.

It only works in a terminal emulator within a desktop environment.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.