how to clear specific written content in terminal using zig-spoon

108 views Asked by At

I'm trying to make a TUI menu that shows the selected option in green color and when you click on up or down it should clear only the written text by application, so basically only the text that was added after script was run should be deleted.

The problem is that while using zig-spoon library I couldn't find a way to clear a specific part, there are functions term.cook() and term.uncook() ( in zig-spoon ) which clear totally all the terminal and I didn't seem yet to find any solution how to prevent that.

I've tried to change a little bit source code of zig-spoon, I've noticed the following: in file Term.zig, function uncook() if you change spells.enter_alt_buffer to spells.leave_alt_buffer - you already won't have cleared console by the start, however it will appear after another render

If I would also be able to change spells.clear() in cook() function into something that would clear the last X lines - that would also solve the problem

I would also accept as an answer an alternative library or another solution without using zig-spoon. Thanks in advance for your help.

Additional information:

My Zig version: 0.11.0 Zig-spoon source code

0

There are 0 answers