• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ show_prompt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

int main(int argc,char** argv,char** envp) {
	char cmd[size];
	char* ret;
	int sys_ret;
	show_prompt();
	ret=fgets(cmd,size,stdin);
	if(ret==NULL) {
		perror("problem with fgets");
		return EXIT_FAILURE;
	}
	while(!feof(stdin)) {
		sys_ret=system(cmd);
		if(sys_ret==-1) {
			perror("problem with system(3)");
			return EXIT_FAILURE;
		}
		show_prompt();
		ret=fgets(cmd,size,stdin);
		if(ret==NULL) {
			perror("problem with fgets");
			return EXIT_FAILURE;
		}
	}
	return EXIT_SUCCESS;
}
开发者ID:veltzer,项目名称:demos-shell,代码行数:25,代码来源:cshell.c


示例2: main

/*
 * Function: main
 * Returns: exit status of the program
 * Description: The main controller of the whole program,
 * connects with other functions and accomplishes the given task.
 */
int main() {
	sig_t signal_return = signal(SIGINT, interrupt_handler);
	assert(signal_return != SIG_ERR);
	signal_return = signal(SIGTSTP, interrupt_handler);
	assert(signal_return != SIG_ERR);

	show_prompt();
	char buffer[BUFFER_SIZE], *shell_args[ARGS_SUPPORTED + 1];
	while (fgets(buffer, BUFFER_SIZE, stdin)) {
		// If read input contains only newline/ is empty, do nothing and show prompt
		// else if the last character is newline, replace it with null terminator. Doing so
		// will help while splitting the read line.
		if (buffer[0] == '\n' || is_empty(buffer)) {
			show_prompt();
			continue;
		} else if (buffer[strlen(buffer) - 1] == '\n') {
			buffer[strlen(buffer) - 1] = 0;
		}
		split_string(buffer, shell_args);
		if (!strcmp(shell_args[0], EXIT_COMMAND[0])
				|| !strcmp(shell_args[0], EXIT_COMMAND[1])) {
			exit(EXIT_SUCCESS);
		}
		execute_command(shell_args);
		show_prompt();
	}
	return EXIT_SUCCESS;
}
开发者ID:sandeep-tr,项目名称:Operating-System-Components,代码行数:34,代码来源:MavShell.c


示例3: main

