7 ms·
Eons ago, Ctrl-C was mapped to 'Break' on various terminals, which will halt the running program, and was a useful function. Desktop/GUI's mapped Ctrl-C to (C)
by jasonjayr 1y ago
Eons ago, Ctrl-C was mapped to 'Break' on various terminals, which will halt the running program, and was a useful function. Desktop/GUI's mapped Ctrl-C to (C)opy, since the mnemonic made way more sense, and interrupting a GUI program hard like Break tends to do was not very useful.
- yoz-y 1y agoThis is where I find cmd+c/v better. It just works everywhere. On windows win+v works, not sure if win+c does, it’s been a while.
- bmacho 1y agoWin+c works too on windows. So does ctrl+insert/shift+insert on the terminals I just tested (cmd.exe, microsoft terminal with tabs, git bash, blue powershell terminal). Win+c/win+v looks like a good compromise, using the Windows button for OS/DE commands, instead of application commands.
- fc417fc802 1y agoAlso worth noting that many other ctrl-letter combinations map to signals in the terminal. In all the terminal emulators that I've used shift-ctrl-c & co are mapped by default for clipboard operations.
- mprovost 1y agoOn terminals, the control key masked off the 6th and 7th bits of the 8-bit value sent by the letter key. That's a bitwise AND with octal 037, or in decimal subtracting 96 from the lower case key value. This happens in the terminal (or keyboard) itself, so the computer doesn't see it as two pressed keys, it just gets the masked value. In ASCII 'c' is 99 (decimal), so when modified with control is 3, ETX (end of text), which teletypes used to indicate the end of text. So unix shells reused that control character to terminate the current program with SIGINT. But every letter key maps to a control character at the start of the ASCII range, like 'g' maps to BEL for the bell, or 'h' maps to BS (backspace). '[' maps to ESC (escape) which is handy when Apple decides to move the escape key on their laptop keyboard.
- tedunangst 1y agoThe funny bit is the other six control codes are mapped ctrl-2 to nul, and ctrl-3 forward to the five remaining.
- int_19h 1y agoUnless we're talking about ancient hardware terminals, the computer sees the actual raw scancodes coming from the keyboard. Control (whether by itself or in combination with something else) is no different than any other key. It's the software that maps those combinations to ASCII control characters, which is why this works the way you described on most Unices (where, if I remember correctly, it's the tty that is doing the mapping) but not e.g. on DOS/Windows.
- mprovost 1y agoYes, modern software terminals have to emulate how the control key operated on ancient hardware terminals because unix baked that behaviour in.
- vintermann 1y agoIt's not just the mnemonic, it's also that the location on the keyboard makes ctrl-c "prime real estate" so to say, and cutting and pasting is one of the most common and useful things you do.
- thaumasiotes 1y ago> It's not just the mnemonic, it's also that the location on the keyboard makes ctrl-c "prime real estate" so to say Considering the hotkeys for xut and vaste, I think it's safe to say the mnemonic accounts for zero of the decision and the keyboard location accounts for all of it.
- andrewshadura 1y agoX is for the scissors, V is for the insertion mark
- ZoomZoomZoom 1y ago> and interrupting a GUI program hard like Break tends to do was not very useful. I find it extremely useful, GUI or not. Too bad it doesn't work half the time when it matters, especially on Windows.
- hiAndrewQuinn 1y agoAlt-F4 is pretty reliable on Windows, but it's not as catchy because no one likes craning their left hand to reach the function key (even though you could just hold right Alt).
- tom_ 1y agoRight Alt doesn't exist on all keyboard layouts. On the UK layout it's replaced by AltGr, which doesn't do much appart from fail to act as Alt for Alt+F4 purposes, but it has actual uses in other layouts: https://en.wikipedia.org/wiki/AltGr_key https://en.wikipedia.org/wiki/AltGr_key
- thaumasiotes 1y agoNobody ever uses right alt even if it exists, but it's straightforward to hit F4 with your right hand. Alt+F4 on Windows has the undesirable property that if you hit it several times, and it works, you'll close several different things. Ctrl-C in the terminal won't do this.
- spauldo 1y agoAmerican Emacs-using touch typists use right ALT all the time. ALT-x prompts you for a command, ALT-q in most modes runs fill-paragraph, ALT-f moves the cursor forward by one word, etc.
- thaumasiotes 1y agoWhen I want alt in emacs I use C-[.
- lupusreal 1y agoThe mnemonic logic of the copy shortcut is undermined by the arbitrary paste shortcut. Also, from what I've seem a whole lot of average Joe computer users don't know or use these shortcuts, I think they're a lot further to the power user side of the skill spectrum than a lot of people here might expect.
- chuckadams 1y agoOn a US keyboard where these shortcuts were developed, you'd have to stretch your hand across the keyboard to reach Ctrl-P. That's why it's Ctrl-V, it wasn't arbitrary. I miss Sun keyboards and their dedicated copy/paste keys.
- Henchman21 1y agoAnd a control key in the right place. Dammit.
- silon42 1y agoI have a conspiracy theory that MS made IBM move the control key to kill WordStar, which had the superior keyboard shortcuts.
- physicles 1y agoSeems plausible. If anyone else is curious about the history here, I found [1]: > The original computer terminals and microcomputers for which WordStar was developed, many running the CP/M operating system, did not have function keys or cursor control keys (arrow keys, Page Up/Page Down). WordStar used sequences of alphabetic keys combined with the "Control" key, which on keyboards of the time was conveniently next to the letter A in the position now usually occupied by the Caps Lock key. For touch typists, in addition, reaching the function and cursor keys generally requires them to take their fingers off the "home keys" with consequent loss of typing rhythm. [1]: https://www.wikiwand.com/en/articles/Wordstar https://www.wikiwand.com/en/articles/Wordstar
- 1y ago
- whartung 1y agoWhat’s funny is when I started on SCO Unix ages ago, the default break key was DEL. It quickly morphed into ^C, but the first few months were interesting. Coming from the VAX, it was ^T.