Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!batcomputer!munnari.oz.au!metro!natmlab.dap.csiro.au!ditsydh.syd.dit.CSIRO.AU!evans From: evans@syd.dit.CSIRO.AU (Bruce.Evans) Newsgroups: comp.os.minix Subject: Re: curses Keywords: curses libcurses Message-ID: <1990Sep25.130506.5737@syd.dit.CSIRO.AU> Date: 25 Sep 90 13:05:06 GMT References: <1990Sep18.175937.6490@nucleus.mi.org> Distribution: comp.os.minix Organization: CSIRO Division of Info Tech, Sydney, Australia Lines: 279 In article <1990Sep18.175937.6490@nucleus.mi.org> dec@nucleus.mi.org (Donald E. Cope) writes: > > Below is a turbo c rendition of Bjorn Larsson's PCCURSES >in 3 parts. It has been converted to run under MINIX and will >compile using either the ACK compiler or Bruce's compiler. This version is based on PCCURSES 1.0, while Larsson's version is up to 1.4. However, the 1.4 version doesn't have good support for color. Strange. The output was extremely slow. The main reason was that an escape sequence to locate the cursor was generated for *every* character. This expanded output by almost a factor of 9 (8 characters in ESC [ xx;yy H) as well as generating lots of work to format and parse the sequence. I removed most of the escape sequence by keeping track of the column. This assumes the buffer doesn't have any non-printing characters. Now output is merely slow. It's still much faster than under DOS because gotoxy remains necessary with the current method of using the BIOS for output, and BIOS output is slow. To make the output faster under Minix, the best method for the console driver is essentially a copy, with escape sequences only for color changes and at the beginnings of lines. Serial terminals need more escape sequences with things like clear-to-end-of-line and clear-n-characters. The color support won't do for any old terminal but it works well apart from speed when another Minix system's console is the terminal. Minix's term program by default strips the high bit so the box characters get messed up. Use "term -nostrip" to avoid this. My compiler fails with the doubles in prntscan.c. Don't write code like that :-). Notes on the diffs: attrib.c: Fixed formatting. beep.c: Fixed lint. charget.c: Fixed lint. charins.c: Fixed lint. curspriv.h. Fixed lint. longname.c: Fixed typo. prntscan.c: Kludged the kludged varargs functions some more. bcc is missing a library function needed for the doubles. refresh.c: Flushed stdout. Argghh. update.c Fixed major typo bugs. Fixed off-by-one error in avoiding printing to last spot on screen. Improved performance by a factor of 8. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'curses.cdif' <<'END_OF_FILE' Xdiff -c1 orig/attrib.c ./attrib.c X*** orig/attrib.c Sat Sep 22 19:12:45 1990 X--- ./attrib.c Sat Sep 22 21:37:19 1990 X*************** X*** 136,138 **** X /* setcolors() set the forground and background window colors */ X! /* of stdscr X /****************************************************************/ X--- 136,138 ---- X /* setcolors() set the forground and background window colors */ X! /* of stdscr */ X /****************************************************************/ Xdiff -c1 orig/beep.c ./beep.c X*** orig/beep.c Sat Sep 22 19:12:46 1990 X--- ./beep.c Sat Sep 22 21:40:20 1990 X*************** X*** 36,39 **** X { X int i; X- /* X _cursesscroll(0,0,LINES-1,COLS-1,0,0x70); X--- 36,39 ---- X { X+ #if 0 X int i; X _cursesscroll(0,0,LINES-1,COLS-1,0,0x70); X*************** X*** 42,44 **** X _cursesscroll(0,0,LINES-1,COLS-1,0,0x0); X! wrefresh(curscr); */ X } /* flash */ X--- 42,45 ---- X _cursesscroll(0,0,LINES-1,COLS-1,0,0x0); X! wrefresh(curscr); X! #endif X } /* flash */ Xdiff -c1 orig/charget.c ./charget.c X*** orig/charget.c Sat Sep 22 19:12:48 1990 X--- ./charget.c Sat Sep 22 21:42:59 1990 X*************** X*** 141,143 **** X wmove(stdscr,y,x); X! wgetch(stdscr); X } /* mvgetch */ X--- 141,143 ---- X wmove(stdscr,y,x); X! return wgetch(stdscr); X } /* mvgetch */ X*************** X*** 155,157 **** X wmove(win,y,x); X! wgetch(win); X } /* mvwgetch */ X--- 155,157 ---- X wmove(win,y,x); X! return wgetch(win); X } /* mvwgetch */ X*************** X*** 188,190 **** X /****************************************************************/ X! /* #undef getch /* we use MSC getch() below */ X X--- 188,192 ---- X /****************************************************************/ X! #if 0 X! #undef getch /* we use MSC getch() below */ X! #endif X X*************** X*** 192,194 **** X--- 194,198 ---- X { X+ #ifndef MINIX X int c; X+ #endif X X*************** X*** 221,223 **** X { X- int *scanp; X #ifdef MINIX X--- 225,226 ---- X*************** X*** 225,226 **** X--- 228,231 ---- X #else X+ int *scanp; X+ X if (c == 0x0300) /* special case, ^@ = NULL */ Xdiff -c1 orig/charins.c ./charins.c X*** orig/charins.c Sat Sep 22 19:12:49 1990 X--- ./charins.c Sat Sep 22 21:44:51 1990 X*************** X*** 59,61 **** X { X! winsch(stdscr,c); X } /* insch */ X--- 59,61 ---- X { X! return winsch(stdscr,c); X } /* insch */ Xdiff -c1 orig/curspriv.h ./curspriv.h X*** orig/curspriv.h Sat Sep 22 23:08:46 1990 X--- ./curspriv.h Sat Sep 22 21:50:52 1990 X*************** X*** 68,74 **** X extern char *malloc(); X extern void free(); X- #ifndef MINIX X- extern int sprintf(); X- extern int sscanf(); X- #endif X X--- 68,71 ---- X extern char *malloc(); X+ extern void exit(); X extern void free(); X Xdiff -c1 orig/longname.c ./longname.c X*** orig/longname.c Sat Sep 22 19:12:51 1990 X--- ./longname.c Sat Sep 22 21:46:44 1990 X*************** X*** 31,33 **** X #else X! return(IBM PC BIOS"); X #endif X--- 31,33 ---- X #else X! return("IBM PC BIOS"); X #endif Xdiff -c1 orig/prntscan.c ./prntscan.c X*** orig/prntscan.c Sat Sep 22 19:14:15 1990 X--- ./prntscan.c Sat Sep 22 21:51:11 1990 X*************** X*** 1,1 **** X--- 1,2 ---- X+ #define double long X /****************************************************************/ X*************** X*** 18,19 **** X--- 19,21 ---- X #include X+ #include X #include "curspriv.h" Xdiff -c1 orig/refresh.c ./refresh.c X*** orig/refresh.c Sat Sep 22 19:14:13 1990 X--- ./refresh.c Sat Sep 22 20:02:38 1990 X*************** X*** 19,20 **** X--- 19,21 ---- X #include X+ #include X #include "curspriv.h" X*************** X*** 33,34 **** X--- 34,36 ---- X doupdate(); X+ fflush(stdout); X } /* wrefresh */ Xdiff -c1 orig/update.c ./update.c X*** orig/update.c Sat Sep 22 19:14:14 1990 X--- ./update.c Sat Sep 22 22:17:04 1990 X*************** X*** 197,200 **** X srcp = twin->_line[lineno] + x; X! dstc = curscr->_colors; X! srcc - twin->_colors; X X--- 197,200 ---- X srcp = twin->_line[lineno] + x; X! dstc = &curscr->_colors; X! srcc = &twin->_colors; X X*************** X*** 251,254 **** X { X! if ((_cursvar.cursrow < LINES) || (_cursvar.curscol < COLS)) X #ifdef MINIX X _cursessetcolor(win->_colors); X--- 251,255 ---- X { X! if ((_cursvar.cursrow < LINES - 1) || (_cursvar.curscol < COLS - 1)) X #ifdef MINIX X+ { X _cursessetcolor(win->_colors); X*************** X*** 255,256 **** X--- 256,259 ---- X _cursescattr(0,ch,ch >> 8, 0); X+ ++_cursvar.curscol; X+ } X #else END_OF_FILE if test 4527 -ne `wc -c <'curses.cdif'`; then echo shar: \"'curses.cdif'\" unpacked with wrong size! fi # end of 'curses.cdif' fi echo shar: End of shell archive. exit 0 -- Bruce Evans evans@syd.dit.csiro.au