Results 1 to 8 of 8
Hi, I need to update text in terminal. Say update some 90% to 91%. Just like the command line downloaders do. How can I do it in C or bash ...
- 08-06-2007 #1
Updating text in terminal
Hi, I need to update text in terminal. Say update some 90% to 91%. Just like the command line downloaders do. How can I do it in C or bash script (i mean inclusive or).
- 08-06-2007 #2
The trick is to output the backspace character (represented symbolically as '\b'). So for instance, in Bash (though this translates directly into C):
I print out 'ab' (the '-n' disables the trailing newline). I then print out the backspace character and 'c' (the '-e' enables backslash interpretation). The 'b' is erased, and replaced with the 'c'.Code:alex@danu ~ $ echo -n 'ab'; echo -e '\bc' ac
DISTRO=Arch
Registered Linux User #388732
- 08-06-2007 #3
Hah, that's clever as hell Cabhan! I like that. I was thinking use dialog or ncurses.
- 08-08-2007 #4
\b oh no!
How can I update this?
Task 1: 99%
Task 2: 65%
Task 3: 80%
.......
......
Where progress of different tasks is updated by different threads?
\b simply isn't the solution.
- 08-08-2007 #5
yes curses
Now I've got it. Curse that's all google needed to lead me toward what I wanted.
Thanks.
- 08-08-2007 #6
Aha. For that, you'll need separate labels, each of which is managed by its own thread. I've not used curses myself before, but I'm sure that it has the facilities you need.
DISTRO=Arch
Registered Linux User #388732
- 08-09-2007 #7
O I though you were sticking with bash, yea NCurses can do that pretty easily. Don't think you even really need to use threads for it. Just have a loop that does the math on the three counters then uses addstr() to put the information in the window and refresh() to draw it. If you're interested in NCurses, I recommend getting the only book on the topic (besides O Reilly's curses book from the 80s), "Programmer's Guide to NCurses". I have it, and it goes through Ncurses slowly and methodically with TONS of code examples.
- 08-17-2007 #8
Yeah. NCurses
Thanks. NCurses. That's all I needed. There is rich documentation on the web.


Reply With Quote