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


C++ el_init函数代码示例

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


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

示例1: initedit

void
initedit()
{
	editing = 1;

	if (!elc && histc) {
		elc = el_init(__progname, stdin, stdout, stderr);
		el_set(elc, EL_HIST, history, histc); /* use history */
		el_set(elc, EL_EDITOR, "emacs"); /* default type */
		el_set(elc, EL_PROMPT, cprompt); /* set the prompt
						  * function */
		el_set(elc, EL_ADDFN, "complt", "Command completion", complt_c);
		el_set(elc, EL_BIND, "\t", "complt", NULL);
		el_source(elc, NULL);	/* read ~/.editrc */
		el_set(elc, EL_SIGNAL, 1);
	}
	if (!eli && histi) {
		eli = el_init(__progname, stdin, stdout, stderr); /* again */
		el_set(eli, EL_HIST, history, histi);
		el_set(eli, EL_EDITOR, "emacs");
		el_set(eli, EL_PROMPT, iprompt);
		el_set(eli, EL_ADDFN, "complt", "Command completion", complt_i);
		el_set(eli, EL_BIND, "\t", "complt", NULL);
#ifdef notyet
		el_set(eli, EL_ADDFN, "exit", "Exit", NULL);
		el_set(eli, EL_BIND, "\026", "exit", NULL);
#endif
		el_source(eli, NULL);
		el_set(eli, EL_SIGNAL, 1);
	}
}
开发者ID:danrl,项目名称:nsh,代码行数:31,代码来源:complete.c

示例2: initialize_libedit

void initialize_libedit(const char *prog)
{
	/* Init the builtin history */
	hist = history_init();

	/* Remember 100 events */
#ifdef XDC_OLD_LIBEDIT
	history(hist, XDC_H_SETSIZE, 100);
#else
	history(hist, &ev, XDC_H_SETSIZE, 100);
#endif

	/* Initialize editline */
#ifdef XDC_OLD_LIBEDIT
	el = el_init(prog, stdin, stdout);
#else
	el = el_init(prog, stdin, stdout, stderr);
#endif

	el_set(el, EL_EDITOR, "emacs");    /* Default editor is emacs   */
	el_set(el, EL_SIGNAL, 1);          /* Handle signals gracefully */
	el_set(el, EL_PROMPT, get_prompt); /* Set the prompt function   */

	/* Tell editline to use this history interface */
	el_set(el, EL_HIST, history, hist);

	/*
	 * Source the user's defaults file.
	 */
	/* el_source(el, "xdebug"); */
}
开发者ID:s3rj1k,项目名称:php-5.2_wheezy,代码行数:31,代码来源:main.c

示例3: ntp_readline_init

/*
 * ntp_readline_init - setup, set or reset prompt string
 */
int
ntp_readline_init(
	const char *	prompt
	)
{
	int	success;

	success = 1;

	if (prompt) {
		if (lineedit_prompt) 
			free(lineedit_prompt);
		lineedit_prompt = estrdup(prompt);
	}

#ifdef LE_EDITLINE
	if (NULL == ntp_el) {

# if 4 == EL_INIT_ARGS
		ntp_el = el_init(progname, stdin, stdout, stderr);
# else
		ntp_el = el_init(progname, stdin, stdout);
# endif
		if (ntp_el) {

			el_set(ntp_el, EL_PROMPT, ntp_prompt_callback);
			el_set(ntp_el, EL_EDITOR, "emacs");

			ntp_hist = history_init();

			if (NULL == ntp_hist) {

				mfprintf(stderr, "history_init(): %m\n");
				fflush(stderr);

				el_end(ntp_el);
				ntp_el = NULL;

				success = 0;

			} else {
				ZERO(hev);
#ifdef H_SETSIZE
				history(ntp_hist, &hev, H_SETSIZE, 128);
#endif
				el_set(ntp_el, EL_HIST, history,
				       ntp_hist);
				/* use any .editrc */
				el_source(ntp_el, NULL);
			}
		} else
			success = 0;
	}
#endif	/* LE_EDITLINE */

	ntp_readline_initted = success;

	return success;
}
开发者ID:cemeyer,项目名称:freebsd-base-graphics,代码行数:62,代码来源:ntp_lineedit.c

示例4: cmdinit

