3 * Copyright (C) 1984-2017 Mark Nudelman
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Less License, as specified in the README file.
8 * For more information, see the README file.
13 * User-level command processor.
17 #if MSDOS_COMPILER==WIN32C
24 extern int erase_char, erase2_char, kill_char;
26 extern int quit_if_one_screen;
32 extern int jump_sline;
35 extern int top_scroll;
36 extern int ignore_eoi;
41 extern int less_is_more;
42 extern int status_col;
43 extern POSITION highest_hilite;
44 extern POSITION start_attnpos;
45 extern POSITION end_attnpos;
46 extern char *every_first_cmd;
47 extern char version[];
48 extern struct scrpos initial_scrpos;
49 extern IFILE curr_ifile;
50 extern void *ml_search;
51 extern void *ml_examine;
52 #if SHELL_ESCAPE || PIPEC
53 extern void *ml_shell;
57 extern char *editproto;
59 extern int screen_trashed; /* The screen has been overwritten */
60 extern int shift_count;
62 extern int forw_prompt;
65 static char *shellcmd = NULL; /* For holding last shell command for "!!" */
67 static int mca; /* The multicharacter command (action) */
68 static int search_type; /* The previous type of search */
69 static LINENUM number; /* The number typed by the user */
70 static long fraction; /* The fractional part of the number */
71 static struct loption *curropt;
74 static int optgetname;
75 static POSITION bottompos;
76 static int save_hshift;
77 static int save_bs_mode;
82 /* Stack of ungotten chars (via ungetcc) */
84 struct ungot *ug_next;
87 static struct ungot* ungot = NULL;
89 static void multi_search();
92 * Move the cursor to start of prompt line before executing a command.
93 * This looks nicer if the command takes a long time before
94 * updating the screen.
105 * Set up the display to start a new multi-character command.
108 start_mca(action, prompt, mlist, cmdflags)
110 constant char *prompt;
118 set_mlist(mlist, cmdflags);
124 return (mca != 0 && mca != A_PREFIX);
128 * Set up the display to start a new search command.
134 if (search_type & SRCH_FILTER)
138 if (search_type & SRCH_FORW)
146 if (search_type & SRCH_NO_MATCH)
147 cmd_putstr("Non-match ");
148 if (search_type & SRCH_FIRST_FILE)
149 cmd_putstr("First-file ");
150 if (search_type & SRCH_PAST_EOF)
151 cmd_putstr("EOF-ignore ");
152 if (search_type & SRCH_NO_MOVE)
153 cmd_putstr("Keep-pos ");
154 if (search_type & SRCH_NO_REGEX)
155 cmd_putstr("Regex-off ");
158 if (search_type & SRCH_FILTER)
162 if (search_type & SRCH_FORW)
167 set_mlist(ml_search, 0);
171 * Set up the display to start a new toggle-option command.
180 no_prompt = (optflag & OPT_NO_PROMPT);
181 flag = (optflag & ~OPT_NO_PROMPT);
182 dash = (flag == OPT_NO_TOGGLE) ? "_" : "-";
206 * Execute a multicharacter command.
220 multi_search(cbuf, (int) number, 0);
224 search_type ^= SRCH_NO_MATCH;
225 set_filter_pattern(cbuf, search_type);
230 * Skip leading spaces or + signs in the string.
232 while (*cbuf == '+' || *cbuf == ' ')
234 if (every_first_cmd != NULL)
235 free(every_first_cmd);
237 every_first_cmd = NULL;
239 every_first_cmd = save(cbuf);
242 toggle_option(curropt, opt_lower, cbuf, optflag);
246 match_brac(cbuf[0], cbuf[1], 1, (int) number);
249 match_brac(cbuf[1], cbuf[0], 0, (int) number);
257 /* If tag structure is loaded then clean it up. */
265 * !! just uses whatever is in shellcmd.
266 * Otherwise, copy cmdbuf to shellcmd,
267 * expanding any special characters ("%" or "#").
271 if (shellcmd != NULL)
273 shellcmd = fexpand(cbuf);
278 if (shellcmd == NULL)
279 lsystem("", "!done");
281 lsystem(shellcmd, "!done");
288 (void) pipe_mark(pipec, cbuf);
289 error("|done", NULL_PARG);
296 * Is a character an erase or kill char?
302 return (c == erase_char || c == erase2_char || c == kill_char);
306 * Is a character a carriage return or newline?
312 return (c == '\n' || c == '\r');
316 * Handle the first char of an option (after the initial dash).
319 mca_opt_first_char(c)
322 int flag = (optflag & ~OPT_NO_PROMPT);
323 if (flag == OPT_NO_TOGGLE)
328 /* "__" = long option name. */
339 optflag = (flag == OPT_UNSET) ?
340 OPT_TOGGLE : OPT_UNSET;
345 optflag = (flag == OPT_SET) ?
346 OPT_TOGGLE : OPT_SET;
350 optflag ^= OPT_NO_PROMPT;
354 /* "--" = long option name. */
360 /* Char was not handled here. */
365 * Add a char to a long option name.
366 * See if we've got a match for an option name yet.
367 * If so, display the complete name and stop
368 * accepting chars until user hits RETURN.
371 mca_opt_nonfirst_char(c)
380 * Already have a match for the name.
381 * Don't accept anything but erase/kill.
383 if (is_erase_char(c))
388 * Add char to cmd buffer and try to match
391 if (cmd_char(c) == CC_QUIT)
394 opt_lower = ASCII_IS_LOWER(p[0]);
395 curropt = findopt_name(&p, &oname, NULL);
400 * Remember the option and
401 * display the full option name.
405 for (p = oname; *p != '\0'; p++)
408 if (!opt_lower && ASCII_IS_LOWER(c))
409 c = ASCII_TO_UPPER(c);
410 if (cmd_char(c) != CC_OK)
418 * Handle a char of an option toggle command.
427 * This may be a short option (single char),
428 * or one char of a long option name,
429 * or one char of the option parameter.
431 if (curropt == NULL && len_cmdbuf() == 0)
433 int ret = mca_opt_first_char(c);
439 /* We're getting a long option name. */
440 if (!is_newline_char(c))
441 return (mca_opt_nonfirst_char(c));
444 parg.p_string = get_cmdbuf();
445 error("There is no --%s option", &parg);
452 if (is_erase_char(c))
455 /* We're getting the option parameter. */
457 curropt = findopt(c);
460 parg.p_string = propt(c);
461 error("There is no %s option", &parg);
466 * If the option which was entered does not take a
467 * parameter, toggle the option immediately,
468 * so user doesn't have to hit RETURN.
470 if ((optflag & ~OPT_NO_PROMPT) != OPT_TOGGLE ||
471 !opt_has_param(curropt))
473 toggle_option(curropt, ASCII_IS_LOWER(c), "", optflag);
477 * Display a prompt appropriate for the option parameter.
479 start_mca(A_OPT_TOGGLE, opt_prompt(curropt), (void*)NULL, 0);
484 * Handle a char of a search command.
493 * Certain characters as the first char of
494 * the pattern have special meaning:
495 * ! Toggle the NO_MATCH flag
496 * * Toggle the PAST_EOF flag
497 * @ Toggle the FIRST_FILE flag
499 if (len_cmdbuf() > 0)
507 case CONTROL('E'): /* ignore END of file */
509 flag = SRCH_PAST_EOF;
514 case CONTROL('F'): /* FIRST file */
516 flag = SRCH_FIRST_FILE;
518 case CONTROL('K'): /* KEEP position */
522 case CONTROL('R'): /* Don't use REGULAR EXPRESSIONS */
523 flag = SRCH_NO_REGEX;
525 case CONTROL('N'): /* NOT match */
527 flag = SRCH_NO_MATCH;
541 * Handle a character of a multi-character command.
553 * We're not in a multicharacter command.
559 * In the prefix of a command.
560 * This not considered a multichar command
561 * (even tho it uses cmdbuf, etc.).
562 * It is handled in the commands() switch.
568 * Entering digits of a number.
569 * Terminated by a non-digit.
571 if (!((c >= '0' && c <= '9') || c == '.') &&
572 editchar(c, EC_PEEK|EC_NOHISTORY|EC_NOCOMPLETE|EC_NORIGHTLEFT) == A_INVALID)
575 * Not part of the number.
576 * End the number and treat this char
577 * as a normal command character.
579 number = cmd_int(&fraction);
587 ret = mca_opt_char(c);
595 ret = mca_search_char(c);
601 /* Other multicharacter command. */
606 * The multichar command is terminated by a newline.
608 if (is_newline_char(c))
611 * Execute the command.
618 * Append the char to the command buffer.
620 if (cmd_char(c) == CC_QUIT)
622 * Abort the multi-char command.
626 if ((mca == A_F_BRACKET || mca == A_B_BRACKET) && len_cmdbuf() >= 2)
629 * Special case for the bracket-matching commands.
630 * Execute the command after getting exactly two
631 * characters from the user.
638 * Need another character.
644 * Discard any buffered file data.
649 if (!(ch_getflags() & CH_CANSEEK))
659 * Make sure the screen is displayed.
665 * If nothing is displayed yet, display starting from initial_scrpos.
669 if (initial_scrpos.pos == NULL_POSITION)
671 * {{ Maybe this should be:
672 * jump_loc(ch_zero(), jump_sline);
673 * but this behavior seems rather unexpected
674 * on the first screen. }}
676 jump_loc(ch_zero(), 1);
678 jump_loc(initial_scrpos.pos, initial_scrpos.ln);
679 } else if (screen_trashed)
681 int save_top_scroll = top_scroll;
682 int save_ignore_eoi = ignore_eoi;
685 if (screen_trashed == 2)
687 /* Special case used by ignore_eoi: re-open the input file
688 * and jump to the end of the file. */
693 top_scroll = save_top_scroll;
694 ignore_eoi = save_ignore_eoi;
699 * Display the appropriate prompt.
706 if (ungot != NULL && ungot->ug_char != CHAR_END_COMMAND)
709 * No prompt necessary if commands are from
710 * ungotten chars rather than from the user.
716 * Make sure the screen is displayed.
719 bottompos = position(BOTTOM_PLUS_ONE);
722 * If we've hit EOF on the last file and the -E flag is set, quit.
724 if (get_quit_at_eof() == OPT_ONPLUS &&
725 eof_displayed() && !(ch_getflags() & CH_HELPFILE) &&
726 next_ifile(curr_ifile) == NULL_IFILE)
730 * If the entire file is displayed and the -F flag is set, quit.
732 if (quit_if_one_screen &&
733 entire_file_displayed() && !(ch_getflags() & CH_HELPFILE) &&
734 next_ifile(curr_ifile) == NULL_IFILE)
737 #if MSDOS_COMPILER==WIN32C
739 * In Win32, display the file name in the window title.
741 if (!(ch_getflags() & CH_HELPFILE))
742 SetConsoleTitle(pr_expand("Less?f - %f.", 0));
745 * Select the proper prompt and display it.
748 * If the previous action was a forward movement,
749 * don't clear the bottom line of the display;
750 * just print the prompt since the forward movement guarantees
751 * that we're in the right position to display the prompt.
752 * Clearing the line could cause a problem: for example, if the last
753 * line displayed ended at the right screen edge without a newline,
754 * then clearing would clear the last displayed line rather than
764 if (p == NULL || *p == '\0')
768 at_enter(AT_STANDOUT);
776 * Display the less version message.
783 parg.p_string = version;
784 error("less %s", &parg);
788 * Return a character to complete a partial command, if possible.
796 /* We have a number but no command. Treat as #g. */
800 /* We have "/string" but no newline. Add the \n. */
803 /* Some other incomplete command. Let user complete it. */
809 * Get command character.
810 * The character normally comes from the keyboard,
811 * but may come from ungotten characters
812 * (characters previously given to ungetcc or ungetsc).
820 /* Normal case: no ungotten chars.
821 * Get char from the user. */
825 /* Ungotten chars available:
826 * Take the top of stack (most recent). */
827 struct ungot *ug = ungot;
832 if (c == CHAR_END_COMMAND)
833 c = getcc_end_command();
839 * Get a command character, but if we receive the orig sequence,
840 * convert it to the repl sequence.
843 getcc_repl(orig, repl, gr_getc, gr_ungetc)
846 LWCHAR (*gr_getc)(VOID_PARAM);
847 void (*gr_ungetc)(LWCHAR);
854 if (orig == NULL || orig[0] == '\0')
859 if (c != orig[ki] || ki >= sizeof(keys)-1)
861 /* This is not orig we have been receiving.
862 * If we have stashed chars in keys[],
863 * unget them and return the first one. */
865 (*gr_ungetc)(keys[ki--]);
868 if (orig[++ki] == '\0')
870 /* We've received the full orig sequence.
871 * Return the repl sequence. */
874 (*gr_ungetc)(repl[ki--]);
877 /* We've received a partial orig sequence (ki chars of it).
878 * Get next char and see if it continues to match orig. */
884 * Get command character.
889 /* Replace kent (keypad Enter) with a newline. */
890 return getcc_repl(kent, "\n", getccu, ungetcc);
894 * "Unget" a command character.
895 * The next getcc() will return this character.
901 struct ungot *ug = (struct ungot *) ecalloc(1, sizeof(struct ungot));
909 * Unget a whole string of command characters.
910 * The next sequence of getcc()'s will return this string.
918 for (p = s + strlen(s) - 1; p >= s; p--)
923 * Peek the next command character, without consuming it.
934 * Search for a pattern, possibly in multiple files.
935 * If SRCH_FIRST_FILE is set, begin searching at the first file.
936 * If SRCH_PAST_EOF is set, continue the search thru multiple files.
939 multi_search(pattern, n, silent)
949 save_ifile = save_curr_ifile();
951 if (search_type & SRCH_FIRST_FILE)
954 * Start at the first (or last) file
955 * in the command line list.
957 if (search_type & SRCH_FORW)
958 nomore = edit_first();
960 nomore = edit_last();
963 unsave_ifile(save_ifile);
967 search_type &= ~SRCH_FIRST_FILE;
972 n = search(search_type, pattern, n);
974 * The SRCH_NO_MOVE flag doesn't "stick": it gets cleared
975 * after being used once. This allows "n" to work after
976 * using a /@@ search.
978 search_type &= ~SRCH_NO_MOVE;
984 unsave_ifile(save_ifile);
990 * Some kind of error in the search.
991 * Error message has been printed by search().
995 if ((search_type & SRCH_PAST_EOF) == 0)
997 * We didn't find a match, but we're
998 * supposed to search only one file.
1002 * Move on to the next file.
1004 if (search_type & SRCH_FORW)
1005 nomore = edit_next(1);
1007 nomore = edit_prev(1);
1015 * Print an error message if we haven't already.
1017 if (n > 0 && !silent)
1018 error("Pattern not found", NULL_PARG);
1023 * Restore the file we were originally viewing.
1025 reedit_ifile(save_ifile);
1028 unsave_ifile(save_ifile);
1033 * Forward forever, or until a highlighted line appears.
1036 forw_loop(until_hilite)
1041 if (ch_getflags() & CH_HELPFILE)
1042 return (A_NOACTION);
1045 jump_forw_buffered();
1046 curr_len = ch_length();
1047 highest_hilite = until_hilite ? curr_len : NULL_POSITION;
1051 if (until_hilite && highest_hilite > curr_len)
1063 * This gets us back in "F mode" after processing
1064 * a non-abort signal (e.g. window-change).
1066 if (sigs && !ABORT_SIGS())
1067 return (until_hilite ? A_F_UNTIL_HILITE : A_F_FOREVER);
1069 return (A_NOACTION);
1073 * Main command processor.
1074 * Accept and execute commands until a quit command.
1083 int save_search_type;
1091 search_type = SRCH_FORW;
1092 wscroll = (sc_height + 1) / 2;
1093 newaction = A_NOACTION;
1103 * See if any signals need processing.
1109 quit(QUIT_SAVED_STATUS);
1113 * See if window size changed, for systems that don't
1114 * generate SIGWINCH.
1119 * Display prompt and accept a character.
1125 if (newaction == A_NOACTION)
1132 if (newaction != A_NOACTION)
1135 newaction = A_NOACTION;
1139 * If we are in a multicharacter command, call mca_char.
1140 * Otherwise we call fcmd_decode to determine the
1141 * action to be performed.
1144 switch (mca_char(c))
1148 * Need another character.
1154 * Command has been handled by mca_char.
1155 * Start clean with a prompt.
1160 * Not a multi-char command
1161 * (at least, not anymore).
1167 * Decode the command character and decide what to do.
1172 * We're in a multichar command.
1173 * Add the character to the command buffer
1174 * and display it on the screen.
1175 * If the user backspaces past the start
1176 * of the line, abort the command.
1178 if (cmd_char(c) == CC_QUIT || len_cmdbuf() == 0)
1180 cbuf = get_cmdbuf();
1184 * Don't use cmd_char if we're starting fresh
1185 * at the beginning of a command, because we
1186 * don't want to echo the command until we know
1187 * it is a multichar command. We also don't
1188 * want erase_char/kill_char to be treated
1189 * as line editing characters.
1196 action = fcmd_decode(cbuf, &extra);
1198 * If an "extra" string was returned,
1199 * process it as a string of command characters.
1205 * Clear the cmdbuf string.
1206 * (But not if we're in the prefix of a command,
1207 * because the partial command string is kept there.)
1209 if (action != A_PREFIX)
1216 * First digit of a number.
1218 start_mca(A_DIGIT, ":", (void*)NULL, CF_QUIT_ON_ERASE);
1223 * Forward one window (and set the window size).
1226 swindow = (int) number;
1230 * Forward one screen.
1233 number = get_swindow();
1236 set_attnpos(bottompos);
1237 forward((int) number, 0, 1);
1242 * Backward one window (and set the window size).
1245 swindow = (int) number;
1249 * Backward one screen.
1252 number = get_swindow();
1254 backward((int) number, 0, 1);
1259 * Forward N (default 1) line.
1264 if (show_attn == OPT_ONPLUS && number > 1)
1265 set_attnpos(bottompos);
1266 forward((int) number, 0, 0);
1271 * Backward N (default 1) line.
1276 backward((int) number, 0, 0);
1281 * Force forward N (default 1) line.
1286 if (show_attn == OPT_ONPLUS && number > 1)
1287 set_attnpos(bottompos);
1288 forward((int) number, 1, 0);
1293 * Force backward N (default 1) line.
1298 backward((int) number, 1, 0);
1303 * Force forward one screen.
1306 number = get_swindow();
1308 if (show_attn == OPT_ONPLUS)
1309 set_attnpos(bottompos);
1310 forward((int) number, 1, 0);
1315 * Forward forever, ignoring EOF.
1318 set_attnpos(bottompos);
1319 newaction = forw_loop(0);
1322 case A_F_UNTIL_HILITE:
1323 newaction = forw_loop(1);
1329 * (default same as last 'd' or 'u' command).
1332 wscroll = (int) number;
1334 if (show_attn == OPT_ONPLUS)
1335 set_attnpos(bottompos);
1336 forward(wscroll, 0, 0);
1342 * (default same as last 'd' or 'u' command).
1345 wscroll = (int) number;
1347 backward(wscroll, 0, 0);
1352 * Flush buffers, then repaint screen.
1353 * Don't flush the buffers on a pipe!
1367 * Go to line N, default beginning of file.
1377 * Go to a specified percentage into the file.
1390 jump_percent((int) number, fraction);
1395 * Go to line N, default end of file.
1406 * Go to line N, default last buffered byte.
1410 jump_forw_buffered();
1417 * Go to a specified byte position in the file.
1422 jump_line_loc((POSITION) number, jump_sline);
1427 * Print file name, etc.
1429 if (ch_getflags() & CH_HELPFILE)
1432 parg.p_string = eq_message();
1438 * Print version number, without the "@(#)".
1448 if (curr_ifile != NULL_IFILE &&
1449 ch_getflags() & CH_HELPFILE)
1452 * Quit while viewing the help file
1453 * just means return to viewing the
1456 hshift = save_hshift;
1457 bs_mode = save_bs_mode;
1458 if (edit_prev(1) == 0)
1467 * Define abbreviation for a commonly used sequence below.
1469 #define DO_SEARCH() \
1470 if (number <= 0) number = 1; \
1473 multi_search((char *)NULL, (int) number, 0);
1478 * Search forward for a pattern.
1479 * Get the first char of the pattern.
1481 search_type = SRCH_FORW;
1490 * Search backward for a pattern.
1491 * Get the first char of the pattern.
1493 search_type = SRCH_BACK;
1502 search_type = SRCH_FORW | SRCH_FILTER;
1507 error("Command not available", NULL_PARG);
1511 case A_AGAIN_SEARCH:
1513 * Repeat previous search.
1518 case A_T_AGAIN_SEARCH:
1520 * Repeat previous search, multiple files.
1522 search_type |= SRCH_PAST_EOF;
1526 case A_REVERSE_SEARCH:
1528 * Repeat previous search, in reverse direction.
1530 save_search_type = search_type;
1531 search_type = SRCH_REVERSE(search_type);
1533 search_type = save_search_type;
1536 case A_T_REVERSE_SEARCH:
1538 * Repeat previous search,
1539 * multiple files in reverse direction.
1541 save_search_type = search_type;
1542 search_type = SRCH_REVERSE(search_type);
1543 search_type |= SRCH_PAST_EOF;
1545 search_type = save_search_type;
1550 * Clear search string highlighting.
1559 if (ch_getflags() & CH_HELPFILE)
1562 save_hshift = hshift;
1564 save_bs_mode = bs_mode;
1565 bs_mode = BS_SPECIAL;
1566 (void) edit(FAKE_HELPFILE);
1571 * Edit a new file. Get the filename.
1576 start_mca(A_EXAMINE, "Examine: ", ml_examine, 0);
1581 error("Command not available", NULL_PARG);
1586 * Invoke an editor on the input file.
1591 if (ch_getflags() & CH_HELPFILE)
1593 if (strcmp(get_filename(curr_ifile), "-") == 0)
1595 error("Cannot edit standard input", NULL_PARG);
1598 if (get_altfilename(curr_ifile) != NULL)
1600 error("WARNING: This file was viewed via LESSOPEN",
1603 start_mca(A_SHELL, "!", ml_shell, 0);
1605 * Expand the editor prototype string
1606 * and pass it to the system to execute.
1607 * (Make sure the screen is displayed so the
1608 * expansion of "+%lm" works.)
1612 lsystem(pr_expand(editproto, 0), (char*)NULL);
1616 error("Command not available", NULL_PARG);
1621 * Examine next file.
1626 error("No next file", NULL_PARG);
1632 if (edit_next((int) number))
1634 if (get_quit_at_eof() && eof_displayed() &&
1635 !(ch_getflags() & CH_HELPFILE))
1637 parg.p_string = (number > 1) ? "(N-th) " : "";
1638 error("No %snext file", &parg);
1644 * Examine previous file.
1649 error("No previous file", NULL_PARG);
1655 if (edit_prev((int) number))
1657 parg.p_string = (number > 1) ? "(N-th) " : "";
1658 error("No %sprevious file", &parg);
1664 * Jump to the next tag in the current tag list.
1669 tagfile = nexttag((int) number);
1670 if (tagfile == NULL)
1672 error("No next tag", NULL_PARG);
1676 if (edit(tagfile) == 0)
1678 POSITION pos = tagsearch();
1679 if (pos != NULL_POSITION)
1680 jump_loc(pos, jump_sline);
1683 error("Command not available", NULL_PARG);
1689 * Jump to the previous tag in the current tag list.
1694 tagfile = prevtag((int) number);
1695 if (tagfile == NULL)
1697 error("No previous tag", NULL_PARG);
1701 if (edit(tagfile) == 0)
1703 POSITION pos = tagsearch();
1704 if (pos != NULL_POSITION)
1705 jump_loc(pos, jump_sline);
1708 error("Command not available", NULL_PARG);
1714 * Examine a particular file.
1718 if (edit_index((int) number))
1719 error("No such file", NULL_PARG);
1724 * Remove a file from the input file list.
1726 if (ch_getflags() & CH_HELPFILE)
1728 old_ifile = curr_ifile;
1729 new_ifile = getoff_ifile(curr_ifile);
1730 if (new_ifile == NULL_IFILE)
1735 if (edit_ifile(new_ifile) != 0)
1737 reedit_ifile(old_ifile);
1740 del_ifile(old_ifile);
1745 * Change the setting of an option.
1747 optflag = OPT_TOGGLE;
1755 * Report the setting of an option.
1757 optflag = OPT_NO_TOGGLE;
1765 * Set an initial command for new files.
1767 start_mca(A_FIRSTCMD, "+", (void*)NULL, 0);
1778 start_mca(A_SHELL, "!", ml_shell, 0);
1783 error("Command not available", NULL_PARG);
1791 if (ch_getflags() & CH_HELPFILE)
1793 start_mca(A_SETMARK, "set mark: ", (void*)NULL, 0);
1795 if (is_erase_char(c) || is_newline_char(c))
1797 setmark(c, action == A_SETMARKBOT ? BOTTOM : TOP);
1805 start_mca(A_CLRMARK, "clear mark: ", (void*)NULL, 0);
1807 if (is_erase_char(c) || is_newline_char(c))
1815 * Jump to a marked position.
1817 start_mca(A_GOMARK, "goto mark: ", (void*)NULL, 0);
1819 if (is_erase_char(c) || is_newline_char(c))
1827 * Write part of the input to a pipe to a shell command.
1832 start_mca(A_PIPE, "|mark: ", (void*)NULL, 0);
1834 if (is_erase_char(c))
1836 if (is_newline_char(c))
1841 start_mca(A_PIPE, "!", ml_shell, 0);
1846 error("Command not available", NULL_PARG);
1851 start_mca(action, "Brackets: ", (void*)NULL, 0);
1860 shift_count = number;
1862 number = (shift_count > 0) ?
1863 shift_count : sc_width / 2;
1864 if (number > hshift)
1875 shift_count = number;
1877 number = (shift_count > 0) ?
1878 shift_count : sc_width / 2;
1885 * Shift view left to margin.
1893 * Shift view right to view rightmost char on screen.
1901 * The command is incomplete (more chars are needed).
1902 * Display the current char, so the user knows
1903 * what's going on, and get another character.
1905 if (mca != A_PREFIX)
1908 start_mca(A_PREFIX, " ", (void*)NULL,