LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Curses library trouble! (\r\n) (http://www.linuxquestions.org/questions/programming-9/curses-library-trouble-%5Cr%5Cn-107951/)

Skute 10-24-2003 07:02 AM

Curses library trouble! (\r\n)
 
im having a problem with the curses library - the dreaded \r\n!

in a normal console, if i do:

printf("Some text\r\n");

it will print the text and then a new line, however, with the curses library, it moves the cursor to the beginning of the line, clears the text, then moves the cursor down.

So if i try:

printf("Some text\r\n");

with the curses library, all that i see is a new line (the cursor moves down).

Is there some sort of flag i can set to stop this? Or is it best to try to reverse the \r\n when using the curses library (reverse by searching the string for \r\n sequence)?

Any help / hints / advice is much appreciated cause this is driving me mad ;)

kev82 10-24-2003 07:19 AM

silly idea - dont use printf, use printw and mvprintw and then you dont need \r\n because you can move the cursor wherever you need it to be.

Skute 10-24-2003 07:28 AM

i am using printw

this is the code:

char* message = "testing123\r\n";

printw(message);
refresh();


And all i get is a line break.

kev82 10-24-2003 07:35 AM

but why are you putting the \r\n in there? use the move or wmove function curses isnt meant for terminal style output.

Skute 10-24-2003 08:48 AM

because the application is actually a socket server. its just displaying data that got sent to it. when i connect from telnet (in linux) i type a sentance in, hit return and it automatically puts the \r\n onto the end.

kev82 10-24-2003 10:26 AM

the two questions that come to mind are

1) if all it does is display data from a telnet session then why use curses?
2) if you do need to use curses then why not just remove the \r\n off the end?

Skute 10-24-2003 10:31 AM

yeah ive been using this curses now and ive switched the \r\n around to \n\r which makes it display properly. but ive decided to ditch it anyway, because the screen doesnt scroll like a normal console.

reason ive been using curses is because i wanted to use the getch function, i was told the only way to get a character from the keyboard without pressing enter is with the curses library?

ill go back to using getchar() now. thanks


All times are GMT -5. The time now is 06:59 PM.