Search code examples
curses

Add line when end of the window is reached using curses?


I have a small repl app using curses but I'm facing a problem to add new lines when end of window is reach. Output looks like the following, being --- the window limits:

---
REPL> :dothis
====>  Well done!
REPL> :dothat
====>  OK, done
REPL> :dothatagain====>  All right...REPL> // can't add more lines :(
---

How do I addstr when end of window is reached just like a normal terminal buffer? I don't need to scroll back, just write a trail of lines. Is there any window setting to get an infinite vertical window?

Answers in any common language are fine (C preferred)


Solution

  • After some research on curses native API I noticed there is a int scrollok(WINDOW *win, bool bf); function:

    scrollok(*window, true);
    

    I didn't find the function before because the curses biding library I was using didn't have this function implemented so I just made a wrapper for it. Conclusion is to always look at the native curses API when using external language API bidings.