Page 1 of 1

Issue with Curses and C68

Posted: Sat Dec 19, 2020 5:35 am
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

Re: Issue with Curses and C68

Posted: Sat Dec 19, 2020 5:37 am
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

Re: Issue with Curses and C68

Posted: Sat Dec 19, 2020 6:54 am
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).

Re: Issue with Curses and C68

Posted: Sat Dec 19, 2020 4:18 pm
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

Re: Issue with Curses and C68

Posted: Sat Dec 19, 2020 9:02 pm
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.

Re: Issue with Curses and C68

Posted: Sat Jan 02, 2021 6:09 pm
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

Re: Issue with Curses and C68

Posted: Sun Jan 03, 2021 10:17 am
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.

Re: Issue with Curses and C68

Posted: Tue Jan 05, 2021 6:59 pm
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

Re: Issue with Curses and C68

Posted: Mon Aug 02, 2021 4:42 pm
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)

Re: Issue with Curses and C68

Posted: Tue Aug 03, 2021 12:32 am
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