Example #1
0
File: fileio.c Project: aksr/esnc
/*
 * Read a line from a file, and store the bytes in the supplied buffer. The
 * "nbuf" is the length of the buffer. Complain about long lines and lines at
 * the end of the file that don't have a newline present. Check for I/O errors
 * too. Return status.
 */
int ffgetline (char buf[], int nbuf)
{
  int c, i;

  i = 0;

  while ((c = fgetc (ffp)) != EOF && c != '\n')
    {
      if (i >= nbuf - 2)
	{
	  buf[nbuf - 2] = c;	   /* store last char read */
	  buf[nbuf - 1] = 0;	   /* and terminate it */
	  mlwrite ("File has long line");
	  return (FIOLNG);
	}
      buf[i++] = c;
    }

  if (c == EOF)
    {
      if (ferror (ffp))
	{
	  mlwrite ("File read error");
	  return (FIOERR);
	}
      if (i != 0)
	{
	  mlwrite ("File has funny line at EOF");
	  return (FIOERR);
	}
      return (FIOEOF);
    }
  buf[i] = 0;
  return (FIOSUC);
}
Example #2
0
/*
 * Save the contents of the current
 * buffer in its associatd file. No nothing
 * if nothing has changed (this may be a bug, not a
 * feature). Error if there is no remembered file
 * name for the buffer. Bound to "C-X C-S". May
 * get called by "C-Z".
 */
int filesave(int f, int n)
{
	struct window *wp;
	int s;

	if (curbp->b_mode & MDVIEW)	/* don't allow this command if      */
		return rdonly();	/* we are in read only mode     */
	if ((curbp->b_flag & BFCHG) == 0)	/* Return, no changes.  */
		return TRUE;
	if (curbp->b_fname[0] == 0) {	/* Must have a name.    */
		mlwrite("No file name");
		return FALSE;
	}

	/* complain about truncated files */
	if ((curbp->b_flag & BFTRUNC) != 0) {
		if (mlyesno("Truncated file ... write it out") == FALSE) {
			mlwrite("(Aborted)");
			return FALSE;
		}
	}

	if ((s = writeout(curbp->b_fname)) == TRUE) {
		curbp->b_flag &= ~BFCHG;
		wp = wheadp;	/* Update mode lines.   */
		while (wp != NULL) {
			if (wp->w_bufp == curbp)
				wp->w_flag |= WFMODE;
			wp = wp->w_wndp;
		}
	}
	return s;
}
Example #3
0
/*
 * findRegistry
 * Find a key in the registry by indexing
 */
int
findRegistry (int f, int n)
{
    meUByte rootbuf [meBUF_SIZE_MAX];
    meUByte valbuf [12];
    int index;
    meRegNode *rnp ;

    /* Get the arguments */
    if((meGetString((meUByte *)"Registry Path", 0, 0, rootbuf, meBUF_SIZE_MAX) == meABORT) ||
       (meGetString((meUByte *)"Index", 0, 0, valbuf, 12) == meABORT))
        return meABORT;
    index = meAtoi (valbuf);

    /* Assigns the new value */
    if((rnp = regFind (&root, rootbuf)) == NULL)
        return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",rootbuf);
    /* Find the node that is indexed */
    f = index ;
    rnp = rnp->child;
    while((--index >= 0) && rnp)
        rnp = rnp->next;
    if(rnp == NULL)
    {
        resultStr [0] ='\0';
        return mlwrite (MWCLEXEC|MWABORT,(meUByte *)"Cannot find node at index %d", f);
    }
    meStrncpy(resultStr, rnp->name, meBUF_SIZE_MAX-1);
    resultStr[meBUF_SIZE_MAX-1] = '\0';
    return meTRUE;
}
Example #4
0
int forwhunt (int f, int n)
{
  int status=FALSE;

  /* resolve the repeat count */
  if (n == 0)
    n = 1;
  if (n < 1)			/* search backwards */
    return (backhunt (f, -n));

  /* Make sure a pattern exists */
  if (pat[0] == 0)
    {
      mlwrite ("No pattern set");
      return (FALSE);
    }
  /* search for the pattern */
  while (n-- > 0)
    {
      if ((status = forscan (&pat[0], PTEND)) == FALSE)
	break;
    }

  /* and complain if not there */
  if (status == FALSE)
    mlwrite ("Not found");
  return (status);
}
Example #5
0
/*
 * This function performs the details of file writing. Uses the file
 * management routines in the "fileio.c" package. The number of lines written
 * is displayed. Sadly, it looks inside a LINE; provide a macro for this. Most
 * of the grief is error checking of some sort.
 */
