Exemple #1
0
void display_search_result(point_t found, int dir, char *prompt, char *search)
{
	if (found != -1 ) {
		curbp->b_point = found;
		msg("%s%s",prompt, search);
		display(curwp, TRUE);
	} else {
		msg("Failing %s%s",prompt, search);
		dispmsg();
		curbp->b_point = (dir == FWD_SEARCH ? 0 : pos(curbp, curbp->b_ebuf));
	}
}
Exemple #2
0
void  eraseof(
              union both_scr  *posptr,
              int  toright,
              int  rowcol[][5],
              char  inptext[] [25] [80],
              int  line_no,
              int  col_no)
/**********************************************************************/
/*                                                                    */
/* Perform the ERASEEOF command.  This command is only valid from a   */
/* function key.                                                      */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
register int  i;
register int  f;


for (f = 0; line_no > rowcol[f] [BOTTOM_MAR]; ++f)
    {;}; /* end for */
for ( ; col_no > rowcol[f] [RIGHT_MAR]; ++f)
    {;}; /* end for */

if (rowcol[f] [ATTRIB] < RC_PROTECT)
    {
    if (rowcol[f] [ATTRIB] == RC_NORMAL)
        /* flag as changed */
        ++rowcol[f] [ATTRIB];
    if (toright)
        for (i = ATR; i <= OVR; ++i)
            memset(&inptext[i] [line_no] [col_no], 0x00,
                (rowcol[f] [RIGHT_MAR] - col_no) + 1);
    else
        for (i = ATR; i <= OVR; ++i)
            memset(&inptext[i] [line_no] [rowcol[f] [LEFT_MAR]], 0x00,
                (col_no - rowcol[f] [LEFT_MAR]) + 1);
    rdsplin(posptr, line_no, rowcol[f] [LEFT_MAR],
        rowcol[f] [RIGHT_MAR], inptext);
    } /* end then */
else
    dispmsg(posptr, ERASEOF_MSG1);

} /* end eraseof */
Exemple #3
0
struct bufline  *lnecmd3(
              union both_scr  *posptr,
              int  maxlrecl,
              register struct bufline  *curr,
              register struct lineptrs  *place,
              char  *pos,
              char  ccnt[8],
              int  *line_no,
              int  *dschanged)
/**********************************************************************/
/*                                                                    */
/* Process line commands from edit screen.  Anything > o.             */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
struct bufline  *hold;
struct bufline  *top;

register int  n;
register int  cnt;
unsigned int  len_bufline;


switch(*pos)
    {
    case 'r':
        if (ccnt[0] == 'e')  /* regular chars command */
            {
            if (lcinval(posptr, lc_any, curr))
                break;
            *dschanged = YES;
            curr -> script = BUF_ASCII;
            srpbufr(posptr, maxlrecl, curr);
            srpbufr(posptr, maxlrecl, curr -> next);
            break;
            } /* end then */
        if (lcinval(posptr, lc_both, curr))
            break;
        if (ckplace(posptr, rep_cmd, place))
            break;
        if (ccnt[0] == 'r')
            {
            if (place -> repst)
                {
                if (cmpline(place -> repst, curr) > 0)
                    {
                    place -> repfn = place -> repst;
                    place -> repst = curr;
                    } /* end then */
                else
                    place -> repfn = curr;
                if (place -> repst -> status == ST_XBLK)
                    place -> repst = place -> repst -> bblk;
                } /* end then */
            else
                place -> repst = curr;
            /* check for number following rep */
            ccnt[0] = '0';
            } /* end then */
        if (!(cnt = vrepcnt(posptr, ccnt)))
            break;
        place -> count = cnt;
        if (place -> repst)
            {
            if (place -> repfn)
                {
                curr = place -> repfn -> next;
                rrepblk(posptr, place, maxlrecl);
                curr = curr -> prev;
                *dschanged = YES;
                } /* end then */
            break;
            } /* end then */
        if (curr -> status == ST_XBLK)
            {
            place -> repst = curr -> bblk;
            place -> repfn = curr;
            curr = curr -> next;
            rrepblk(posptr, place, maxlrecl);
            curr = curr -> prev;
            *dschanged = YES;
            break;
            } /* end then */
        place -> count = 0;
        len_bufline = sizeof(struct bufline_hdr) + maxlrecl;
        top = curr;
        hold = curr -> next;
        for (n = 0; n < cnt; ++n)
            {
            curr -> next = (struct bufline *) malloc(len_bufline);
            if (!(curr -> next))
                zfinish(posptr, no_storage);
            memset(curr -> next, '\0', len_bufline);
            curr -> next -> prev = curr;
            curr -> next -> script = curr -> script;
            curr -> next -> status = curr -> status;
            strcpy(curr -> next -> bline, curr -> bline);
            curr = curr -> next;
            } /* end for */
        curr -> next = hold;
        hold -> prev = curr;
        renbufr(top);
        *dschanged = YES;
        break;
    case 's':
        if (ccnt[0] == 'p')  /* special chars command */
            {
            if (lcinval(posptr, lc_any, curr))
                break;
            *dschanged = YES;
            curr -> script = BUF_ROMCHAR;
            srpbufr(posptr, maxlrecl, curr);
            srpbufr(posptr, maxlrecl, curr -> next);
            dispmsg(posptr, LNECMD3_MSG1);
            break;
            } /* end then */
        if (curr -> status != ST_XBLK)
            break;
        if (!(cnt = vrepcnt(posptr, ccnt)))
            break;
        place -> excst = curr;
        place -> count = cnt;
        curr = excshow(posptr, place, maxlrecl);
        break;
    case 't':
        switch(ccnt[0])
            {
            case 'e':  /* @ text entry */
                if (lcinval(posptr, lc_bottom, curr))
                    break;
                break;
            case 'f':  /* @ text flow  */
                if (lcinval(posptr, lc_any, curr))
                    break;
                break;
            case 's':  /* @ text split */
                if (lcinval(posptr, lc_any, curr))
                    break;
                break;
            default:
                dispmsg(posptr, LNECMD3_MSG2);
                break;
            } /* end switch */
        break;
    case 'x':  /* exclude */
        if (lcinval(posptr, lc_both, curr))
            break;
        if (ckplace(posptr, exc_cmd, place))
            break;
        if (ccnt[0] == 'x')
            {
            if (place -> excst)
                {
                if (cmpline(place -> excst, curr) > 0)
                    {
                    place -> excfn = place -> excst;
                    place -> excst = curr;
                    } /* end then */
                else
                    place -> excfn = curr;
                curr = exclude(posptr, place);
                } /* end then */
            else
                place -> excst = curr;
            break;
            } /* end then */
        if (!(cnt = vrepcnt(posptr, ccnt)))
            break;
        place -> count = cnt;
        place -> excst = curr;
        place -> excfn = curr;
        curr = exclude(posptr, place);
        *line_no += cnt - 1;
        break;
    } /* end switch */

