home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_100
/
158_01
/
qe3a
< prev
next >
Wrap
Text File
|
1987-10-12
|
6KB
|
301 lines
/* VERSION 0003 (DATE: 24/10/86) (TIME: 21:19) */
/*
e (qe) screen editor
(C) G. Nigel Gilbert, MICROLOGY, 1981
August-December 1981
Modified: To QE from e (ver 4.6a) by J.W. Haefner -- Oct 84-Mar 85
FILE: qe3
FUNCTIONS: putline,putoffset,putstatusline,putlineno,,putpage,
putmess,unmess,puts,rewrite,calcoffset,resetcursor
PURPOSE: write text to screen
*/
#include "qe.h"
putline(line,y)
int line, y;
{
char *getline(), *p, c;
int cp, bright, lastcol, off, x, nblank;
deleteline(0,y);
if (line <= lastl) {
#if (SCRNDIMMD) /* highlight blocked lines */
bright= line == cline;
if (blocking && !bright) {
if (to) bright= (line >= from) && (line <= to);
else bright= (line >= (from > cline ? cline : from)) &&
(line <= (from > cline ? from : cline));
}
#else /* dim blocked lines if screen is brite */
bright = YES;
if (blocking) { /* dim blocked lines */
if (to) bright= !( (line >= from) && (line <= to) );
else bright= !( (line >= (from > cline ? cline : from)) &&
(line <= (from > cline ? from : cline)) );
}
#endif
lastcol=SWIDTH;
off=x=0;
p=getline(line);
if ( (line == cline && calcoffset()) || (blockscroll && offset) ) {
lastcol+=offset-1;
off=offset;
x=1;
makedim();
putch('<');
makebright();
}
if (!bright) makedim();
for (cp=nblank=0; *p && cp < lastcol; p++) {
if (*p == '\t')
do {
if (cp >= off && cp < lastcol)
/*putch(' ');*/
nblank++;
}
while (++cp % tabwidth);
else {
if (cp++ >= off) { /*dispch(*p);*/
if (*p == ' ') nblank++;
else {
if (nblank) {
x+=nblank;
if (nblank < GOTOLEN)
for (; nblank; nblank--)
bdos(DIRIO,' ');
else {
gotoxy(x,y);
nblank=0;
}
}
dispch(*p);
x++;
}
}
}
}
if (*p && y < SHEIGHT) {
if (bright) makedim();
else makebright();
putch('>');
}
makebright();
/* check for input after each line put, save if there*/
if ( (c=bdos(DIRIO,0xff))) inbuf[inbufp++]=c & ~PARBIT;
}
}
putoffset()
{
int i;
gotoxy(0,0);
if (offset) for(i=3-uspr(offset); i>0; i--) putch(' ');
else puts(" ");
gotoxy(0,cursory);
}
putstatusline(line)
int line;
{
deleteline(FNPOS,0);
makedim();
puts(filename);
putlineno(line);
makebright();
if (errmess != NULL) {
gotoxy(EMPOS,0);
puts(errmess);
}
}
putlineno(line)
int line;
{
int i;
if (!displaypos) return;
gotoxy(LNPOS,0);
makedim();
i=uspr(line);
putch(':');
for (i=8-i-uspr(cursorx+1); i > 0; i--) putch(' ');
makebright();
}
putpage() /*display page more or less centered about 'cline'*/
{
int y,line;
char c;
pfirst= loc(cline,(topline-SHEIGHT)/2);
plast = loc(pfirst,SHEIGHT-topline);
putstatusline(cline);
for (line=pfirst, y=topline; line <= plast; line++, y++) {
if (cline == line) {
cursory = y;
cursorx = adjustc(cursorx);
}
putline(line, y);
if (inbufp && (cline != 1) && (cline != lastl) )
if (((c=inbuf[0]) == tran[DOWNPAGE])
|| (c == tran[UPPAGE]) ) return;
}
if (y <= SHEIGHT) delpage(y);
}
putmess(message)
char *message;
{
int lines;
if (blankedmess && topline > blankedmess) {
gotoxy(3,blankedmess++);
puts(message);
return;
}
if (topline == (helpon ? HELPLINES : 1)) lines=2;
else lines=1;
if (cursory <= (topline+=lines)) {
gotoxy(0,cursory);
/*for ( ; cursory < topline; cursory++) {*/
/* insertline(); */
adputpage(pfirst,topline);
if (plast != lastl) plast-=lines;
}
else pfirst+= lines;
deleteline(0,topline-2);
deleteline(0,topline-1);
gotoxy(3,topline-2);
puts(message);
}
xprtmess(message) /*if an expert, short message of statusline*/
char *message;
{
deleteline(EMPOS,0);
puts(message);
blankedmess=NO;
}
xmessoff()
{
if (errmess==NULL) deleteline(EMPOS,0);
blankedmess=YES;
}
unmess()
{
int l, i, newtop, diff;
newtop= (helpon ? HELPLINES : 1);
if (!(diff=topline-newtop)) return;
/*
if ((diff < PAGEOVERLAP) && ((pfirst-diff) < 1) ) {
if (blankedmess == newtop) return;
for (l=newtop; l < topline; l++) deleteline(0,l);
blankedmess=newtop;
return;
*/
blankedmess=NO;
if (((pfirst-=diff) <= 1) && (cursory-topline<=1) ) {
topline=newtop;
putpage();
}
else {
for (l=newtop, i=0; l < topline; l++, i++) putline(pfirst+i,l);
topline=newtop;
}
}
puts(s)
char *s;
{
int dim;
char c;
dim=NO;
while ( (c=*s++) )
switch(c) {
case BRIDIM :
(dim=!dim) ? begdim() : enddim();
break;
case '\n':
putch('\r');
default :
putch(c);
}
if (dim) enddim();
}
rewrite(cp,x) /*rewrites current line from char 'cp', col 'x', onwards*/
int cp, x;
{
int i, begmark;
char cc,c;
begmark= (calcoffset() > 0);
i= x-offset+begmark;
deleteline((i>0 ? i : 0),cursory);
if (!x && begmark) {
begdim();
putch('<');
enddim();
}
while (x < SWIDTH+offset-begmark && (c=text[cp++])) {
if (c == '\t') {
for (i=tabwidth-x%tabwidth; i>0 && x<SWIDTH+offset-begmark; x++, i--)
if (x >= offset) bdos(DIRIO,' ');
}
else if (x++ >= offset) {
dispch(c);
if (cc=bdos(DIRIO,0xff)) inbuf[inbufp++] = cc & ~PARBIT;
}
}
if (c && cursory < SHEIGHT) {
begdim();
putch('>');
enddim();
}
}
calcoffset()
{
for (offset=0; cursorx >= SWIDTH+offset-(offset>0); offset+=OFFWIDTH);
return offset;
}
resetcursor()
{
int line, y;
if (lastoff != calcoffset()) {
if (blockscroll) {
for (line=pfirst, y=topline; line <= plast; line++, y++)
if (line != cline) putline(line,y);
}
putoffset();
rewrite(0,0);
lastoff=offset;
}
gotoxy(cursorx-offset+(offset>0),cursory);
}
f statusline*/
char *message;
{
deleteline(EMPOS,0);
puts(message);
blank