int writeout(char *fn)
{
  LINE *lp;
  int nline, s;

  if ((s = ffwopen(fn)) != FIOSUC) /* Open writes message */
    return (FALSE);
  mlwrite("[Writing]");		/* tell us were writing */
  lp = lforw(curbp->b_linep);	/* First line */
  nline = 0;			/* Number of lines */
  while (lp != curbp->b_linep)
    {
      if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC)
	break;
      ++nline;
      lp = lforw(lp);
    }
  if (s == FIOSUC)
    {				/* No write error */
      s = ffclose();
      if (s == FIOSUC)
	{			/* No close error */
	  if (nline != 1)
	    mlwrite("[Wrote %d lines]", nline);
	  else
	    mlwrite("[Wrote 1 line]");
	}
    }
  else				/* ignore close error */
    ffclose();			/* if a write error */
  if (s != FIOSUC)		/* some sort of error */
    return (FALSE);
  return (TRUE);
}
Example #6
0
PASCAL NEAR delfold(f, n)
{
	BUFFER *bp;		 /* buffer having fold deleted */
	WINDOW *wp;		 /* windows to fix up pointers in as well */
	LINE   *lp;		 /* lines being deleted */

	/* find the proper buffer */
	bp = curwp->w_bufp;		

	if (curwp->w_dotp->l_type == LSOFOLD) {

		/* set all line types to normal */
		lp = curwp->w_dotp;
		while (lp != curwp->w_dotp->l_foldp->l_fp) {
			lp->l_type = LNORMAL; 
			lp = lp->l_fp;
		}
		curwp->w_doto = 0;
		curwp->w_markp[0] = curwp->w_dotp->l_foldp->l_fp;
		curwp->w_marko[0] = 0;
		killregion(FALSE, 0);
		mlwrite(TEXT229);
		/* "[Fold Deleted]" */
		return(TRUE);
	}
	else {
		mlwrite(TEXT225);
		/* "%% Not a fold line" */
		return(FALSE);
	}
}
Example #7
0
int getfile(char fname[])
{
  BUFFER *bp;
  LINE *lp;
  char bname[NBUFN];		/* buffer name to put file */
  int i, s;

  for (bp = bheadp; bp != (BUFFER*)0; bp = bp->b_bufp)
    {
      if ((bp->b_flag & BFTEMP) == 0 && strcmp(bp->b_fname, fname) == 0)
	{
	  if (--curbp->b_nwnd == 0)
	    {
	      curbp->b_dotp = curwp->w_dotp;
	      curbp->b_doto = curwp->w_doto;
	      curbp->b_markp = curwp->w_markp;
	      curbp->b_marko = curwp->w_marko;
	    }
	  swbuffer(bp);
	  lp = curwp->w_dotp;
	  i = curwp->w_ntrows / 2;
	  while (i-- && lback(lp) != curbp->b_linep)
	    lp = lback(lp);
	  curwp->w_linep = lp;
	  curwp->w_flag |= WFMODE | WFHARD;
	  mlwrite("[Old buffer]");
	  return (TRUE);
	}
    }
  makename(bname, fname);	/* New buffer name */
  while ((bp = bfind(bname, FALSE, 0)) != (BUFFER*)0)
    {
      s = mlreply("Buffer name: ", bname, NBUFN);
      if (s == ABORT)		/* ^G to just quit */
	return (s);
      if (s == FALSE)
	{			/* CR to clobber it */
	  makename(bname, fname);
	  break;
	}
    }
  if (bp == (BUFFER*)0 && (bp = bfind(bname, TRUE, 0)) == (BUFFER*)0)
    {
      mlwrite("Cannot create buffer");
      return (FALSE);
    }
  if (--curbp->b_nwnd == 0)
    {				/* Undisplay */
      curbp->b_dotp = curwp->w_dotp;
      curbp->b_doto = curwp->w_doto;
      curbp->b_markp = curwp->w_markp;
      curbp->b_marko = curwp->w_marko;
    }
  curbp = bp;			/* Switch to it */
  curwp->w_bufp = bp;
  curbp->b_nwnd++;
  return (readin(fname));	/* Read it in */
}
Example #8
0
File: main.c Project: qwitwa/pEmacs
/*
 * End keyboard macro. Check for the same limit conditions as the above
 * routine. Set up the variables and return to the caller.
 */