return(curr);

} /* end lnecmd3 */
Exemple #4
0
void  phebchr(
              union both_scr  *posptr,
              int  inpt,
              unsigned int  shift,
              int  toright,
              int  nfield,
              int  rowcol[] [5],
              int  *line_no,
              int  *col_no,
              char  inptext[] [25] [80],
              unsigned int  display)
/**********************************************************************/
/*                                                                    */
/* Process character by character changes to the screen for Hebrew    */
/* charset.                                                           */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
/* ineligible is initialized in keyboard order */
static char  ineligible[] = {'!', '@', '*', '(', ')',
    '`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', MAQQEPH, '=',
    PASEQ, '[', ']', '\\', SOPH_PASUQ, '"', '?', ',', '.', '/', '\0'};

static char  trope[] = {MAHPAKATUM, SEGHOLTA, GERES, GARSAYIM,
    SILLUQ, REBIA, ZAQEF, ZAQEF_MAG, KEPULA, MEREKA, TIPHA, MUNAH,
    GALGAL, ILLUJ, TEBIR, DEHI, SALSELET, DARGA, PAZER_MAG, PAZER,
    MAHPAK, YETIB, ATNAH, TELISA_PAR, TELISA_MAG, SINNORIT};

int  f;
enum csrfunc  dirforw;


/* checks done on preceding letter */
if (toright)
    if (shift & INS_LOCK)
        dirforw = nopcsr;
    else
        {
        entfield(leftcsr, toright, nfield, rowcol, line_no, col_no);
        dirforw = rightcsr;
        } /* end else, then */
else
    {
    entfield(rightcsr, toright, nfield, rowcol, line_no, col_no);
    dirforw = leftcsr;
    } /* end else */


if ((inptext[SRP] [*line_no] [*col_no] & SRP_MASK) == SRP_HEBREW  &&
    !strchr(ineligible, inptext[TXT] [*line_no] [*col_no]))
    {
    if (shift & INS_LOCK)
        {
        for (f = 0; *line_no > rowcol[f] [BOTTOM_MAR]; ++f)
            {;}; /* end for */
        for ( ; *col_no > rowcol[f] [RIGHT_MAR]; ++f)
            {;}; /* end for */
        } /* end then */
    switch(inpt)
        {
        /* symbols */
        case PATHAH:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_PATHAH;
            break;
        case SEGHOL:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_SEGHOL;
            break;
        case HIREQ:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_HIREQ;
            break;
        case QIBBUS:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_QIBBUS;
            break;
        case QAMES:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_QAMES;
            break;
        case SERE:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_SERE;
            break;
        case HOLEM:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_HOLEM;
            break;
        case SHEWA:
            inptext[OVR] [*line_no] [*col_no] |= OVR_SHEWA;
            break;
        case DAGESH:
            if (inptext[TXT] [*line_no] [*col_no] != ALEPH  &&
                inptext[TXT] [*line_no] [*col_no] != HETH   &&
                inptext[TXT] [*line_no] [*col_no] != AYIN)
                {
                inptext[OVR] [*line_no] [*col_no] &= (~OVR_RAPHE);
                inptext[OVR] [*line_no] [*col_no] |= OVR_DAGESH;
                } /* end then */
            else
                { /* Dagesh not used with this letter */
                dispmsg(posptr, PHEBCHR_MSG1);
                return;
                } /* end else */
            break;
        case RAPHE:
            if (inptext[TXT] [*line_no] [*col_no] != ALEPH  &&
                inptext[TXT] [*line_no] [*col_no] != HE     &&
                inptext[TXT] [*line_no] [*col_no] != HETH   &&
                inptext[TXT] [*line_no] [*col_no] != AYIN   &&
                inptext[TXT] [*line_no] [*col_no] != RESH)
                {
                inptext[OVR] [*line_no] [*col_no] &= (~OVR_DAGESH);
                inptext[OVR] [*line_no] [*col_no] |= OVR_RAPHE;
                } /* end then */
            else
                { /* Raphe not used with this letter */
                dispmsg(posptr, PHEBCHR_MSG2);
                return;
                } /* end else */
            break;
        case QAMES_KATUPH:
            inptext[OVR] [*line_no] [*col_no] &= OVR_RHTMASK;
            inptext[OVR] [*line_no] [*col_no] |= OVR_KATUPH;
            break;
        /* tropes */
        case MAHPAKATUM:
            inptext[SRP] [*line_no] [*col_no] = TRP_MAHPAKATUM;
            break;
        case SEGHOLTA:
            inptext[SRP] [*line_no] [*col_no] = TRP_SEGHOLTA;
            break;
        case GERES:
            inptext[SRP] [*line_no] [*col_no] = TRP_GERES;
            break;
        case GARSAYIM:
            inptext[SRP] [*line_no] [*col_no] = TRP_GARSAYIM;
            break;
        case SILLUQ:
            inptext[SRP] [*line_no] [*col_no] = TRP_SILLUQ;
            break;
        case REBIA:
            inptext[SRP] [*line_no] [*col_no] = TRP_REBIA;
            break;
        case ZAQEF:
            inptext[SRP] [*line_no] [*col_no] = TRP_ZAQEF;
            break;
        case ZAQEF_MAG:
            inptext[SRP] [*line_no] [*col_no] = TRP_ZAQEFMAG;
            break;
        case KEPULA:
            inptext[SRP] [*line_no] [*col_no] = TRP_KEPULA;
            break;
        case MEREKA:
            inptext[SRP] [*line_no] [*col_no] = TRP_MEREKA;
            break;
        case TIPHA:
            inptext[SRP] [*line_no] [*col_no] = TRP_TIPHA;
            break;
        case MUNAH:
            inptext[SRP] [*line_no] [*col_no] = TRP_MUNAH;
            break;
        case GALGAL:
            inptext[SRP] [*line_no] [*col_no] = TRP_GALGAL;
            break;
        case ILLUJ:
            inptext[SRP] [*line_no] [*col_no] = TRP_ILLUJ;
            break;
        case TEBIR:
            inptext[SRP] [*line_no] [*col_no] = TRP_TEBIR;
            break;
        case DEHI:
            inptext[SRP] [*line_no] [*col_no] = TRP_DEHI;
            break;
        case SALSELET:
            inptext[SRP] [*line_no] [*col_no] = TRP_SALSELET;
            break;
        case DARGA:
            inptext[SRP] [*line_no] [*col_no] = TRP_DARGA;
            break;
        case PAZER_MAG:
            inptext[SRP] [*line_no] [*col_no] = TRP_PAZERMAG;
            break;
        case PAZER:
            inptext[SRP] [*line_no] [*col_no] = TRP_PAZER;
            break;
        case MAHPAK:
            inptext[SRP] [*line_no] [*col_no] = TRP_MAHPAK;
            break;
        case YETIB:
            inptext[SRP] [*line_no] [*col_no] = TRP_YETIB;
            break;
        case ATNAH:
            inptext[SRP] [*line_no] [*col_no] = TRP_ATNAH;
            break;
        case TELISA_PAR:
            inptext[SRP] [*line_no] [*col_no] = TRP_TELISAPAR;
            break;
        case TELISA_MAG:
            inptext[SRP] [*line_no] [*col_no] = TRP_TELISAMAG;
            break;
        case SINNORIT:
            inptext[SRP] [*line_no] [*col_no] = TRP_SINNORIT;
            break;
        default:
            /* if term combination stay at present position */
            if ((inptext[OVR] [*line_no] [*col_no] == 0x00)  &&
               ((inptext[TXT] [*line_no] [*col_no] == KAPH  &&
                inpt == KAPH_TERM) || (inpt == MEM_TERM  &&
                inptext[TXT] [*line_no] [*col_no] == MEM) ||
                (inptext[TXT] [*line_no] [*col_no] == NUN  &&
                inpt == NUN_TERM) || (inpt == PE_TERM  &&
                inptext[TXT] [*line_no] [*col_no] == PE) ||
                (inptext[TXT] [*line_no] [*col_no] == SADHE  &&
                inpt == SADHE_TERM)))
                break;
            if (!toright  &&  shift != EXCLMSG)
                if (inptext[OVR] [*line_no] [*col_no] & OVR_TERM  &&
                  isalpha(inpt)  &&
                  !(*col_no == rowcol[nfield][LEFT_MAR]))
                    { /* terminal char inside of word */
                    dispmsg(posptr, PHEBCHR_MSG3);
                    return;
                    } /* end then */
                else if ((inpt == BLANK  ||
                  inpt == SOPH_PASUQ  ||  inpt == MAQQEPH)  &&
                 (inptext[TXT] [*line_no] [*col_no] == KAPH  ||
                  inptext[TXT] [*line_no] [*col_no] == MEM   ||
                  inptext[TXT] [*line_no] [*col_no] == NUN   ||
                  inptext[TXT] [*line_no] [*col_no] == PE    ||
                  inptext[TXT] [*line_no] [*col_no] == SADHE)  &&
                  !(inptext[OVR] [*line_no] [*col_no] & OVR_TERM)  &&
                  !(*col_no == rowcol[nfield][LEFT_MAR]))
                    { /* non terminal used at end of word */
                    dispmsg(posptr, PHEBCHR_MSG4);
                    return;
                    } /* end then, else */
            entfield(dirforw, toright, nfield, rowcol, line_no, col_no);
            if (shift & INS_LOCK)
                if ((f = inschar(posptr, toright, rowcol, *line_no,
                    *col_no, inptext)) < 0)
                    return;
            inptext[OVR] [*line_no] [*col_no] = 0x00;
            break;
        } /* end switch */
    } /* end then */
else
    {
    entfield(dirforw, toright, nfield, rowcol, line_no, col_no);
    if (shift & INS_LOCK)
        if ((f = inschar(posptr, toright, rowcol, *line_no, *col_no,
            inptext)) < 0)
            return;
    inptext[OVR] [*line_no] [*col_no] = 0x00;
    } /* end else */

if ((inptext[OVR] [*line_no] [*col_no] == 0x00)  &&
    !strchr(trope, inpt))
    switch(inpt)
        {
        case KAPH_TERM:
            inptext[TXT] [*line_no] [*col_no] = KAPH;
            inptext[OVR] [*line_no] [*col_no] |= OVR_TERM;
            break;
        case MEM_TERM:
            inptext[TXT] [*line_no] [*col_no] = MEM;
            inptext[OVR] [*line_no] [*col_no] |= OVR_TERM;
            break;
        case NUN_TERM:
            inptext[TXT] [*line_no] [*col_no] = NUN;
            inptext[OVR] [*line_no] [*col_no] |= OVR_TERM;
            break;
        case PE_TERM:
            inptext[TXT] [*line_no] [*col_no] = PE;
            inptext[OVR] [*line_no] [*col_no] |= OVR_TERM;
            break;
        case SADHE_TERM:
            inptext[TXT] [*line_no] [*col_no] = SADHE;
            inptext[OVR] [*line_no] [*col_no] |= OVR_TERM;
            break;
        default:
            inptext[TXT] [*line_no] [*col_no] = (char) inpt;
            break;
        } /* end switch */

inptext[SRP] [*line_no] [*col_no] = (char) (SRP_HEBREW  |
    (inptext[SRP] [*line_no] [*col_no] & TRP_MASK));

if (display)
    if (shift & INS_LOCK)
        {
        rdsplin(posptr, *line_no, rowcol[f] [LEFT_MAR],
            rowcol[f] [RIGHT_MAR], inptext);
        if (display == YESXGA)
            xga8514(posptr, *line_no, RDSPLIN);
        } /* end then */
    else
        {
        rdspheb(posptr, *line_no, *col_no, inptext);
        if (display == YESXGA)
            xga8514(posptr, *line_no, *col_no);
        } /* end else, then */