int					main(int ac, char **av, char **env)
{
	char	*line2;
	t_e		e;

	(void)ac;
	(void)av;
	e.list = ft_env_cpy(env);
	signal(SIGQUIT, ft_signal);
	show_prompt(e.list);
	while (get_next_line(0, &(e.line)) == 1)
	{
		line2 = exange_tab_or_space(e.line);
		e.args = ft_strsplit(line2, ' ');
		if (e.args && e.args[0])
		{
			if (ft_strchr(e.args[0], '/'))
				exec_absolu(e.line, e.list);
			else
				do_command(&(e.list), e.line);
		}
		free(e.line);
		show_prompt(e.list);
		free_char_array(e.args);
	}
	ft_putchar('\n');
	return (0);
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:28,代码来源:ft_sh1.c


示例4: main

int			main(void)
{
	char	*line;
	char	*line2;
	t_list	*list;
	char	**args;

	list = ft_env_cpy();
	signal(SIGINT, ft_signal);
	show_prompt(list);
	while (get_next_line(0, &line) == 1)
	{
		line2 = exchange_tab_for_space(line);
		args = ft_strsplit(line2, ' ');
		if (args && args[0])
		{
			if (ft_strchr(args[0], '/'))
				exec_absolu(line, list);
			else
				do_command(&list, line);
		}
		free(line);
		show_prompt(list);
		free_char_array(args);
	}
	ft_putchar('\n');
	return (0);
}
开发者ID:bensisko69,项目名称:42,代码行数:28,代码来源:ft_sh2.c


示例5: run

void run (callback_t h)
{
	show_prompt ();
	running = true;
	handler = h;
	while (running) _process_byte ();
}
开发者ID:gitter-badger,项目名称:min_raw_osd,代码行数:7,代码来源:console.cpp


示例6: reset

	/**
	 * Perform the user interface function of editing a program buffer.
	 * @param program The base pointer to the buffer text to edit.
	 * Never returns.
	 */
	void CVue::interpret()
	{
	    if ( !m_running )
	    {
	        reset();
            do_new();
            for(;;)
            {
            	CARIBOU::CString output;
                show_prompt();
                read_line();
                if ( compile(output) )
				{
					m_command = output;
					if (m_command.toInt())
					{
						inherited::reset();
						place();
					}
					else
					{
						m_running = true;
						inherited::reset();
						do_line();
						m_running=false;
					}
				}
            }
	    }
	    inherited::interpret();
	}
开发者ID:8bitgeek,项目名称:caribou-rtos,代码行数:36,代码来源:cvue.cpp


示例7: _process_byte

void _process_byte ()
{
	uint16_t data = CONSOLE_UART::receive ();
	if (data & 0xff00) return;
	uint8_t byte = data & 0xff;
	switch (byte)
	{
		case KEY_ENTER:
			if (_command_len)
			{
				_command [_command_len] = 0;
				eol ();
				if (handler) handler (_command);
			}
			show_prompt ();
			return;
		case KEY_DEL:
		case KEY_BS:
			if (!_command_len) return;
			_command_len --;
			CONSOLE_UART::send_string_p (PSTR ("\x08 \x08"));
			return;
		default:
			if (byte < 0x20 || _command_len == CONSOLE_MAX_CMD_LENGTH - 1)
			{
				CONSOLE_UART::send (0x07);
				return;
			}
			_command [_command_len ++] = byte;
			CONSOLE_UART::send (byte);
	}
	return;
}
开发者ID:gitter-badger,项目名称:min_raw_osd,代码行数:33,代码来源:console.cpp


示例8: interact

SchObj interact()
{
    SchPort* port;
    show_prompt();
    port = (SchPort*)make_input_port_stream(stdin);
    return read_obj( port );
}
开发者ID:hellcoderz,项目名称:MameScheme,代码行数:7,代码来源:read.c


示例9: render_ui

static void render_ui(ui_t *ui) {
  chat_tab = COLS-12;
  log_tab = COLS-6;
  render_tab_bar(ACTIVE_CHAT);

  ui->screen = newwin(LINES - 6, COLS - 1, 1, 1);
  scrollok(ui->screen, TRUE);
  box(ui->screen, 0, 0);
  ui->next_line = 1;
  CHAT = new_panel(ui->screen);
  chat_history = ui_history_create();

  ui->log = newwin(LINES - 6, COLS - 1, 1, 1);
  scrollok(ui->log, TRUE);
  box(ui->log, 0, 0);
  ui->next_log_line = 1;
  LOG = new_panel(ui->log);
  log_history = ui_history_create();

  ui->alert = newwin(3, COLS, 1, 0);
  ALERT = new_panel(ui->alert);

  set_panel_userptr(CHAT, LOG);
  set_panel_userptr(LOG, ALERT);
  set_panel_userptr(ALERT, CHAT);

  top_panel(CHAT);
  hide_panel(LOG);
  hide_panel(ALERT);
  update_panels();
  doupdate();

  ui->prompt = newwin(4, COLS - 1, LINES - 5, 1);
  show_prompt(ui, NULL);
}
开发者ID:draganglumac,项目名称:whisper-shell,代码行数:35,代码来源:ui.c


示例10: buddy_unaway

/* PROTO */
void
buddy_unaway(void *c, const char *who)
{
	struct BuddyList *trav;
	char           *sn = simplify_sn(who);

	trav = buddylist;

	while (trav != NULL) {
		if (strcmp(sn, trav->sn) == 0) {
			trav->away = 0;
			break;
		}
		trav = trav->next;
	}

	free(sn);

	if (conn->squelchaway)
		return;

	eraseline();
	b_echostr();

	if (conn->timestamps) {
		putchar(' ');
		addts();
	}
	set_color(COLOR_BUDDY_AWAY);
	printf(" %s ", who);
	set_color(0);
	printf("is no longer away.\n");
	show_prompt();
	return;
}
开发者ID:esseye,项目名称:bsflite-otr,代码行数:36,代码来源:aim.c


示例11: show_prompt

void parser_imp::sync_command() {
    // Keep consuming tokens until we find a Command or End-of-file
    show_prompt();
    while (curr() != scanner::token::CommandId && curr() != scanner::token::Eof && curr() != scanner::token::Period)
        next();
    if (curr_is_period())
        next();
}
开发者ID:Paradoxika,项目名称:lean,代码行数:8,代码来源:parser_imp.cpp


示例12: sj_prompt_init

void sj_prompt_init(struct v7 *v7) {
  memset(&s_sjp, 0, sizeof(s_sjp));

  /* TODO(alashkin): load cfg from flash */
  s_sjp.v7 = v7;

  retarget_putc('\n');
  show_prompt();
}
开发者ID:WayenWeng,项目名称:CodeLite_for_RePhone,代码行数:9,代码来源:sj_prompt.c


示例13: buddy_idle

/* PROTO */
void
buddy_idle(void *c, const char *who, long idletime)
{
	struct BuddyList *trav;
	int             changed = 1;
	char           *sn = simplify_sn(who);

	trav = buddylist;

	while (trav != NULL) {
		if (strcmp(trav->sn, sn) == 0) {
			trav->idletime = idletime;

			if (idletime >= 10) {
				if (trav->idle)
					changed = 0;
				trav->idle = 1;
			} else {
				if (trav->idle == 0)
					changed = 0;
				trav->idle = 0;
			}
			break;
		}
		trav = trav->next;
	}

	free(sn);

	/*
         * in case for whatever reason the buddy isn't in the list (shouldn't
         * happen)
         */
	if (trav == NULL) {
		return;
	}
	if (!changed) {
		return;
	}
	if (conn->squelchidle)
		return;

	eraseline();
	b_echostr();

	if (conn->timestamps) {
		putchar(' ');
		addts();
	}
	set_color(COLOR_BUDDY_IDLE);
	printf(" %s ", who);
	set_color(0);

	printf("is %s idle.\n", (trav->idle ? "now" : "no longer"));
	show_prompt();
	return;
}
开发者ID:esseye,项目名称:bsflite-otr,代码行数:58,代码来源:aim.c


示例14: ft_signal

static void	ft_signal(int sig)
{
	t_list	*list;

	(void)sig;
	list = ft(NULL);
	ft_putchar('\n');
	show_prompt(list);
}
开发者ID:bensisko69,项目名称:42,代码行数:9,代码来源:ft_sh2.c


示例15: sj_prompt_init

void sj_prompt_init(struct v7 *v7) {
  memset(&s_sjp, 0, sizeof(s_sjp));

  /* TODO(alashkin): load cfg from flash */
  s_sjp.v7 = v7;

  printf("\n");
  show_prompt();
}
开发者ID:alvarlaigna,项目名称:smart.js,代码行数:9,代码来源:sj_prompt.c


示例16: sj_prompt_process_char

void sj_prompt_process_char(char ch) {
  if (s_sjp.pos >= RX_BUFSIZE - 1) {
    printf("\nCommand buffer overflow.\n");
    s_sjp.pos = 0;
    show_prompt();
  }
  s_sjp.buf[s_sjp.pos++] = ch;
  s_sjp.buf[s_sjp.pos] = '\0';
  s_sjp.char_processor(ch);
}
开发者ID:alvarlaigna,项目名称:smart.js,代码行数:10,代码来源:sj_prompt.c


示例17: ft_signal

static void			ft_signal(int sig)
{
	t_list	*list;

	if (sig == 3)
		exit(0);
	list = ft(NULL);
	ft_putchar('\n');
	show_prompt(list);
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:10,代码来源:ft_sh1.c


示例18: process_command

static void process_command(char *cmd) {
  if (*cmd == ':') {
    int i;
    for (i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++) {
      if (strncmp(cmd + 1, cmds[i].command, strlen(cmds[i].command)) == 0) {
        cmds[i].proc(0, 0, cmds[i].param);
        break;
      }
    }
    if (i == sizeof(cmds) / sizeof(cmds[0])) {
      printf("Unknown command, type :help for the list of commands\n");
    }
    if (s_sjp.char_processor == process_prompt_char) show_prompt();
  } else {
    /* skip empty commands */
    if (*cmd) process_js(cmd);
    show_prompt();
  }
}
开发者ID:alvarlaigna,项目名称:smart.js,代码行数:19,代码来源:sj_prompt.c


示例19: process_here_char

static void process_here_char(char ch) {
  printf("%c", ch);

  if (s_sjp.pos >= 7 &&
      strncmp(&s_sjp.buf[s_sjp.pos - 7], "\r\nEOF\r\n", 7) == 0 ||
      s_sjp.pos >= 5 &&
      (strncmp(&s_sjp.buf[s_sjp.pos - 5], "\nEOF\n", 5) == 0 ||
       strncmp(&s_sjp.buf[s_sjp.pos - 5], "\rEOF\r", 5) == 0)) {
    int end_pos = s_sjp.pos - (s_sjp.buf[s_sjp.pos - 2] == '\r' ? 7 : 5);
    s_sjp.buf[end_pos] = '\0';
    printf("\n");
    process_js(s_sjp.buf);
    show_prompt();
  } else {
    if (s_sjp.pos >= RX_BUFSIZE) {
      printf("Input too long\n");
      show_prompt();
    }
  }
}
开发者ID:alvarlaigna,项目名称:smart.js,代码行数:20,代码来源:sj_prompt.c


示例20: main_loop

/**
 * void main_loop(FILE *stream, int interactive)
 *
 * Reads, tokenises, parses ane executes input from the given stream. If
 * interactive mode is on, outputs a welcome message and a prompt.
 */
void main_loop(FILE *stream, int interactive) {
	char buffer[BUFFER_MAX_SIZE];
	char last_line[BUFFER_MAX_SIZE];
	int more_to_read = TRUE;
	tokarray_t *tokens;
	expression_t *expr;
	
	bzero(buffer, BUFFER_MAX_SIZE);
	bzero(last_line, BUFFER_MAX_SIZE);
	
	if (interactive == TRUE) {
		show_welcome();
	}
	
	while (more_to_read == TRUE) {
		if (interactive == TRUE) {
			show_prompt();
		}
		
		/* Read a line of input. */
		more_to_read = read_data(stream, buffer, BUFFER_MAX_SIZE);
		
		if (strlen(buffer) == 0) {
			continue;
		}
		
		strcpy(last_line, buffer);
		
		/* Tokenise the input. */
		tokens = tokenise_input(buffer);
		
		if (tokens == NULL) {
			printf("!tmnsh: Could not tokenise input: %s\n", last_line);
			continue;
		}
		
		/* Parse the tokens into an expression. */
		expr = parse_tokens(tokens);
		
		if (expr == NULL) {
			printf("!tmnsh: Could not parse input: %s\n", last_line);
			tokarray_destroy(tokens); /* Clean up. */
			continue;
		}
		
		/* Interpret the expression and execute the commands. */
		interpret_expression(expr);
		
		expression_destroy(expr); /* Clean up. */
		bzero(buffer, BUFFER_MAX_SIZE);
		bzero(last_line, BUFFER_MAX_SIZE);
	}
}
开发者ID:ecdavis,项目名称:tmnsh,代码行数:59,代码来源:tmnsh.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ show_registers函数代码示例发布时间:2022-05-30
下一篇:
C++ show_progress函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap