5
jestdotty
44d

fuck my amount of things I have to write is exponentially increasing as I fail to keep up with all the features i need fucking hell

at least I bought groceries before shops closed today. gotta go through my potatoes and make sure they're not bad and throw out all the bad ones and eat any sus ones first

fuck I haven't even began exploring how to do a TUI. I need a few days to explore it but the things I need yesterday are stressing me out so I don't know how I could calm down enough to have a nice deep dive into it and gain expertise if I'm so distracted all the time but coming up with more fucking things I need, fuck

how do i

Comments
  • 2
    I know that panic.

    Mine was resolved when our team was firm on the amount of work we were committing to each sprint (always giving ourselves breathing room too to account for surprises).

    Also helps to have the next few high priority tickets sitting waiting at the top of the backlog so your team can pick bits up when available if work was completed sooner.

    Sounds like you don't have any discovery tasks / refinement ones _before_ starting the real ticket? Are you just expected to get it right and implemented - first time - when working in an unfamiliar area? That doesn't sound sustainable at all if that's the case and their expectations need to be managed better. No human can perform that kind of magic without paying for it with their soul. Folk tales taught us that! 😈

    (Fuck em all sweetheart, you'll get though this)
  • 1
    My soul can't operate well if it can't follow this mantra: 'Programming is the art of doing one thing at a time'
  • 2
    It's important to know the ANSII codes for clearing screen and applying colors and reset the usage of those colors to default.

    It's important to redraw on both key down and a interval of say 10Ms. You let the application read a key with a timeout of 10. Why not only on keypress? Well, maybe some module needs to react every 'tick'. Imagine if you would display time in your screen or incrementing counter, you don't want it to stand still. It's ok for the computer. My TUI app uses 1% CPU or so.

    It's important to render to a string with a size of the terminal width*terminal height. Having a cursor pointing to a point in the string that get's automatically updated after every "print" to that string after input is nice. Everytime printing to terminal is slow. It's better to print at once.

    If you need to scroll, the cursor on screen won't match the cursor in your "document" anymore. You need to convert the cursor position on screen to cursor position of document
  • 1
    Does Rust have ncurses bindings? Ncurses is a popular way to build TUI apps and does certain stuff for you. I didn't use it because I like to do things from scratch. Want to know how it works.

    Also, you need to set your stdin to raw, else it wouldn't react on every key input. Everytime your application crashes, the terminal won't show anything assuming you have NO_ECHO enabled. Just smash return a few times and enter 'reset' (you won't see it) to restore your terminal.

    These are my learned things when writing such app. Hope a few where useful / new to you
  • 1
    If your TUI app needs plugins consider the wren language as your choice! It's good embed-able. See https://github.com/Jengamon/ruwren.

    I've implemented keybindings using wren in my TUI editor. Now my editor code itself is super clean, it only handles kinda redraw, cursor and resizing and trigger events to communicate like "before_render, after_render, after_press". In plugins / wren i do the "dirty" stuff. It feels good to have it separated. Bit lame is that i've build in the vim keybindings in a new editor. I did convert key-codes to text like "Ctrl+3". Ctrl+3 is a combination of multiple chars. That's something annoying to figure out.

    Post the progress, i'm interested :)
  • 1
    @jestdotty a wren interpreter in Rust isn't strange :) wren is kind made for to be embedded. Using wren scripts to power your TUI is cool because now you can extend your app without compilation. Ultimate way to make plugin support.

    I'll make maybe thread support in wren. Have no idea of impact. I'll just timebox it for a few hours.

    I have three projects running now:

    - rrex3 (my regex parser) it is tested well but still gave issues when i tried to actually use it for other stuff i write

    - rmerge2, first version worked well, it did merge all locally included C files to one file. But the new version, i want it only contain functions and stuff that the main script uses. It's writing a half C parser and support for C macros. It's kinda challenging. It depends on rrex3

    - reditor, a VIM like editor in C for C (only language it'll support prolly) but powered by wren. It also depends on rrex3

    I switch between those three projects to keep it fun. They're quite different.
  • 1
    @jestdotty that's some cool stuff indeed. Probably better than the ncurses i recommended. Ncurses is old as F tbh
  • 1
    @jestdotty bit weird, multiple spans fit on a line right? If we talk about html jargon? I kinda hate the names lines and cols. I think in x and y. I currently have these terms mixed in code
  • 0
    @jestdotty bit weird, multiple spans fit on a line right? If we talk about html jargon? I kinda hate the names lines and cols. I think in x and y. I currently have these terms mixed in code
  • 0
    @jestdotty Nah, ANSII lib.. You can make it yourself. Created with GPT, all 256 colors using Rust (fore and back):

    fn main() {

    // Generate foreground colors

    for i in 0..256 {

    println!("const FG_COLOR_{}: &str = \"\\x1b[38;5;{}m\";", i, i);

    }

    // Generate background colors

    for i in 0..256 {

    println!("const BG_COLOR_{}: &str = \"\\x1b[48;5;{}m\";", i, i);

    }

    }
  • 0
    \\x1b is bit weird. Not sure about Rust, but you can prolly use \e instead. It means escape
  • 0
    @jestdotty yes, totally do that. Colors do not really deserve to be a library anyway. Your crate boilerplate is maybe bigger.

    Edit: personally i have just 7 colors or so and they have own their own print function. rprinty (yellow) rprintr (red) etc. What those function do is print color, the formatted string, clear ansii to reset the color
  • 1
    @jestdotty what about marquee?
  • 1
    @jestdotty HTML && Css don't have to win. There are also normal gui's. Why not look for some gkt binding?

    https://www.gpui.rs/ is used for zed.

    I'm tired of html && Css too. I prefer smth I didn't use yet.

    TUI was a time swallowing solution anyway
  • 1
    @jestdotty wow, i've seen it. Didn't know it was written in Rust. The exams in the Netherlands for construction (carpenters) regarding drawing with Autocad is designed by my dad and a few people. He can draw with nearly touching the mouse. It's like w'ere vimming. Because my dad did this, we always had the most extreme kind of computer at home. The employer paid 50% of the computer price whatever you spend on it. Autocad in browser, but also openttd in browser completely converted blew my mind

    That UI is very beautiful. Is wasm so much faster than JS? I often have the feeling it came late to the party. I mean, ever seen what they can render with threeJS these days? Anything you draw with blender. I played with it because I had a VR. Sadly, due lack of creativity it was pointless for me to spend time on. If i could design, i would've made a VPS shooter already for sure. But I also have to admit i had some issue with math regarding scaling and stuff
Add Comment