entfield(dirforw, toright, nfield, rowcol, line_no, col_no);

} /* end phebchr */
Exemple #5
0
/*** fDoReplace - called by fScan as file is scanned.
*
* Purpose:
*
* Input:
*
* Output:
*  Returns .....
*
* Exceptions:
*
* Notes:
*
*************************************************************************/
flagType
fDoReplace (
    void
    )
{
    int  c;
    char *p = pLog (scanreal, flScan.col, TRUE);

    if (fRplRePrev) {
	int rem;
	flagType fAgain = TRUE;

        do {
	    switch (rem = REMatch (patBuf, scanreal, p, REStack, MaxREStack, TRUE)) {
		case REM_NOMATCH:
		    flScan.col = scanlen;
		    return FALSE;

		case REM_STKOVR:
		    MaxREStack += 128;
                    REStack = (RE_OPCODE **)ZEROREALLOC ((char *)REStack, MaxREStack * sizeof(*REStack));
		    break;

		default:
		    printerror ("Internal Error: RE error %d, line %ld", rem, flScan.lin);

		case REM_MATCH:
		    fAgain = FALSE;
		    break;
            }
        } while (fAgain);

	c = colPhys (scanreal, REStart (patBuf));
	srchlen = RELength (patBuf, 0);
        if (c + srchlen - 1 > scanlen) {
            return FALSE;
        }
	flScan.col = c;
    } else {
        if ( (*(fSrchCasePrev ? strncmp : _strnicmp)) (srcbuf, p, srchlen)) {
            return FALSE;
        }
        if (flScan.col + srchlen - 1 > scanlen) {
            return FALSE;
        }
    }

    if (fQrpl) {
    ClearHiLite (pFileHead, TRUE);
    Display();
	cursorfl (flScan);
	HighLight (flScan.col, flScan.lin, flScan.col+srchlen-1, flScan.lin);
	Display ();
        c = askuser ('n', 'a', "Replace this occurrence? (Yes/No/All/Quit): ",
			  NULL);
	ClearHiLite (pFileHead, TRUE);
	redraw (pFileHead, flScan.lin, flScan.lin);
        RSETFLAG (fDisplay, RHIGH);

        switch (c) {

	case -1:
	case 'q':
	    fCtrlc = TRUE;
            return TRUE;

	case 'n':
            return FALSE;

	case 'a':
	    dispmsg(0); 		/* clear dialog line		*/
	    fQrpl = FALSE;
	    break;
        }
    }

    if (fRplRePrev) {
	patRpl ();
    } else {
        simpleRpl (p);
    }
    return FALSE;
}
Exemple #6
0
/*** mrepl1file - search/replace the contents of 1 file.
*
*  Searches through one file for stuff.
*
* Input:
*
* Output:
*  Returns .....
*
* Exceptions:
*
* Notes:
*
*************************************************************************/
void
mrepl1file (
    char   *szGrepFile,
    struct findType *pfbuf,
    void *dummy
    )
{
    flagType fDiscard;                      /* discard the file read?       */
    fl      flGrep;                         /* ptr to current grep loc      */
    int     cReplBefore;                    /* number of matches before     */
    PFILE   pFileGrep;                      /* file to be grepped           */

    assert (szGrepFile);
    assert (_pinschk(pInsCur));

    if (fCtrlc) {
        return;
    }

    /*
     * If we can get a handle to the file, then it's alread in the list, and we
     * should not discard it when done. If it is not in the list, we read it in,
     * but we'll discard it, unless something is found there.
     */
    if (!(pFileGrep = FileNameToHandle (szGrepFile, szGrepFile))) {
        pFileGrep = AddFile (szGrepFile);
        SETFLAG (FLAGS (pFileGrep), REFRESH);
        fDiscard = TRUE;
    } else {
        fDiscard = FALSE;
    }

    assert (_pinschk(pInsCur));

    /*
     * If the file needs to be physically read, do so.
     */
    if ((FLAGS (pFileGrep) & (REFRESH | REAL)) != REAL) {
        FileRead (pFileGrep->pName, pFileGrep, FALSE);
        RSETFLAG (FLAGS(pFileGrep), REFRESH);
    }

    dispmsg (MSG_SCANFILE, szGrepFile);
    pFileToTop (pFileGrep);

    /*
     * run through the file, searching and replacing as we go.
     */
    cReplBefore = cRepl;
    setAllScan (FALSE);
    flGrep.col = rnScan.flFirst.col-1;
    flGrep.lin = rnScan.flFirst.lin;
    fScan (flGrep, fDoReplace, TRUE, FALSE);
    /*
     * If the search was not successfull, discard the file, if needed, and move
     * to the next.
     */
    if (cReplBefore == cRepl) {
        if (fDiscard) {
            RemoveFile (pFileGrep);
        }
    } else {
        AutoSaveFile (pFileGrep);
    }

    assert (_pinschk(pInsCur));

    pfbuf; dummy;

}
Exemple #7
0
/*** doreplace - perform search-replace
*
*  Performs the actual search and replace argument verification, set up and
*  high level control.
*
* Input:
*  fQuery	= TRUE if a query replace
*  pArg 	= pArg of parent function
*  fMeta	= fMeta of parent function
*  fFiles	= TRUE is multiple file search and replace.
*
* Output:
*  Returns .....
*
* Exceptions:
*
* Notes:
*
*************************************************************************/
flagType
doreplace (
    flagType fQuery,
    ARG * pArg,
    flagType fMeta,
    flagType fFiles
    )
{
    buffer  bufFn;                          /* filename buffer              */
    fl      flStart;
    char    *p;
    PCMD    pCmd;
    PFILE   pFileSave;                      /* file to save as top of heap  */

    p = "Query Search string: ";
    if (!fQuery) {
        p += 6;
    }

    fQrpl = fQuery;
    fSrchCasePrev = fMeta ? (flagType)!fSrchCaseSwit : fSrchCaseSwit;
    Display ();
    cRepl = 0;

    /*
     * If not menu-driven, ask the user for a search string. If none is entered,
     * we're done.
     */
    if ((pCmd = getstring (srcbuf, sizeof(srcbuf), p, NULL, GS_NEWLINE | GS_INITIAL)) == NULL || (PVOID)pCmd->func == (PVOID)cancel) {
        return FALSE;
    }

    if (srcbuf[0] == '\0') {
        return FALSE;
    }

    /*
     * If RE search to take place, the compile the expression.
     */
    if (pArg->arg.nullarg.cArg == 2) {
	if (patBuf != NULL) {
            FREE ((char *) patBuf);
	    patBuf = NULL;
        }
	patBuf = RECompile (srcbuf, fSrchCaseSwit, (flagType)!fUnixRE);
	if (patBuf == NULL) {
	    printerror ((RESize == -1) ?
			"Invalid pattern" :
			"Not enough memory for pattern");
	    return FALSE;
        }
	fRplRePrev = TRUE;
    } else {
        fRplRePrev = FALSE;
    }

    /*
     * If not menu driven, ask the user for a replacement string. Confirm the
     * entry of a null string. Error check the replacement if an RE search.
     */
    if ((pCmd = getstring (rplbuf, sizeof(rplbuf), "Replace string: ", NULL, GS_NEWLINE | GS_INITIAL)) == NULL ||
        (PVOID)pCmd->func == (PVOID)cancel) {
        return FALSE;
    }

    if (rplbuf[0] == 0) {
        if (!confirm ("Empty replacement string, confirm: ", NULL)) {
            return FALSE;
        }
    }

    if (fRplRePrev && !RETranslate (patBuf, rplbuf, scanreal)) {
	printerror ("Invalid replacement pattern");
	return FALSE;
    }

    srchlen = strlen (srcbuf);

    switch (pArg->argType) {

    case NOARG:
    case NULLARG:
	setAllScan (TRUE);
        break;

    case LINEARG:
	rnScan.flFirst.col = 0;
        rnScan.flLast.col  = sizeof(linebuf)-1;
	rnScan.flFirst.lin = pArg->arg.linearg.yStart;
        rnScan.flLast.lin  = pArg->arg.linearg.yEnd;
        break;

    case BOXARG:
	rnScan.flFirst.col = pArg->arg.boxarg.xLeft;
        rnScan.flLast.col  = pArg->arg.boxarg.xRight;
	rnScan.flFirst.lin = pArg->arg.boxarg.yTop;
        rnScan.flLast.lin  = pArg->arg.boxarg.yBottom;
        break;

    case STREAMARG:
	if (pArg->arg.streamarg.yStart == pArg->arg.streamarg.yEnd) {
	    rnScan.flFirst.col = pArg->arg.streamarg.xStart;
            rnScan.flLast.col  = pArg->arg.streamarg.xEnd;
	    rnScan.flFirst.lin = pArg->arg.streamarg.yStart;
            rnScan.flLast.lin  = pArg->arg.streamarg.yEnd;
        } else {
	    rnScan.flFirst.col = 0;   /* Do all but last line first */
            rnScan.flLast.col  = sizeof(linebuf)-1;
	    rnScan.flFirst.lin = pArg->arg.streamarg.yStart;
            rnScan.flLast.lin  = pArg->arg.streamarg.yEnd - 1;
	    flStart.col = pArg->arg.streamarg.xStart - 1;
	    flStart.lin = rnScan.flFirst.lin;
	    fScan (flStart, fDoReplace , TRUE, fSrchWrapSwit);

            rnScan.flLast.col   = pArg->arg.streamarg.xEnd;
	    rnScan.flFirst.lin	= ++rnScan.flLast.lin;
        }
    }

    flStart.col = rnScan.flFirst.col-1;
    flStart.lin = rnScan.flFirst.lin;
    if (fRplRePrev) {
	MaxREStack = 512;
        REStack = (RE_OPCODE **)ZEROMALLOC (MaxREStack * sizeof(*REStack));
    }

    if (fFiles) {
        /*
         * Get the list handle, and initialize to start at the head of the list.
         * Attempt to read each file.
         */
	if (pCmd = GetListHandle ("mgreplist", TRUE)) {
	    pFileSave = pFileHead;
	    p = ScanList (pCmd, TRUE);
	    while (p) {
		CanonFilename (p, bufFn);
		forfile (bufFn, A_ALL, mrepl1file, &p);
		p = ScanList (NULL, TRUE);
                if (fCtrlc) {
                    return FALSE;
                }
            }
	    pFileToTop (pFileSave);
            dispmsg (0);
        }
    } else {
        fScan (flStart, fDoReplace , TRUE, fSrchWrapSwit);
    }

    if (fRplRePrev) {
        FREE (REStack);
    }
    domessage ("%d occurrences replaced", cRepl);
    return (flagType)(cRepl != 0);
}
Exemple #8
0
void  panlcmd(
              union both_scr  *posptr,
              int  *line_no,
              int  *col_no,
              unsigned int  *panel,
              int  *nfield,
              int  **rowcol,
              char  inptext[] [25] [80],
              char  dsn[56],
              int  maxlrecl,
              unsigned int  cmd[],
              int  *coloffset,
              struct bufline  **first,
              struct bufline  **curr,
              int  wherest[25],
              int  wherend[25],
              int  *dschanged,
              struct lineptrs  *place,
              int  rightmar)
