LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-24-2003, 07:02 AM   #1
Skute
Member
 
Registered: Jul 2003
Distribution: SUSE 9.0 Pro
Posts: 45

Rep: Reputation: 15
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
 
Old 10-24-2003, 07:19 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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.
 
Old 10-24-2003, 07:28 AM   #3
Skute
Member
 
Registered: Jul 2003
Distribution: SUSE 9.0 Pro
Posts: 45

Original Poster
Rep: Reputation: 15
i am using printw

this is the code:

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

printw(message);
refresh();


And all i get is a line break.
 
Old 10-24-2003, 07:35 AM   #4
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
but why are you putting the \r\n in there? use the move or wmove function curses isnt meant for terminal style output.
 
Old 10-24-2003, 08:48 AM   #5
Skute
Member
 
Registered: Jul 2003
Distribution: SUSE 9.0 Pro
Posts: 45

Original Poster
Rep: Reputation: 15
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.
 
Old 10-24-2003, 10:26 AM   #6
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
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?
 
Old 10-24-2003, 10:31 AM   #7
Skute
Member
 
Registered: Jul 2003
Distribution: SUSE 9.0 Pro
Posts: 45

Original Poster
Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xscreensaver install trouble: library dependencies marquitico Linux - Newbie 4 08-26-2005 08:28 PM
do I need curses? jake_01 Programming 1 04-28-2005 06:24 AM
Where is curses.h and semun.h DavidW567 Programming 1 01-13-2005 11:57 AM
Library trouble? punkmonkey Arch 2 07-30-2004 04:44 PM
Curses nitinkatageri Linux - General 2 08-18-2003 04:58 AM


All times are GMT -5. The time now is 02:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration