Results 1 to 3 of 3

Thread: console progress bar?

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    44

    Default console progress bar?

    i am building a project.

    i would like to make a progress bar in linux console, like this:

    |=================> |

    but i dont have any idea how to do it. i am using pure C.

    only thing i can think of is to clear the whole screen and rewrite it again, but i was hoping for a more elegant solution.

    thanks.

  2. #2
    Just burned his ISO
    Join Date
    Jan 2007
    Posts
    4

    Default

    using clear would make it look like this:
    |
    |>
    |=>
    and so on (the command clear is afaik not clearing the text printed till now, just scrolling down so the prompt (example: # for root) is in the most upper line visible):

    <start of text>
    line one
    line two
    clear
    <here the shell becomes visible>
    #
    (free space)
    (free space)
    <here the shell-window ends>

    for better understanding: type clear when you have some output in the shell, for example ls. then use shift+arrows to scroll up.

    Now, back to your problem. I haven't got my shell-script-book lying around, so you will have to look the details up - should be similiar in c.

    After you outputtet the line
    |==>
    you make a carriage-return (not a new line, just go to the beginning of the current line!) and overwrite it. It may be a character like this: \r
    Experiment a little with it and you can change not only the last line, but several lines (like wget does).

  3. #3
    Senior Member shamanvirtuel's Avatar
    Join Date
    Mar 2010
    Location
    Somewhere in the "Ex" human right country
    Posts
    2,988
    Watch your back, your packetz will belong to me soon... xD

    BackTrack :
    Giving Machine Guns to Monkeys since 2006

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •