Live data from Hacker News

Entering text in the terminal is complicated

jvns.ca

201–210 of 229 posts

Re: Entering text in the terminal is complicated

#201

Earlier quoted context omitted.

> The terminal just happens to invisibly turn \n into \r\n. No, it was actually done by the Unixen itself, in the part of the kernel that handled ttys: it convert '\n' to '\r\n' on writes to ttys, and '\r' to '\n' on reads from ttys. Linux only recently have moved this functionality out into the user-land layer.

> in the part of the kernel that handled ttys Yes, that's what I meant. OPOST Enable implementation-defined output processing. That gets set in a termios structure that gets passed to the kernel's terminal subsystem via ioctl. https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... h…

Hmmm, I could swear I have read about moving line discipline out of the kernel in some LWN article but apparently no, it never happened (although it probably should've, there is no much reason to perform mapping of NL to CR-NL in the privilleged mode). Maybe I've confused it with what happened on the Windows side of things? They moved almost all of the console infrastructure out of the kernel recently and into the user space, and that definitely has happened.

Re: Entering text in the terminal is complicated

#203
post #70

This is nice. As always, Julia's articles are always a win. Here's some stuff that's missing: Within shell scripts, you can use `stty` to change a lot of stuff about the terminal, including how it deals with inputs. You can rewire all of these defaults and behaviors. Here's an experiment I did a while ago using sh and stty: https://gist.github.com/alganet/63f1dbc97b8fd35f7bb14ec30f79... It is able to capture and unde…

> you can use `stty` to change a lot of stuff about the terminal, including how it deals with inputs > You can rewire all of these defaults and behaviors I've also found this article on implementing a terminal text editor to be illuminating: https://viewsourcecode.org/snaptoken/kilo/ https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode... Also, just in case anyone is wondering, as I once did, where many of th…

I like your comparison with browsers. In many ways, the only way to know for sure is to test in the desired terminals and figure out what works on all of them.

There's some "new" stuff as well (90's), like SIXEL graphics. I was surprised by how broad the support is (however not that broad to count on it).

Re: Entering text in the terminal is complicated

#204

Earlier quoted context omitted.

> you can use `stty` to change a lot of stuff about the terminal, including how it deals with inputs > You can rewire all of these defaults and behaviors I've also found this article on implementing a terminal text editor to be illuminating: https://viewsourcecode.org/snaptoken/kilo/ https://viewsourcecode.org/snaptoken/kilo/02.enteringRawMode... Also, just in case anyone is wondering, as I once did, where many of th…

I like your comparison with browsers. In many ways, the only way to know for sure is to test in the desired terminals and figure out what works on all of them. There's some "new" stuff as well (90's), like SIXEL graphics. I was surprised by how broad the support is (however not that broad to count on it).

Yeah. Even more recent efforts are the efforts to bring powerful features to terminals. Kitty in particular came up with many of them and had to deal with ncurses refusing to support it.

Re: Entering text in the terminal is complicated

#205
post #9

I plan to make one day an alternative to terminals. My idea is not fully fleshed out, but I would like to try to forgo TTYs altogether. Use only pipes, file descriptors and job control. The closest thing I saw to what I have in mind is this: https://github.com/letoram/cat9/ but more in a way of interface.

The utility in your link, and the entire Arcan system, seem very pleasant to me; a dream of mine is to have a complete graphical LISP command-and-control via an interface like that; like the old lisp machine UIs but with more direct incorporation and seamless handling of multimedia Objects.

Re: Entering text in the terminal is complicated

#206

Earlier quoted context omitted.

> in the part of the kernel that handled ttys Yes, that's what I meant. OPOST Enable implementation-defined output processing. That gets set in a termios structure that gets passed to the kernel's terminal subsystem via ioctl. https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... https://github.com/torvalds/linux/blob/master/include/uapi/a... h…

Hmmm, I could swear I have read about moving line discipline out of the kernel in some LWN article but apparently no, it never happened (although it probably should've, there is no much reason to perform mapping of NL to CR-NL in the privilleged mode). Maybe I've confused it with what happened on the Windows side of things? They moved almost all of the console infrastructure out of the kernel recently and into the us…

I suspect Linux actually can't move it to user space. It would break binary compatibility with all user space code that sets OPOST via the ioctl. They can't hide it in a libc either.

Re: Entering text in the terminal is complicated

#207
post #169

Earlier quoted context omitted.

I feel like you're being willfully obtuse here. I can't remember the last time I used a laptop which had Home / End keys. Edit: actually I do remember -- it was an HP ProBook from 2011.

For the complaint to make any sense in the first place there needs to be an expected alternative way to go back to the beginning and end of a line. Otherwise it would be "it took me maybe 15 years to get used to being able to go to the beginning or end of a line in one keystroke". The two such options I'm aware of are Home/End (on macbooks I believe that is Fn+arrow keys) and Ctrl-a/Ctrl-e. What alternative key combi…

I think I didn't communicate that well. What I saw was:

    jvns: I didn't know you could go to the beginning of the line
    you: But you could have just pressed the Home key
The obvious answer is: jvns doesn't have a Home key.

Re: Entering text in the terminal is complicated

#208
post #118
post #99

Earlier quoted context omitted.

Oh I always do ctrl+shift+r for that last bit, like reverse-tabbing on a gui. Good to know about ctrl+s, though I imagine muscle memory will prevent me for ever using it. :)

normally control-shift-r is just control-r; both key combinations send the same byte, 0x12, so they both search backwards in readline history. is your terminal emulator doing something different? if you type control-v control-shift-r enter control-d as the input to the command od -t x1a, what does it say?

You’re right, I was wrong. Thank you for the gentle lesson. :)

Re: Entering text in the terminal is complicated

#209
post #73

Earlier quoted context omitted.

I think the command “reset” does something similar

You are correct! I think it does a little more (restoring cursor if hidden, etc). If you have it, it is probably better than `stty sane`

Any idea what can cause the cursor to suddenly dissappear? It's the only issue I currently have with wezterm, an otherwise fantastic terminal emulator

Re: Entering text in the terminal is complicated

#210
post #52

So when I use Windows Terminal and I press Ctrl-C, it always does the right thing: If I’m selecting text I want to copy it, if I’m not selecting text I want to kill the running process. On Linux, every Terminal app I’ve used stubbornly refuses to copy when I press Ctrl-C, demanding I press Ctrl-Shift-C. When I paste, if I forget my manners and use Ctrl-V instead of Ctrl-Shift-V, I am punished by getting a weird chara…

Most decent linux terminals let you configure this. For example in kitty:

map ctrl+c copy_or_interrupt

https://sw.kovidgoyal.net/kitty/actions/#action-copy_or_inte...

Post reply on HN