Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Basic C/C++ stdout question. Print on top of other things?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
OdinsDream
Veteran
Veteran


Joined: 01 Jun 2002
Posts: 1057

PostPosted: Mon Sep 23, 2002 10:56 pm    Post subject: Basic C/C++ stdout question. Print on top of other things? Reply with quote

Many programs show their output in a progress-bar fashion, and I can understand how one can say, "Print out a period every 100 items..." or, something simple like that.

What I'm wondering, though, is how something like wget works, Where the progress bar is drawn...

[ ]

and then filled in later

[ >> ]

In other words, it's not like a stack of characters. It's the ability to jump back through the stream, and change the items that were already printed out. How can this be done?

I've tried using cout.tellp() in hopes of finding out that I could fseek() backwards, but this results in compile errors.

Again, a simple question, I know... but something I've never figured out. Thanks for any help.
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Mon Sep 23, 2002 11:28 pm    Post subject: Re: Basic C/C++ stdout question. Print on top of other thing Reply with quote

OdinsDream wrote:
Again, a simple question, I know

Actually, it is anything but simple. C++ iostreams have no notion of screen representation. wget uses a trick of outputting ASCII BS ^H and CR ^M to do that printing magic in a terminal window. See bar_set_params in progress.c for details.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
OdinsDream
Veteran
Veteran


Joined: 01 Jun 2002
Posts: 1057

PostPosted: Tue Sep 24, 2002 5:12 pm    Post subject: Reply with quote

Interesting... so there's no class available for this type of manipulation?

I'll take a look at the file you mention, thanks for the tips.
Back to top
View user's profile Send private message
TripKnot
Apprentice
Apprentice


Joined: 29 May 2002
Posts: 213

PostPosted: Wed Sep 25, 2002 9:54 pm    Post subject: Reply with quote

Hmmm, I've written some apps where I can freely place the cursor where ever I want using the window(x1,y1,x2,y2) function. It might be in conio.h. There may be a similar function to get the current cursor position and in combination with window you can do the progress bat you want.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum