3

When typing in a terminal, why is it that text does not behave the way it would in any other text environment, like in any text editor or browser? Things like highlighting text while moving the cursor using typical key bindings (Meta+Shift+Arrow Key) and simply just deleting the current highlighted text by pressing backspace are not possible.

Is this behavior necessary for a terminal to stay compatible or caused by some restriction that I am not thinking of? Sorry if this is a dumb question. Thank you.

2
  • 2
    The Terminal is not a text editor, it is a command environment.
    – Solar Mike
    May 21, 2020 at 10:55
  • @Solar Mike is correct, however BBEdit has an interesting feature called a Shell Worksheet that is, in effect, a shell that behaves much like a word processor. And it is free to download and demo, but that feature requires a purchase. Worth a try? May 21, 2020 at 17:41

2 Answers 2

5

The terminal does not behave the way that you expect because it is made to emulate the behavior of a DEC VT100 terminal. Computer terminals — such as the VT100 — did not have a mouse, so any actions that is triggered by the mouse is bolted on as an afterthought. Most terminal emulators default to a set of keybindings that are similar to those of Emacs (a text editor), but this layer (provided by GNU Readline) does not provide mechanisms for selecting text and whatever else you are describing.

It is up to the terminal emulator (for example, Terminal.app or iTerm2) to define what events are triggered upon mouse clicks and text selection. For example, hitting Option ⌥, followed by a mouse click somewhere in your current prompt will place your cursor at that position. If you select a piece of text and hit backspace Delete ⌦, only a single character at your current cursor position will be deleted because the terminal that is being emulated does not have the notion of text selection by itself.

2
  • Think of the terminal as a typewriter and any thing after enter I pressed is inked on the page. You might be able to alter somethings before you press return.
    – mmmmmm
    May 21, 2020 at 13:43
  • GNU Readline is not provided for by Terminal , but by the Shell, like Bash. The Emacs keybindings that Terminal uses came from OpenStep. The Terminal app can emulate many terminals including the DEC, but it usually defaults to xterm. Terminals have had mouse support for a long time, but it was limited to text selection. Xterms , because they supported the full X window environment had full mouse support.
    – Allan
    May 21, 2020 at 16:28
1

The Unix terminal application is based on what a physical terminal could do.

A common earlier terminal.

enter image description here

DEC_VT100 -- Could output 30 characters per second. Used computer line printer paper.

enter image description here

The DEC LA36 DECwriter II -- Saved your ears.

enter image description here

1
  • Not even Apple can get rid of certain kinds of legacy skeuomorphism....
    – masterxilo
    Jun 24, 2022 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .