当前位置: 首页>>代码示例>>C++>>正文


C++ dobeep函数代码示例

本文整理汇总了C++中dobeep函数的典型用法代码示例。如果您正苦于以下问题:C++ dobeep函数的具体用法?C++ dobeep怎么用?C++ dobeep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dobeep函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: anycb

/*
 * Look through the list of buffers, giving the user a chance to save them.
 * Return TRUE if there are any changed buffers afterwards.  Buffers that don't
 * have an associated file don't count.  Return FALSE if there are no changed
 * buffers.  Return ABORT if an error occurs or if the user presses c-g.
 */
int
anycb(int f)
{
	struct buffer	*bp;
	int		 s = FALSE, save = FALSE, save2 = FALSE, ret;
	char		 pbuf[NFILEN + 11];

	for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
		if (*(bp->b_fname) != '\0' && (bp->b_flag & BFCHG) != 0) {
			ret = snprintf(pbuf, sizeof(pbuf), "Save file %s",
			    bp->b_fname);
			if (ret < 0 || ret >= sizeof(pbuf)) {
				dobeep();
				ewprintf("Error: filename too long!");
				return (UERROR);
			}
			if ((f == TRUE || (save = eyorn(pbuf)) == TRUE) &&
			    (save2 = buffsave(bp)) == TRUE) {
				bp->b_flag &= ~BFCHG;
				upmodes(bp);
			} else {
				if (save2 == FIOERR)
					return (save2);
				s = TRUE;
			}
			if (save == ABORT)
				return (save);
			save = TRUE;
		}
	}
	if (save == FALSE /* && kbdmop == NULL */ )	/* experimental */
		ewprintf("(No files need saving)");
	return (s);
}
开发者ID:troglobit,项目名称:mg,代码行数:40,代码来源:buffer.c

示例2: backchar

/* ARGSUSED */
int
backchar(int f, int n)
{
	struct line   *lp;

	if (n < 0)
		return (forwchar(f, -n));
	while (n--) {
		if (curwp->w_doto == 0) {
			if ((lp = lback(curwp->w_dotp)) == curbp->b_headp) {
				if (!(f & FFRAND)) {
					dobeep();
					ewprintf("Beginning of buffer");
				}
				return (FALSE);
			}
			curwp->w_dotp = lp;
			curwp->w_doto = llength(lp);
			curwp->w_rflag |= WFMOVE;
			curwp->w_dotline--;
		} else
			curwp->w_doto--;
	}
	return (TRUE);
}
开发者ID:WizardGed,项目名称:mg,代码行数:26,代码来源:basic.c

示例3: dorevert

int
dorevert(void)
{
	int lineno;
	struct undo_rec *rec;

	if (access(curbp->b_fname, F_OK|R_OK) != 0) {
		dobeep();
		if (errno == ENOENT)
			ewprintf("File %s no longer exists!",
			    curbp->b_fname);
		else
			ewprintf("File %s is no longer readable!",
			    curbp->b_fname);
		return (FALSE);
	}

	/* Save our current line, so we can go back after reloading. */
	lineno = curwp->w_dotline;

	/* Prevent readin from asking if we want to kill the buffer. */
	curbp->b_flag &= ~BFCHG;

	/* Clean up undo memory */
	while ((rec = TAILQ_FIRST(&curbp->b_undo))) {
		TAILQ_REMOVE(&curbp->b_undo, rec, next);
		free_undo_record(rec);
	}

	if (readin(curbp->b_fname))
		return(setlineno(lineno));
	return (FALSE);
}
开发者ID:troglobit,项目名称:mg,代码行数:33,代码来源:buffer.c

示例4: setfillcol

/*
 * Set fill column to n for justify.
 */
int
setfillcol(int f, int n)
{
	char buf[32], *rep;
	const char *es;
	int nfill;

	if ((f & FFARG) != 0) {
		fillcol = n;
	} else {
		if ((rep = eread("Set fill-column: ", buf, sizeof(buf),
		    EFNEW | EFCR)) == NULL)
			return (ABORT);
		else if (rep[0] == '\0')
			return (FALSE);
		nfill = strtonum(rep, 0, INT_MAX, &es);
		if (es != NULL) {
			dobeep();
			ewprintf("Invalid fill column: %s", rep);
			return (FALSE);
		}
		fillcol = nfill;
		ewprintf("Fill column set to %d", fillcol);
	}
	return (TRUE);
}
开发者ID:troglobit,项目名称:mg,代码行数:29,代码来源:paragraph.c

