Path: utzoo!utgpu!cs.utexas.edu!sdd.hp.com!think.com!cayman!pgf From: pgf@cayman.COM (Paul Fox) Newsgroups: alt.sources Subject: Vile 17/17 - vi feel-alike (multi-window) Message-ID: <4536@cayman.COM> Date: 7 Jun 91 22:10:29 GMT Organization: Cayman Systems Inc., Cambridge Ma Lines: 1612 Submitted-by: pgf@cayman.com Archive-name: Vile/part17 #!/bin/sh # this is vileshar.17 (part 17 of Vile) # do not concatenate these parts, unpack them in order with /bin/sh # file window.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 17; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 echo 'x - continuing file window.c' sed 's/^X//' << 'SHAR_EOF' >> 'window.c' && X * all the hard work. You don't just set "force reframe" because dot would X * move. X */ enlargewind(f, n) { X register WINDOW *adjwp; X register LINE *lp; X register int i; X X if (n < 0) X return (shrinkwind(f, -n)); X if (wheadp->w_wndp == NULL) { X mlwrite("Only one window"); X return (FALSE); X } X if ((adjwp=curwp->w_wndp) == NULL) { X adjwp = wheadp; X while (adjwp->w_wndp != curwp) X adjwp = adjwp->w_wndp; X } X if (adjwp->w_ntrows <= n) { X mlwrite("Impossible change"); X return (FALSE); X } X if (curwp->w_wndp == adjwp) { /* Shrink below. */ X lp = adjwp->w_linep; X for (i=0; iw_bufp->b_linep; ++i) X lp = lforw(lp); X adjwp->w_linep = lp; X adjwp->w_toprow += n; X } else { /* Shrink above. */ X lp = curwp->w_linep; X for (i=0; ib_linep; ++i) X lp = lback(lp); X curwp->w_linep = lp; X curwp->w_toprow -= n; X } X curwp->w_ntrows += n; X adjwp->w_ntrows -= n; X curwp->w_flag |= WFMODE|WFHARD|WFINS; X adjwp->w_flag |= WFMODE|WFHARD|WFKILLS; X return (TRUE); } X /* X * Shrink the current window. Find the window that gains space. Hack at the X * window descriptions. Ask the redisplay to do all the hard work. X */ shrinkwind(f, n) { X register WINDOW *adjwp; X register LINE *lp; X register int i; X X if (n < 0) X return (enlargewind(f, -n)); X if (wheadp->w_wndp == NULL) { X mlwrite("Only one window"); X return (FALSE); X } X if ((adjwp=curwp->w_wndp) == NULL) { X adjwp = wheadp; X while (adjwp->w_wndp != curwp) X adjwp = adjwp->w_wndp; X } X if (curwp->w_ntrows <= n) { X mlwrite("Impossible change"); X return (FALSE); X } X if (curwp->w_wndp == adjwp) { /* Grow below. */ X lp = adjwp->w_linep; X for (i=0; iw_bufp->b_linep; ++i) X lp = lback(lp); X adjwp->w_linep = lp; X adjwp->w_toprow -= n; X } else { /* Grow above. */ X lp = curwp->w_linep; X for (i=0; ib_linep; ++i) X lp = lforw(lp); X curwp->w_linep = lp; X curwp->w_toprow += n; X } X curwp->w_ntrows -= n; X adjwp->w_ntrows += n; X curwp->w_flag |= WFMODE|WFHARD|WFKILLS; X adjwp->w_flag |= WFMODE|WFHARD|WFINS; X return (TRUE); } X #if !SMALLER X /* Resize the current window to the requested size */ resize(f, n) int f, n; /* default flag and numeric argument */ { X int clines; /* current # of lines in window */ X X /* must have a non-default argument, else ignore call */ X if (f == FALSE) X return(TRUE); X X /* find out what to do */ X clines = curwp->w_ntrows; X X /* already the right size? */ X if (clines == n) X return(TRUE); X X return(enlargewind(TRUE, n - clines)); } #endif X /* X * Pick a window for a pop-up. Split the screen if there is only one window. X * Pick the uppermost window that isn't the current window. An LRU algorithm X * might be better. Return a pointer, or NULL on error. X */ WINDOW * wpopup() { X register WINDOW *wp; X X if (wheadp->w_wndp == NULL /* Only 1 window */ X && splitwind(FALSE, 0) == FALSE) /* and it won't split */ X return (NULL); X wp = wheadp; /* Find window to use */ X while (wp!=NULL && wp==curwp) X wp = wp->w_wndp; X return (wp); } X scrnextup(f, n) /* scroll the next window up (back) a page */ { X nextwind(FALSE, 1); X backhpage(f, n); X prevwind(FALSE, 1); } X scrnextdw(f, n) /* scroll the next window down (forward) a page */ { X nextwind(FALSE, 1); X forwhpage(f, n); X prevwind(FALSE, 1); } X #if ! SMALLER savewnd(f, n) /* save ptr to current window */ { X swindow = curwp; X return(TRUE); } X restwnd(f, n) /* restore the saved screen */ { X register WINDOW *wp; X X /* find the window */ X wp = wheadp; X while (wp != NULL) { X if (wp == swindow) { X curwp = wp; X make_current(curwp->w_bufp); X upmode(); X return (TRUE); X } X wp = wp->w_wndp; X } X X mlwrite("[No such window exists]"); X return(FALSE); } #endif X newlength(f,n) /* resize the screen, re-writing the screen */ int n; /* numeric argument */ { X WINDOW *wp; /* current window being examined */ X WINDOW *nextwp; /* next window to scan */ X WINDOW *lastwp; /* last window scanned */ X int lastline; /* screen line of last line of current window */ X X if (!f) { X mlwrite("No length given"); X return FALSE; X } X X /* make sure it's in range */ X if (n < 3 || n > term.t_mrow + 1) { X mlwrite("Screen size out of range"); X return(FALSE); X } X X if (term.t_nrow == n - 1) X return(TRUE); X else if (term.t_nrow < n - 1) { X X /* go to the last window */ X wp = wheadp; X while (wp->w_wndp != NULL) X wp = wp->w_wndp; X X /* and enlarge it as needed */ X wp->w_ntrows = n - wp->w_toprow - 2; X wp->w_flag |= WFHARD|WFMODE; X X } else { X X /* rebuild the window structure */ X nextwp = wheadp; X wp = NULL; X lastwp = NULL; X while (nextwp != NULL) { X wp = nextwp; X nextwp = wp->w_wndp; X X /* get rid of it if it is too low */ X if (wp->w_toprow > n - 2) { X X if (--wp->w_bufp->b_nwnd == 0) { X undispbuff(wp->w_bufp,wp); X } X X /* update curwp and lastwp if needed */ X if (wp == curwp) X curwp = wheadp; X make_current(curwp->w_bufp); X if (lastwp != NULL) X lastwp->w_wndp = NULL; X X /* free the structure */ X free((char *)wp); X wp = NULL; X X } else { X /* need to change this window size? */ X lastline = wp->w_toprow + wp->w_ntrows - 1; X if (lastline >= n - 2) { X wp->w_ntrows = n - wp->w_toprow - 2; X wp->w_flag |= WFHARD|WFMODE; X } X } X X lastwp = wp; X } X } X X /* screen is garbage */ X term.t_nrow = n - 1; X sgarbf = TRUE; X return(TRUE); } X newwidth(f,n) /* resize the screen, re-writing the screen */ int n; /* numeric argument */ { X register WINDOW *wp; X X if (!f) { X mlwrite("No width given"); X return FALSE; X } X X /* make sure it's in range */ X if (n < 10 || n > term.t_mcol) { #if NeWS /* serious error for NeWS, halt */ X fprintf(stderr, "Screen width out of range\n") ; X newsclose() ; X exit(1) ; #else X mlwrite("Screen width out of range"); X return(FALSE); #endif X } X X /* otherwise, just re-width it (no big deal) */ X term.t_ncol = n; X term.t_margin = n / 10; X term.t_scrsiz = n - (term.t_margin * 2); X X /* force all windows to redraw */ X wp = wheadp; X while (wp) { X wp->w_flag |= WFHARD | WFMOVE | WFMODE; X wp = wp->w_wndp; X } X sgarbf = TRUE; X X return(TRUE); } X #if ! SMALLER int getwpos() /* get screen offset of current line in current window */ { X register int sline; /* screen line from top of window */ X register LINE *lp; /* scannile line pointer */ X X /* search down the line we want */ X lp = curwp->w_linep; X sline = 1; X while (lp != curwp->w_dotp) { X ++sline; X lp = lforw(lp); X } X X /* and return the value */ X return(sline); } #endif X /* X * Initialize all of the windows. X */ winit() { X register WINDOW *wp; X X wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */ X if (wp==NULL ) X exit(1); X wheadp = wp; X curwp = wp; X wp->w_wndp = NULL; /* Initialize window */ X wp->w_doto = 0; X wp->w_mkp = NULL; X wp->w_mko = 0; X wp->w_ldmkp = NULL; X wp->w_ldmko = 0; X wp->w_toprow = 0; X wp->w_sideways = 0; #if COLOR X /* initalize colors to global defaults */ X wp->w_fcolor = gfcolor; X wp->w_bcolor = gbcolor; #endif X wp->w_ntrows = term.t_nrow-1; /* "-1" for mode line. */ X wp->w_force = 0; X wp->w_flag = WFMODE|WFHARD; /* Full. */ } X X SHAR_EOF echo 'File window.c is complete' && chmod 0444 window.c || echo 'restore of window.c failed' Wc_c="`wc -c < 'window.c'`" test 20419 -eq "$Wc_c" || echo 'window.c: original size 20419, current size' "$Wc_c" # ============= word.c ============== echo 'x - extracting word.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'word.c' && /* X * The routines in this file implement commands that work word or a X * paragraph at a time. There are all sorts of word mode commands. If I X * do any sentence mode commands, they are likely to be put in this file. X */ X #include #include "estruct.h" #include "edef.h" X /* Word wrap on n-spaces. Back-over whatever precedes the point on the current X * line and stop on the first word-break or the beginning of the line. If we X * reach the beginning of the line, jump back to the end of the word and start X * a new line. Otherwise, break the line at the word-break, eat it, and jump X * back to the end of the word. X * Returns TRUE on success, FALSE on errors. X */ wrapword() { X register int cnt; /* size of word wrapped to next line */ X register int c; /* charector temporary */ X X /* backup from the 1 char */ X if (!backchar(0, 1)) X return(FALSE); X X /* back up until we aren't in a word, X make sure there is a break in the line */ X cnt = 0; X while (c = lgetc(curwp->w_dotp, curwp->w_doto), !isspace(c)) { X cnt++; X if (!backchar(0, 1)) X return(FALSE); X /* if we make it to the beginning, start a new line */ X if (curwp->w_doto == 0) { X gotoeol(FALSE, 0); X return(lnewline()); X } X } X X /* delete the forward white space */ X if (!ldelete(1L, FALSE)) X return(FALSE); X X /* put in a end of line */ X if (!newline(TRUE,1)) X return FALSE; X X /* and past the first word */ X while (cnt-- > 0) { X if (forwchar(FALSE, 1) == FALSE) X return(FALSE); X } X return(TRUE); } X X /* X * Move the cursor forward by the specified number of words. All of the motion X * is done by "forwchar". Error if you try and move beyond the buffer's end. X * X * Returns of SORTOFTRUE result if we're doing a non-delete operation. X * Whitespace after a word is always included on deletes (and non-operations, X * of course), but only on intermediate words for other operations, for X * example. The last word of non-delete ops does _not_ include its whitespace. X */ X forwviword(f, n) { X int s; X X if (n < 0) X return (backword(f, -n)); X setchartype(); X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X while (n--) { X while (((s = isnewviwordf()) == FALSE) || X (s == SORTOFTRUE && n != 0)) { X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X } X } X return TRUE; } X /* X * Move the cursor forward by the specified number of words. All of the motion X * is done by "forwchar". Error if you try and move beyond the buffer's end. X */ forwword(f, n) { X int s; X X if (n < 0) X return (backword(f, -n)); X setchartype(); X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X while (n--) { X while (((s = isnewwordf()) == FALSE) || X (s == SORTOFTRUE && n != 0)) { X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X } X } X return(TRUE); } X /* X * Move the cursor forward by the specified number of words. All of the motion X * is done by "forwchar". Error if you try and move beyond the buffer's end. X */ forwviendw(f, n) { X int s; X if (n < 0) X return (FALSE); X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X setchartype(); X while (n--) { X while ((s = isendviwordf()) == FALSE) { X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X } X X } X if (s == SORTOFTRUE) X return TRUE; X else X return backchar(FALSE, 1); } X /* X * Move the cursor forward by the specified number of words. All of the motion X * is done by "forwchar". Error if you try and move beyond the buffer's end. X */ forwendw(f, n) { X int s; X if (n < 0) X return (FALSE); X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X setchartype(); X while (n--) { X while ((s = isendwordf()) == FALSE) { X if (forwchar(FALSE, 1) == FALSE) X return (FALSE); X } X X } X if (s == SORTOFTRUE) X return TRUE; X else X return backchar(FALSE, 1); } X /* X * Move the cursor backward by "n" words. All of the details of motion are X * performed by the "backchar" and "forwchar" routines. Error if you try to X * move beyond the buffers. X */ backviword(f, n) { X if (n < 0) X return (forwword(f, -n)); X if (backchar(FALSE, 1) == FALSE) X return (FALSE); X setchartype(); X while (n--) { X while (isnewviwordb() == FALSE) { X if (backchar(FALSE, 1) == FALSE) X return (FALSE); X } X } X return (forwchar(FALSE, 1)); } X /* X * Move the cursor backward by "n" words. All of the details of motion are X * performed by the "backchar" and "forwchar" routines. Error if you try to X * move beyond the buffers. X */ backword(f, n) { X if (n < 0) X return (forwword(f, -n)); X if (backchar(FALSE, 1) == FALSE) X return (FALSE); X setchartype(); X while (n--) { X while (isnewwordb() == FALSE) { X if (backchar(FALSE, 1) == FALSE) X return (FALSE); X } X } X return (forwchar(FALSE, 1)); } X /* X * Return TRUE if the character at dot is a character that is considered to be X * part of a word. The word character list is hard coded. Should be setable. X */ inword() { X register int c; X X if (curwp->w_doto == llength(curwp->w_dotp)) X return (FALSE); X c = lgetc(curwp->w_dotp, curwp->w_doto); X if (islower(c)) X return (TRUE); X if (isupper(c)) X return (TRUE); X if (isdigit(c)) X return (TRUE); X return (FALSE); } X join(f,n) { X register int s; X register int doto; X X if (n < 0) return FALSE; X if (n == 0) return TRUE; X if (lforw(curwp->w_dotp) == curbp->b_linep) X return FALSE; X while(n--) { X s = lastnonwhite(f,n); X if (s == TRUE) s = forwchar(FALSE,1); X if (s == TRUE) s = setmark(); X if (s == TRUE) s = forwline(f,1); X if (s == TRUE) s = firstnonwhite(f,1); X if (s == TRUE) s = killregion(f,1); X if (s != TRUE) X return s ; X X doto = curwp->w_doto; X if (doto == 0) X return TRUE; X if (lgetc(curwp->w_dotp,doto) == ')') X return TRUE; X if (lgetc(curwp->w_dotp,doto-1) == '.') X s = linsert(2,' '); X else X s = linsert(1,' '); X } X X return s; } X formatregion(f,n) { X register int c; /* current char durring scan */ X register int wordlen; /* length of current word */ X register int clength; /* position on line during fill */ X register int i; /* index during word copy */ X register int newlength; /* tentative new line length */ X register int finished; /* Are we at the End-Of-Paragraph? */ X register int firstflag; /* first word? (needs no space) */ X register LINE *pastline; /* pointer to line just past EOP */ X register int sentence; /* was the last char a period? */ X char wbuf[NSTRING]; /* buffer for current word */ X int secondindent; X REGION region; X int s; X X if (curbp->b_mode & MDVIEW) /* don't allow this command if */ X return(rdonly()); /* we are in read only mode */ X X if (curwp->w_mkp != curwp->w_dotp) { X getregion(®ion); X if (region.r_linep == curwp->w_mkp) X swapmark(); X } X pastline = curwp->w_mkp; X if (pastline != curbp->b_linep) X pastline = lforw(pastline); X X secondindent = indentlen(curwp->w_dotp); X X /* go forward to get the indent for the second and following lines */ X curwp->w_dotp = lforw(curwp->w_dotp); X X if (curwp->w_dotp != pastline) { X secondindent = indentlen(curwp->w_dotp); X } X X /* and back where we should be */ X curwp->w_dotp = lback(curwp->w_dotp); X firstnonwhite(FALSE,1); X X clength = indentlen(curwp->w_dotp); X wordlen = 0; X sentence = FALSE; X X /* scan through lines, filling words */ X firstflag = TRUE; X finished = FALSE; X while (!finished) { X X if (interrupted) return ABORT; X X /* get the next character in the paragraph */ X if (curwp->w_doto == llength(curwp->w_dotp)) { X c = ' '; X if (lforw(curwp->w_dotp) == pastline) X finished = TRUE; X } else { X c = lgetc(curwp->w_dotp, curwp->w_doto); X } X /* and then delete it */ X if (!finished) { X s = ldelete(1L, FALSE); X if (s != TRUE) return s; X } X X /* if not a separator, just add it in */ X if (c != ' ' && c != '\t') { X /* was it the end of a "sentence"? */ X sentence = (c == '.' || c == '?' || c == '!'); X if (wordlen < NSTRING - 1) X wbuf[wordlen++] = c; X } else if (wordlen) { X /* at a word break with a word waiting */ X /* calculate tentative new length with word added */ X newlength = clength + 1 + wordlen; X if (newlength <= fillcol) { X /* add word to current line */ X if (!firstflag) { X s = linsert(1, ' '); /* the space */ X if (s != TRUE) return s; X ++clength; X } X firstflag = FALSE; X } else { X if (lnewline() == FALSE X || ((i=secondindent/TABVAL)!=0 && X linsert(i, '\t')==FALSE) X || ((i=secondindent%TABVAL)!=0 && X linsert(i, ' ')==FALSE)) { X return FALSE; X } X clength = secondindent; X } X X /* and add the word in in either case */ X for (i=0; i= 'a' && ch <= 'z') || X (ch >= 'A' && ch <= 'Z') || X (ch >= '0' && ch <= '9')); X if (wordflag == TRUE && lastword == FALSE) X ++nwords; X lastword = wordflag; X ++nchars; X } X X /* and report on the info */ X if (nwords > 0L) X avgch = (int)((100L * nchars) / nwords); X else X avgch = 0; X X mlwrite("lines %d, words, %D chars %D avg chars/word %f", X nlines + 1, nwords, nchars, avgch); X return(TRUE); } #endif SHAR_EOF chmod 0444 word.c || echo 'restore of word.c failed' Wc_c="`wc -c < 'word.c'`" test 10449 -eq "$Wc_c" || echo 'word.c: original size 10449, current size' "$Wc_c" # ============= wordmov.c ============== echo 'x - extracting wordmov.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'wordmov.c' && X #include #include "estruct.h" #include "edef.h" X /* These routines report on transitions between word boundaries, both X in the punctuated vi sense, and in the whitespace/darkspace X sense. The transition is reported _after_ it has occurred. You X need to back up to get to the char. before the transition. X Written for vile by Paul Fox, (c)1990 */ X #define WASSPACE 0 #define ISSPACE 0 #define WASIDENT 1 #define ISIDENT 1 #define WASOTHER 2 #define ISOTHER 2 #define WASNL 3 #define ISNL 3 X static int ochartype; X setchartype() { X ochartype = getchartype(); } X getchartype() { X register int c; X X if (curwp->w_doto == llength(curwp->w_dotp)) X return (ISNL); X else X c = lgetc(curwp->w_dotp, curwp->w_doto); X return (isspace(c) ? ISSPACE : X ( isident(c) ? ISIDENT : ISOTHER ) ); } X X isnewwordf() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X switch (type) { X case ISNL: if (doingopcmd) { ret = SORTOFTRUE; break;} X case ISSPACE: ret = FALSE; break; X case ISIDENT: X case ISOTHER: ret = TRUE; break; X } X break; X case WASIDENT: X case WASOTHER: X switch (type) { X case ISNL: if (doingopcmd) { ret = SORTOFTRUE; break;} X case ISSPACE: if (doingopcmd && opcmd != OPDEL) X { ret = SORTOFTRUE; break;} X case ISIDENT: X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X isnewwordb() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X ret = FALSE; break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: ret = TRUE; break; X case ISIDENT: X case ISOTHER: ret = FALSE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: ret = TRUE; break; X case ISIDENT: X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X isnewviwordf() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X switch (type) { X case ISNL: if (doingopcmd) { ret = SORTOFTRUE; break;} X case ISSPACE: ret = FALSE; break; X case ISIDENT: X case ISOTHER: ret = TRUE; break; X } X break; X case WASIDENT: X switch (type) { X case ISNL: if (doingopcmd) { ret = SORTOFTRUE; break;} X case ISSPACE: if (doingopcmd && opcmd != OPDEL) X { ret = SORTOFTRUE; break;} X case ISIDENT: ret = FALSE; break; X case ISOTHER: ret = TRUE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: if (doingopcmd) { ret = SORTOFTRUE; break;} X case ISSPACE: if (doingopcmd && opcmd != OPDEL) X { ret = SORTOFTRUE; break;} X case ISOTHER: ret = FALSE; break; X case ISIDENT: ret = TRUE; break; X } X break; X } X ochartype = type; X return (ret); } X isnewviwordb() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X ret = FALSE; break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: X case ISOTHER: ret = TRUE; break; X case ISIDENT: ret = FALSE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: X case ISIDENT: ret = TRUE; break; X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X X isendwordb() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X switch (type) { X case ISNL: X case ISSPACE: ret = FALSE; break; X case ISIDENT: X case ISOTHER: ret = TRUE; break; X } X break; X case WASIDENT: X case WASOTHER: X ret = FALSE; break; X } X ochartype = type; X return (ret); } X isendviwordb() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X switch (type) { X case ISNL: X case ISSPACE: ret = FALSE; break; X case ISOTHER: X case ISIDENT: ret = TRUE; break; X } X break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: X case ISOTHER: ret = TRUE; break; X case ISIDENT: ret = FALSE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: X case ISIDENT: ret = TRUE; break; X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X isendwordf() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X ret = FALSE; break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: X if (doingopcmd) ret = SORTOFTRUE; X else ret = TRUE; X break; X case ISIDENT: X case ISOTHER: ret = FALSE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: X if (doingopcmd) ret = SORTOFTRUE; X else ret = TRUE; X break; X case ISIDENT: X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X isendviwordf() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X ret = FALSE; break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: X case ISOTHER: X if (doingopcmd) ret = SORTOFTRUE; X else ret = TRUE; X break; X case ISIDENT: ret = FALSE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: X case ISIDENT: X if (doingopcmd) ret = SORTOFTRUE; X else ret = TRUE; X break; X case ISOTHER: ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } X #ifdef template isANYTHING() { X register int ret; X register int type; X X type = getchartype(); X X switch (ochartype) { X case WASNL: X case WASSPACE: X switch (type) { X case ISNL: X case ISSPACE: X ret = FALSE; break; X case ISIDENT: X ret = FALSE; break; X case ISOTHER: X ret = FALSE; break; X } X break; X case WASIDENT: X switch (type) { X case ISNL: X case ISSPACE: X ret = TRUE; break; X case ISIDENT: X ret = FALSE; break; X case ISOTHER: X ret = TRUE; break; X } X break; X case WASOTHER: X switch (type) { X case ISNL: X case ISSPACE: X ret = TRUE; break; X case ISIDENT: X ret = TRUE; break; X case ISOTHER: X ret = FALSE; break; X } X break; X } X ochartype = type; X return (ret); } #endif /* template */ X SHAR_EOF chmod 0444 wordmov.c || echo 'restore of wordmov.c failed' Wc_c="`wc -c < 'wordmov.c'`" test 6094 -eq "$Wc_c" || echo 'wordmov.c: original size 6094, current size' "$Wc_c" # ============= z100bios.asm ============== echo 'x - extracting z100bios.asm (Text)' sed 's/^X//' << 'SHAR_EOF' > 'z100bios.asm' && ;History:46,1 X _TEXT SEGMENT BYTE PUBLIC 'CODE' _TEXT ENDS _DATA SEGMENT WORD PUBLIC 'DATA' _DATA ENDS CONST SEGMENT WORD PUBLIC 'CONST' CONST ENDS _BSS SEGMENT WORD PUBLIC 'BSS' _BSS ENDS X bios_seg segment at 40h X org 9 bios_conout label far bios_seg ends X DGROUP GROUP CONST, _BSS, _DATA X ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP X parm equ ss:[bp] X _TEXT SEGMENT X X public _asmputc X putc_stack struc X putc_bp dw ? X putc_return dd ? X char db ? putc_stack ends X _asmputc proc far X push bp X mov bp,sp X mov al,parm.char X call bios_conout X pop bp X ret _asmputc endp X _TEXT ends X end X SHAR_EOF chmod 0444 z100bios.asm || echo 'restore of z100bios.asm failed' Wc_c="`wc -c < 'z100bios.asm'`" test 652 -eq "$Wc_c" || echo 'z100bios.asm: original size 652, current size' "$Wc_c" # ============= z309.c ============== echo 'x - extracting z309.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'z309.c' && /* X * The routines in this file provide support for the Zenith Z-100 PC X * family. It goes directly to the graphics RAM to do screen output. X * It compiles into nothing if not a Zenith driver. X */ X #define termdef 1 /* don't define "term" external */ X #include #include "estruct.h" #include "edef.h" X #if Z309 X /* set NROW to 25 for 25-line interlaced mode */ #define NROW 50 /* Screen size. */ #define NCOL 80 /* Edit if you want to. */ #define MARGIN 8 /* size of minimim margin and */ #define SCRSIZ 64 /* scroll size for extended lines */ #define NPAUSE 200 /* # times thru update to pause */ #define BEL 0x07 /* BEL character. */ #define ESC 0x1B /* ESC character. */ #define SPACE 32 /* space character */ X #define SCADC 0xb8000000L /* CGA address of screen RAM */ #define SCADM 0xb0000000L /* MONO address of screen RAM */ X #define CDMONO 0 /* monochrome text card */ #define CDCGA50 1 /* 50-line color graphics card */ #define CDCGI25 2 /* 25-line interlaced CGA text */ #define CDCGA25 3 /* 25-line color graphics card */ #define CDSENSE 9 /* detect the card type */ X int dtype = CDCGA50; /* current display type */ long scadd; /* address of screen ram */ int *scptr[NROW]; /* pointer to screen lines */ int sline[NCOL]; /* screen line image */ extern union REGS rg; /* cpu register for use of DOS calls */ X extern int ttopen(); /* Forward references. */ extern int ttgetc(); extern int ttputc(); extern int ttflush(); extern int ttclose(); extern int z309move(); extern int z309eeol(); extern int z309eeop(); extern int z309beep(); extern int z309open(); extern int z309rev(); extern int z309cres(); extern int z309close(); extern int z309putc(); extern int z309kopen(); extern int z309kclose(); X #if COLOR extern int z309fcol(); extern int z309bcol(); X int cfcolor = -1; /* current forground color */ int cbcolor = -1; /* current background color */ int ctrans[] = /* ansi to z309 color translation table */ X {0, 4, 2, 6, 1, 5, 3, 7}; #endif X /* X * Standard terminal interface dispatch table. Most of the fields point into X * "termio" code. X */ TERM term = { X NROW-1, X NROW-1, X NCOL, X NCOL, X MARGIN, X SCRSIZ, X NPAUSE, X z309open, X z309close, X z309kopen, X z309kclose, X ttgetc, X z309putc, X ttflush, X z309move, X z309eeol, X z309eeop, X z309beep, X z309rev, X z309cres #if COLOR X , z309fcol, X z309bcol #endif }; X extern union REGS rg; X #if COLOR z309fcol(color) /* set the current output color */ X int color; /* color to set */ X { X cfcolor = ctrans[color]; } X z309bcol(color) /* set the current background color */ X int color; /* color to set */ X { X cbcolor = ctrans[color]; } #endif z309move(row, col) { X rg.h.ah = 2; /* set cursor position function code */ X rg.h.dl = col; X rg.h.dh = row; X rg.h.bh = 0; /* set screen page number */ X int86(0x10, &rg, &rg); } X z309eeol() /* erase to the end of the line */ X { X int attr; /* attribute byte mask to place in RAM */ X int *lnptr; /* pointer to the destination line */ X int i; X int ccol; /* current column cursor lives */ X int crow; /* row */ X X /* find the current cursor position */ X rg.h.ah = 3; /* read cursor position function code */ X rg.h.bh = 0; /* current video page */ X int86(0x10, &rg, &rg); X ccol = rg.h.dl; /* record current column */ X crow = rg.h.dh; /* and row */ X X /* build the attribute byte and setup the screen pointer */ #if COLOR X if (dtype != CDMONO) X attr = (((cbcolor & 15) << 4) | (cfcolor & 15)) << 8; X else X attr = 0x0700; #else X attr = 0x0700; #endif X lnptr = &sline[0]; X for (i=0; i < term.t_ncol; i++) X *lnptr++ = SPACE | attr; X #if 0 /* Heath/Zenith builds flicker-less CGAs */ X if (flickcode) { X /* wait for vertical retrace to be off */ X while ((inp(0x3da) & 8)) X ; X X /* and to be back on */ X while ((inp(0x3da) & 8) == 0) X ; X } #endif X X /* and send the string out */ X movmem(&sline[0], scptr[crow]+ccol, (term.t_ncol-ccol)*2); X } X z309putc(ch) /* put a character at the current position in the X current colors */ X int ch; X { X rg.h.ah = 14; /* write char to screen with current attrs */ X rg.h.al = ch; #if COLOR X if (dtype != CDMONO) X rg.h.bl = cfcolor; X else X rg.h.bl = 0x07; #else X rg.h.bl = 0x07; #endif X int86(0x10, &rg, &rg); } X z309eeop() { X int attr; /* attribute to fill screen with */ X X rg.h.ah = 6; /* scroll page up function code */ X rg.h.al = 0; /* # lines to scroll (clear it) */ X rg.x.cx = 0; /* upper left corner of scroll */ /*HERE*/ rg.x.dx = 0x184f; /* lower right corner of scroll */ #if COLOR X if (dtype != CDMONO) X attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15); X else X attr = 0; #else X attr = 0; #endif X rg.h.bh = attr; X int86(0x10, &rg, &rg); } X z309rev(state) /* change reverse video state */ X int state; /* TRUE = reverse, FALSE = normal */ X { X /* This never gets used under the z309-PC driver */ } X z309cres(res) /* change screen resolution */ X char *res; /* resolution to change to */ X { X if (strcmp(res, "CGA50") == 0) { X scinit(CDCGA50); X return(TRUE); X } else if (strcmp(res, "MONO") == 0) { X scinit(CDMONO); X return(TRUE); X } else X return(FALSE); } X z309beep() { #if MWC86 X putcnb(BEL); #else X bdos(6, BEL, 0); #endif } X z309open() { X scinit(CDSENSE); X revexist = TRUE; X ttopen(); } X z309close() X { X rg.h.ah = 101; X rg.h.al = 1; /* 25-line interlace mode */ X int86(0x10, &rg, &rg); #if COLOR X z309fcol(7); X z309bcol(0); #endif X ttclose(); } X z309kopen() /* open the keyboard */ X { } X z309kclose() /* close the keyboard */ X { } X scinit(type) /* initialize the screen head pointers */ X int type; /* type of adapter to init for */ X { X union { X long laddr; /* long form of address */ X int *paddr; /* pointer form of address */ X } addr; X int i; X X /* if asked...find out what display is connected */ X int86(0x11, &rg, &rg); X dtype = CDCGA50; X scadd = SCADC; X strcpy(sres, "CGA50"); X if ((((rg.x.ax >> 4) & 11) == 3) || type == CDMONO) { X strcpy(sres, "MONO"); X dtype = CDMONO; X scadd = SCADM; X } X else { X rg.h.ah = 101; /* set al = 1 for 25-line interlace mode */ X rg.h.al = 2; /* 50-line interlace mode */ X int86(0x10, &rg, &rg); X } X X /* initialize the screen pointer array */ X for (i = 0; i < NROW; i++) { X addr.laddr = scadd + (long)(NCOL * i * 2); X scptr[i] = addr.paddr; X } } X scwrite(row, outstr, forg, bacg) /* write a line out*/ X int row; /* row of screen to place outstr on */ char *outstr; /* string to write out (must be term.t_ncol long) */ int forg; /* forground color of string to write */ int bacg; /* background color */ X { X int attr; /* attribute byte mask to place in RAM */ X int *lnptr; /* pointer to the destination line */ X int i; X X /* build the attribute byte and setup the screen pointer */ #if COLOR X if (dtype != CDMONO) X attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8; X else X attr = (((bacg & 15) << 4) | (forg & 15)) << 8; #else X attr = (((bacg & 15) << 4) | (forg & 15)) << 8; #endif X lnptr = &sline[0]; X for (i=0; i