version 1.20, 2003/08/15 23:23:18 |
version 1.21, 2005/04/03 02:09:28 |
|
|
* changes things around for memory mapped video. With |
* changes things around for memory mapped video. With |
* both off, the terminal is a VT52. |
* both off, the terminal is a VT52. |
*/ |
*/ |
#include "def.h" |
#include "def.h" |
#include "kbd.h" |
#include "kbd.h" |
|
|
#include <ctype.h> |
#include <ctype.h> |
|
|
|
|
int ttcol = HUGE; /* Physical cursor column. */ |
int ttcol = HUGE; /* Physical cursor column. */ |
int tttop = HUGE; /* Top of scroll region. */ |
int tttop = HUGE; /* Top of scroll region. */ |
int ttbot = HUGE; /* Bottom of scroll region. */ |
int ttbot = HUGE; /* Bottom of scroll region. */ |
int lbound = 0; /* leftmost bound of the current line */ |
int lbound = 0; /* leftmost bound of the current */ |
/* being displayed */ |
/* line being displayed */ |
|
|
VIDEO **vscreen; /* Edge vector, virtual. */ |
VIDEO **vscreen; /* Edge vector, virtual. */ |
VIDEO **pscreen; /* Edge vector, physical. */ |
VIDEO **pscreen; /* Edge vector, physical. */ |
VIDEO *video; /* Actual screen data. */ |
VIDEO *video; /* Actual screen data. */ |
VIDEO blanks; /* Blank line image. */ |
VIDEO blanks; /* Blank line image. */ |
|
|
#ifdef GOSLING |
#ifdef GOSLING |
/* |
/* |
|
|
int |
int |
vtresize(int force, int newrow, int newcol) |
vtresize(int force, int newrow, int newcol) |
{ |
{ |
int i; |
int i; |
int rowchanged, colchanged; |
int rowchanged, colchanged; |
static int first_run = 1; |
static int first_run = 1; |
VIDEO *vp; |
VIDEO *vp; |
|
|
if (newrow < 1 || newcol < 1) |
if (newrow < 1 || newcol < 1) |
return (FALSE); |
return (FALSE); |
|
|
} while (0) |
} while (0) |
|
|
/* No update needed */ |
/* No update needed */ |
if (!first_run && !force && !rowchanged && !colchanged) { |
if (!first_run && !force && !rowchanged && !colchanged) |
return (TRUE); |
return (TRUE); |
} |
|
|
|
if (first_run) { |
if (first_run) |
memset(&blanks, 0, sizeof(blanks)); |
memset(&blanks, 0, sizeof(blanks)); |
} |
|
|
|
if (rowchanged || first_run) { |
if (rowchanged || first_run) { |
int vidstart; |
int vidstart; |
|
|
vidstart = 2 * (nrow - 1); |
vidstart = 2 * (nrow - 1); |
|
|
/* |
/* |
* We're shrinking, free some internal data |
* We're shrinking, free some internal data. |
*/ |
*/ |
if (newrow < nrow) { |
if (newrow < nrow) { |
for (i = 2 * (newrow - 1); i < 2 * (nrow - 1); i++) { |
for (i = 2 * (newrow - 1); i < 2 * (nrow - 1); i++) { |
|
|
TRYREALLOC(video, (2 * (newrow - 1)) * sizeof(VIDEO)); |
TRYREALLOC(video, (2 * (newrow - 1)) * sizeof(VIDEO)); |
|
|
/* |
/* |
* Zero-out the entries we just allocated |
* Zero-out the entries we just allocated. |
*/ |
*/ |
for (i = vidstart; i < 2 * (newrow - 1); i++) |
for (i = vidstart; i < 2 * (newrow - 1); i++) |
memset(&video[i], 0, sizeof(VIDEO)); |
memset(&video[i], 0, sizeof(VIDEO)); |
|
|
void |
void |
vttidy(void) |
vttidy(void) |
{ |
{ |
|
|
ttcolor(CTEXT); |
ttcolor(CTEXT); |
ttnowindow(); /* No scroll window. */ |
ttnowindow(); /* No scroll window. */ |
ttmove(nrow - 1, 0); /* Echo line. */ |
ttmove(nrow - 1, 0); /* Echo line. */ |
|
|
else { |
else { |
char bf[5]; |
char bf[5]; |
|
|
snprintf(bf, sizeof bf, "\\%o", c); |
snprintf(bf, sizeof(bf), "\\%o", c); |
vtputs(bf); |
vtputs(bf); |
} |
} |
} |
} |
|
|
} |
} |
} |
} |
|
|
|
|
/* |
/* |
* Erase from the end of the software cursor to the end of the line on which |
* Erase from the end of the software cursor to the end of the line on which |
* the software cursor is located. The display routines will decide if a |
* the software cursor is located. The display routines will decide if a |
|
|
MGWIN *wp; |
MGWIN *wp; |
VIDEO *vp1; |
VIDEO *vp1; |
VIDEO *vp2; |
VIDEO *vp2; |
int i, j; |
int c, i, j; |
int c; |
int hflag; |
int hflag; |
int currow, curcol; |
int currow; |
int offs, size; |
int curcol; |
|
int offs; |
|
int size; |
|
|
|
if (typeahead()) |
if (typeahead()) |
return; |
return; |
|
|
wp = wp->w_wndp; |
wp = wp->w_wndp; |
} |
} |
} |
} |
hflag = FALSE; /* Not hard. */ |
hflag = FALSE; /* Not hard. */ |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
/* |
/* |
* Nothing to be done. |
* Nothing to be done. |
|
|
i = wp->w_ntrows / 2; /* current center, no change */ |
i = wp->w_ntrows / 2; /* current center, no change */ |
|
|
/* |
/* |
* Find the line |
* Find the line. |
*/ |
*/ |
lp = wp->w_dotp; |
lp = wp->w_dotp; |
while (i != 0 && lback(lp) != wp->w_bufp->b_linep) { |
while (i != 0 && lback(lp) != wp->w_bufp->b_linep) { |
|
|
wp->w_flag = 0; |
wp->w_flag = 0; |
wp->w_force = 0; |
wp->w_force = 0; |
} |
} |
lp = curwp->w_linep; /* Cursor location. */ |
lp = curwp->w_linep; /* Cursor location. */ |
currow = curwp->w_toprow; |
currow = curwp->w_toprow; |
while (lp != curwp->w_dotp) { |
while (lp != curwp->w_dotp) { |
++currow; |
++currow; |
|
|
else { |
else { |
char bf[5]; |
char bf[5]; |
|
|
snprintf(bf, sizeof bf, "\\%o", c); |
snprintf(bf, sizeof(bf), "\\%o", c); |
curcol += strlen(bf); |
curcol += strlen(bf); |
} |
} |
} |
} |
|
|
lbound = 0; /* not extended line */ |
lbound = 0; /* not extended line */ |
|
|
/* |
/* |
* make sure no lines need to be de-extended because the cursor is no |
* Make sure no lines need to be de-extended because the cursor is no |
* longer on them |
* longer on them. |
*/ |
*/ |
wp = wheadp; |
wp = wheadp; |
while (wp != NULL) { |
while (wp != NULL) { |
|
|
} |
} |
|
|
if (sgarbf != FALSE) { /* Screen is garbage. */ |
if (sgarbf != FALSE) { /* Screen is garbage. */ |
sgarbf = FALSE; /* Erase-page clears */ |
sgarbf = FALSE; /* Erase-page clears. */ |
epresf = FALSE; /* the message area. */ |
epresf = FALSE; /* The message area. */ |
tttop = HUGE; /* Forget where you set */ |
tttop = HUGE; /* Forget where you set. */ |
ttbot = HUGE; /* scroll region. */ |
ttbot = HUGE; /* scroll region. */ |
tthue = CNONE; /* Color unknown. */ |
tthue = CNONE; /* Color unknown. */ |
ttmove(0, 0); |
ttmove(0, 0); |
|
|
void |
void |
ucopy(VIDEO *vvp, VIDEO *pvp) |
ucopy(VIDEO *vvp, VIDEO *pvp) |
{ |
{ |
|
|
vvp->v_flag &= ~VFCHG; /* Changes done. */ |
vvp->v_flag &= ~VFCHG; /* Changes done. */ |
pvp->v_flag = vvp->v_flag; /* Update model. */ |
pvp->v_flag = vvp->v_flag; /* Update model. */ |
pvp->v_hash = vvp->v_hash; |
pvp->v_hash = vvp->v_hash; |
|
|
/* |
/* |
* updext: update the extended line which the cursor is currently on at a |
* updext: update the extended line which the cursor is currently on at a |
* column greater than the terminal width. The line will be scrolled right or |
* column greater than the terminal width. The line will be scrolled right or |
* left to let the user see where the cursor is |
* left to let the user see where the cursor is. |
*/ |
*/ |
void |
void |
updext(int currow, int curcol) |
updext(int currow, int curcol) |
{ |
{ |
LINE *lp; /* pointer to current line */ |
LINE *lp; /* pointer to current line */ |
int j; /* index into line */ |
int j; /* index into line */ |
|
|
if (ncol < 2) |
if (ncol < 2) |
return; |
return; |
|
|
lp = curwp->w_dotp; /* line to output */ |
lp = curwp->w_dotp; /* line to output */ |
for (j = 0; j < llength(lp); ++j) /* until the end-of-line */ |
for (j = 0; j < llength(lp); ++j) /* until the end-of-line */ |
vtpute(lgetc(lp, j)); |
vtpute(lgetc(lp, j)); |
vteeol(); /* truncate the virtual line */ |
vteeol(); /* truncate the virtual line */ |
vscreen[currow]->v_text[0] = '$'; /* and put a '$' in column 1 */ |
vscreen[currow]->v_text[0] = '$'; /* and put a '$' in column 1 */ |
} |
} |
|
|
|
|
char *cp3; |
char *cp3; |
char *cp4; |
char *cp4; |
char *cp5; |
char *cp5; |
int nbflag; |
int nbflag; |
|
|
#ifdef MEMMAP |
#ifdef MEMMAP |
putline(row + 1, 1, &vvp->v_text[0]); |
putline(row + 1, 1, &vvp->v_text[0]); |
|
|
#ifdef STANDOUT_GLITCH |
#ifdef STANDOUT_GLITCH |
cp1 = &vvp->v_text[magic_cookie_glitch > 0 ? magic_cookie_glitch : 0]; |
cp1 = &vvp->v_text[magic_cookie_glitch > 0 ? magic_cookie_glitch : 0]; |
/* |
/* |
* the odd code for magic_cookie_glitch==0 is to avoid |
* The odd code for magic_cookie_glitch==0 is to avoid |
* putting the invisable glitch character on the next line. |
* putting the invisible glitch character on the next line. |
* (Hazeltine executive 80 model 30) |
* (Hazeltine executive 80 model 30) |
*/ |
*/ |
cp2 = &vvp->v_text[ncol - (magic_cookie_glitch >= 0 ? (magic_cookie_glitch != 0 ? magic_cookie_glitch : 1) : 0)]; |
cp2 = &vvp->v_text[ncol - (magic_cookie_glitch >= 0 ? (magic_cookie_glitch != 0 ? magic_cookie_glitch : 1) : 0)]; |
|
|
#endif |
#endif |
return; |
return; |
} |
} |
cp1 = &vvp->v_text[0]; /* Compute left match. */ |
cp1 = &vvp->v_text[0]; /* Compute left match. */ |
cp2 = &pvp->v_text[0]; |
cp2 = &pvp->v_text[0]; |
while (cp1 != &vvp->v_text[ncol] && cp1[0] == cp2[0]) { |
while (cp1 != &vvp->v_text[ncol] && cp1[0] == cp2[0]) { |
++cp1; |
++cp1; |
|
|
if (cp1 == &vvp->v_text[ncol]) /* All equal. */ |
if (cp1 == &vvp->v_text[ncol]) /* All equal. */ |
return; |
return; |
nbflag = FALSE; |
nbflag = FALSE; |
cp3 = &vvp->v_text[ncol]; /* Compute right match. */ |
cp3 = &vvp->v_text[ncol]; /* Compute right match. */ |
cp4 = &pvp->v_text[ncol]; |
cp4 = &pvp->v_text[ncol]; |
while (cp3[-1] == cp4[-1]) { |
while (cp3[-1] == cp4[-1]) { |
--cp3; |
--cp3; |
|
|
|
|
/* |
/* |
* Redisplay the mode line for the window pointed to by the "wp". |
* Redisplay the mode line for the window pointed to by the "wp". |
* This is the only routine that has any idea of how the modeline is |
* This is the only routine that has any idea of how the mode line is |
* formatted. You can change the modeline format by hacking at this |
* formatted. You can change the modeline format by hacking at this |
* routine. Called by "update" any time there is a dirty window. Note |
* routine. Called by "update" any time there is a dirty window. Note |
* that if STANDOUT_GLITCH is defined, first and last magic_cookie_glitch |
* that if STANDOUT_GLITCH is defined, first and last magic_cookie_glitch |
|
|
{ |
{ |
int n; |
int n; |
BUFFER *bp; |
BUFFER *bp; |
int mode; |
int mode; |
|
|
n = wp->w_toprow + wp->w_ntrows; /* Location. */ |
n = wp->w_toprow + wp->w_ntrows; /* Location. */ |
vscreen[n]->v_color = CMODE; /* Mode line color. */ |
vscreen[n]->v_color = CMODE; /* Mode line color. */ |
|
|
n += vtputs("Mg: "); |
n += vtputs("Mg: "); |
if (bp->b_bname[0] != '\0') |
if (bp->b_bname[0] != '\0') |
n += vtputs(&(bp->b_bname[0])); |
n += vtputs(&(bp->b_bname[0])); |
while (n < 42) { /* Pad out with blanks */ |
while (n < 42) { /* Pad out with blanks. */ |
vtputc(' '); |
vtputc(' '); |
++n; |
++n; |
} |
} |
|
|
} |
} |
vtputc(')'); |
vtputc(')'); |
++n; |
++n; |
while (n < ncol) { /* Pad out. */ |
while (n < ncol) { /* Pad out. */ |
vtputc('-'); |
vtputc('-'); |
++n; |
++n; |
} |
} |
} |
} |
|
|
/* |
/* |
* output a string to the mode line, report how long it was. |
* Output a string to the mode line, report how long it was. |
*/ |
*/ |
int |
int |
vtputs(const char *s) |
vtputs(const char *s) |
|
|
vtputc(*s++); |
vtputc(*s++); |
++n; |
++n; |
} |
} |
return n; |
return (n); |
} |
} |
|
|
#ifdef GOSLING |
#ifdef GOSLING |
|
|
void |
void |
hash(VIDEO *vp) |
hash(VIDEO *vp) |
{ |
{ |
int i; |
int i, n; |
int n; |
char *s; |
char *s; |
|
|
|
if ((vp->v_flag & VFHBAD) != 0) { /* Hash bad. */ |
if ((vp->v_flag & VFHBAD) != 0) { /* Hash bad. */ |
s = &vp->v_text[ncol - 1]; |
s = &vp->v_text[ncol - 1]; |
|
|
void |
void |
setscores(int offs, int size) |
setscores(int offs, int size) |
{ |
{ |
SCORE *sp; |
SCORE *sp; |
SCORE *sp1; |
SCORE *sp1; |
int tempcost; |
|
int bestcost; |
|
int j, i; |
|
VIDEO **vp, **pp; |
VIDEO **vp, **pp; |
VIDEO **vbase, **pbase; |
VIDEO **vbase, **pbase; |
|
int tempcost; |
|
int bestcost; |
|
int j, i; |
|
|
vbase = &vscreen[offs - 1]; /* By hand CSE's. */ |
vbase = &vscreen[offs - 1]; /* By hand CSE's. */ |
pbase = &pscreen[offs - 1]; |
pbase = &pscreen[offs - 1]; |
|
|
void |
void |
traceback(int offs, int size, int i, int j) |
traceback(int offs, int size, int i, int j) |
{ |
{ |
int itrace; |
int itrace, jtrace; |
int jtrace; |
|
int k; |
int k; |
int ninsl; |
int ninsl, ndraw, ndell; |
int ndraw; |
|
int ndell; |
|
|
|
if (i == 0 && j == 0) /* End of update. */ |
if (i == 0 && j == 0) /* End of update. */ |
return; |
return; |