/**********************************************************************/
/*                                                                    */
/* Execute panel commands.                                            */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
FILE  *ds;
unsigned int  pcmd;
char  selfor[8];

/* cmd subscript */
register int  c;


/* turn off cmd grouping */
pcmd = cmd[0] & WHCHPAN;

if (pcmd & PRIMARY)
    {
    *panel = PRIMARY;
    primary(posptr, line_no, col_no, nfield, rowcol, inptext);
    } /* end then */
else if (pcmd & DSENTRY)
    {
    *panel = DSENTRY;
    switch(cmd[3])
        {
        case SEL_BROWPAN:
            strcpy(selfor, "BROWSE");
            break;
        case SEL_EDITPAN:
            strcpy(selfor, "EDIT");
            break;
        case SEL_COPYDSN:
            strcpy(selfor, "COPY");
            break;
        case IGRKPRC:
            strcpy(selfor, "IMPGRK");
            break;
        case IHEBPRC:
            strcpy(selfor, "IMPHEB");
            break;
        case EGRKPRC:
            strcpy(selfor, "EXPGRK");
            break;
        case EHEBPRC:
            strcpy(selfor, "EXPHEB");
            break;
        case EHHIPRC:
            strcpy(selfor, "EXPHHI");
            break;
        } /* end switch */
    dsentry(posptr, line_no, col_no, nfield, rowcol, inptext, selfor);
    } /* end then */
else if (pcmd & BROWPAN)
    {
    ds = fopen(dsn, OLD_INPUT);
    if (ds)
        {
        *first = readbuf(posptr, ds, maxlrecl);
        *curr = *first;
        fclose(ds);
        *panel = BROWPAN;
        browpan(posptr, line_no, col_no, nfield, rowcol, inptext,
            dsn, rightmar);
        *coloffset = 0;
        buftscr(posptr, *nfield, (int (*)[5]) *rowcol, inptext, *curr,
            maxlrecl, *coloffset, wherest, wherend, place, YES);
        } /* end then */
    else
        {
        /* clean off the stack */
        for (c = 2; c < STACKMAX; ++c)
            cmd[c] = NOP;
        cmd[1] = BROWSE;
        dispmsg(posptr, PANLCMD_MSG1);
        } /* end else */
    } /* end then */
else if (pcmd & EDITPAN)
    {
    ds = fopen(dsn, MOD_INOUT);
#ifdef S370
    if (ds)
        ds = fopen(dsn, OLD_INPUT);
#endif
    if (ds)
        {
        *dschanged = NO;
        fseek(ds, 0L, SEEK_SET);
        *first = readbuf(posptr, ds, maxlrecl);
        *curr = *first;
        fclose(ds);
        *panel = EDITPAN;
        editpan(posptr, line_no, col_no, nfield, rowcol, inptext,
            dsn, rightmar);
        *coloffset = 0;
        buftscr(posptr, *nfield, (int (*)[5]) *rowcol, inptext, *curr,
            maxlrecl, *coloffset, wherest, wherend, place, NO);
        } /* end then */
    else
        {
        /* clean off the stack */
        for (c = 2; c < STACKMAX; ++c)
            cmd[c] = NOP;
        cmd[1] = EDIT;
        dispmsg(posptr, PANLCMD_MSG2);
        } /* end else */
    } /* end then */
