kaka.farm

Unnamed repository; edit this file 'description' to name the repository.
git clone https://kaka.farm/~git/kaka.farm
Log | Files | Refs | README

terminal-programming.markdown (1542B)


      1 title: Notes on terminal programming.
      2 
      3 # Notes on terminal programming.
      4 
      5 If you want get keys pressed immediately, not only after pressing enter, amongst other nice terminal programs features, you have to talk with the "termios driver", according to this talk, at 09:06.
      6 
      7 - `stty -onlcr` - will disable the "translate newline to carriage return newline" (from man's STTY(1)), so its negation is just move cursor one row down, without changing column.
      8 - `stty -echo` - disable STTY(1) "echo input characters" or the "Where did my keyboard go?!" mode.
      9 - `stty -icanon` - disable the "line editor" (Brandon Rhodes).
     10         STTY(1): "enable special characters: erase, kill, werase, rprnt"
     11 - `stty raw` - too?
     12 
     13 `Animations In The TERMINAL [Animating With ASCII]`: <https://youtu.be/K_6peGEsq0U?t=9m6s>
     14 
     15 You can read stty state with `stty -g` at the start of the program and then use that as the argument of stty to return to the previous state.
     16 While using it to read the state within a program, stty complained about something like "not a typewriter". Need to figure that one out. Right now there is no other way but to use something like termion, the "gay space communism" (sheesh...) project ([I wish I were kidding...](https://gitlab.redox-os.org/redox-os/termion/-/blob/master/examples/commie.rs)).
     17 
     18 Oops! According to `#rust:matrix.org` I can do this:
     19 
     20 ```
     21 std::process::Command::new("stty")
     22     .arg("-g")
     23     .stdin(std::process::Stdio::inherit())
     24     .output()
     25 ```
     26 
     27 What exactly is inherited stdin? the same stdin as the father process?