LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   changing console text in-place (https://www.linuxquestions.org/questions/programming-9/changing-console-text-in-place-213165/)

1337 Twinkie 08-04-2004 12:15 AM

changing console text in-place
 
Ok, weird question. What I want to do is change a line in the console window (Linux or DOS) without re-printing it on a new line. Like the status bars ( |=== | )things in YUM, for example. So, does anyone know how to do this or where to go to get info/examples?

I would like to use Python, but I also know C++.

Cedrik 08-04-2004 03:16 AM

On linux, you could use the ncurse library wich can control caracter position in a terminal.

1337 Twinkie 08-04-2004 10:26 AM

not compiling
 
Ok, I did a helloworld program with ncurses. Problem is that it won't compile. G++ gives "undefined reference to: xxx()" where xxx() is any ncurses function. I found this strange because the ncurses.h header is right there in my '/usr/include' directory. Here is the program:

Code:

#include <ncurses.h>

int main()
{       
        initscr();                        /* Start curses mode */
        printw("Hello World !!!");        /* Print Hello World*/
        refresh();                        /* Print it on to the real screen */
        getch();                        /* Wait for user input */
        endwin();                        /* End curses mode*/

        return 0;
}

and here are the errors (from G++):

Quote:

/tmp/ccJvUTS2.o(.text+0x11): In function `main':
: undefined reference to `initscr'
/tmp/ccJvUTS2.o(.text+0x1e): In function `main':
: undefined reference to `printw'
/tmp/ccJvUTS2.o(.text+0x26): In function `main':
: undefined reference to `refresh'
/tmp/ccJvUTS2.o(.text+0x2f): In function `main':
: undefined reference to `stdscr'
/tmp/ccJvUTS2.o(.text+0x34): In function `main':
: undefined reference to `wgetch'
/tmp/ccJvUTS2.o(.text+0x3c): In function `main':
: undefined reference to `endwin'
So, what gives? The program is copied line for line from this place: http://en.tldp.org/HOWTO/NCURSES-Pro...lloworld.html, so I believe it should work.

[edit[
Ok, I looked at the errors again and the problem seems to go al llittle deaper than I thought. Why is this: '/tmp/ccJvUTS2.o(.text+0x1e): ' there? That's just weird.
[/edit]

itsme86 08-04-2004 10:48 AM

Add -lcurses to your compile command.

1337 Twinkie 08-04-2004 10:51 AM

Cool! Thanks, that worked. ^_^


All times are GMT -5. The time now is 07:47 PM.