Issue with Curses and C68

Anything QL Software or Programming Related.
Post Reply
swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Issue with Curses and C68

Post by swensont »

I'm porting an old program from Unix to the QL. It compiles and runs, but the text output has an issue. The part that uses curses seems to run fine.

When printing text, the program uses "fprintf(stderr,"text \n"); ". The output on the screen looks like this:
text
text
text
as if the screen is getting a line feed, but not a carriage return. I've created a short program that demonstrates the issue. If it compile it without using "-lcurses" it works as expected. Adding "-lcurses" and I get the odd behavior. I also noticed that without curses, the text is white, with curses the text is green. I've used printf instead of fprintf and I get the same behavior.

Here is the test program:

/* testf_c */
/* exec cc;"-o testf_exe testf_c -lcurses" */

#include <stdio.h>
#include <curses.h>

main() {

printf("This is a test \n");
printf("this is a test \n");
printf("This is a test \n");

}

I'm thinking it is a bug with the curses library. Can anyone else reproduce the issue? I am using SMSQmulator as my test platform.

Thanks,

Tim


swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Issue with Curses and C68

Post by swensont »

Well the example text did not show as I wanted in my posting, Let me try it this way (using dots instead of spaces).

text
......text
............text

Tim


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Issue with Curses and C68

Post by tofro »

Well, most of my books say "don't mix Curses and standard text output". I guess what you're seeing seems to confirm this.
(Although I think that Curses should be deactivated outside of initscr() / endwin() blocks).


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Issue with Curses and C68

Post by swensont »

Tofro, Thanks for the reply. I've not done any curses programming on Unix/Linux before, so I've not read up on any caveats.

I have not tried to compile the program on LInux to see if it is a pure curses issue. The DOS version uses it's own display routines and not curses. If it is a curses issue, I could just use printw() instead of fprintf() to get around the issue. Just will take some editing to get that done throughout the code.

Tim


User avatar
ppe
Trump Card
Posts: 171
Joined: Tue Dec 14, 2010 10:48 am
Location: Espoo, Finland

Re: Issue with Curses and C68

Post by ppe »

Tried the test code out on Mac/GCC, works correctly, i.e. all lines start in the leftmost column. On Q-Emulator with C68 behaviour is the same as Tim observed on SMSQmulator.


swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Issue with Curses and C68

Post by swensont »

I've made some more progress in the program that I am porting. I got beyond a C68 compile issue just by adding some code back in.

Now I'm hitting an issue of the display. Curses does not seem to be clearing the screen when it should. The printw statements are initially working, but then they start going back to using only LF and no CR on the screen. I'm starting to worry that the QL version of Curses is broken.

I know that QL Curses is early Curses, but has anyone done any real testing of the Curses library?

(I know that Rogue was ported, but it does not come with source code)

Tim


User avatar
NormanDunbar
Forum Moderator
Posts: 2251
Joined: Tue Dec 14, 2010 9:04 am
Location: Leeds, West Yorkshire, UK
Contact:

Re: Issue with Curses and C68

Post by NormanDunbar »

Hi Tim,

Sorry, I have never had to use curses -- either on *nix or on the QL. I might be wrong but I have a feeling that the QL version of Emacs (hack, spit, duck, run) might use it? The last time I used QL Emacs and looked at the source was back in the 1990s though.


Cheers,
Norm.


Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts

No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
swensont
Forum Moderator
Posts: 252
Joined: Tue Dec 06, 2011 3:30 am
Location: SF Bay Area
Contact:

Re: Issue with Curses and C68

Post by swensont »

The final bit of this saga is that in the end, I just got rid of Curses. The two main calls were move() and addch(). I just wrote wrappers for each one of these. I removed the other curses calls, esp. the refresh() calls and got things working that way. The oddest thing that was the clear() (like CLS) was not working at all, so it make for a very confusing looking screen.

Tim


User avatar
XorA
Site Admin
Posts: 1358
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Issue with Curses and C68

Post by XorA »

Found another issue with C68 curses.

When a window has scrollok(true) set, actually scrolling the window crashes.

I take it there has never been an update for QL version of curses? (using the one from C68 4.24f)


User avatar
XorA
Site Admin
Posts: 1358
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: Issue with Curses and C68

Post by XorA »

XorA wrote:Found another issue with C68 curses.

When a window has scrollok(true) set, actually scrolling the window crashes.

I take it there has never been an update for QL version of curses? (using the one from C68 4.24f)
Found and fixed the issue, Ill start another thread with links to the fix and updated libcurses.a


Post Reply