int ctlxrp (int f, int n)
{
  if (kbdmip == NULL)
    {
      mlwrite ("Not now");
      return (FALSE);
    }
  mlwrite ("[End macro]");
  kbdmip = NULL;
  return (TRUE);
}
Example #9
0
File: main.c Project: qwitwa/pEmacs
/*
 * Begin a keyboard macro. Error if not at the top level in keyboard
 * processing. Set up variables and return.
 */
int ctlxlp (int f, int n)
{
  if (kbdmip != NULL || kbdmop != NULL)
    {
      mlwrite ("Not now");
      return (FALSE);
    }
  mlwrite ("[Start macro]");
  kbdmip = &kbdm[0];
  return (TRUE);
}
Example #10
0
/*
 * getfile()
 *
 * char fname[];	file name to find
 * int lockfl;		check the file for locks?
 */
int getfile(char *fname, int lockfl)
{
	struct buffer *bp;
	struct line *lp;
	int i;
	int s;
	char bname[NBUFN];	/* buffer name to put file */

#if	MSDOS
	mklower(fname);		/* msdos isn't case sensitive */
#endif
	for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
		if ((bp->b_flag & BFINVS) == 0
		    && strcmp(bp->b_fname, fname) == 0) {
			swbuffer(bp);
			lp = curwp->w_dotp;
			i = curwp->w_ntrows / 2;
			while (i-- && lback(lp) != curbp->b_linep)
				lp = lback(lp);
			curwp->w_linep = lp;
			curwp->w_flag |= WFMODE | WFHARD;
			cknewwindow();
			mlwrite("(Old buffer)");
			return TRUE;
		}
	}
	makename(bname, fname);	/* New buffer name.     */
	while ((bp = bfind(bname, FALSE, 0)) != NULL) {
		/* old buffer name conflict code */
		s = mlreply("Buffer name: ", bname, NBUFN);
		if (s == ABORT)	/* ^G to just quit      */
			return s;
		if (s == FALSE) {	/* CR to clobber it     */
			makename(bname, fname);
			break;
		}
	}
	if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
		mlwrite("Cannot create buffer");
		return FALSE;
	}
	if (--curbp->b_nwnd == 0) {	/* Undisplay.           */
		curbp->b_dotp = curwp->w_dotp;
		curbp->b_doto = curwp->w_doto;
		curbp->b_markp = curwp->w_markp;
		curbp->b_marko = curwp->w_marko;
	}
	curbp = bp;		/* Switch to it.        */
	curwp->w_bufp = bp;
	curbp->b_nwnd++;
	s = readin(fname, lockfl);	/* Read it in.          */
	cknewwindow();
	return s;
}
Example #11
0
PASCAL NEAR removefold(
  int f,
  int n )
{
	BUFFER *bp;		 /* buffer having fold removed */
	WINDOW *wp;		 /* windows to fix up pointers in as well */
	LINE   *lp;		 /* line loop for reset of margin */
	int    margval;		 /* value to set margin to */

        if (curbp->b_mode&MDVIEW)       /* don't allow this command if  */
                return(rdonly());       /* we are in read only mode     */

	/* find the proper buffer */
	bp = curwp->w_bufp;		

	if (curwp->w_dotp->l_type == LSOFOLD) {

		/* set line types to normal */
		curwp->w_dotp->l_type = LNORMAL;
		curwp->w_dotp->l_foldp->l_type = LNORMAL;

		/* set all margins to that of any outer fold */
		margval = minleftmarg(curwp->w_dotp);
		lp = curwp->w_dotp->l_fp;
		while (lp != curwp->w_dotp->l_foldp) {
			lp->l_lmargin = margval;
			lp = lforw(lp);
		}

		/* and remove them */
		lfree(curwp->w_dotp->l_foldp);
		lfree(curwp->w_dotp);

		/* let all the proper windows be updated */
		wp = wheadp;
		while (wp) {
			if (wp->w_bufp == bp)
				wp->w_flag |= (WFHARD|WFMODE);
			wp = wp->w_wndp;
		}
		bp->b_flag |= BFCHG; /* flag change */
		mlwrite(TEXT233);
		/* "[Fold Removed]" */
		return(TRUE);
	}
	else {
		mlwrite(TEXT235);
		/* "%% Not a fold line" */
		return(FALSE);
	}
}
Example #12
0
File: macro.c Project: collects/me
/*
 * Begin a keyboard macro.
 * Error if not at the top level in keyboard processing. Set up variables and
 * return.
 */
