Hi!
i am new to NIM, I'm just a hobby programmer - and i need some mentorship: Started with Nim in Action, then i found terminal.nim, so i jumped into terminal programming.
STUI will be a Simplified Terminal UI. https://github.com/nais314/stui
I have an App = ref object, as a central object, and it is passed to every object. app has the seq[Window], stores cursorPos, etc. Keyboard & Mouse events are catched by a spawned proc (mainloop.inc.nim), then app.onKeypress or app.activeControll.onKeypress (etc) handles the event.
I am stuck with 2 things: 1: in mainloop.inc.nim (76): if kmloopFlowVar.isReady(): consumes lot of CPU, but it is non blocking, so app.runTimers() can do its job - run procs at timed interval like watching for terminal resize 2: stui.nim (1462), app.runTimers(): i wish to run proc-s parallel
I tried Channels, with no luck so far, but its maybe a user error ;)
Soo, before i clean up, add more controlls etc, i wish someone could show me the way with the core structure, main loop, overall structure.
Thanks, and best wishes: István
You probably want a sleep in your loop. sleep(0) or sleep(1) should work.
You can't pass ref objects between threads but you can ptr objects but you need to make sure all threads are done with it before freeing manually.
Channels might be a better choice. I think they copy your ref objects between threads so it should be ok.