else if (pcmd & CFGKPAN)
    {
    *panel = CFGKPAN;
    cfgkpan(posptr, line_no, col_no, nfield, rowcol, inptext);
    } /* end then */
else if (pcmd & CFGFPAN)
    {
    *panel = CFGFPAN;
    cfgfpan(posptr, line_no, col_no, nfield, rowcol, inptext);
    } /* end then */

} /* end panlcmd */
Exemple #9
0
int  cfgkget(
              union both_scr  *posptr,
              int  rowcol[] [5],
              char  inptext[] [25] [80])
/**********************************************************************/
/*                                                                    */
/* Process the config keyboard panel.                                 */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
extern char  grkexch[256];
extern char  hebexch[256];

register int  i;
register int  r;
char  grkhold[128];
char  hebhold[128];
char  work[3];


/* Greek character set */
grkhold[127] = '\0';

for (i = 0;  i < 32;  ++i)
    grkhold[i] = ' ';

for (r = 1;  i < 127;  ++i, ++r)
    {
    convout(0, &inptext[TXT] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        &inptext[SRP] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        &inptext[OVR] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        BUF_GREEK, work, 0, "");
    grkhold[i] = work[strlen(work) - 1];
    } /* end for */

for (i = 32; i < 127; ++i)
    if (strchr(&grkhold[i+1], grkhold[i]))
       {
       dispmsg(posptr, CFGKGET_MSG1);
       return(YES);
       } /* end then */


/* Hebrew character set */
hebhold[127] = '\0';

for (i = 0;  i < 32;  ++i)
    hebhold[i] = ' ';

for ( ;  i < 127;  ++i, ++r)
    {
    convout(0, &inptext[TXT] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        &inptext[SRP] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        &inptext[OVR] [rowcol[r][TOP_MAR]] [rowcol[r][LEFT_MAR]],
        BUF_HEBREW, work, 0, "");
    hebhold[i] = work[strlen(work) - 1];
    } /* end for */

for (i = 32; i < 127; ++i)
    if (strchr(&hebhold[i+1], hebhold[i]))
       {
       dispmsg(posptr, CFGKGET_MSG2);
       return(YES);
       } /* end then */