示例5: ffputbuf

/*
 * Write a buffer to the already opened file. bp points to the
 * buffer. Return the status.
 */
int
ffputbuf(FILE *ffp, struct buffer *bp)
{
	struct line   *lp, *lpend;

	lpend = bp->b_headp;
	for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) {
		if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) {
			dobeep();
			ewprintf("Write I/O error");
			return (FIOERR);
		}
		if (lforw(lp) != lpend)		/* no implied \n on last line */
			putc('\n', ffp);
	}
	/*
	 * XXX should be variable controlled (once we have variables)
	 */
	if (llength(lback(lpend)) != 0) {
		if (eyorn("No newline at end of file, add one") == TRUE) {
			lnewline_at(lback(lpend), llength(lback(lpend)));
			putc('\n', ffp);
		}
	}
	return (FIOSUC);
}
开发者ID:Scarletts,项目名称:LiteBSD,代码行数:30,代码来源:fileio.c

示例6: addctag

/*
 * tags line is of the format "<tag>\t<filename>\t<pattern>". Split them
 * by replacing '\t' with '\0'. This wouldn't alter the size of malloc'ed
 * l, and can be freed during cleanup.
 */
int
addctag(char *l)
{
	struct ctag *t;
	
	if ((t = malloc(sizeof(struct ctag))) == NULL) {
		dobeep();
		ewprintf("Out of memory");
		return (FALSE);
	}
	t->tag = l;
	if ((l = strchr(l, '\t')) == NULL)
		goto cleanup;
	*l++ = '\0';
	t->fname = l;
	if ((l = strchr(l, '\t')) == NULL)
		goto cleanup;
	*l++ = '\0';
	if (*l == '\0')
		goto cleanup;
	t->pat = strip(l, strlen(l));
	RB_INSERT(tagtree, &tags, t);
	return (TRUE);
cleanup:
	free(t);
	free(l);
	return (TRUE);
}
开发者ID:scott-parker,项目名称:mg-openbsd,代码行数:33,代码来源:tags.c

示例7: poptag

/* ARGSUSED */
int
poptag(int f, int n)
{
	struct line *dotp;
	struct tagpos *s;
	
	if (SLIST_EMPTY(&shead)) {
		dobeep();
		ewprintf("No previous location for find-tag invocation");
		return (FALSE);
	}
	s = SLIST_FIRST(&shead);
	SLIST_REMOVE_HEAD(&shead, entry);
	if (loadbuffer(s->bname) == FALSE)
		return (FALSE);
	curwp->w_dotline = s->dotline;
	curwp->w_doto = s->doto;
	
	/* storing of dotp in tagpos wouldn't work out in cases when
	 * that buffer is killed by user(dangling pointer). Explicitly
	 * traverse till dotline for correct handling. 
	 */
	dotp = curwp->w_bufp->b_headp;
	while (s->dotline--)
		dotp = dotp->l_fp;
	
	curwp->w_dotp = dotp;
	free(s->bname);
	free(s);
	return (TRUE);
}
开发者ID:scott-parker,项目名称:mg-openbsd,代码行数:32,代码来源:tags.c

示例8: do_redraw

/* ARGSUSED */
int
do_redraw(int f, int n, int force)
{
	struct mgwin	*wp;
	int		 oldnrow, oldncol;

	oldnrow = nrow;
	oldncol = ncol;
	ttresize();
	if (nrow != oldnrow || ncol != oldncol || force) {

		/* find last */
		wp = wheadp;
		while (wp->w_wndp != NULL)
			wp = wp->w_wndp;

		/* check if too small */
		if (nrow < wp->w_toprow + 3) {
			dobeep();
			ewprintf("Display unusable");
			return (FALSE);
		}
		wp->w_ntrows = nrow - wp->w_toprow - 2;
		sgarbf = TRUE;
		update(CMODE);
	} else
		sgarbf = TRUE;
	return (TRUE);
}
开发者ID:sctb,项目名称:em,代码行数:30,代码来源:window.c

示例9: enlargewind

