Example #1
0
/*
 * If no warning messages were encountered during startup, and the popup-msgs
 * mode wasn't enabled, discard the informational messages that are there
 * already.
 */
void
purge_msgs(void)
{
    TRACE(("purge_msgs mode:%d, warnings:%d\n",
	   global_g_val(GMDPOPUP_MSGS), warnings));

    if ((global_g_val(GMDPOPUP_MSGS) == -TRUE)
	&& (warnings == 0)) {
	BUFFER *bp = find_b_name(MESSAGES_BufName);
	if (valid_buffer(bp)
	    && bp->b_nwnd == 0) {
	    (void) zotbuf(bp);
	}
	set_global_g_val(GMDPOPUP_MSGS, FALSE);
    }
}
Example #2
0
/*
 * Pipe a one line command into a window
 */
int
pipecmd(int f, int n)
{
	register int	s;	/* return status from CLI */
	register WINDOW *wp;	/* pointer to new window */
	register BUFFER *bp;	/* pointer to buffer to zot */
	static char oline[NLINE];	/* command line send to shell */
	char	line[NLINE];	/* command line send to shell */
	WINDOW *ocurwp;		/* save the current window during delete */

	static char filnam[NSTRING] = "command";

	/* get the command to pipe in */
	if ((s=mlreply("cmd: <", oline, NLINE)) != TRUE)
		return(s);

	(void)strcpy(line,oline);

	/* get rid of the command output buffer if it exists */
	if ((bp=find_b_name(OUTPUT_BufName)) != NULL) {
		/* try to make sure we are off screen */
		ocurwp = NULL;
		for_each_window(wp) {
			if (wp->w_bufp == bp) {
				if (curwp != wp) {
					ocurwp = curwp;
					curwp = wp;
				}
				delwind(FALSE, 1);
				if (ocurwp != NULL)
					curwp = ocurwp;
				break;
			}
		}
		if (zotbuf(bp) != TRUE)
			return(FALSE);
	}
Example #3
0
/* For the "operator" commands -- the following command is a motion, or
 *  the operator itself is repeated.  All operate on regions.
 */
int
vile_op(int f, int n, OpsFunc fn, const char *str)
{
    int c = 0;
    int thiskey;
    int status;
    const CMDFUNC *cfp;		/* function to execute */
    const CMDFUNC *save_cmd_motion = cmd_motion;
    BUFFER *ourbp;
#if OPT_MOUSE
    WINDOW *wp0 = curwp;
#endif

    TRACE((T_CALLED "vile_op(%s)\n", str));

    doingopcmd = TRUE;

    pre_op_dot = DOT;
    ourbp = curbp;

    if (havemotion != NULL) {
	cfp = havemotion;
	havemotion = NULL;
    } else {
	TBUFF *tok = 0;

	mlwrite("%s operation pending...", str);
	(void) update(FALSE);

	/* get the next command from the keyboard */
	/* or a command line, as approp. */
	if (clexec) {
	    char *value = mac_unquotedarg(&tok);	/* get the next token */
	    if (value != 0 && strcmp(value, "lines"))
		cfp = engl2fnc(value);
	    else
		cfp = &f_godotplus;
	} else {
	    thiskey = lastkey;
	    c = kbd_seq();

#if OPT_MOUSE
	    if (curwp != wp0) {
		unkeystroke(c);
		doingopcmd = FALSE;
		returnCode(FALSE);
	    }
#endif
	    /* allow second chance for entering counts */
	    do_repeats(&c, &f, &n);

	    if (thiskey == lastkey)
		cfp = &f_godotplus;
	    else
		cfp = DefaultKeyBinding(c);

	}
	if (cfp != 0) {
	    mlerase();
	} else {
	    if (!clexec) {
		char temp[NSTRING];
		lsprintf(temp, "(%d)", c);
		tb_scopy(&tok, temp);
	    }
	    (void) no_such_function(tb_values(tok));
	}
	tb_free(&tok);
    }

    if (!cfp) {
	status = FALSE;
    } else if ((cfp->c_flags & MOTION) == 0) {
	kbd_alarm();
	status = ABORT;
    } else {
	/* motion is interpreted as affecting full lines */
	if (regionshape == rgn_EXACT) {
	    if (cfp->c_flags & FL)
		regionshape = rgn_FULLLINE;
	    if (cfp->c_flags & VL_RECT)
		regionshape = rgn_RECTANGLE;
	}

	/* and execute the motion */
	if ((status = execute(cfp, f, n)) == TRUE) {
	    post_op_dot = DOT;
	} else {
	    mlforce("[Motion failed]");
	    status = FALSE;
	}
    }

    if (status == TRUE) {
	opcmd = 0;

	MK = pre_op_dot;

	/* we've successfully set up a region */
	if (!fn) {		/* be defensive */
	    mlforce("BUG -- null func pointer in operator");
	    status = FALSE;
	} else if (fn == user_operator) {
	    swapmark();
	    cmd_motion = cfp;
	    status = dobuf(find_b_name(str), 1, f ? n : 1);
	} else {
	    status = (fn) ();
	}

	if (ourbp == curbp)	/* in case the func switched buffers on us */
	    swapmark();

	if (regionshape == rgn_FULLLINE)
	    (void) firstnonwhite(FALSE, 1);
    }

    regionshape = rgn_EXACT;
    doingopcmd = FALSE;
    haveregion = FALSE;
    cmd_motion = save_cmd_motion;

    returnCode(status);
}
/*
 * Returns the buffer-list pointer, if it exists.
 */
static
BUFFER *find_BufferList()
{
	return find_b_name(BUFFER_LIST_NAME);
}
Example #5
0
static BUFFER *
gettagsfile(int n, int *endofpathflagp, int *did_read)
{
#ifdef MDCHK_MODTIME
    time_t current;
#endif
    char *tagsfile;
    BUFFER *tagbp;
    char tagbufname[NBUFN];
    char tagfilename[NFILEN];

    *endofpathflagp = FALSE;
    *did_read = FALSE;

    (void) lsprintf(tagbufname, TAGFILE_BufName, n + 1);

    /* is the buffer around? */
    if ((tagbp = find_b_name(tagbufname)) == NULL) {
	char *tagf = global_b_val_ptr(VAL_TAGS);

	nth_name(tagfilename, tagf, n);
	if (!doglob(tagfilename)
	    || tagfilename[0] == EOS) {
	    *endofpathflagp = TRUE;
	    return NULL;
	}

	/* look up the tags file */
	tagsfile = cfg_locate(tagfilename, LOCATE_TAGS);

	/* if it isn't around, don't sweat it */
	if (tagsfile == NULL) {
	    return NULL;
	}

	/* find the pointer to that buffer */
	if ((tagbp = bfind(tagbufname, BFINVS)) == NULL) {
	    mlforce("[Can't create tags buffer]");
	    return NULL;
	}

	if (readin(tagsfile, FALSE, tagbp, FALSE) != TRUE) {
	    zotbuf(tagbp);
	    return NULL;
	}
	*did_read = TRUE;
    }
#ifdef MDCHK_MODTIME
    /*
     * Re-read the tags buffer if we are checking modification-times and
     * find that the tags file's been changed. We check the global mode
     * value because it's too awkward to set the local mode value for a
     * scratch buffer.
     */
    if (global_b_val(MDCHK_MODTIME)
	&& get_modtime(tagbp, &current)
	&& tagbp->b_modtime != current) {
	if (!*did_read
	    && readin(tagbp->b_fname, FALSE, tagbp, FALSE) != TRUE) {
	    zotbuf(tagbp);
	    return NULL;
	}
	set_modtime(tagbp, tagbp->b_fname);
	*did_read = TRUE;
    }
#endif
    b_set_invisible(tagbp);
    return tagbp;
}