/* both character sets verified */
strcpy(grkexch, grkhold);
strcpy(hebexch, hebhold);
return(NO);

} /* end cfgkget */
Exemple #10
0
int32_t main(int32_t argc, char** argv) {
  FILE* infile = NULL;
  char* outname = NULL;
  uintptr_t column_sep = 2;
  uint32_t flags = 0;
  int32_t retval = 0;
  uintptr_t* col_widths = NULL;
  unsigned char* spacebuf = NULL;
  unsigned char* rjustify_buf = NULL;
  uintptr_t col_ct = 0;
  uint32_t infile_param_idx = 0;
  char* param_ptr;
#ifndef _WIN32
  char* cptr;
#endif
  uint32_t param_idx;
  uint32_t uii;
  int32_t ii;
  char cc;
  if (argc == 1) {
    goto main_ret_HELP;
  }
  for (param_idx = 1; param_idx < (uint32_t)argc; param_idx++) {
    if ((!strcmp(argv[param_idx], "--help")) || (!strcmp(argv[param_idx], "-help")) || (!strcmp(argv[param_idx], "-?")) || (!strcmp(argv[param_idx], "-h"))) {
      goto main_ret_HELP;
    }
  }

  if (argc > 10) {
    fputs("Error: Too many parameters.\n\n", stderr);
    goto main_ret_INVALID_CMDLINE_2;
  }
  for (param_idx = 1; param_idx < (uint32_t)argc; param_idx++) {
    if (argv[param_idx][0] != '-') {
      if (!infile_param_idx) {
	infile_param_idx = param_idx;
      } else if (!outname) {
	if (flags & FLAG_INPLACE) {
	  goto main_ret_INVALID_CMDLINE_3;
	}
        outname = argv[param_idx];
      } else {
	fputs("Error: Invalid parameter sequence.\n\n", stderr);
	goto main_ret_INVALID_CMDLINE_2;
      }
      continue;
    }
    param_ptr = &(argv[param_idx][1]);
    if (*param_ptr == '-') {
      // allow both single- and double-dash
      param_ptr++;
    }
    if (!strcmp(param_ptr, "inplace")) {
      if (outname) {
	goto main_ret_INVALID_CMDLINE_3;
      }
      flags |= FLAG_INPLACE;
    } else if ((!strcmp(param_ptr, "spacing")) || (!strcmp(param_ptr, "s"))) {
      if (++param_idx == (uint32_t)argc) {
	fputs("Error: Missing --spacing parameter.\n", stderr);
	goto main_ret_INVALID_CMDLINE;
      }
      ii = atoi(argv[param_idx]);
      if (ii < 1) {
	fprintf(stderr, "Error: Invalid --spacing parameter '%s'.\n", argv[param_idx]);
	goto main_ret_INVALID_CMDLINE;
      }
      column_sep = (uint32_t)ii;
    } else if (!strcmp(param_ptr, "ralign")) {
      flags |= FLAG_RJUSTIFY;
    } else if (!strcmp(param_ptr, "leading")) {
      flags |= FLAG_SPACES_BEFORE_FIRST;
    } else if (!strcmp(param_ptr, "extend-short")) {
      flags |= FLAG_PAD;
    } else if (!strcmp(param_ptr, "trailing")) {
      flags |= FLAG_SPACES_AFTER_LAST;
    } else if (!strcmp(param_ptr, "force-eoln")) {
      flags |= FLAG_FINAL_EOLN;
    } else if (!strcmp(param_ptr, "noblank")) {
      flags |= FLAG_STRIP_BLANK;
    } else {
      if ((argv[param_idx][1] != '-') && argv[param_idx][1]) {
	// permit abbreviated style
	while (1) {
	  cc = *param_ptr++;
	  if (!cc) {
	    break;
	  }
	  switch (cc) {
	  case 'i':
	    if (outname) {
	      goto main_ret_INVALID_CMDLINE_3;
	    }
	    flags |= FLAG_INPLACE;
	    break;
	  case 'r':
	    flags |= FLAG_RJUSTIFY;
	    break;
	  case 'l':
	    flags |= FLAG_SPACES_BEFORE_FIRST;
	    break;
	  case 'e':
	    flags |= FLAG_PAD;
	    break;
	  case 't':
	    flags |= FLAG_SPACES_AFTER_LAST;
	    break;
	  case 'f':
	    flags |= FLAG_FINAL_EOLN;
	    break;
	  case 'n':
	    flags |= FLAG_STRIP_BLANK;
	    break;
	  default:
            fprintf(stderr, "Error: Invalid flag '%s'.\n\n", argv[param_idx]);
	    goto main_ret_INVALID_CMDLINE_2;
	  }
	}
      } else {
	fprintf(stderr, "Error: Invalid flag '%s'.\n\n", argv[param_idx]);
	goto main_ret_INVALID_CMDLINE_2;
      }
    }
  }
  if (!infile_param_idx) {
    fputs("Error: No input filename.\n\n", stderr);
    goto main_ret_INVALID_CMDLINE_2;
  }
  if (flags & FLAG_INPLACE) {
    uii = strlen(argv[infile_param_idx]);
    outname = (char*)malloc(uii + 11);
    if (!outname) {
      goto main_ret_NOMEM;
    }
    memcpy(outname, argv[infile_param_idx], uii);
    memcpy(&(outname[uii]), "-temporary", 11);
  } else if (outname) {
#ifdef _WIN32
    uii = GetFullPathName(argv[infile_param_idx], FNAMESIZE, pathbuf, NULL);
    if ((!uii) || (uii > FNAMESIZE))
#else
    if (!realpath(argv[infile_param_idx], pathbuf))
#endif
    {
      fprintf(stderr, "Error: Failed to open %s.\n", argv[infile_param_idx]);
      goto main_ret_OPEN_FAIL;
    }
#ifdef _WIN32
    uii = GetFullPathName(outname, FNAMESIZE, &(pathbuf[FNAMESIZE + 64]), NULL);
    if (uii && (uii <= FNAMESIZE) && (!strcmp(pathbuf, &(pathbuf[FNAMESIZE + 64]))))
#else
    cptr = realpath(outname, &(pathbuf[FNAMESIZE + 64]));
    if (cptr && (!strcmp(pathbuf, &(pathbuf[FNAMESIZE + 64]))))
#endif
    {
      fputs("Error: Input and output files match.  Use --inplace instead.\n", stderr);
      goto main_ret_INVALID_CMDLINE;
    }
  }
  if (fopen_checked(&infile, argv[infile_param_idx], "rb")) {
    goto main_ret_OPEN_FAIL;
  }
  retval = scan_column_widths(infile, column_sep, &col_widths, &col_ct, &spacebuf, (flags & FLAG_RJUSTIFY)? (&rjustify_buf) : NULL);
  if (retval) {
    goto main_ret_1;
  }
  retval = pretty_write(infile, outname, flags, column_sep, col_widths, col_ct, spacebuf, rjustify_buf);
  if (retval) {
    goto main_ret_1;
  }
  fclose_null(&infile);
  if (flags & FLAG_INPLACE) {
    unlink(argv[infile_param_idx]);
    if (rename(outname, argv[infile_param_idx])) {
      fprintf(stderr, "Error: File rename failed.  Output is in %s instead of %s.\n", outname, argv[infile_param_idx]);
      goto main_ret_OPEN_FAIL;
    }
  }
  while (0) {
  main_ret_HELP:
    fputs(
"prettify v1.04 (21 Feb 2014)   Christopher Chang ([email protected])\n\n"
"Takes a tab-and/or-space-delimited text table, and generates a space-delimited\n"
"pretty-printed version.  Multibyte character encodings are not currently\n"
"supported.\n\n"
, stdout);
    disp_usage(stdout);
    fputs(
"\nTo perform the simplest reverse conversion (multiple spaces to one tab), you\n"
"can use\n"
"  cat [input filename] | tr -s ' ' '\\t' > [output filename]\n"
"For one-to-one conversion between spaces and tabs instead, omit the \"-s\".  And\n"
"to strip leading and trailing tabs and spaces, try\n"
"  cat [in] | sed 's/^[[:space:]]*//g' | sed 's/[[:space:]]*$//g' > [out]\n"
, stdout);
    retval = RET_HELP;
    break;
  main_ret_NOMEM:
    retval = RET_NOMEM;
    break;
  main_ret_OPEN_FAIL:
    retval = RET_OPEN_FAIL;
    break;
  main_ret_INVALID_CMDLINE_3:
    fputs("Error: --inplace cannot be used with an output filename.\n", stderr);
    retval = RET_INVALID_CMDLINE;
    break;
  main_ret_INVALID_CMDLINE_2:
    disp_usage(stderr);
  main_ret_INVALID_CMDLINE:
    retval = RET_INVALID_CMDLINE;
    break;
  }
 main_ret_1:
  free_cond(col_widths);
  fclose_cond(infile);
  dispmsg(retval);
  return retval;
}
Exemple #11
0
/*** DoPrint - Does the printing
*
*   If a <printcmd> has been defined
*	queue up the job for the <print> thread (synchronous exec under DOS)
*   else
*	send the file to the printer, each line at a time
*
*   Input:
*	pFile = File to be printed.
*
*   Output:
*	Returns True if the printing has been succesful, False otherwise
*
*************************************************************************/
flagType
DoPrint (
    PFILE    pFile,
    flagType fDelete
    )
{
    assert (pFile);

    if (pPrintCmd) {
	buffer	 pCmdBuf;		// Buffer for command construction

        if (TESTFLAG (FLAGS (pFile), DIRTY) && confirmx ("File %s is dirty, do you want to save it ?", pFile->pName))
            FileWrite (pFile->pName, pFile);

	sprintf (pCmdBuf, pPrintCmd, pFile->pName);


	if (pBTDPrint->cBTQ > MAXBTQ-2)
	    disperr (MSGERR_PRTFULL);
	else
	if (BTAdd (pBTDPrint, (PFUNCTION)NULL, pCmdBuf) &&
	    (!fDelete || BTAdd (pBTDPrint, (PFUNCTION)CleanPrint, pFile->pName)))
            return TRUE;
	else
            disperr (MSGERR_PRTCANT);

	if (fDelete)
            _unlink (pFile->pName);

	return FALSE;
    }
    else {
        static char   szPrn[] = "PRN";
	flagType      fOK = TRUE;	//  Holds the return value
	LINE	      lCur;		//  Number of line we're printing
	char	      pLineBuf[sizeof(linebuf)+1];
					//  Holds the line we're printing
	unsigned int  cLen;		//  Length of line we're printing
	EDITOR_KEY    Key;		//  User input (for abortion)
	int	      hPrn;		//  PRN file handle

	dispmsg (MSG_PRINTING,pFile->pName);

	if ((hPrn = _open (szPrn, O_WRONLY)) == -1) {
	    disperr (MSGERR_OPEN, szPrn, error());
	    fOK = FALSE;
	}
	else {
	    for (lCur = 0; lCur < pFile->cLines; lCur++) {
		if (TypeAhead () &&
		    (Key = TranslateKey(ReadChar()), (Key.KeyCode == 0x130)) &&
		    (!Key.KeyInfo.KeyData.Flags)) {

		    fOK = FALSE;
		    break;
                }
		cLen = GetLine (lCur, pLineBuf, pFile);
//		* (int UNALIGNED *) (pLineBuf + cLen++) = '\n';
		* (pLineBuf + cLen++) = '\n';
		if (_write (hPrn, pLineBuf, cLen) == -1) {
		    disperr (MSGERR_PRTCANT);
		    fOK = FALSE;
		    break;
                }
            }
	    _close (hPrn);
        }
	domessage (NULL);

        if (fDelete) {
            _unlink (pFile->pName);
        }
	return fOK;
    }
}
Exemple #12
0
void  chngprm(
              union both_scr  *posptr,
              int  maxlrecl,
              char  pat[],
              char  prm2[],
              int  map[],
              int  onscr,
              register struct bufline  *ptr,
              int  *dschanged)