/* ARGSUSED */
int
enlargewind(int f, int n)
{
	struct mgwin	*adjwp;
	struct line	*lp;
	int		 i;

	if (n < 0)
		return (shrinkwind(f, -n));
	if (wheadp->w_wndp == NULL) {
		dobeep();
		ewprintf("Only one window");
		return (FALSE);
	}
	if ((adjwp = curwp->w_wndp) == NULL) {
		adjwp = wheadp;
		while (adjwp->w_wndp != curwp)
			adjwp = adjwp->w_wndp;
	}
	if (adjwp->w_ntrows <= n) {
		dobeep();
		ewprintf("Impossible change");
		return (FALSE);
	}

	/* shrink below */
	if (curwp->w_wndp == adjwp) {
		lp = adjwp->w_linep;
		for (i = 0; i < n && lp != adjwp->w_bufp->b_headp; ++i)
			lp = lforw(lp);
		adjwp->w_linep = lp;
		adjwp->w_toprow += n;
	/* shrink above */
	} else {
		lp = curwp->w_linep;
		for (i = 0; i < n && lback(lp) != curbp->b_headp; ++i)
			lp = lback(lp);
		curwp->w_linep = lp;
		curwp->w_toprow -= n;
	}
	curwp->w_ntrows += n;
	adjwp->w_ntrows -= n;
	curwp->w_rflag |= WFMODE | WFFULL;
	adjwp->w_rflag |= WFMODE | WFFULL;
	return (TRUE);
}
开发者ID:troglobit,项目名称:mg,代码行数:47,代码来源:window.c

示例10: setsize

/*
 * Set size, and check for overflow.
 */
static int
setsize(struct region *rp, RSIZE size)
{
	rp->r_size = size;
	if (rp->r_size != size) {
		dobeep();
		ewprintf("Region is too large");
		return (FALSE);
	}
	return (TRUE);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:14,代码来源:region.c

示例11: filewrite

/* ARGSUSED */
int
filewrite(int f, int n)
{
	struct stat     statbuf;
	int	 s;
	char	 fname[NFILEN], bn[NBUFN], tmp[NFILEN + 25];
	char	*adjfname, *bufp;
        FILE    *ffp;

	if (getbufcwd(fname, sizeof(fname)) != TRUE)
		fname[0] = '\0';
	if ((bufp = eread("Write file: ", fname, NFILEN,
	    EFDEF | EFNEW | EFCR | EFFILE)) == NULL)
		return (ABORT);
	else if (bufp[0] == '\0')
		return (FALSE);

	adjfname = adjustname(fname, TRUE);
	if (adjfname == NULL)
		return (FALSE);

        /* Check if file exists; write checks done later */
        if (stat(adjfname, &statbuf) == 0) {
		if (S_ISDIR(statbuf.st_mode)) {
			dobeep();
			ewprintf("%s is a directory", adjfname);
			return (FALSE);
		}
		snprintf(tmp, sizeof(tmp), "File `%s' exists; overwrite",
		    adjfname);
		if ((s = eyorn(tmp)) != TRUE)
                        return (s);
        }

	/* old attributes are no longer current */
	bzero(&curbp->b_fi, sizeof(curbp->b_fi));
	if ((s = writeout(&ffp, curbp, adjfname)) == TRUE) {
		(void)strlcpy(curbp->b_fname, adjfname, sizeof(curbp->b_fname));
		if (getbufcwd(curbp->b_cwd, sizeof(curbp->b_cwd)) != TRUE)
			(void)strlcpy(curbp->b_cwd, "/", sizeof(curbp->b_cwd));
		if (augbname(bn, curbp->b_fname, sizeof(bn))
		    == FALSE)
			return (FALSE);
		free(curbp->b_bname);
		if ((curbp->b_bname = strdup(bn)) == NULL)
			return (FALSE);
		(void)fupdstat(curbp);
		curbp->b_flag &= ~BFCHG;
		upmodes(curbp);
		undo_add_boundary(FFRAND, 1);
		undo_add_modified();
	}
	return (s);
}
开发者ID:sctb,项目名称:em,代码行数:55,代码来源:file.c

示例12: next_error

/* ARGSUSED */
int
next_error(int f, int n)
{
	if (compile_win == NULL || compile_buffer == NULL) {
		dobeep();
		ewprintf("No compilation active");
		return (FALSE);
	}
	curwp = compile_win;
	curbp = compile_buffer;
	if (curwp->w_dotp == blastlp(curbp)) {
		dobeep();
		ewprintf("No more hits");
		return (FALSE);
	}
	curwp->w_dotp = lforw(curwp->w_dotp);
	curwp->w_rflag |= WFMOVE;

	return (compile_goto_error(f, n));
}
开发者ID:WizardGed,项目名称:mg,代码行数:21,代码来源:grep.c

示例13: pipeio

/*
 * Create a socketpair, fork and execv path with argv.
 * STDIN, STDOUT and STDERR of child process are redirected to socket.
 * Parent writes len chars from text to socket.
 */
int
pipeio(const char* const path, char* const argv[], char* const text, int len,
    struct buffer *outbp)
{
	int s[2];
	char *err;

	if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, s) == -1) {
		dobeep();
		ewprintf("socketpair error");
		return (FALSE);
	}

	switch(fork()) {
	case -1:
		dobeep();
		ewprintf("Can't fork");
		return (FALSE);
	case 0:
		/* Child process */
		close(s[0]);
		if (dup2(s[1], STDIN_FILENO) == -1)
			_exit(1);
		if (dup2(s[1], STDOUT_FILENO) == -1)
			_exit(1);
		if (dup2(s[1], STDERR_FILENO) == -1)
			_exit(1);
		if (path == NULL)
			_exit(1);

		execv(path, argv);
		err = strerror(errno);
		write(s[1], err, strlen(err));
		_exit(1);
	default:
		/* Parent process */
		close(s[1]);
		return (iomux(s[0], text, len, outbp));
	}
	return (FALSE);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:46,代码来源:region.c