int
startKbdMacro(int f, int n)
{
    if (kbdmode != meSTOP)
    {
        mlwrite(0,(meUByte *)"Macro already active");
        return false ;
    }
    mlwrite(0,(meUByte *)"[Start macro]");
    kbdptr = &lkbdptr[0];
    kbdlen = 0 ;
    kbdmode = meRECORD;
    frameAddModeToWindows(WFMODE) ;  /* and update ALL mode lines */
    return true ;
}
Example #13
0
/* kill the buffer pointed to by bp
 */
int zotbuf (BUFFER *bp)
{
  BUFFER *bp1, *bp2;
  int s;

  if (bp->b_nwnd != 0)
    {				/* Error if on screen */
      mlwrite ("Buffer is being displayed");
      return (FALSE);
    }
  if ((s = bclear (bp)) != TRUE) /* Blow text away */
    return (s);
  free (bp->b_linep);		/* Release header line */
  bp1 = 0;			/* Find the header */
  bp2 = bheadp;
  while (bp2 != bp)
    {
      bp1 = bp2;
      bp2 = bp2->b_bufp;
    }
  bp2 = bp2->b_bufp;		/* Next one in chain */
  if (bp1 == NULL)		/* Unlink it */
    bheadp = bp2;
  else
    bp1->b_bufp = bp2;
  free (bp);			/* Release buffer block */
  return (TRUE);
}
Example #14
0
File: macro.c Project: collects/me
meMacro *
userGetMacro(meUByte *buf, int len)
{
    register int idx ;
    
    if(meGetString((meUByte *)"Enter macro name ", MLCOMMAND,2,buf,len) > 0)
    {        
        if((idx = decode_fncname(buf,0)) < 0)
            mlwrite(MWABORT,(meUByte *)"%s not defined",buf) ;
        else if(idx < CK_MAX)
            mlwrite(MWABORT,(meUByte *)"%s is a command",buf) ;
        else
            return getMacro(idx) ;
    }
    return NULL ;
}
Example #15
0
File: macro.c Project: collects/me
/*
 * End keyboard macro. Check for the same limit conditions as the above
 * routine. Set up the variables and return to the caller.
 */
int
endKbdMacro(int f, int n)
{
    if (kbdmode == mePLAY)
        return true ;
    if (kbdmode == meRECORD)
    {
        frameAddModeToWindows(WFMODE) ;  /* and update ALL mode lines */
        mlwrite(0,(meUByte *)"[End macro]");
        kbdmode = meSTOP;

        lkbdlen = kbdlen ;
        return true ;
    }
    return mlwrite(MWABORT,(meUByte *)"Macro not active");
}
Example #16
0
/* ARGSUSED0 */
int setmark(int f, int n)
{
  curwp->w_markp = curwp->w_dotp;
  curwp->w_marko = curwp->w_doto;
  mlwrite("[Mark set]");
  return (TRUE);
}
Example #17
0
PASCAL NEAR gotoline(	/* move to a particular line.
			   argument (n) must be a positive integer for
			   this to actually do anything		*/

  int f,
  int n )	/* prefix flag and argument */

