4 ms·
Nice guide, especially the terminal raw mode stuff. I haven't seen much on that before, I really appreciate that this guide goes over that. I've been messing a
by briansteffens 10y ago
Nice guide, especially the terminal raw mode stuff. I haven't seen much on that before, I really appreciate that this guide goes over that.
I've been messing around with a little text editor component myself in golang:
https://github.com/briansteffens/tui/blob/master/editbox.go https://github.com/briansteffens/tui/blob/master/editbox.go
For a SQL editor project:
https://github.com/briansteffens/prequel https://github.com/briansteffens/prequel
- ohmygeek 10y agotui looks pretty interesting! Can you please add a README? I would love to go over the source code :)
- briansteffens 10y agoThanks! It's still pretty rough but I'm hoping to put some notes up soon.
- bigger_cheese 10y agoIf you are looking for an interesting project that uses terminal input modes try writing a command line utility that reads in a password correctly. (eg. Masks the password input so it does not appear on screen whilst it is being typed, prevents someone from scrolling up in terminal and copy/pasting the typed password and zeros out the password after use to prevent it being visible in process address space). It is surprisingly tricky to get right. There used to be a POSIX function in the c standard library - "getpass" to handle this but the implementation was not thread safe and thus it was depreciated from posix spec - the only portable way I know to do this is to "roll your own code" using termios - not ideal. see: http://man7.org/linux/man-pages/man3/getpass.3.html http://man7.org/linux/man-pages/man3/getpass.3.html note the comment: "This function is obsolete. Do not use it" - there is a heap of potentially vulnerable code out in the wild that uses getpass.
- idbehold 10y agoYeah, this is still a problem. Trying to write a simple CLI in node and the library I'm using to prompt a user for their credentials only replaces the user's input with asterisks. There is still an open issue for properly masking the password input: https://github.com/SBoudrias/Inquirer.js/issues/177 https://github.com/SBoudrias/Inquirer.js/issues/177