void *
cmdinit(struct clit *cmds, int ncmds)
{
	struct clitenv *env;
	HistEvent ev;

	if ((env = malloc(sizeof(*env))) == NULL)
		err(1, "Can't init cmd interpreter.");

	env->cmds = cmds;
	env->ncmds = ncmds;

	env->hist = history_init();
	history(env->hist, &ev, H_SETSIZE, 100);

	env->el = el_init(__progname, stdin, stdout, stderr);

	el_set(env->el, EL_EDITOR, "emacs");
	el_set(env->el, EL_PROMPT, prompt);
	el_set(env->el, EL_HIST, history, env->hist);
	el_set(env->el, EL_ADDFN, "complt", "complete", complt);
	el_set(env->el, EL_BIND, "\t", "complt");
	el_source(env->el, NULL);

	/* XXX - EL_SIGNAL ? */

	return env;
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:28,代码来源:clit.c

示例5: history_init

static char *fetchline(void)
{
    static EditLine *el;
    static History *hist;
    HistEvent hevent;
    char *line;
    int count;

    if (!el) {
        hist = history_init();
        history(hist, &hevent, H_SETSIZE, 100);
        el = el_init(progname, stdin, stdout, stderr);
        el_source(el, NULL);
        el_set(el, EL_SIGNAL, 1);
        el_set(el, EL_PROMPT, el_get_prompt);
        el_set(el, EL_HIST, history, (const char *)hist);
    }
    line = strdup(el_gets(el, &count));
    if (line) {
        if (count > 0) {
            line[count-1] = '\0';
        }
        if (*line) {
            history(hist, &hevent, H_ENTER, line);
        }
    }
    return line;
}
开发者ID:jgottula,项目名称:qemu-vfio,代码行数:28,代码来源:qemu-io.c

示例6: acc_el_initialize

static int acc_el_initialize(void)
{
    HistEvent ev;

    if (el != NULL)
        el_end(el);
    if (el_hist != NULL)
        history_end(el_hist);

    el = el_init("accedian", stdin, stdout, stderr);
    el_set(el, EL_PROMPT, cli_prompt);

    el_set(el, EL_EDITMODE, 1);
    el_set(el, EL_EDITOR, "emacs");
    el_hist = history_init();
    if (!el || !el_hist)
        return -1;

    /* setup history with 100 entries */
    history(el_hist, &ev, H_SETSIZE, 100);
    el_set(el, EL_HIST, history, el_hist);

    el_set(el, EL_ADDFN, "ed-complete", "Complete argument", cli_complete);

    /* Bind <tab> to command completion */
    el_set(el, EL_BIND, "^I", "ed-complete", NULL);
    #if 0   // Ticket #8152 - This corrupts show_rc passwords containing question marks
    /* Bind ? to command completion */
    el_set(el, EL_BIND, "?", "ed-complete", NULL);
    #endif
    /* Bind ^D to redisplay */
    el_set(el, EL_BIND, "^D", "ed-redisplay", NULL);

    return 0;
}
开发者ID:thechinh,项目名称:play-with-code,代码行数:35,代码来源:cli.c

示例7: ntp_readline_init

/*
 * ntp_readline_init - setup, set or reset prompt string
 */
int
ntp_readline_init(
	const char *	prompt
	)
{
	int	success;

	success = 1;

	if (prompt) {
		if (lineedit_prompt) 
			free(lineedit_prompt);
		lineedit_prompt = estrdup(prompt);
	}

#ifdef LE_EDITLINE
	if (NULL == ntp_el) {

		ntp_el = el_init(progname, stdin, stdout, stderr);
		if (ntp_el) {

			el_set(ntp_el, EL_PROMPT, ntp_prompt_callback);
			el_set(ntp_el, EL_EDITOR, "emacs");

			ntp_hist = history_init();

			if (NULL == ntp_hist) {

				fprintf(stderr, "history_init(): %s\n",
						strerror(errno));
				fflush(stderr);

				el_end(ntp_el);
				ntp_el = NULL;

				success = 0;

			} else {
				memset(&hev, 0, sizeof hev);

				history(ntp_hist, &hev,	H_SETSIZE, 128);

				el_set(ntp_el, EL_HIST, history, ntp_hist);

				/* use any .editrc */
				el_source(ntp_el, NULL);
			}
		} else
			success = 0;
	}
#endif	/* LE_EDITLINE */

	ntp_readline_initted = success;

	return success;
}
开发者ID:ystk,项目名称:debian-ntp,代码行数:59,代码来源:ntp_lineedit.c

示例8: el_reset

/* This routine resets the interface. */
void el_reset(int unit)
{
	int s;

	dprintf(("elreset()\n"));
	s = splimp();
	el_stop(unit);
	el_init(unit);
	splx(s);
}
开发者ID:metacore,项目名称:spin,代码行数:11,代码来源:if_el.c

示例9: _history

EditLineReader::EditLineReader()
	: _history(history_init())
	, _editLine(el_init("ccons", stdin, stdout, stderr))
{
	reader = this;
	history(_history, &_event, H_SETSIZE, INT_MAX);
	el_set(_editLine, EL_PROMPT, ccons_prompt);
	el_set(_editLine, EL_EDITOR, "emacs");
	el_set(_editLine, EL_HIST, history, _history);
	el_set(_editLine, EL_ADDFN, "ccons-ac", "autocomplete", ccons_autocomplete);
	el_set(_editLine, EL_BIND, "^I", "ccons-ac", NULL);
}
开发者ID:asvitkine,项目名称:ccons,代码行数:12,代码来源:EditLineReader.cpp

示例10: readline

char *
readline(const char* prompt)
{
    static EditLine *e;
#ifdef H_SETSIZE
    HistEvent ev;
#endif
    int count;
    const char *str;

    if(e == NULL){
#ifdef EL_INIT_FOUR
	e = el_init("", stdin, stdout, stderr);
#else
	e = el_init("", stdin, stdout);
#endif
	el_set(e, EL_PROMPT, ret_prompt);
	h = history_init();
#ifdef H_SETSIZE
	history(h, &ev, H_SETSIZE, 25);
#else
	history(h, H_EVENT, 25);
#endif
	el_set(e, EL_HIST, history, h);
	el_set(e, EL_EDITOR, "emacs"); /* XXX? */
    }
    pr = prompt ? prompt : "";
    str = el_gets(e, &count);
    if (str && count > 0) {
	char *ret = strdup (str);

	if (ret == NULL)
	    return NULL;

	if (ret[strlen(ret) - 1] == '\n')
	    ret[strlen(ret) - 1] = '\0';
	return ret;
    }
    return NULL;
}
开发者ID:SimonWilkinson,项目名称:heimdal,代码行数:40,代码来源:edit_compat.c

示例11: mtranApi_ussrSetup

void mtranApi_ussrSetup(int portRC, int portEvent, char* host, void (*msgHandler)(char*, char, char)) {
  /*Initialize Message Handler*/
  mtranApi_msgHandler = msgHandler;

  /*Initialize command sender*/
  cs_init(portRC, host);
  cs_sendCommand_void("setup"); //initializes simulator

  /*Initialize event listener*/
  el_init(portEvent, host);
  el_installEvent("handleMessage", mtranApi_handleMessage);
  el_startEventListen();
}
开发者ID:DavidJohan,项目名称:Assemble-and-Animate,代码行数:13,代码来源:MTRANSocketApi.c

示例12: el

 EditLine::EditLine(std::string argv0, FILE* input, FILE* output,
         FILE* error) :
     el(el_init(argv0.c_str(), input, output, error)),
     mPromptCallback(0) {
     el_set(el, EL_EDITOR, "emacs");
     el_set(el, EL_SIGNAL, 1);
     el_set(el, EL_CLIENTDATA, this);
     el_set(el, EL_SETTY, "-d", "intr=^@", NULL);
     el_set(el, EL_SETTY, "-d", "eof=^@", NULL);
     el_set(el, EL_ADDFN, "cust-control-c", "", controlC);
     el_set(el, EL_BIND, "^C", "cust-control-c", NULL);
     el_set(el, EL_BIND, "^D", "ed-end-of-file", NULL);
 }
开发者ID:Symaxion,项目名称:seychelles,代码行数:13,代码来源:libedit.cpp

示例13: history_init

static EditLine *initEditLine()
{
    EditLine    *e;
    HistEvent   ev; 

    cmdHistory = history_init(); 
    history(cmdHistory, &ev, H_SETSIZE, 100); 
    e = el_init("ejs", stdin, stdout, stderr); 
    el_set(e, EL_EDITOR, "vi");
    el_set(e, EL_HIST, history, cmdHistory);
    el_source(e, NULL);
    return e;
}
开发者ID:satanupup,项目名称:appweb,代码行数:13,代码来源:ejs.c

示例14: el_init

CommandPrompt::CommandPrompt()
{
#ifdef ZORBA_HAVE_LIBEDIT_H
  theEditLine = el_init("xqdb", stdin, stdout, stderr);
  theHistory = history_init();
  HistEvent lHistoryEvent;
  history(theHistory, &lHistoryEvent, H_SETSIZE, 100);

  el_set(theEditLine, EL_PROMPT, prompt);

  el_set(theEditLine, EL_HIST, history, theHistory);
  el_set(theEditLine, EL_EDITOR, "emacs");
#endif
}
开发者ID:alyst,项目名称:zorba,代码行数:14,代码来源:command_prompt.cpp

示例15: main

int
main(int argc, char *argv[])
{
	HistEvent he;
	static EditLine *el;
	static History *hist;
	bool interactive;

	acting_as_client = 1;
	peer = -1;
	strcpy(mode, "netascii");
	signal(SIGINT, intr);

	interactive = isatty(STDIN_FILENO);
	if (interactive) {
		el = el_init("tftp", stdin, stdout, stderr);
		hist = history_init();
		history(hist, &he, H_SETSIZE, 100);
		el_set(el, EL_HIST, history, hist);
		el_set(el, EL_EDITOR, "emacs");
		el_set(el, EL_PROMPT, command_prompt);
		el_set(el, EL_SIGNAL, 1);
		el_source(el, NULL);
	}

	if (argc > 1) {
		if (setjmp(toplevel) != 0)
			exit(txrx_error);

		if (strncmp(argv[1], "tftp://", 7) == 0) {
			urihandling(argv[1]);
			exit(txrx_error);
		}

		setpeer(argc, argv);
	}

	if (setjmp(toplevel) != 0) {
		if (interactive)
			el_reset(el);
		(void)putchar('\n');
	}

	init_options();
	command(interactive, el, hist, &he);
}
开发者ID:derekmarcotte,项目名称:freebsd,代码行数:46,代码来源:main.c


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