diff --git a/lib/libncurses/Makefile b/lib/libncurses/Makefile index 5cb0429121fd..8e4d3ea252ca 100644 --- a/lib/libncurses/Makefile +++ b/lib/libncurses/Makefile @@ -1,209 +1,209 @@ # Makefile for ncurses -# $Id: Makefile,v 1.21 1997/02/22 15:07:38 peter Exp $ +# $Id: Makefile,v 1.22 1997/08/24 19:09:32 ache Exp $ LIB= ncurses SHLIB_MAJOR= 3 SHLIB_MINOR= 1 SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \ lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \ lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \ lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c lib_keyname.c\ lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \ lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\ lib_box.c lib_clear.c lib_delch.c lib_insch.c lib_instr.c \ lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \ lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \ lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c -CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO +CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE DPADD= ${LIBMYTINFO} LDADD= -lmytinfo CLEANFILES+= lib_keyname.c keys.tries beforedepend: keys.tries beforeinstall: ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/unctrl.h \ ${DESTDIR}/usr/include ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/curses.h \ ${DESTDIR}/usr/include/ncurses.h keys.tries: ${.CURDIR}/keys.list ${.CURDIR}/MKkeys.awk awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > keys.tries # in case you don't run make depend lib_options.o lib_options.so lib_options.po: keys.tries lib_keyname.c: ${.CURDIR}/keys.list ${.CURDIR}/MKkeyname.awk awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c MAN3 = curs_addch.3 \ curs_addchst.3 \ curs_addstr.3 \ curs_attr.3 \ curs_beep.3 \ curs_bkgd.3 \ curs_border.3 \ curs_clear.3 \ curs_color.3 \ curs_delch.3 \ curs_delln.3 \ curs_getch.3 \ curs_getstr.3 \ curs_getyx.3 \ curs_inch.3 \ curs_inchstr.3 \ curs_initscr.3 \ curs_inopts.3 \ curs_insch.3 \ curs_insstr.3 \ curs_instr.3 \ curs_kernel.3 \ curs_move.3 \ curs_outopts.3 \ curs_overlay.3 \ curs_pad.3 \ curs_printw.3 \ curs_refresh.3 \ curs_scanw.3 \ curs_scr_dmp.3 \ curs_scroll.3 \ curs_slk.3 \ curs_termatt.3 \ curs_termin.3 \ curs_touch.3 \ curs_util.3 \ curs_window.3 \ ncurses.3 MAN5 = term.5 terminfo.5 MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 echochar.3 \ curs_addch.3 wechochar.3 curs_addch.3 mvaddch.3 \ curs_addch.3 mvwaddch.3 MLINKS+=curs_addchst.3 addchstr.3 curs_addchst.3 addchnstr.3 \ curs_addchst.3 waddchstr.3 curs_addchst.3 waddchnstr.3 \ curs_addchst.3 mvaddchstr.3 curs_addchst.3 mvaddchnstr.3 \ curs_addchst.3 mvwaddchstr.3 curs_addchst.3 mvwaddchnstr.3 MLINKS+=curs_addstr.3 addstr.3 curs_addstr.3 addnstr.3 \ curs_addstr.3 waddstr.3 curs_addstr.3 waddnstr.3 \ curs_addstr.3 mvaddstr.3 curs_addstr.3 mvaddnstr.3 \ curs_addstr.3 mvwaddstr.3 curs_addstr.3 mvwaddnstr.3 MLINKS+=curs_attr.3 attroff.3 curs_attr.3 wattroff.3 \ curs_attr.3 attron.3 curs_attr.3 wattron.3 \ curs_attr.3 attrset.3 curs_attr.3 wattrset.3 \ curs_attr.3 standend.3 curs_attr.3 wstandend.3 \ curs_attr.3 standout.3 curs_attr.3 wstandout.3 MLINKS+=curs_beep.3 beep.3 curs_beep.3 flash.3 MLINKS+=curs_bkgd.3 bkgdset.3 curs_bkgd.3 wbkgdset.3 \ curs_bkgd.3 bkgd.3 curs_bkgd.3 wbkgd.3 MLINKS+=curs_border.3 border.3 curs_border.3 wborder.3 curs_border.3 box.3 \ curs_border.3 hline.3 curs_border.3 whline.3 \ curs_border.3 vline.3 curs_border.3 wvline.3 MLINKS+=curs_clear.3 erase.3 curs_clear.3 werase.3 curs_clear.3 clear.3 \ curs_clear.3 wclear.3 curs_clear.3 clrtobot.3 \ curs_clear.3 wclrtobot.3 curs_clear.3 clrtoeol.3 \ curs_clear.3 wclrtoeol.3 MLINKS+=curs_color.3 start_color.3 curs_color.3 init_pair.3 \ curs_color.3 init_color.3 curs_color.3 has_colors.3 \ curs_color.3 can_change_color.3 curs_color.3 color_content.3 \ curs_color.3 pair_content.3 MLINKS+=curs_delch.3 delch.3 curs_delch.3 wdelch.3 curs_delch.3 mvdelch.3 \ curs_delch.3 mvwdelch.3 MLINKS+=curs_delln.3 deleteln.3 curs_delln.3 wdeleteln.3 \ curs_delln.3 insdelln.3 curs_delln.3 winsdelln.3 \ curs_delln.3 insertln.3 curs_delln.3 winsertln.3 MLINKS+=curs_getch.3 getch.3 curs_getch.3 wgetch.3 curs_getch.3 mvgetch.3 \ curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3 MLINKS+=curs_getstr.3 getstr.3 curs_getstr.3 wgetstr.3 \ curs_getstr.3 mvgetstr.3 curs_getstr.3 mvwgetstr.3 \ curs_getstr.3 wgetnstr.3 MLINKS+=curs_getyx.3 getyx.3 curs_getyx.3 pgetparyx.3 curs_getyx.3 getbegyx.3 \ curs_getyx.3 getmaxyx.3 MLINKS+=curs_inch.3 inch.3 curs_inch.3 winch.3 curs_inch.3 mvinch.3 \ curs_inch.3 mvwinch.3 MLINKS+=curs_inchstr.3 inchstr.3 curs_inchstr.3 inchnstr.3 \ curs_inchstr.3 winchstr.3 curs_inchstr.3 winchnstr.3 \ curs_inchstr.3 mvinchstr.3 curs_inchstr.3 mvinchnstr.3 \ curs_inchstr.3 mvwinchstr.3 curs_inchstr.3 mvwinchnstr.3 MLINKS+=curs_initscr.3 initscr.3 curs_initscr.3 newterm.3 \ curs_initscr.3 endwin.3 curs_initscr.3 isendwin.3 \ curs_initscr.3 set_term.3 curs_initscr.3 delscreen.3 MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 nocbreak.3 curs_inopts.3 echo.3 \ curs_inopts.3 noecho.3 curs_inopts.3 halfdelay.3 \ curs_inopts.3 intrflush.3 curs_inopts.3 keypad.3 curs_inopts.3 meta.3 \ curs_inopts.3 nodelay.3 curs_inopts.3 notimeout.3 curs_inopts.3 raw.3 \ curs_inopts.3 noraw.3 curs_inopts.3 noqiflush.3 \ curs_inopts.3 qiflush.3 curs_inopts.3 timeout.3 \ curs_inopts.3 wtimeout.3 curs_inopts.3 typeahead.3 MLINKS+=curs_insch.3 insch.3 curs_insch.3 winsch.3 curs_insch.3 mvinsch.3 \ curs_insch.3 mvwinsch.3 MLINKS+=curs_insstr.3 insstr.3 curs_insstr.3 insnstr.3 \ curs_insstr.3 winsstr.3 curs_insstr.3 winsnstr.3 \ curs_insstr.3 mvinsstr.3 curs_insstr.3 mvinsnstr.3 \ curs_insstr.3 mvwinsstr.3 curs_insstr.3 mvwinsnstr.3 MLINKS+=curs_instr.3 instr.3 curs_instr.3 innstr.3 curs_instr.3 winstr.3 \ curs_instr.3 winnstr.3 curs_instr.3 mvinstr.3 curs_instr.3 mvinnstr.3 \ curs_instr.3 mvwinstr.3 curs_instr.3 mvwinnstr.3 MLINKS+=curs_kernel.3 def_prog_mode.3 curs_kernel.3 def_shell_mode.3 \ curs_kernel.3 reset_prog_mode.3 curs_kernel.3 reset_shell_mode.3 \ curs_kernel.3 resetty.3 curs_kernel.3 savetty.3 \ curs_kernel.3 getsyx.3 curs_kernel.3 setsyx.3 \ curs_kernel.3 ripoffline.3 curs_kernel.3 curs_set.3 \ curs_kernel.3 napms.3 MLINKS+=curs_move.3 move.3 curs_move.3 wmove.3 MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idlok.3 \ curs_outopts.3 idcok.3 curs_outopts.3 immedok.3 \ curs_outopts.3 leaveok.3 curs_outopts.3 setscrreg.3 \ curs_outopts.3 wsetscrreg.3 curs_outopts.3 scrollok.3 \ curs_outopts.3 nl.3 curs_outopts.3 nonl.3 MLINKS+=curs_overlay.3 overlay.3 curs_overlay.3 overwrite.3 \ curs_overlay.3 copywin.3 MLINKS+=curs_pad.3 newpad.3 curs_pad.3 subpad.3 curs_pad.3 prefresh.3 \ curs_pad.3 pnoutrefresh.3 curs_pad.3 pechochar.3 MLINKS+=curs_printw.3 printw.3 curs_printw.3 wprintw.3 \ curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \ curs_printw.3 vwprintw.3 MLINKS+=curs_refresh.3 refresh.3 curs_refresh.3 wrefresh.3 \ curs_refresh.3 wnoutrefresh.3 curs_refresh.3 doupdate.3 \ curs_refresh.3 redrawwin.3 curs_refresh.3 wredrawln.3 MLINKS+=curs_scanw.3 scanw.3 curs_scanw.3 wscanw.3 curs_scanw.3 mvscanw.3 \ curs_scanw.3 mvwscanw.3 curs_scanw.3 vwscanw.3 MLINKS+=curs_scr_dmp.3 scr_dump.3 curs_scr_dmp.3 scr_restore.3 \ curs_scr_dmp.3 scr_init.3 curs_scr_dmp.3 scr_set.3 MLINKS+=curs_scroll.3 scroll.3 curs_scroll.3 scrl.3 curs_scroll.3 wscrl.3 MLINKS+=curs_slk.3 slk_init.3 curs_slk.3 slk_set.3 curs_slk.3 slk_refresh.3 \ curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_label.3 \ curs_slk.3 slk_clear.3 curs_slk.3 slk_restore.3 \ curs_slk.3 slk_touch.3 curs_slk.3 slk_attron.3 \ curs_slk.3 slk_attrset.3 curs_slk.3 slk_attroff.3 MLINKS+=curs_termatt.3 baudrate.3 curs_termatt.3 erasechar.3 \ curs_termatt.3 has_ic.3 curs_termatt.3 has_il.3 \ curs_termatt.3 killchar.3 curs_termatt.3 longname.3 \ curs_termatt.3 termattrs.3 curs_termatt.3 termname.3 # XXX name clash with termcap(3) # MLINKS+= curs_termin.3 tparm.3 MLINKS+=curs_termin.3 setupterm.3 curs_termin.3 setterm.3 \ curs_termin.3 set_curterm.3 curs_termin.3 del_curterm.3 \ curs_termin.3 restartterm.3 \ curs_termin.3 putp.3 curs_termin.3 vidputs.3 \ curs_termin.3 vidattr.3 curs_termin.3 mvcur.3 \ curs_termin.3 tigetflag.3 curs_termin.3 tigetnum.3 \ curs_termin.3 tigetstr.3 MLINKS+=curs_touch.3 touchwin.3 curs_touch.3 touchline.3 \ curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3 \ curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3 MLINKS+=curs_util.3 unctrl.3 curs_util.3 keyname.3 \ curs_util.3 filter.3 curs_util.3 use_env.3 \ curs_util.3 putwin.3 curs_util.3 getwin.3 \ curs_util.3 delay_output.3 curs_util.3 flushinp.3 MLINKS+=curs_window.3 newwin.3 curs_window.3 delwin.3 \ curs_window.3 mvwin.3 curs_window.3 subwin.3 \ curs_window.3 derwin.3 curs_window.3 mvderwin.3 \ curs_window.3 dupwin.3 curs_window.3 wsyncup.3 \ curs_window.3 syncok.3 curs_window.3 wcursyncup.3 \ curs_window.3 wsyncdown.3 .include diff --git a/lib/libncurses/lib_doupdate.c b/lib/libncurses/lib_doupdate.c index 39c8b8f1ea41..cf7d284b70ca 100644 --- a/lib/libncurses/lib_doupdate.c +++ b/lib/libncurses/lib_doupdate.c @@ -1,593 +1,593 @@ /* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for * * details. If they are missing then this copy is in violation of * * the copyright conditions. */ /*----------------------------------------------------------------- * * lib_doupdate.c * * The routine doupdate() and its dependents * *-----------------------------------------------------------------*/ #include #include #ifdef SYS_SELECT #include #endif #include #include "curses.priv.h" #include "terminfo.h" #ifdef SVR4_ACTION #define _POSIX_SOURCE #endif #include static void ClrUpdate( WINDOW *scr ); static void TransformLine( int lineno ); static void NoIDcTransformLine( int lineno ); static void IDcTransformLine( int lineno ); static void ClearScreen( void ); static void InsStr( chtype *line, int count ); static void DelChar( int count ); static inline void PutAttrChar(chtype ch) { TR(TRACE_CHARPUT, ("PutAttrChar(%s, %s)", _tracechar(ch & A_CHARTEXT), _traceattr((ch & (chtype)A_ATTRIBUTES)))); if (curscr->_attrs != (ch & (chtype)A_ATTRIBUTES)) { curscr->_attrs = ch & (chtype)A_ATTRIBUTES; vidputs(curscr->_attrs, _outch); } putc(ch & A_CHARTEXT, SP->_ofp); } static int LRCORNER = FALSE; static inline void PutChar(chtype ch) { if (LRCORNER == TRUE && SP->_curscol == columns-1) { int i = lines -1; int j = columns -1; LRCORNER = FALSE; if ( (!enter_insert_mode || !exit_insert_mode) && !insert_character ) return; if (cursor_left) putp(cursor_left); else mvcur(-1, -1, i, j); PutAttrChar(ch); if (cursor_left) putp(cursor_left); else mvcur(-1, -1, i, j); if (enter_insert_mode && exit_insert_mode) { putp(enter_insert_mode); PutAttrChar(newscr->_line[i][j-1]); putp(exit_insert_mode); } else if (insert_character) { putp(insert_character); PutAttrChar(newscr->_line[i][j-1]); } return; } PutAttrChar(ch); SP->_curscol++; if (SP->_curscol >= columns) { if (auto_right_margin) { SP->_curscol = 0; SP->_cursrow++; } else { SP->_curscol--; } } } static inline void GoTo(int row, int col) { mvcur(SP->_cursrow, SP->_curscol, row, col); SP->_cursrow = row; SP->_curscol = col; } int _outch(int ch) { if (SP != NULL) putc(ch, SP->_ofp); else putc(ch, stdout); return OK; } int doupdate(void) { int i; sigaction_t act, oact; T(("doupdate() called")); act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; sigaction(SIGTSTP, &act, &oact); if (SP->_endwin == TRUE) { T(("coming back from shell mode")); reset_prog_mode(); + if (enter_ca_mode) + putp(enter_ca_mode); /* is this necessary? */ if (enter_alt_charset_mode) init_acs(); newscr->_clear = TRUE; SP->_endwin = FALSE; } #if 0 /* Not works for output-only pgms */ /* check for pending input */ { fd_set fdset; struct timeval timeout = {0,0}; FD_ZERO(&fdset); FD_SET(SP->_checkfd, &fdset); if (select(SP->_checkfd+1, &fdset, NULL, NULL, &timeout) != 0) { fflush(SP->_ofp); return OK; } } #endif if (curscr->_clear) { /* force refresh ? */ T(("clearing and updating curscr")); - ClrUpdate(curscr); /* yes, clear all & update */ + ClrUpdate(newscr); /* yes, clear all & update */ curscr->_clear = FALSE; /* reset flag */ + } else if (newscr->_clear) { + T(("clearing and updating newscr")); + ClrUpdate(newscr); + newscr->_clear = FALSE; } else { - if (newscr->_clear) { - T(("clearing and updating newscr")); - ClrUpdate(newscr); - newscr->_clear = FALSE; - } else { - T(("Transforming lines")); - for (i = 0; i < lines ; i++) { - if(newscr->_firstchar[i] != _NOCHANGE) - TransformLine(i); - } + T(("Transforming lines")); + for (i = 0; i < lines ; i++) { + if(newscr->_firstchar[i] != _NOCHANGE) + TransformLine(i); } } T(("marking screen as updated")); for (i = 0; i < lines; i++) { newscr->_firstchar[i] = _NOCHANGE; newscr->_lastchar[i] = _NOCHANGE; } curscr->_curx = newscr->_curx; curscr->_cury = newscr->_cury; GoTo(curscr->_cury, curscr->_curx); /* perhaps we should turn attributes off here */ if (curscr->_attrs != A_NORMAL) vidattr(curscr->_attrs = A_NORMAL); fflush(SP->_ofp); sigaction(SIGTSTP, &oact, NULL); return OK; } static int move_right_cost = -1; static int countc(int c) { return(move_right_cost++); } /* ** ClrUpdate(scr) ** ** Update by clearing and redrawing the entire screen. ** */ static void ClrUpdate(WINDOW *scr) { int i = 0, j = 0; int lastNonBlank; T(("ClrUpdate(%x) called", scr)); if (back_color_erase && curscr->_attrs != A_NORMAL) { T(("back_color_erase, turning attributes off")); vidattr(curscr->_attrs = A_NORMAL); } ClearScreen(); if ((move_right_cost == -1) && parm_right_cursor) { move_right_cost = 0; tputs(tparm(parm_right_cursor, 10), 1, countc); } T(("updating screen from scratch")); - for (i = 0; i < lines; i++) { - lastNonBlank = columns - 1; + for (i = 0; i < min(lines, scr->_maxy + 1); i++) { + lastNonBlank = scr->_maxx; while (lastNonBlank >= 0 && scr->_line[i][lastNonBlank] == BLANK) lastNonBlank--; /* check if we are at the lr corner */ if (i == lines-1) if ((auto_right_margin) && !(eat_newline_glitch) && (lastNonBlank == columns-1)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } for (j = 0; j <= lastNonBlank; j++) { - if (parm_right_cursor) { - static int inspace = 0; + int inspace = 0; - T(("trying to use parm_right_cursor")); + if (parm_right_cursor) { if ((scr->_line[i][j]) == BLANK) { inspace++; continue; } else if(inspace) { if (inspace < move_right_cost) { for (; inspace > 0; inspace--) PutChar(scr->_line[i][j-1]); } else { + T(("trying to use parm_right_cursor")); putp(tparm(parm_right_cursor, inspace)); SP->_curscol += inspace; } inspace = 0; } } PutChar(scr->_line[i][j]); } /* move cursor to the next line */ if ((!auto_right_margin) || (lastNonBlank < columns - 1) || (auto_right_margin && eat_newline_glitch && lastNonBlank == columns-1)) { SP->_curscol = (lastNonBlank < 0) ? 0 : lastNonBlank; SP->_cursrow++; GoTo(i+1, 0); } } if (scr != curscr) { for (i = 0; i < lines ; i++) for (j = 0; j < columns; j++) curscr->_line[i][j] = scr->_line[i][j]; } } /* ** TransformLine(lineno) ** ** Call either IDcTransformLine or NoIDcTransformLine to do the ** update, depending upon availability of insert/delete character. */ static void TransformLine(int lineno) { T(("TransformLine(%d) called",lineno)); if ( (insert_character || (enter_insert_mode && exit_insert_mode)) && delete_character) IDcTransformLine(lineno); else NoIDcTransformLine(lineno); } /* ** NoIDcTransformLine(lineno) ** ** Transform the given line in curscr to the one in newscr, without ** using Insert/Delete Character. ** ** firstChar = position of first different character in line ** lastChar = position of last different character in line ** ** overwrite all characters between firstChar and lastChar. ** */ static void NoIDcTransformLine(int lineno) { int firstChar, lastChar; chtype *newLine = newscr->_line[lineno]; chtype *oldLine = curscr->_line[lineno]; int k; int attrchanged = 0; T(("NoIDcTransformLine(%d) called", lineno)); firstChar = 0; while (firstChar < columns - 1 && newLine[firstChar] == oldLine[firstChar]) { if(ceol_standout_glitch) { if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES)) attrchanged = 1; } firstChar++; } T(("first char at %d is %x", firstChar, newLine[firstChar])); if (firstChar > columns) return; if(ceol_standout_glitch && attrchanged) { firstChar = 0; lastChar = columns - 1; GoTo(lineno, firstChar); if(clr_eol) { if (back_color_erase && curscr->_attrs != A_NORMAL) { T(("back_color_erase, turning attributes off")); vidattr(curscr->_attrs = A_NORMAL); } putp(clr_eol); } } else { lastChar = columns - 1; while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar]) lastChar--; GoTo(lineno, firstChar); } /* check if we are at the lr corner */ if (lineno == lines-1) if ((auto_right_margin) && !(eat_newline_glitch) && (lastChar == columns-1)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } T(("updating chars %d to %d", firstChar, lastChar)); for (k = firstChar; k <= lastChar; k++) { PutChar(newLine[k]); oldLine[k] = newLine[k]; } } /* ** IDcTransformLine(lineno) ** ** Transform the given line in curscr to the one in newscr, using ** Insert/Delete Character. ** ** firstChar = position of first different character in line ** oLastChar = position of last different character in old line ** nLastChar = position of last different character in new line ** ** move to firstChar ** overwrite chars up to min(oLastChar, nLastChar) ** if oLastChar < nLastChar ** insert newLine[oLastChar+1..nLastChar] ** else ** delete oLastChar - nLastChar spaces */ static void IDcTransformLine(int lineno) { int firstChar, oLastChar, nLastChar; chtype *newLine = newscr->_line[lineno]; chtype *oldLine = curscr->_line[lineno]; int k, n; int attrchanged = 0; T(("IDcTransformLine(%d) called", lineno)); if(ceol_standout_glitch && clr_eol) { firstChar = 0; while(firstChar < columns) { if((newLine[firstChar] & (chtype)A_ATTRIBUTES) != (oldLine[firstChar] & (chtype)A_ATTRIBUTES)) attrchanged = 1; firstChar++; } } firstChar = 0; if (attrchanged) { GoTo(lineno, firstChar); if (back_color_erase && curscr->_attrs != A_NORMAL) { T(("back_color_erase, turning attributes off")); vidattr(curscr->_attrs = A_NORMAL); } putp(clr_eol); /* check if we are at the lr corner */ if (lineno == lines-1) if ((auto_right_margin) && !(eat_newline_glitch)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } for( k = 0 ; k <= (columns-1) ; k++ ) PutChar(newLine[k]); } else { while (firstChar < columns && newLine[firstChar] == oldLine[firstChar]) firstChar++; if (firstChar >= columns) return; oLastChar = columns - 1; while (oLastChar > firstChar && oldLine[oLastChar] == BLANK) oLastChar--; nLastChar = columns - 1; while (nLastChar > firstChar && newLine[nLastChar] == BLANK) nLastChar--; if((nLastChar == firstChar) && clr_eol) { GoTo(lineno, firstChar); if (back_color_erase && curscr->_attrs != A_NORMAL) { T(("back_color_erase, turning attributes off")); vidattr(curscr->_attrs = A_NORMAL); } putp(clr_eol); if(newLine[firstChar] != BLANK ) { /* check if we are at the lr corner */ if (lineno == lines-1) if ((auto_right_margin) && !(eat_newline_glitch) && (firstChar == columns-1)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } PutChar(newLine[firstChar]); } } else if( newLine[nLastChar] != oldLine[oLastChar] ) { n = max( nLastChar , oLastChar ); GoTo(lineno, firstChar); /* check if we are at the lr corner */ if (lineno == lines-1) if ((auto_right_margin) && !(eat_newline_glitch) && (n == columns-1)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } for( k=firstChar ; k <= n ; k++ ) PutChar(newLine[k]); } else { while (newLine[nLastChar] == oldLine[oLastChar]) { nLastChar--; oLastChar--; } n = min(oLastChar, nLastChar); GoTo(lineno, firstChar); /* check if we are at the lr corner */ if (lineno == lines-1) if ((auto_right_margin) && !(eat_newline_glitch) && (n == columns-1)) { T(("Lower-right corner needs special handling")); LRCORNER = TRUE; } for (k=firstChar; k <= n; k++) PutChar(newLine[k]); if (oLastChar < nLastChar) InsStr(&newLine[k], nLastChar - oLastChar); else if (oLastChar > nLastChar ) DelChar(oLastChar - nLastChar); } } for (k = firstChar; k < columns; k++) oldLine[k] = newLine[k]; } /* ** ClearScreen() ** ** Clear the physical screen and put cursor at home ** */ static void ClearScreen() { T(("ClearScreen() called")); if (clear_screen) { putp(clear_screen); SP->_cursrow = SP->_curscol = 0; } else if (clr_eos) { SP->_cursrow = SP->_curscol = -1; GoTo(0,0); putp(clr_eos); } else if (clr_eol) { SP->_cursrow = SP->_curscol = -1; while (SP->_cursrow < lines) { GoTo(SP->_cursrow, 0); putp(clr_eol); } GoTo(0,0); } T(("screen cleared")); } /* ** InsStr(line, count) ** ** Insert the count characters pointed to by line. ** */ static void InsStr(chtype *line, int count) { T(("InsStr(%x,%d) called", line, count)); if (enter_insert_mode && exit_insert_mode) { putp(enter_insert_mode); while (count) { PutChar(*line); line++; count--; } putp(exit_insert_mode); } else if (parm_ich) { putp(tparm(parm_ich, count)); while (count) { PutChar(*line); line++; count--; } } else { while (count) { putp(insert_character); PutChar(*line); line++; count--; } } } /* ** DelChar(count) ** ** Delete count characters at current position ** */ static void DelChar(int count) { T(("DelChar(%d) called", count)); if (back_color_erase && curscr->_attrs != A_NORMAL) { T(("back_color_erase, turning attributes off")); vidattr(curscr->_attrs = A_NORMAL); } if (parm_dch) { putp(tparm(parm_dch, count)); } else { while (count--) putp(delete_character); } } diff --git a/lib/libncurses/lib_initscr.c b/lib/libncurses/lib_initscr.c index 5c9dfc3326ee..1c2d9e374123 100644 --- a/lib/libncurses/lib_initscr.c +++ b/lib/libncurses/lib_initscr.c @@ -1,31 +1,40 @@ /* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for * * details. If they are missing then this copy is in violation of * * the copyright conditions. */ /* ** lib_initscr.c ** ** The routine initscr(). ** */ #include #include "curses.priv.h" WINDOW *initscr() { +static bool initialized = FALSE; +char *name; #ifdef TRACE _init_trace(); T(("initscr() called")); #endif - if (newterm(getenv("TERM"), stdout, stdin) == NULL) - return NULL; - else { - def_shell_mode(); + /* Portable applications must not call initscr() more than once */ + if (!initialized) { + initialized = TRUE; + + if ((name = getenv("TERM")) == 0) + name = "unknown"; + if (newterm(name, stdout, stdin) == 0) { + fprintf(stderr, "Error opening terminal: %s.\n", name); + exit(1); + } + /* def_shell_mode - done in newterm */ def_prog_mode(); - return(stdscr); } + return(stdscr); } diff --git a/lib/libncurses/lib_tstp.c b/lib/libncurses/lib_tstp.c index 4412dcb6d915..cb96ff022124 100644 --- a/lib/libncurses/lib_tstp.c +++ b/lib/libncurses/lib_tstp.c @@ -1,50 +1,78 @@ /* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for * * details. If they are missing then this copy is in violation of * * the copyright conditions. */ /* ** lib_tstp.c ** ** The routine tstp(). ** */ #include "curses.priv.h" #include "terminfo.h" #ifdef SVR4_ACTION #define _POSIX_SOURCE #endif #include void tstp(int dummy) { sigaction_t act, oact; -sigset_t mask; +sigset_t mask, omask; T(("tstp() called")); + /* + * The user may have changed the prog_mode tty bits, so save them. + */ + def_prog_mode(); + + /* + * Block window change and timer signals. The latter + * is because applications use timers to decide when + * to repaint the screen. + */ + (void)sigemptyset(&mask); + (void)sigaddset(&mask, SIGALRM); +#ifdef SIGWINCH + (void)sigaddset(&mask, SIGWINCH); +#endif + (void)sigprocmask(SIG_BLOCK, &mask, &omask); + endwin(); sigemptyset(&mask); sigaddset(&mask, SIGTSTP); sigprocmask(SIG_UNBLOCK, &mask, NULL); act.sa_handler = SIG_DFL; sigemptyset(&act.sa_mask); act.sa_flags = 0; #ifdef SA_RESTART act.sa_flags |= SA_RESTART; #endif sigaction(SIGTSTP, &act, &oact); kill(getpid(), SIGTSTP); T(("SIGCONT received")); sigaction(SIGTSTP, &oact, NULL); - reset_prog_mode(); flushinp(); - if (enter_ca_mode) - putp(enter_ca_mode); + + /* + * If the user modified the tty state while suspended, he wants + * those changes to stick. So save the new "default" terminal state. + */ + def_shell_mode(); + + /* + * This relies on the fact that doupdate() will restore the + * program-mode tty state, and issue enter_ca_mode if need be. + */ doupdate(); + + /* Reset the signals. */ + (void)sigprocmask(SIG_SETMASK, &omask, NULL); } diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile index 5cb0429121fd..8e4d3ea252ca 100644 --- a/lib/ncurses/ncurses/Makefile +++ b/lib/ncurses/ncurses/Makefile @@ -1,209 +1,209 @@ # Makefile for ncurses -# $Id: Makefile,v 1.21 1997/02/22 15:07:38 peter Exp $ +# $Id: Makefile,v 1.22 1997/08/24 19:09:32 ache Exp $ LIB= ncurses SHLIB_MAJOR= 3 SHLIB_MINOR= 1 SRCS= lib_kernel.c lib_pad.c lib_bkgd.c \ lib_unctrl.c lib_raw.c lib_vidattr.c lib_trace.c lib_beep.c \ lib_doupdate.c lib_refresh.c lib_initscr.c lib_newwin.c lib_addch.c \ lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c lib_keyname.c\ lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \ lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\ lib_box.c lib_clear.c lib_delch.c lib_insch.c lib_instr.c \ lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \ lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \ lib_insstr.c lib_insdel.c lib_twait.c lib_window.c copyright.c -CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO +CFLAGS+= -I. -I${.CURDIR} -Wall -DMYTINFO #-DTRACE DPADD= ${LIBMYTINFO} LDADD= -lmytinfo CLEANFILES+= lib_keyname.c keys.tries beforedepend: keys.tries beforeinstall: ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/unctrl.h \ ${DESTDIR}/usr/include ${INSTALL} -C -m 444 -o $(BINOWN) -g $(BINGRP) ${.CURDIR}/curses.h \ ${DESTDIR}/usr/include/ncurses.h keys.tries: ${.CURDIR}/keys.list ${.CURDIR}/MKkeys.awk awk -f ${.CURDIR}/MKkeys.awk ${.CURDIR}/keys.list > keys.tries # in case you don't run make depend lib_options.o lib_options.so lib_options.po: keys.tries lib_keyname.c: ${.CURDIR}/keys.list ${.CURDIR}/MKkeyname.awk awk -f ${.CURDIR}/MKkeyname.awk ${.CURDIR}/keys.list > lib_keyname.c MAN3 = curs_addch.3 \ curs_addchst.3 \ curs_addstr.3 \ curs_attr.3 \ curs_beep.3 \ curs_bkgd.3 \ curs_border.3 \ curs_clear.3 \ curs_color.3 \ curs_delch.3 \ curs_delln.3 \ curs_getch.3 \ curs_getstr.3 \ curs_getyx.3 \ curs_inch.3 \ curs_inchstr.3 \ curs_initscr.3 \ curs_inopts.3 \ curs_insch.3 \ curs_insstr.3 \ curs_instr.3 \ curs_kernel.3 \ curs_move.3 \ curs_outopts.3 \ curs_overlay.3 \ curs_pad.3 \ curs_printw.3 \ curs_refresh.3 \ curs_scanw.3 \ curs_scr_dmp.3 \ curs_scroll.3 \ curs_slk.3 \ curs_termatt.3 \ curs_termin.3 \ curs_touch.3 \ curs_util.3 \ curs_window.3 \ ncurses.3 MAN5 = term.5 terminfo.5 MLINKS+=curs_addch.3 addch.3 curs_addch.3 waddch.3 curs_addch.3 echochar.3 \ curs_addch.3 wechochar.3 curs_addch.3 mvaddch.3 \ curs_addch.3 mvwaddch.3 MLINKS+=curs_addchst.3 addchstr.3 curs_addchst.3 addchnstr.3 \ curs_addchst.3 waddchstr.3 curs_addchst.3 waddchnstr.3 \ curs_addchst.3 mvaddchstr.3 curs_addchst.3 mvaddchnstr.3 \ curs_addchst.3 mvwaddchstr.3 curs_addchst.3 mvwaddchnstr.3 MLINKS+=curs_addstr.3 addstr.3 curs_addstr.3 addnstr.3 \ curs_addstr.3 waddstr.3 curs_addstr.3 waddnstr.3 \ curs_addstr.3 mvaddstr.3 curs_addstr.3 mvaddnstr.3 \ curs_addstr.3 mvwaddstr.3 curs_addstr.3 mvwaddnstr.3 MLINKS+=curs_attr.3 attroff.3 curs_attr.3 wattroff.3 \ curs_attr.3 attron.3 curs_attr.3 wattron.3 \ curs_attr.3 attrset.3 curs_attr.3 wattrset.3 \ curs_attr.3 standend.3 curs_attr.3 wstandend.3 \ curs_attr.3 standout.3 curs_attr.3 wstandout.3 MLINKS+=curs_beep.3 beep.3 curs_beep.3 flash.3 MLINKS+=curs_bkgd.3 bkgdset.3 curs_bkgd.3 wbkgdset.3 \ curs_bkgd.3 bkgd.3 curs_bkgd.3 wbkgd.3 MLINKS+=curs_border.3 border.3 curs_border.3 wborder.3 curs_border.3 box.3 \ curs_border.3 hline.3 curs_border.3 whline.3 \ curs_border.3 vline.3 curs_border.3 wvline.3 MLINKS+=curs_clear.3 erase.3 curs_clear.3 werase.3 curs_clear.3 clear.3 \ curs_clear.3 wclear.3 curs_clear.3 clrtobot.3 \ curs_clear.3 wclrtobot.3 curs_clear.3 clrtoeol.3 \ curs_clear.3 wclrtoeol.3 MLINKS+=curs_color.3 start_color.3 curs_color.3 init_pair.3 \ curs_color.3 init_color.3 curs_color.3 has_colors.3 \ curs_color.3 can_change_color.3 curs_color.3 color_content.3 \ curs_color.3 pair_content.3 MLINKS+=curs_delch.3 delch.3 curs_delch.3 wdelch.3 curs_delch.3 mvdelch.3 \ curs_delch.3 mvwdelch.3 MLINKS+=curs_delln.3 deleteln.3 curs_delln.3 wdeleteln.3 \ curs_delln.3 insdelln.3 curs_delln.3 winsdelln.3 \ curs_delln.3 insertln.3 curs_delln.3 winsertln.3 MLINKS+=curs_getch.3 getch.3 curs_getch.3 wgetch.3 curs_getch.3 mvgetch.3 \ curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3 MLINKS+=curs_getstr.3 getstr.3 curs_getstr.3 wgetstr.3 \ curs_getstr.3 mvgetstr.3 curs_getstr.3 mvwgetstr.3 \ curs_getstr.3 wgetnstr.3 MLINKS+=curs_getyx.3 getyx.3 curs_getyx.3 pgetparyx.3 curs_getyx.3 getbegyx.3 \ curs_getyx.3 getmaxyx.3 MLINKS+=curs_inch.3 inch.3 curs_inch.3 winch.3 curs_inch.3 mvinch.3 \ curs_inch.3 mvwinch.3 MLINKS+=curs_inchstr.3 inchstr.3 curs_inchstr.3 inchnstr.3 \ curs_inchstr.3 winchstr.3 curs_inchstr.3 winchnstr.3 \ curs_inchstr.3 mvinchstr.3 curs_inchstr.3 mvinchnstr.3 \ curs_inchstr.3 mvwinchstr.3 curs_inchstr.3 mvwinchnstr.3 MLINKS+=curs_initscr.3 initscr.3 curs_initscr.3 newterm.3 \ curs_initscr.3 endwin.3 curs_initscr.3 isendwin.3 \ curs_initscr.3 set_term.3 curs_initscr.3 delscreen.3 MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 nocbreak.3 curs_inopts.3 echo.3 \ curs_inopts.3 noecho.3 curs_inopts.3 halfdelay.3 \ curs_inopts.3 intrflush.3 curs_inopts.3 keypad.3 curs_inopts.3 meta.3 \ curs_inopts.3 nodelay.3 curs_inopts.3 notimeout.3 curs_inopts.3 raw.3 \ curs_inopts.3 noraw.3 curs_inopts.3 noqiflush.3 \ curs_inopts.3 qiflush.3 curs_inopts.3 timeout.3 \ curs_inopts.3 wtimeout.3 curs_inopts.3 typeahead.3 MLINKS+=curs_insch.3 insch.3 curs_insch.3 winsch.3 curs_insch.3 mvinsch.3 \ curs_insch.3 mvwinsch.3 MLINKS+=curs_insstr.3 insstr.3 curs_insstr.3 insnstr.3 \ curs_insstr.3 winsstr.3 curs_insstr.3 winsnstr.3 \ curs_insstr.3 mvinsstr.3 curs_insstr.3 mvinsnstr.3 \ curs_insstr.3 mvwinsstr.3 curs_insstr.3 mvwinsnstr.3 MLINKS+=curs_instr.3 instr.3 curs_instr.3 innstr.3 curs_instr.3 winstr.3 \ curs_instr.3 winnstr.3 curs_instr.3 mvinstr.3 curs_instr.3 mvinnstr.3 \ curs_instr.3 mvwinstr.3 curs_instr.3 mvwinnstr.3 MLINKS+=curs_kernel.3 def_prog_mode.3 curs_kernel.3 def_shell_mode.3 \ curs_kernel.3 reset_prog_mode.3 curs_kernel.3 reset_shell_mode.3 \ curs_kernel.3 resetty.3 curs_kernel.3 savetty.3 \ curs_kernel.3 getsyx.3 curs_kernel.3 setsyx.3 \ curs_kernel.3 ripoffline.3 curs_kernel.3 curs_set.3 \ curs_kernel.3 napms.3 MLINKS+=curs_move.3 move.3 curs_move.3 wmove.3 MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idlok.3 \ curs_outopts.3 idcok.3 curs_outopts.3 immedok.3 \ curs_outopts.3 leaveok.3 curs_outopts.3 setscrreg.3 \ curs_outopts.3 wsetscrreg.3 curs_outopts.3 scrollok.3 \ curs_outopts.3 nl.3 curs_outopts.3 nonl.3 MLINKS+=curs_overlay.3 overlay.3 curs_overlay.3 overwrite.3 \ curs_overlay.3 copywin.3 MLINKS+=curs_pad.3 newpad.3 curs_pad.3 subpad.3 curs_pad.3 prefresh.3 \ curs_pad.3 pnoutrefresh.3 curs_pad.3 pechochar.3 MLINKS+=curs_printw.3 printw.3 curs_printw.3 wprintw.3 \ curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \ curs_printw.3 vwprintw.3 MLINKS+=curs_refresh.3 refresh.3 curs_refresh.3 wrefresh.3 \ curs_refresh.3 wnoutrefresh.3 curs_refresh.3 doupdate.3 \ curs_refresh.3 redrawwin.3 curs_refresh.3 wredrawln.3 MLINKS+=curs_scanw.3 scanw.3 curs_scanw.3 wscanw.3 curs_scanw.3 mvscanw.3 \ curs_scanw.3 mvwscanw.3 curs_scanw.3 vwscanw.3 MLINKS+=curs_scr_dmp.3 scr_dump.3 curs_scr_dmp.3 scr_restore.3 \ curs_scr_dmp.3 scr_init.3 curs_scr_dmp.3 scr_set.3 MLINKS+=curs_scroll.3 scroll.3 curs_scroll.3 scrl.3 curs_scroll.3 wscrl.3 MLINKS+=curs_slk.3 slk_init.3 curs_slk.3 slk_set.3 curs_slk.3 slk_refresh.3 \ curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_label.3 \ curs_slk.3 slk_clear.3 curs_slk.3 slk_restore.3 \ curs_slk.3 slk_touch.3 curs_slk.3 slk_attron.3 \ curs_slk.3 slk_attrset.3 curs_slk.3 slk_attroff.3 MLINKS+=curs_termatt.3 baudrate.3 curs_termatt.3 erasechar.3 \ curs_termatt.3 has_ic.3 curs_termatt.3 has_il.3 \ curs_termatt.3 killchar.3 curs_termatt.3 longname.3 \ curs_termatt.3 termattrs.3 curs_termatt.3 termname.3 # XXX name clash with termcap(3) # MLINKS+= curs_termin.3 tparm.3 MLINKS+=curs_termin.3 setupterm.3 curs_termin.3 setterm.3 \ curs_termin.3 set_curterm.3 curs_termin.3 del_curterm.3 \ curs_termin.3 restartterm.3 \ curs_termin.3 putp.3 curs_termin.3 vidputs.3 \ curs_termin.3 vidattr.3 curs_termin.3 mvcur.3 \ curs_termin.3 tigetflag.3 curs_termin.3 tigetnum.3 \ curs_termin.3 tigetstr.3 MLINKS+=curs_touch.3 touchwin.3 curs_touch.3 touchline.3 \ curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3 \ curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3 MLINKS+=curs_util.3 unctrl.3 curs_util.3 keyname.3 \ curs_util.3 filter.3 curs_util.3 use_env.3 \ curs_util.3 putwin.3 curs_util.3 getwin.3 \ curs_util.3 delay_output.3 curs_util.3 flushinp.3 MLINKS+=curs_window.3 newwin.3 curs_window.3 delwin.3 \ curs_window.3 mvwin.3 curs_window.3 subwin.3 \ curs_window.3 derwin.3 curs_window.3 mvderwin.3 \ curs_window.3 dupwin.3 curs_window.3 wsyncup.3 \ curs_window.3 syncok.3 curs_window.3 wcursyncup.3 \ curs_window.3 wsyncdown.3 .include