Lines Matching +full:constant +full:- +full:current
2 * Copyright (C) 1984-2025 Mark Nudelman
30 static char cmdbuf[CMDBUF_SIZE]; /* Buffer for holding a multi-char command */
31 static int cmd_col; /* Current column of the cursor */
46 static constant char *tk_ipoint;
47 static constant char *tk_trial = NULL;
61 #define HISTFILE_FIRST_LINE ".less-history-file:"
107 * History for the current command.
144 public void cmd_putstr(constant char *s) in cmd_putstr()
148 constant char *endline = s + strlen(s); in cmd_putstr()
151 constant char *os = s; in cmd_putstr()
173 constant char *s = cmdbuf; in len_cmdbuf()
174 constant char *endline = s + strlen(s); in len_cmdbuf()
200 static constant char * cmd_step_common(char *p, LWCHAR ch, size_t len, int *pwidth, int *bswidth) in cmd_step_common()
202 constant char *pr; in cmd_step_common()
218 LWCHAR prev_ch = step_char(&p, -1, cmdbuf); in cmd_step_common()
235 static constant char * cmd_step_right(char **pp, int *pwidth, int *bswidth) in cmd_step_right()
246 static constant char * cmd_step_left(char **pp, int *pwidth, int *bswidth) in cmd_step_left()
249 LWCHAR ch = step_char(pp, -1, cmdbuf); in cmd_step_left()
265 while (bswidth-- > 0) in cmd_home()
267 cmd_col -= width; in cmd_home()
277 public void cmd_repaint(constant char *old_cp) in cmd_repaint()
280 * Repaint the line from the current position. in cmd_repaint()
292 constant char *pr = cmd_step_right(&np, &width, NULL); in cmd_repaint()
303 constant char *pr = cmd_step_right(&np, &width, NULL); in cmd_repaint()
328 * Shift the cmdbuf display left a half-screen.
342 while (cols < (sc_width - prompt_col) / 2 && *s != '\0') in cmd_lshift()
358 cmd_offset = (int) (s - cmdbuf); in cmd_lshift()
365 * Shift the cmdbuf display right a half-screen.
375 * left we'd have to move to traverse a half-screen width in cmd_rshift()
380 while (cols < (sc_width - prompt_col) / 2 && s > cmdbuf) in cmd_rshift()
387 cmd_offset = (int) (s - cmdbuf); in cmd_rshift()
398 constant char *pr; in cmd_right()
411 else if (cmd_col + width == sc_width - 1 && cp[1] != '\0') in cmd_right()
451 cmd_col -= width; in cmd_left()
452 while (bswidth-- > 0) in cmd_left()
458 * Insert a char into the command buffer, at the current position.
460 static int cmd_ichar(constant char *cs, size_t clen) in cmd_ichar()
464 if (strlen(cmdbuf) + clen >= sizeof(cmdbuf)-1) in cmd_ichar()
474 for (s = &cmdbuf[strlen(cmdbuf)]; s >= cp; s--) in cmd_ichar()
512 clen = (int) (s - cp); in cmd_erase()
532 * to abort the current command, if CF_QUIT_ON_ERASE is set. in cmd_erase()
562 if (cp > cmdbuf && cp[-1] == ' ') in cmd_werase()
566 * erase all the spaces left of cursor (to the first non-space). in cmd_werase()
568 while (cp > cmdbuf && cp[-1] == ' ') in cmd_werase()
576 while (cp > cmdbuf && cp[-1] != ' ') in cmd_werase()
614 /* Buffer is already empty; abort the current command. */ in cmd_kill()
625 * to abort the current command, if CF_QUIT_ON_ERASE is set. in cmd_kill()
633 * Select an mlist structure to be the current command history.
641 /* Make sure the next up-arrow moves to the last string in the mlist. */ in set_mlist()
643 curr_mlist->curr_mp = curr_mlist; in set_mlist()
655 constant char *s; in cmd_updown()
661 * The current command has no history list. in cmd_updown()
676 for (ml = curr_mlist->curr_mp;;) in cmd_updown()
678 ml = (action == EC_UP) ? ml->prev : ml->next; in cmd_updown()
686 if (strncmp(cmdbuf, ml->string, updown_match) == 0) in cmd_updown()
692 curr_mlist->curr_mp = ml; in cmd_updown()
693 s = ml->string; in cmd_updown()
718 return (ssize_t)(-1); in save_updown_match()
725 have_updown_match = (udm != (ssize_t)(-1)); in restore_updown_match()
734 ml->next = mlist; in ml_link()
735 ml->prev = mlist->prev; in ml_link()
736 mlist->prev->next = ml; in ml_link()
737 mlist->prev = ml; in ml_link()
745 ml->prev->next = ml->next; in ml_unlink()
746 ml->next->prev = ml->prev; in ml_unlink()
752 public void cmd_addhist(struct mlist *mlist, constant char *cmd, lbool modified) in cmd_addhist()
766 for (ml = mlist->next; ml->string != NULL; ml = next) in cmd_addhist()
768 next = ml->next; in cmd_addhist()
769 if (strcmp(ml->string, cmd) == 0) in cmd_addhist()
772 free(ml->string); in cmd_addhist()
782 ml = mlist->prev; in cmd_addhist()
783 if (ml == mlist || strcmp(ml->string, cmd) != 0) in cmd_addhist()
790 ml->string = save(cmd); in cmd_addhist()
791 ml->modified = modified; in cmd_addhist()
795 * Point to the cmd just after the just-accepted command. in cmd_addhist()
798 mlist->curr_mp = ml->next; in cmd_addhist()
815 curr_mlist->modified = TRUE; in cmd_accept()
820 * Try to perform a line-edit function on the command buffer,
821 * using a specified char as a line-editing command.
825 * CC_QUIT The char requests the current command to be aborted.
835 * See if the char is indeed a line-editing command. in cmd_edit()
841 * No current history; don't accept history manipulation cmds. in cmd_edit()
889 while (cp > cmdbuf && cp[-1] == ' ') in cmd_edit()
891 while (cp > cmdbuf && cp[-1] != ' ') in cmd_edit()
947 * Insert a string into the command buffer, at the current position.
949 static int cmd_istr(constant char *str) in cmd_istr()
951 constant char *endline = str + strlen(str); in cmd_istr()
952 constant char *s; in cmd_istr()
957 constant char *os = s; in cmd_istr()
969 static void set_tk_original(constant char *word) in set_tk_original()
979 * Find the beginning and end of the "current" word.
991 constant char *esc = get_meta_escape(); in delimit_word()
1006 } else if (cp > cmdbuf && cp[-1] != ' ') in delimit_word()
1048 p += esclen - 1; in delimit_word()
1090 * a blank-separated list of filenames. in init_file_compl()
1127 * Return the next word in the current completion list.
1129 static constant char * next_compl(int action, constant char *prev) in next_compl()
1150 constant char *s; in cmd_complete()
1228 if (cp > cmdbuf && cp[-1] == closequote) in cmd_complete()
1247 * Build a UTF-8 char in cmd_mbc_buf.
1249 * CC_OK Char has been stored but we don't have a complete UTF-8 sequence yet.
1250 * CC_ERROR This is an invalid UTF-8 sequence.
1251 * CC_PASS There is a complete UTF-8 sequence in cmd_mbc_buf.
1294 /* complete, but not well formed (non-shortest form), sequence */ in cmd_uchar()
1308 *plen = (size_t) cmd_mbc_buf_len; /*{{type-issue}}*/ in cmd_uchar()
1315 * Process a single character of a multi-character command, such as
1332 * Insert the char, even if it is a line-editing char. in cmd_char2()
1339 * See if it is a line-editing character. in cmd_char2()
1368 public int cmd_setstring(constant char *s, lbool uc) in cmd_setstring()
1389 constant char *p; in cmd_int()
1395 if (ckd_mul(&n, n, 10) || ckd_add(&n, n, *p - '0')) in cmd_int()
1413 public constant char * get_cmdbuf(void) in get_cmdbuf()
1423 * Return the last (most recent) string in the current command history.
1425 public constant char * cmd_lastpattern(void) in cmd_lastpattern()
1429 return (curr_mlist->curr_mp->prev->string); in cmd_lastpattern()
1439 for (ml = ml->next; ml->string != NULL; ml = ml->next) in mlist_size()
1449 constant char *home = lgetenv("HOME"); in histfile_find()
1476 constant char *name; in histfile_name()
1483 if (strcmp(name, "-") == 0 || strcmp(name, "/dev/null") == 0) in histfile_name()
1484 /* $LESSHISTFILE == "-" means don't use a history file. */ in histfile_name()
1490 if (strcmp(LESSHISTFILE, "") == 0 || strcmp(LESSHISTFILE, "-") == 0) in histfile_name()
1507 static void read_cmdhist2(void (*action)(void*,struct mlist*,constant char*), void *uparam, int ski… in read_cmdhist2()
1561 --(*skip); in read_cmdhist2()
1573 static void read_cmdhist(void (*action)(void*,struct mlist*,constant char*), void *uparam, lbool sk… in read_cmdhist()
1581 static void addhist_init(void *uparam, struct mlist *ml, constant char *string) in addhist_init()
1620 for (ml = ml->next; ml->string != NULL; ml = ml->next) in write_mlist()
1622 if (!ml->modified) in write_mlist()
1624 fprintf(f, "\"%s\n", ml->string); in write_mlist()
1625 ml->modified = FALSE; in write_mlist()
1627 ml->modified = FALSE; /* entire mlist is now unmodified */ in write_mlist()
1633 static char * make_tempname(constant char *filename) in make_tempname()
1638 lastch = tempname[strlen(tempname)-1]; in make_tempname()
1639 tempname[strlen(tempname)-1] = (lastch == 'Q') ? 'Z' : 'Q'; in make_tempname()
1654 static void copy_hist(void *uparam, struct mlist *ml, constant char *string) in copy_hist()
1658 if (ml != NULL && ml != ctx->mlist) { in copy_hist()
1660 if (ctx->mlist) in copy_hist()
1661 /* Append any new entries to the end of the current mlist. */ in copy_hist()
1662 write_mlist(ctx->mlist, ctx->fout); in copy_hist()
1664 ctx->mlist = ml; in copy_hist()
1665 write_mlist_header(ctx->mlist, ctx->fout); in copy_hist()
1673 write_mlist_header(&mlist_search, ctx->fout); in copy_hist()
1674 write_mlist(&mlist_search, ctx->fout); in copy_hist()
1679 write_mlist_header(&mlist_shell, ctx->fout); in copy_hist()
1680 write_mlist(&mlist_shell, ctx->fout); in copy_hist()
1686 fprintf(ctx->fout, "\"%s\n", string); in copy_hist()
1740 constant char *s; in save_cmdhist()
1759 skip_search = mlist_size(&mlist_search) - histsize; in save_cmdhist()
1761 skip_shell = mlist_size(&mlist_shell) - histsize; in save_cmdhist()