{
	register int status;	/* status return */
	char arg[NSTRING];	/* buffer to hold argument */

	/* get an argument if one doesnt exist */
	if (f == FALSE) {
		if ((status = mlreply(TEXT7, arg, NSTRING)) != TRUE) {
/*                                    "Line to GOTO: " */
			mlwrite(TEXT8);
/*                              "[Aborted]" */
			return(status);
		}
		n = asc_int(arg);
	}

	if (n < 1)		/* if a bogus argument...then leave */
		return(FALSE);

	/* first, we go to the start of the buffer */
        curwp->w_dotp  = lforw(curbp->b_linep);
        curwp->w_doto  = 0;
	return(forwline(f,n-1,TRUE));
}
Example #18
0
/*
 * Swap the values of "." and "mark" in the current window. This is pretty
 * easy, bacause all of the hard work gets done by the standard routine
 * that moves the mark about. The only possible error is "no mark". Bound to
 * "C-X C-X".
 */
PASCAL NEAR swapmark(
  int f,
  int n )/* argument falg and num */

{
        register LINE   *odotp;
        register int    odoto;

	/* make sure it is in range */
	if (f == FALSE)
		n = 0;
	n %= NMARKS;

        if (curwp->w_markp[n] == NULL) {
                mlwrite(TEXT11, n);
/*                      "No mark %d in this window" */
                return(FALSE);
        }
        odotp = curwp->w_dotp;
        odoto = curwp->w_doto;
        curwp->w_dotp  = curwp->w_markp[n];
        curwp->w_doto  = curwp->w_marko[n];
        curwp->w_markp[n] = odotp;
        curwp->w_marko[n] = odoto;
        curwp->w_flag |= WFMOVE;
	openoutfolds();
        return(TRUE);
}
Example #19
0
File: main.c Project: qwitwa/pEmacs
/*
 * Execute a macro. The command argument is the number of times to loop. Quit
 * as soon as a command gets an error. Return TRUE if all ok, else FALSE.
 */
int ctlxe (int f, int n)
{
  int c, af, an, s;

  if (kbdmip != NULL || kbdmop != NULL)
    {
      mlwrite ("No macro defined");
      return (FALSE);
    }
  if (n <= 0)
    return (TRUE);
  do
    {
      kbdmop = &kbdm[0];
      do
	{
	  af = FALSE;
	  an = 1;
	  if ((c = *kbdmop++) == (CTRL | 'U'))
	    {
	      af = TRUE;
	      an = *kbdmop++;
	      c = *kbdmop++;
	    }
	  s = TRUE;
	}
      while (c != (CTLX | ')') && (s = execute (c, af, an)) == TRUE);
      kbdmop = NULL;
    }
  while (s == TRUE && --n);
  return (s);
}
Example #20
0
/*
 * Execute a macro.
 * The command argument is the number of times to loop. Quit as soon as a
 * command gets an error. Return TRUE if all ok, else FALSE.
 */
globle int ctlxe(
  void *theEnv,
  int f,
  int n)
{
        register int    c;
        register int    af;
        register int    an;
        register int    s;

        if (kbdmip!=NULL || kbdmop!=NULL) {
                mlwrite("Not now");
                return (FALSE);
        }
        if (n <= 0)
                return (TRUE);
        do {
                kbdmop = &kbdm[0];
                do {
                        af = FALSE;
                        an = 1;
                        if ((c = *kbdmop++) == (COTL|'U')) {
                                af = TRUE;
                                an = *kbdmop++;
                                c  = *kbdmop++;
                        }
                        s = TRUE;
                } while (c!=(CTLX|')') && (s=execute(theEnv,c, af, an))==TRUE);
                kbdmop = NULL;
        } while (s==TRUE && --n);
        return (s);
}
Example #21
0
File: frame.c Project: collects/me
/*
 * frameChangeDepth  - Change the depth of the screen.
 * Resize the screen, re-writing the screen
 */
