Changing back line (DevKitPro)

Discussion in 'Wii - Hacking' started by D-Jay, Feb 15, 2009.

  1. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    Hi guys,

    I'm working on some code for an install-dol.

    So, I want to put a "waiting-cursor" behing each installing WAD.
    For that I use the follwing code:

    Code:
    ÂÂÂÂprintf("Some Text\n");
    ÂÂÂÂfflush(stdout);
    
    ÂÂÂÂ/* Opening */
    ÂÂÂÂfp = fopen(filepath, "rb");
    ÂÂÂÂif (!fp) {
    ÂÂÂÂÂÂÂÂprintf(" ERROR!\n");
    ÂÂÂÂÂÂÂÂgoto out;
    ÂÂÂÂ}
    ÂÂÂÂprintf("\b Waiting-Cursor-Text");

    But "Waiting-Cursor-Text" appears in the NEXT line and not as defined behind "Some Text"!?

    I guess, I do not see the wood for the trees...
     


  2. Holt

    Holt Member

    Newcomer
    44
    0
    Jan 23, 2009
    Brazil
    Fortaleza
    \n makes u jump a line
     
  3. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    Yes, I know. I have I list-view for all available WAD-files, so behind each WAD-file in the list, there's a "\n" to break the line.

    But I want to "break back" (if you know what I mean) the line to output some text behind the WAD-file-title.
     
  4. Holt

    Holt Member

    Newcomer
    44
    0
    Jan 23, 2009
    Brazil
    Fortaleza
    put the line in the place you want to, i know a lots of commands in java/C++ but i don't remeber any to back a line. Sorry.
     
  5. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    How?
     
  6. Holt

    Holt Member

    Newcomer
    44
    0
    Jan 23, 2009
    Brazil
    Fortaleza
    in the place that you want for it to appear.
     
  7. mousex

    mousex GBAtemp Advanced Fan

    Member
    987
    0
    Jan 23, 2009
    United States
    Code:
    ÂÂ printf("Some Text");
    ÂÂÂÂfflush(stdout);
    
    ÂÂÂÂ/* Opening */
    ÂÂÂÂfp = fopen(filepath, "rb");
    ÂÂÂÂif (!fp) {
    ÂÂÂÂÂÂÂÂprintf(" ERROR!\n");
    ÂÂÂÂÂÂÂÂgoto out;
    ÂÂÂÂ}
    ÂÂÂÂprintf("\b Waiting-Cursor-Text\n");
    Provided that "Some Text" is the WADs name. You write "Some Text", then "Waiting -Cursor-Text" and then a new line.
     
  8. Holt

    Holt Member

    Newcomer
    44
    0
    Jan 23, 2009
    Brazil
    Fortaleza
    do you want to appear on your screen like this?:
    Waiting-Cursor-Text

    Some Text
     
  9. blitter

    blitter Advanced Member

    Newcomer
    74
    0
    Jan 26, 2009
    I use a ttf font, but looking through the examples there's one which allows you to position the cursor with coords direct:

    Code:
    ÂÂÂÂ// The console understands VT terminal escape codes
    ÂÂÂÂ// This positions the cursor on row 2, column 0
    ÂÂÂÂ// we can use variables for this with format codes too
    ÂÂÂÂ// e.g. printf ("\x1b[%d;%dH", row, column );
    ÂÂÂÂprintf("\x1b[2;0H");
    HTH
     
  10. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
     
  11. Holt

    Holt Member

    Newcomer
    44
    0
    Jan 23, 2009
    Brazil
    Fortaleza
    i guess the swith command can solve that.
     
  12. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    So, as you see "Print filename" hast a line breaker after the filename to show the next file in the next line.
     
  13. zapu

    zapu GBAtemp Regular

    Member
    182
    0
    Jul 27, 2006
    Poland
    2up: No and you have no fscking idea about things being discussed now.

    D-Jay, there are special characters to position cursor in a line so you can 'erase' that 'installing' text when you need (just print spaces over it).
     
  14. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    I understand what you mean.

    But the "installing"-text just appears when I run the install-function.
     
  15. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    I have to think about. It's complicated for me. [​IMG]
     
  16. zapu

    zapu GBAtemp Regular

    Member
    182
    0
    Jul 27, 2006
    Poland
    Basically:

    print everything in for loop
    ...
    move back to first enity using VT terminal escape codes
    'rewrite' the text under that line to 'blablabh installing...'
    do the install stuff
    move back to the beginning of the line using VT terminal escape codes
    'rewrite' the text to 'blablabla ' < yup, some spaces to erase 'installing...' part
    ...
    do the same with the rest
     
  17. blitter

    blitter Advanced Member

    Newcomer
    74
    0
    Jan 26, 2009
    Guess you missed this post OP?
     
  18. D-Jay
    OP

    D-Jay GBAtemp Fan

    Member
    477
    8
    Jan 23, 2009
    Gambia, The
    Germany
    FINISHED (Thanks, zapu)
     
  19. blitter

    blitter Advanced Member

    Newcomer
    74
    0
    Jan 26, 2009
    my bad
     
  20. Don Killah

    Don Killah GBAtemp Maniac

    Member
    1,127
    0
    Nov 21, 2002
    France
    So D-Jay, you're really coding an installer.
    My guess was right though ^^
    Maybe you're gonna share this piece of code with us now?