1994-10-07 08:58:58 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------*/
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
#include <stdlib.h>
|
1994-12-02 06:40:24 +00:00
|
|
|
#include <sys/time.h>
|
|
|
|
#ifdef SYS_SELECT
|
|
|
|
#include <sys/select.h>
|
|
|
|
#endif
|
1994-10-07 08:58:58 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include "curses.priv.h"
|
1994-12-02 06:40:24 +00:00
|
|
|
#include "terminfo.h"
|
1994-10-07 08:58:58 +00:00
|
|
|
#ifdef SVR4_ACTION
|
|
|
|
#define _POSIX_SOURCE
|
|
|
|
#endif
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
1994-12-02 06:40:24 +00:00
|
|
|
TR(TRACE_CHARPUT, ("PutAttrChar(%s, %s)",
|
|
|
|
_tracechar(ch & A_CHARTEXT),
|
|
|
|
_traceattr((ch & (chtype)A_ATTRIBUTES))));
|
1994-10-07 08:58:58 +00:00
|
|
|
if (curscr->_attrs != (ch & (chtype)A_ATTRIBUTES)) {
|
|
|
|
curscr->_attrs = ch & (chtype)A_ATTRIBUTES;
|
1994-12-02 06:40:24 +00:00
|
|
|
vidputs(curscr->_attrs, _outch);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
putc(ch & A_CHARTEXT, SP->_ofp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int LRCORNER = FALSE;
|
|
|
|
|
|
|
|
static inline void PutChar(chtype ch)
|
|
|
|
{
|
1994-11-06 15:30:37 +00:00
|
|
|
if (LRCORNER == TRUE && SP->_curscol == columns-1) {
|
1994-12-02 06:40:24 +00:00
|
|
|
int i = lines -1;
|
1994-10-07 08:58:58 +00:00
|
|
|
int j = columns -1;
|
1994-11-06 15:30:37 +00:00
|
|
|
|
|
|
|
LRCORNER = FALSE;
|
|
|
|
if ( (!enter_insert_mode || !exit_insert_mode)
|
|
|
|
&& !insert_character
|
|
|
|
)
|
1994-10-07 08:58:58 +00:00
|
|
|
return;
|
1994-11-06 15:30:37 +00:00
|
|
|
if (cursor_left)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(cursor_left);
|
1994-11-06 15:30:37 +00:00
|
|
|
else
|
1994-12-02 06:40:24 +00:00
|
|
|
mvcur(-1, -1, i, j);
|
1994-11-06 15:30:37 +00:00
|
|
|
PutAttrChar(ch);
|
|
|
|
if (cursor_left)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(cursor_left);
|
1994-11-06 15:30:37 +00:00
|
|
|
else
|
1994-12-02 06:40:24 +00:00
|
|
|
mvcur(-1, -1, i, j);
|
1994-11-06 15:30:37 +00:00
|
|
|
if (enter_insert_mode && exit_insert_mode) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(enter_insert_mode);
|
|
|
|
PutAttrChar(newscr->_line[i][j-1]);
|
|
|
|
putp(exit_insert_mode);
|
1994-11-06 15:30:37 +00:00
|
|
|
} else if (insert_character) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(insert_character);
|
|
|
|
PutAttrChar(newscr->_line[i][j-1]);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
1994-11-06 15:30:37 +00:00
|
|
|
return;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
PutAttrChar(ch);
|
1995-05-30 05:51:47 +00:00
|
|
|
SP->_curscol++;
|
1994-10-07 08:58:58 +00:00
|
|
|
if (SP->_curscol >= columns) {
|
1995-05-30 05:51:47 +00:00
|
|
|
if (auto_right_margin) {
|
|
|
|
SP->_curscol = 0;
|
|
|
|
SP->_cursrow++;
|
1994-10-07 08:58:58 +00:00
|
|
|
} else {
|
|
|
|
SP->_curscol--;
|
|
|
|
}
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
|
|
|
|
static inline void GoTo(int row, int col)
|
|
|
|
{
|
1995-05-30 05:51:47 +00:00
|
|
|
mvcur(SP->_cursrow, SP->_curscol, row, col);
|
|
|
|
SP->_cursrow = row;
|
|
|
|
SP->_curscol = col;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
1994-12-28 14:30:19 +00:00
|
|
|
int _outch(int ch)
|
1994-10-07 08:58:58 +00:00
|
|
|
{
|
1994-12-02 06:40:24 +00:00
|
|
|
if (SP != NULL)
|
|
|
|
putc(ch, SP->_ofp);
|
|
|
|
else
|
|
|
|
putc(ch, stdout);
|
1994-10-07 08:58:58 +00:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int doupdate(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
sigaction_t act, oact;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("doupdate() called"));
|
|
|
|
|
|
|
|
act.sa_handler = SIG_IGN;
|
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
act.sa_flags = 0;
|
|
|
|
sigaction(SIGTSTP, &act, &oact);
|
|
|
|
|
1994-12-02 06:40:24 +00:00
|
|
|
if (SP->_endwin == TRUE) {
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("coming back from shell mode"));
|
|
|
|
reset_prog_mode();
|
|
|
|
/* is this necessary? */
|
|
|
|
if (enter_alt_charset_mode)
|
1995-05-30 05:51:47 +00:00
|
|
|
init_acs();
|
1994-10-07 08:58:58 +00:00
|
|
|
newscr->_clear = TRUE;
|
1994-12-02 06:40:24 +00:00
|
|
|
SP->_endwin = FALSE;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
|
1994-12-03 03:35:30 +00:00
|
|
|
#if 0 /* Not works for output-only pgms */
|
1994-12-02 06:40:24 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
}
|
1994-12-03 03:35:30 +00:00
|
|
|
#endif
|
1994-12-02 06:40:24 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (curscr->_clear) { /* force refresh ? */
|
|
|
|
T(("clearing and updating curscr"));
|
|
|
|
ClrUpdate(curscr); /* yes, clear all & update */
|
|
|
|
curscr->_clear = FALSE; /* reset flag */
|
|
|
|
} 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(("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);
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
/* perhaps we should turn attributes off here */
|
|
|
|
|
1994-11-27 05:23:52 +00:00
|
|
|
if (curscr->_attrs != A_NORMAL)
|
1994-10-07 08:58:58 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
|
|
|
|
|
|
|
fflush(SP->_ofp);
|
|
|
|
|
|
|
|
sigaction(SIGTSTP, &oact, NULL);
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int move_right_cost = -1;
|
|
|
|
|
1994-12-28 14:30:19 +00:00
|
|
|
static int countc(int c)
|
1994-10-07 08:58:58 +00:00
|
|
|
{
|
|
|
|
return(move_right_cost++);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** ClrUpdate(scr)
|
|
|
|
**
|
|
|
|
** Update by clearing and redrawing the entire screen.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BLANK ' '|A_NORMAL
|
|
|
|
|
|
|
|
static void ClrUpdate(WINDOW *scr)
|
|
|
|
{
|
|
|
|
int i = 0, j = 0;
|
|
|
|
int lastNonBlank;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("ClrUpdate(%x) called", scr));
|
1994-11-27 05:23:52 +00:00
|
|
|
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("back_color_erase, turning attributes off"));
|
1994-11-06 09:30:36 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
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;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-12-02 06:40:24 +00:00
|
|
|
while (lastNonBlank >= 0 && scr->_line[i][lastNonBlank] == BLANK)
|
1994-10-07 08:58:58 +00:00
|
|
|
lastNonBlank--;
|
|
|
|
|
|
|
|
/* check if we are at the lr corner */
|
|
|
|
if (i == lines-1)
|
|
|
|
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
1994-11-06 15:30:37 +00:00
|
|
|
(lastNonBlank == columns-1))
|
1994-10-07 08:58:58 +00:00
|
|
|
{
|
|
|
|
T(("Lower-right corner needs special handling"));
|
|
|
|
LRCORNER = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j <= lastNonBlank; j++) {
|
|
|
|
if (parm_right_cursor) {
|
|
|
|
static int inspace = 0;
|
|
|
|
|
|
|
|
T(("trying to use 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 {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(tparm(parm_right_cursor, inspace));
|
|
|
|
SP->_curscol += inspace;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
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;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
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;
|
1995-05-30 05:51:47 +00:00
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
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) {
|
1994-11-27 05:23:52 +00:00
|
|
|
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("back_color_erase, turning attributes off"));
|
1994-11-06 09:30:36 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clr_eol);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lastChar = columns - 1;
|
|
|
|
while (lastChar > firstChar && newLine[lastChar] == oldLine[lastChar])
|
|
|
|
lastChar--;
|
|
|
|
GoTo(lineno, firstChar);
|
1995-05-30 05:51:47 +00:00
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
|
|
|
|
/* check if we are at the lr corner */
|
|
|
|
if (lineno == lines-1)
|
|
|
|
if ((auto_right_margin) && !(eat_newline_glitch) &&
|
1994-11-06 15:30:37 +00:00
|
|
|
(lastChar == columns-1))
|
1994-10-07 08:58:58 +00:00
|
|
|
{
|
|
|
|
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;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
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;
|
1995-05-30 05:51:47 +00:00
|
|
|
firstChar++;
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
firstChar = 0;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (attrchanged) {
|
|
|
|
GoTo(lineno, firstChar);
|
1994-11-27 05:23:52 +00:00
|
|
|
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("back_color_erase, turning attributes off"));
|
1994-11-06 09:30:36 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clr_eol);
|
1994-11-06 15:30:37 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
for( k = 0 ; k <= (columns-1) ; k++ )
|
|
|
|
PutChar(newLine[k]);
|
|
|
|
} else {
|
|
|
|
while (firstChar < columns &&
|
|
|
|
newLine[firstChar] == oldLine[firstChar])
|
|
|
|
firstChar++;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
if (firstChar >= columns)
|
|
|
|
return;
|
|
|
|
|
|
|
|
oLastChar = columns - 1;
|
1994-12-02 06:40:24 +00:00
|
|
|
while (oLastChar > firstChar && oldLine[oLastChar] == BLANK)
|
1994-10-07 08:58:58 +00:00
|
|
|
oLastChar--;
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
nLastChar = columns - 1;
|
1994-12-02 06:40:24 +00:00
|
|
|
while (nLastChar > firstChar && newLine[nLastChar] == BLANK)
|
1994-10-07 08:58:58 +00:00
|
|
|
nLastChar--;
|
|
|
|
|
|
|
|
if((nLastChar == firstChar) && clr_eol) {
|
|
|
|
GoTo(lineno, firstChar);
|
1994-11-27 05:23:52 +00:00
|
|
|
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
1994-10-07 08:58:58 +00:00
|
|
|
T(("back_color_erase, turning attributes off"));
|
1994-11-06 09:30:36 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clr_eol);
|
1994-11-06 15:30:37 +00:00
|
|
|
|
1994-12-02 06:40:24 +00:00
|
|
|
if(newLine[firstChar] != BLANK ) {
|
1994-11-06 15:30:37 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
PutChar(newLine[firstChar]);
|
1994-11-06 15:30:37 +00:00
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
} else if( newLine[nLastChar] != oldLine[oLastChar] ) {
|
|
|
|
n = max( nLastChar , oLastChar );
|
|
|
|
|
|
|
|
GoTo(lineno, firstChar);
|
|
|
|
|
1994-11-06 15:30:37 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
for( k=firstChar ; k <= n ; k++ )
|
|
|
|
PutChar(newLine[k]);
|
|
|
|
} else {
|
|
|
|
while (newLine[nLastChar] == oldLine[oLastChar]) {
|
|
|
|
nLastChar--;
|
|
|
|
oLastChar--;
|
|
|
|
}
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
n = min(oLastChar, nLastChar);
|
|
|
|
|
|
|
|
GoTo(lineno, firstChar);
|
1995-05-30 05:51:47 +00:00
|
|
|
|
1994-11-06 15:30:37 +00:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1994-10-07 08:58:58 +00:00
|
|
|
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) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clear_screen);
|
1994-10-07 08:58:58 +00:00
|
|
|
SP->_cursrow = SP->_curscol = 0;
|
|
|
|
} else if (clr_eos) {
|
|
|
|
SP->_cursrow = SP->_curscol = -1;
|
|
|
|
GoTo(0,0);
|
|
|
|
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clr_eos);
|
1994-10-07 08:58:58 +00:00
|
|
|
} else if (clr_eol) {
|
|
|
|
SP->_cursrow = SP->_curscol = -1;
|
|
|
|
|
|
|
|
while (SP->_cursrow < lines) {
|
|
|
|
GoTo(SP->_cursrow, 0);
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(clr_eol);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
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) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(enter_insert_mode);
|
1994-10-07 08:58:58 +00:00
|
|
|
while (count) {
|
|
|
|
PutChar(*line);
|
|
|
|
line++;
|
|
|
|
count--;
|
|
|
|
}
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(exit_insert_mode);
|
1994-10-07 08:58:58 +00:00
|
|
|
} else if (parm_ich) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(tparm(parm_ich, count));
|
1994-10-07 08:58:58 +00:00
|
|
|
while (count) {
|
|
|
|
PutChar(*line);
|
|
|
|
line++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while (count) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(insert_character);
|
1994-10-07 08:58:58 +00:00
|
|
|
PutChar(*line);
|
|
|
|
line++;
|
|
|
|
count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** DelChar(count)
|
|
|
|
**
|
|
|
|
** Delete count characters at current position
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void DelChar(int count)
|
|
|
|
{
|
|
|
|
T(("DelChar(%d) called", count));
|
|
|
|
|
1994-11-27 05:23:52 +00:00
|
|
|
if (back_color_erase && curscr->_attrs != A_NORMAL) {
|
1994-11-06 08:33:34 +00:00
|
|
|
T(("back_color_erase, turning attributes off"));
|
1994-11-06 09:30:36 +00:00
|
|
|
vidattr(curscr->_attrs = A_NORMAL);
|
1994-11-06 08:33:34 +00:00
|
|
|
}
|
1994-10-07 08:58:58 +00:00
|
|
|
if (parm_dch) {
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(tparm(parm_dch, count));
|
1994-10-07 08:58:58 +00:00
|
|
|
} else {
|
|
|
|
while (count--)
|
1994-12-02 06:40:24 +00:00
|
|
|
putp(delete_character);
|
1994-10-07 08:58:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|