示例14: bufferinsert

/* ARGSUSED */
int
bufferinsert(int f, int n)
{
	struct buffer *bp;
	struct line   *clp;
	int	clo, nline;
	char	bufn[NBUFN], *bufp;

	/* Get buffer to use from user */
	if (curbp->b_altb != NULL)
		bufp = eread("Insert buffer: (default %s) ", bufn, NBUFN,
		    EFNUL | EFNEW | EFBUF, curbp->b_altb->b_bname);
	else
		bufp = eread("Insert buffer: ", bufn, NBUFN, EFNEW | EFBUF);
	if (bufp == NULL)
		return (ABORT);
	if (bufp[0] == '\0' && curbp->b_altb != NULL)
		bp = curbp->b_altb;
	else if ((bp = bfind(bufn, FALSE)) == NULL)
		return (FALSE);

	if (bp == curbp) {
		dobeep();
		ewprintf("Cannot insert buffer into self");
		return (FALSE);
	}
	/* insert the buffer */
	nline = 0;
	clp = bfirstlp(bp);
	for (;;) {
		for (clo = 0; clo < llength(clp); clo++)
			if (linsert(1, lgetc(clp, clo)) == FALSE)
				return (FALSE);
		if ((clp = lforw(clp)) == bp->b_headp)
			break;
		if (enewline(FFRAND, 1) == FALSE)	/* fake newline */
			return (FALSE);
		nline++;
	}
	if (nline == 1)
		ewprintf("[Inserted 1 line]");
	else
		ewprintf("[Inserted %d lines]", nline);

	clp = curwp->w_linep;		/* cosmetic adjustment	*/
	if (curwp->w_dotp == clp) {	/* for offscreen insert */
		while (nline-- && lback(clp) != curbp->b_headp)
			clp = lback(clp);
		curwp->w_linep = clp;	/* adjust framing.	*/
		curwp->w_rflag |= WFFULL;
	}
	return (TRUE);
}
开发者ID:WizardGed,项目名称:mg,代码行数:54,代码来源:buffer.c

示例15: piperegion

/*ARGSUSED */
int
piperegion(int f, int n)
{
	struct region region;
	int len;
	char *cmd, cmdbuf[NFILEN], *text;
	char *argv[] = {"sh", "-c", (char *) NULL, (char *) NULL};

	/* C-u M-| is not supported yet */
	if (n > 1)
		return (ABORT);

	if (curwp->w_markp == NULL) {
		dobeep();
		ewprintf("The mark is not set now, so there is no region");
		return (FALSE);
	}

	if ((cmd = eread("Shell command on region: ", cmdbuf, sizeof(cmdbuf),
	    EFNEW | EFCR)) == NULL || (cmd[0] == '\0'))
		return (ABORT);

	argv[2] = cmd;

	if (getregion(&region) != TRUE)
		return (FALSE);

	len = region.r_size;

	if ((text = malloc(len + 1)) == NULL) {
		dobeep();
		ewprintf("Cannot allocate memory.");
		return (FALSE);
	}

	region_get_data(&region, text, len);

	return shellcmdoutput(argv, text, len);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:40,代码来源:region.c


注:本文中的dobeep函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。