/**********************************************************************/
/*                                                                    */
/* Change the string value of prm1 to prm2.                           */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
register int  b;
register int  e;
register int  j;
int  cnt;
int  lenprm1;
int  lenprm2;


*dschanged = YES;

/* find the beginning location of prm1, b, in bline */
for (b = 0; map[b] != onscr; ++b)
    {;}; /* end for */

/* compute onscr for the ending character of pat */
onscr = onscr + strlen(pat) - 1;

/* find the ending location, e, of prm1 in bline */
for (e = b; map[e] != onscr; ++e)
    {;}; /* end for */

lenprm1 = e - b + 1;
lenprm2 = strlen(prm2);

if (lenprm2 < lenprm1)
    {
    for (j = 0; b <= e; ++b)
        if (prm2[j])
            {
            ptr -> bline[b] = prm2[j];
            ++j;
            } /* end then */
        else
            ptr -> bline[b] = ' ';

    /* scan existing blanks */
    for (++e; ptr -> bline[e] == ' '; ++e)
        {;}; /* end for */

    /* remove just the difference in the parms */
    e -= (lenprm1 - lenprm2);
    leftjust(&(ptr -> bline[e]));
    } /* end then */
else
    {
    cnt = lenprm2 - lenprm1;
    if (cnt)
    /* ie. lenprm2 > lenprm1 */
        {
        /* shift right end of bline for a count of cnt */
        j = strlen(ptr -> bline) + cnt;

        if (j >= maxlrecl)
            {
            dispmsg(posptr, CHNGPRM_MSG1);
            return;
            } /* end then */

        ptr -> bline[j--] = '\0';

        for ( ; j > e + cnt; --j)
            ptr -> bline[j] = ptr -> bline[j - cnt];
        } /* end then */

    /* lenprm1 (is now) == lenprm2 */
    for (j = 0; prm2[j]; ++j, ++b)
        ptr -> bline[b] = prm2[j];
    } /* end else */

/* prm2 could have introduced a new PRECDR-charset */
srpbufr(posptr, maxlrecl, ptr -> next);

} /* end chngprm */
Exemple #13
0
struct bufline  *scrlcmd(
              union both_scr  *posptr,
              unsigned int  panel,
              int  nfield,
              int  rowcol[][5],
              char  inptext[] [25] [80],
              int  amount,
              int  maxlrecl,
              unsigned int  cmd[],
              int  *coloffset,
              struct bufline  *first,
              register struct bufline  *curr,
              int  wherest[25],
              int  wherend[25],
              int  *dschanged,
              register struct lineptrs  *place)
/**********************************************************************/
/*                                                                    */
/* Execute scroll commands.                                           */
/*                                                                    */
/**********************************************************************/
/*                                                                    */
/* This is ZEDIT source material.                                     */
/*                                                                    */
/* ZEDIT Source Materials are intellectual property                   */
/*     (c) Copyright 1987,2001 by Clyde Thomas Zuber.                 */
/*                                                                    */
/**********************************************************************/
{
register int  r;


if (!(panel & EDBRPAN))
    {
    dispmsg(posptr, SCRLCMD_MSG1);
    return(curr);
    } /* end then */

scrtbuf(posptr, nfield, rowcol, inptext, curr, maxlrecl, wherest,
    wherend, dschanged);

/* process cmd either outstanding or from input */
switch(cmd[0])
    {
    case DOWN:
        if (amount < 0)
            for (r = 1; ; ++r)
                {
                if (!(curr -> next))
                    break;
                curr = curr -> next;
                } /* end for */
        else
            for (r = 1; r <= amount; ++r)
                {
                if (!(curr -> next))
                    break;
                curr = curr -> next;
                } /* end for */
        if (!(curr -> next))
            for (r = 1; r <= 12; ++ r)
                {
                if (!(curr -> prev))
                    break;
                curr = curr -> prev;
                } /* end for */
        break;
    case UP:
        if (amount < 0)
            curr = first;
        else
            for (r = 1; r <= amount; ++r)
                {
                if (!(curr -> prev))
                    break;
                curr = curr -> prev;
                } /* end for */
        break;
    case LEFT:
        if (amount < 0)
            *coloffset = 0;
        else
            {
            *coloffset -= amount;
            if (*coloffset < 0)
                *coloffset = 0;
            } /* end else */
        break;
    case RIGHT:
        *coloffset += amount;
        if ((*coloffset > (maxlrecl - (rowcol[nfield] [RIGHT_MAR]
            - rowcol[nfield] [LEFT_MAR] + 3))) || (amount < 0))
            *coloffset = maxlrecl - (rowcol[nfield] [RIGHT_MAR] -
                rowcol[nfield] [LEFT_MAR] + 3);
        break;
    case LOCATE:
        for (curr = first;
            curr  &&  atoi(curr -> lineno) != amount;
            curr = curr -> next)
            {;}; /* end for */
        if (!curr)
            {
            curr = first;
            dispmsg(posptr, SCRLCMD_MSG2);
            } /* end then */
        break;
    case COLMS:
        curr = colslin(posptr, maxlrecl, curr, place);
        break;
    case LETS:
        curr = letslin(posptr, maxlrecl, curr, place);
        break;
    case KEYS:
        curr = keyslin(posptr, curr, place);
        break;
    } /* end switch */

buftscr(posptr, nfield, rowcol, inptext, curr, maxlrecl, *coloffset,
    wherest, wherend, place, YES);

return(curr);

} /* end scrlcmd */