int
frameChangeDepth(int f, int n)
{
    /* if no argument is given then prompt for the new depth */
    if (f == false)
    {
        meUByte buff[meSBUF_SIZE_MAX] ;

        if (meGetString((meUByte *)"New depth", 0, 0, buff, meSBUF_SIZE_MAX) <= 0)
            return false ;
        n = meAtoi(buff) ;
    }
    else
        /* n is a delta, add this to the current width to get the new width */
        n = frameCur->depth + 1 + n ;
    if ((n < 4) || (n > 400))           /* Argument in range ?? */
        return mlwrite(MWABORT,(meUByte *)"[Screen depth %d out of range]", n);
    if (n == (frameCur->depth+1))
        return true;                    /* Already the right size */

    if(meFrameChangeDepth(frameCur,n) <= 0)
        return false ;

#ifdef _WINDOW
    meFrameSetWindowSize(frameCur) ;    /* Change the size of the window */
#endif
    return true ;
}
Example #22
0
/*
 * execproc:
 *	Execute a procedure
 *
 * int f, n;		default flag and numeric arg
 */
int execproc(int f, int n)
{
	struct buffer *bp;	/* ptr to buffer to execute */
	int status;	/* status return */
	char bufn[NBUFN + 2];	/* name of buffer to execute */

	/* find out what buffer the user wants to execute */
	if ((status =
	     mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
		return status;

	/* construct the buffer name */
	bufn[0] = '*';
	strcat(bufn, "*");

	/* find the pointer to that buffer */
	if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
		mlwrite("No such procedure");
		return FALSE;
	}

	/* and now execute it as asked */
	while (n-- > 0)
		if ((status = dobuf(bp)) != TRUE)
			return status;
	return TRUE;
}
Example #23
0
/*
 * storeproc:
 *	Set up a procedure buffer and flag to store all
 *	executed command lines there
 *
 * int f;		default flag
 * int n;		macro number to use
 */
int storeproc(int f, int n)
{
	struct buffer *bp;	/* pointer to macro buffer */
	int status;	/* return status */
	char bname[NBUFN];	/* name of buffer to use */

	/* a numeric argument means its a numbered macro */
	if (f == TRUE)
		return storemac(f, n);

	/* get the name of the procedure */
	if ((status =
	     mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE)
		return status;

	/* construct the macro buffer name */
	bname[0] = '*';
	strcat(bname, "*");

	/* set up the new macro buffer */
	if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
		mlwrite("Can not create macro");
		return FALSE;
	}

	/* and make sure it is empty */
	bclear(bp);

	/* and set the macro store pointers to it */
	mstore = TRUE;
	bstore = bp;
	return TRUE;
}
Example #24
0
int
yankRectangle(int f, int n)
{
    int col ;
#ifdef _CLIPBRD
    TTgetClipboard() ;
#endif
    /* make sure there is something to yank */
    if(klhead == NULL)
        return mlwrite(MWABORT,(meUByte *)"[nothing to yank]");
    /* Check we can change the buffer */
    if(bufferSetEdit() <= 0)
        return meABORT ;
    
    /* get the current column */
    col = getcwcol() ;
    
    /* place the mark on the current line */
    windowSetMark(meFALSE, meFALSE);
    
    /* for each time.... */
    while(--n >= 0)
        if(yankRectangleKill(klhead,col,n) <= 0)
            return meABORT ;
    return meTRUE ;
}
Example #25
0
/*
 * Search forward. Get a search string from the user, and search, beginning at
 * ".", for the string. If found, reset the "." to be just after the match
 * string, and [perhaps] repaint the display. Bound to "C-S"
 */
int forwsearch (int f, int n)
{
  int status=FALSE;

  if (n == 0)			/* resolve the repeat count */
    n = 1;
  if (n < 1)			/* search backwards */
    return (backsearch (f, -n));

  /* ask the user for the text of a pattern */
  if ((status = readpattern ("Search")) != TRUE)
    return (status);

  /* search for the pattern */
  while (n-- > 0)
    {
      if ((status = forscan (&pat[0], PTEND)) == FALSE)
	break;
    }

  /* and complain if not there */
  if (status == FALSE)
    mlwrite ("Not found");
  return (status);
}
Example #26
0
File: main.c Project: qwitwa/pEmacs
/*
 * Handle ANSI escape-extended commands (with "ESC [" or "ESC O" prefix)
 */
int extendedcmd (int f, int n)
{
  int (*cmd)();
  int c;

  c = getctl();
  switch (c)
    {
    case 'A': cmd = backline; break; /* up arrow */
    case 'B': cmd = forwline; break; /* down arrow */
    case 'C': cmd = forwchar; break; /* right arrow */
    case 'D': cmd = backchar; break; /* left arrow */
    case 'H': cmd = gotobol; break;  /* usually home */
    case 'W': cmd = gotoeol; break;  /* maybe end */
    case 'F': cmd = gotoeol; break;  /* maybe end */
    case '3': cmd = forwdel; getctl(); break; /* maybe delete */
    case '5': cmd = backpage; getctl(); break;
    case '6': cmd = forwpage; getctl(); break;
    case '7': cmd = gotobob; getctl(); break;
    case '8': cmd = gotoeob; getctl(); break;
    default: mlwrite ("\007[Key not bound]");
      return (FALSE);
    }
  return cmd(f, n);
}
Example #27
0
/*
 * return a the nth buffer in the list that has been walked through
 * by calling makelist.  Will only be correct if makelist has been recently
 * been called and the list of buffers displayed.  We walk the list in the
 * same way as makelist.
 */
BUFFER *get_buffer(int n)
{
  BUFFER *bp;
  int i = 0;

  bp = bheadp;
  while (bp != NULL)
	{
      if ((bp->b_flag & BFTEMP) != 0)
		{
		  bp = bp->b_bufp;
		  continue;
		}
	 
	  if (++i == n)
		return bp;

	  bp = bp->b_bufp;
	}

  /* we should never get here */
  mlwrite("[Fatal: could not find buffer]");
  exit(1);
  return NULL;
}
Example #28
0
File: macro.c Project: collects/me
/*
 * Asks the user if they wish to continue macro execution.
 * does nothing when recording, must meSTOP the macro execution so 
 * mlyesno goes to the keyboard.
 */
int
macroQuery(int f, int n)
{
    if(kbdmode == mePLAY)
    {
        int   rr ;
        
        /* force a screen update */
        update(true);
        kbdmode = meSTOP ;
        if((rr = mlyesno((meUByte *)"Continue macro")) == meABORT)
            return meABORT ;
        if(rr == false)
        {
            kbdrep-- ;
            kbdoff = 0 ;
        }
        if(kbdrep)
            kbdmode = mePLAY ;
        else
            return false ;
    }
    else if(kbdmode != meRECORD)
        return mlwrite(MWABORT,(meUByte *)"Not defining macro") ;
    return true ;
}
Example #29
0
File: file.c Project: aksr/esnc
/*
 * Save the contents of the current buffer in its associatd file. No nothing
 * if nothing has changed (this may be a bug, not a feature). Error if there
 * is no remembered file name for the buffer. Bound to "C-X C-S". May get
 * called by "C-Z"
 */
int filesave (int f, int n)
{
  WINDOW *wp;
  int s;

  if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes */
    return (TRUE);
  if (curbp->b_fname[0] == 0)
    {				/* Must have a name */
      mlwrite ("No file name");
      return (FALSE);
    }
  if ((s = writeout (curbp->b_fname)) == TRUE)
    {
      curbp->b_flag &= ~BFCHG;
      wp = wheadp;		/* Update mode lines */
      while (wp != NULL)
	{
	  if (wp->w_bufp == curbp)
	    wp->w_flag |= WFMODE;
	  wp = wp->w_wndp;
	}
    }
  return (s);
}
Example #30
0
/*
 * kill the buffer pointed to by bp
 */
int zotbuf(struct buffer *bp)
{
	struct buffer *bp1;
	struct buffer *bp2;
	int s;

	if (bp->b_nwnd != 0) {	/* Error if on screen.  */
		mlwrite("Buffer is being displayed");
		return FALSE;
	}
	if ((s = bclear(bp)) != TRUE)	/* Blow text away.      */
		return s;
	free((char *) bp->b_linep);	/* Release header line. */
	bp1 = NULL;		/* Find the header.     */
	bp2 = bheadp;
	while (bp2 != bp) {
		bp1 = bp2;
		bp2 = bp2->b_bufp;
	}
	bp2 = bp2->b_bufp;	/* Next one in chain.   */
	if (bp1 == NULL)	/* Unlink it.           */
		bheadp = bp2;
	else
		bp1->b_bufp = bp2;
	free((char *) bp);	/* Release buffer block */
	return TRUE;
}