Пример #1
0
/*
 * Move the cursor to start of prompt line before executing a command.
 * This looks nicer if the command takes a long time before
 * updating the screen.
 */
	static void
cmd_exec()
{
	clear_attn();
	clear_bot();
	flush();
}
Пример #2
0
/*
 * Set up the display to start a new toggle-option command.
 */
static void
mca_opt_toggle(void)
{
	int no_prompt;
	int flag;
	char *dash;

	no_prompt = (optflag & OPT_NO_PROMPT);
	flag = (optflag & ~OPT_NO_PROMPT);
	dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";

	mca = A_OPT_TOGGLE;
	clear_bot();
	clear_cmd();
	cmd_putstr(dash);
	if (optgetname)
		cmd_putstr(dash);
	if (no_prompt)
		cmd_putstr("(P)");
	switch (flag) {
	case OPT_UNSET:
		cmd_putstr("+");
		break;
	case OPT_SET:
		cmd_putstr("!");
		break;
	}
	set_mlist(NULL, 0);
}
Пример #3
0
/*
 * Set up the display to start a new search command.
 */
static void
mca_search(void)
{
	if (search_type & SRCH_FILTER)
		mca = A_FILTER;
	else if (search_type & SRCH_FORW)
		mca = A_F_SEARCH;
	else
		mca = A_B_SEARCH;

	clear_bot();
	clear_cmd();

	if (search_type & SRCH_NO_MATCH)
		cmd_putstr("Non-match ");
	if (search_type & SRCH_FIRST_FILE)
		cmd_putstr("First-file ");
	if (search_type & SRCH_PAST_EOF)
		cmd_putstr("EOF-ignore ");
	if (search_type & SRCH_NO_MOVE)
		cmd_putstr("Keep-pos ");
	if (search_type & SRCH_NO_REGEX)
		cmd_putstr("Regex-off ");

	if (search_type & SRCH_FILTER)
		cmd_putstr("&/");
	else if (search_type & SRCH_FORW)
		cmd_putstr("/");
	else
		cmd_putstr("?");
	set_mlist(ml_search, 0);
}
Пример #4
0
/*
 * Move the cursor to start of prompt line before executing a command.
 * This looks nicer if the command takes a long time before
 * updating the screen.
 */
	static void
cmd_exec()
{
#if HILITE_SEARCH
	clear_attn();
#endif
	clear_bot();
	flush();
}
Пример #5
0
/*
 * Set up the display to start a new multi-character command.
 */
static void
start_mca(int action, const char *prompt, void *mlist, int cmdflags)
{
	mca = action;
	clear_bot();
	clear_cmd();
	cmd_putstr((char *)prompt);
	set_mlist(mlist, cmdflags);
}
Пример #6
0
/*
 * Process any signals we have received.
 * A received signal cause a bit to be set in "sigs".
 */
void
psignals(void)
{
	int tsignals;

	if ((tsignals = sigs) == 0)
		return;
	sigs = 0;

	if (tsignals & S_STOP) {
		/*
		 * Clean up the terminal.
		 */
		lsignal(SIGTTOU, SIG_IGN);
		clear_bot();
		deinit();
		flush(0);
		raw_mode(0);
		lsignal(SIGTTOU, SIG_DFL);
		lsignal(SIGTSTP, SIG_DFL);
		kill(getpid(), SIGTSTP);
		/*
		 * ... Bye bye. ...
		 * Hopefully we'll be back later and resume here...
		 * Reset the terminal and arrange to repaint the
		 * screen when we get back to the main command loop.
		 */
		lsignal(SIGTSTP, stop);
		raw_mode(1);
		init();
		screen_trashed = 1;
		tsignals |= S_WINCH;
	}
	if (tsignals & S_WINCH) {
		int old_width, old_height;
		/*
		 * Re-execute scrsize() to read the new window size.
		 */
		old_width = sc_width;
		old_height = sc_height;
		get_term();
		if (sc_width != old_width || sc_height != old_height) {
			wscroll = (sc_height + 1) / 2;
			calc_jump_sline();
			calc_shift_count();
			screen_trashed = 1;
		}
	}
	if (tsignals & S_INTERRUPT) {
		ring_bell();
		if (quit_on_intr)
			quit(QUIT_INTERRUPT);
	}
}
Пример #7
0
/*
 * Display the appropriate prompt.
 */
static void
prompt(void)
{
	const char *p;

	if (ungot != NULL) {
		/*
		 * No prompt necessary if commands are from
		 * ungotten chars rather than from the user.
		 */
		return;
	}

	/*
	 * Make sure the screen is displayed.
	 */
	make_display();
	bottompos = position(BOTTOM_PLUS_ONE);

	/*
	 * If we've hit EOF on the last file and the -E flag is set, quit.
	 */
	if (get_quit_at_eof() == OPT_ONPLUS &&
	    eof_displayed() && !(ch_getflags() & CH_HELPFILE) &&
	    next_ifile(curr_ifile) == NULL_IFILE)
		quit(QUIT_OK);

	/*
	 * If the entire file is displayed and the -F flag is set, quit.
	 */
	if (quit_if_one_screen &&
	    entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) &&
	    next_ifile(curr_ifile) == NULL_IFILE)
		quit(QUIT_OK);

	/*
	 * Select the proper prompt and display it.
	 */
	/*
	 * If the previous action was a forward movement,
	 * don't clear the bottom line of the display;
	 * just print the prompt since the forward movement guarantees
	 * that we're in the right position to display the prompt.
	 * Clearing the line could cause a problem: for example, if the last
	 * line displayed ended at the right screen edge without a newline,
	 * then clearing would clear the last displayed line rather than
	 * the prompt line.
	 */
	if (!forw_prompt)
		clear_bot();
	clear_cmd();
	forw_prompt = 0;
	p = prompt_string();
	if (is_filtering())
		putstr("& ");
	if (p == NULL || *p == '\0') {
		putchr(':');
	} else {
		at_enter(AT_STANDOUT);
		putstr(p);
		at_exit();
	}
	clear_eol();
}