diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-01-30 00:06:40 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-01-30 00:06:40 +0000 |
commit | 18f0756cd2953409aa01cd158da81123319e8728 (patch) | |
tree | 7bbb4fdaa748fdebefb49667236794077e721323 /lib | |
parent | 33d2bb7de6961d9738fb2a836428b81cd797026f (diff) |
Third step in synching with NetBSD:
* rename fkey_t to funckey_t and el_term_t to el_terminal_t
* rename struct editline member el_term to el_terminal
* rename many functions in terminal.c from term_*() to terminal_*(),
for consistency with the file name and to not look related to <term.h>
No functional change.
This makes refresh.c and sig.c almost identical to the NetBSD versions.
It reduces the remaining diff from +2446 -1805 to +2053 -1420.
OK czarkoff@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libedit/chared.c | 4 | ||||
-rw-r--r-- | lib/libedit/common.c | 10 | ||||
-rw-r--r-- | lib/libedit/el.c | 26 | ||||
-rw-r--r-- | lib/libedit/el.h | 4 | ||||
-rw-r--r-- | lib/libedit/eln.c | 10 | ||||
-rw-r--r-- | lib/libedit/emacs.c | 6 | ||||
-rw-r--r-- | lib/libedit/filecomplete.c | 4 | ||||
-rw-r--r-- | lib/libedit/map.c | 16 | ||||
-rw-r--r-- | lib/libedit/parse.c | 8 | ||||
-rw-r--r-- | lib/libedit/prompt.c | 4 | ||||
-rw-r--r-- | lib/libedit/read.c | 20 | ||||
-rw-r--r-- | lib/libedit/refresh.c | 150 | ||||
-rw-r--r-- | lib/libedit/search.c | 12 | ||||
-rw-r--r-- | lib/libedit/sig.c | 8 | ||||
-rw-r--r-- | lib/libedit/terminal.c | 490 | ||||
-rw-r--r-- | lib/libedit/terminal.h | 61 | ||||
-rw-r--r-- | lib/libedit/tty.c | 5 | ||||
-rw-r--r-- | lib/libedit/vi.c | 8 |
18 files changed, 427 insertions, 419 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index 044314b6169..c884d0ea8b3 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chared.c,v 1.12 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: chared.c,v 1.13 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: chared.c,v 1.28 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -745,7 +745,7 @@ c_gets(EditLine *el, Char *buf, const Char *prompt) default: if (len >= EL_BUFSIZ - 16) - term_beep(el); + terminal_beep(el); else { buf[len++] = ch; *cp++ = ch; diff --git a/lib/libedit/common.c b/lib/libedit/common.c index 185f949611c..10661a51b51 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -1,4 +1,4 @@ -/* $OpenBSD: common.c,v 1.8 2010/06/30 00:05:35 nicm Exp $ */ +/* $OpenBSD: common.c,v 1.9 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -149,7 +149,7 @@ ed_delete_next_char(EditLine *el, Int c) return (CC_ERROR); #else /* then do an EOF */ - term_writec(el, c); + terminal_writec(el, c); return (CC_EOF); #endif } else { @@ -580,7 +580,7 @@ protected el_action_t ed_clear_screen(EditLine *el, Int c __attribute__((__unused__))) { - term_clear_screen(el); /* clear the whole real screen */ + terminal_clear_screen(el); /* clear the whole real screen */ re_clear_display(el); /* reset everything */ return (CC_REFRESH); } @@ -904,10 +904,10 @@ ed_command(EditLine *el, Int c __attribute__((__unused__))) int tmplen; tmplen = c_gets(el, tmpbuf, STR("\n: ")); - term__putc(el, '\n'); + terminal__putc(el, '\n'); if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1) - term_beep(el); + terminal_beep(el); el->el_map.current = el->el_map.key; re_clear_display(el); diff --git a/lib/libedit/el.c b/lib/libedit/el.c index 94a939b20fc..9af4cc739aa 100644 --- a/lib/libedit/el.c +++ b/lib/libedit/el.c @@ -1,4 +1,4 @@ -/* $OpenBSD: el.c,v 1.21 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: el.c,v 1.22 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: el.c,v 1.61 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -86,7 +86,7 @@ el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr) } #endif - if (term_init(el) == -1) { + if (terminal_init(el) == -1) { free(el->el_prog); free(el); return NULL; @@ -118,7 +118,7 @@ el_end(EditLine *el) el_reset(el); - term_end(el); + terminal_end(el); keymacro_end(el); map_end(el); tty_end(el); @@ -190,7 +190,7 @@ FUN(el,set)(EditLine *el, int op, ...) } case EL_TERMINAL: - rv = term_set(el, va_arg(ap, char *)); + rv = terminal_set(el, va_arg(ap, char *)); break; case EL_EDITOR: @@ -225,17 +225,17 @@ FUN(el,set)(EditLine *el, int op, ...) case EL_TELLTC: argv[0] = STR("telltc"); - rv = term_telltc(el, i, argv); + rv = terminal_telltc(el, i, argv); break; case EL_SETTC: argv[0] = STR("settc"); - rv = term_settc(el, i, argv); + rv = terminal_settc(el, i, argv); break; case EL_ECHOTC: argv[0] = STR("echotc"); - rv = term_echotc(el, i, argv); + rv = terminal_echotc(el, i, argv); break; case EL_SETTY: @@ -345,7 +345,7 @@ FUN(el,set)(EditLine *el, int op, ...) case EL_REFRESH: re_clear_display(el); re_refresh(el); - term__flush(el); + terminal__flush(el); break; default: @@ -403,7 +403,7 @@ FUN(el,get)(EditLine *el, int op, ...) break; case EL_TERMINAL: - term_get(el, va_arg(ap, const char **)); + terminal_get(el, va_arg(ap, const char **)); rv = 0; break; @@ -420,7 +420,7 @@ FUN(el,get)(EditLine *el, int op, ...) switch (op) { case EL_GETTC: argv[0] = name; - rv = term_gettc(el, i, argv); + rv = terminal_gettc(el, i, argv); break; default: @@ -581,8 +581,8 @@ el_resize(EditLine *el) (void) sigprocmask(SIG_BLOCK, &nset, &oset); /* get the correct window size */ - if (term_get_size(el, &lins, &cols)) - term_change_size(el, lins, cols); + if (terminal_get_size(el, &lins, &cols)) + terminal_change_size(el, lins, cols); (void) sigprocmask(SIG_SETMASK, &oset, NULL); } @@ -595,7 +595,7 @@ public void el_beep(EditLine *el) { - term_beep(el); + terminal_beep(el); } diff --git a/lib/libedit/el.h b/lib/libedit/el.h index 8074bc38313..a1e001f0dcb 100644 --- a/lib/libedit/el.h +++ b/lib/libedit/el.h @@ -1,4 +1,4 @@ -/* $OpenBSD: el.h,v 1.11 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: el.h,v 1.12 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: el.h,v 1.21 2009/12/31 15:58:26 christos Exp $ */ /*- @@ -123,7 +123,7 @@ struct editline { void *el_data; /* Client data */ el_line_t el_line; /* The current line information */ el_state_t el_state; /* Current editor state */ - el_term_t el_term; /* Terminal dependent stuff */ + el_terminal_t el_terminal; /* Terminal dependent stuff */ el_tty_t el_tty; /* Tty dependent stuff */ el_refresh_t el_refresh; /* Refresh stuff */ el_prompt_t el_prompt; /* Prompt stuff */ diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c index 32048078926..728b74f4b1f 100644 --- a/lib/libedit/eln.c +++ b/lib/libedit/eln.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eln.c,v 1.4 2014/05/20 11:59:03 nicm Exp $ */ +/* $OpenBSD: eln.c,v 1.5 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: eln.c,v 1.9 2010/11/04 13:53:12 christos Exp $ */ /*- @@ -169,15 +169,15 @@ el_set(EditLine *el, int op, ...) break; case EL_TELLTC: wargv[0] = STR("telltc"); - ret = term_telltc(el, i, wargv); + ret = terminal_telltc(el, i, wargv); break; case EL_SETTC: wargv[0] = STR("settc"); - ret = term_settc(el, i, wargv); + ret = terminal_settc(el, i, wargv); break; case EL_ECHOTC: wargv[0] = STR("echotc"); - ret = term_echotc(el, i, wargv); + ret = terminal_echotc(el, i, wargv); break; case EL_SETTY: wargv[0] = STR("setty"); @@ -308,7 +308,7 @@ el_get(EditLine *el, int op, ...) if ((argv[i] = va_arg(ap, char *)) == NULL) break; argv[0] = gettc; - ret = term_gettc(el, i, argv); + ret = terminal_gettc(el, i, argv); break; } diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c index f2c4eae272e..011916a839d 100644 --- a/lib/libedit/emacs.c +++ b/lib/libedit/emacs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: emacs.c,v 1.9 2010/06/30 00:05:35 nicm Exp $ */ +/* $OpenBSD: emacs.c,v 1.10 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: emacs.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -53,14 +53,14 @@ em_delete_or_list(EditLine *el, Int c) /* if I'm at the end */ if (el->el_line.cursor == el->el_line.buffer) { /* and the beginning */ - term_writec(el, c); /* then do an EOF */ + terminal_writec(el, c); /* then do an EOF */ return (CC_EOF); } else { /* * Here we could list completions, but it is an * error right now */ - term_beep(el); + terminal_beep(el); return (CC_ERROR); } } else { diff --git a/lib/libedit/filecomplete.c b/lib/libedit/filecomplete.c index 5eda39113c6..c6c2000fed6 100644 --- a/lib/libedit/filecomplete.c +++ b/lib/libedit/filecomplete.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filecomplete.c,v 1.4 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: filecomplete.c,v 1.5 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: filecomplete.c,v 1.22 2010/12/02 04:42:46 dholland Exp $ */ /*- @@ -349,7 +349,7 @@ void fn_display_match_list (EditLine *el, char **matches, size_t num, size_t width) { size_t line, lines, col, cols, thisguy; - int screenwidth = el->el_term.t_size.h; + int screenwidth = el->el_terminal.t_size.h; /* Ignore matches[0]. Avoid 1-based array logic below. */ matches++; diff --git a/lib/libedit/map.c b/lib/libedit/map.c index 09d102feab1..c96329ba0e6 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.13 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: map.c,v 1.14 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: map.c,v 1.25 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -1032,7 +1032,7 @@ map_init_vi(EditLine *el) map_init_nls(el); tty_bind_char(el, 1); - term_bind_arrow(el); + terminal_bind_arrow(el); } @@ -1066,7 +1066,7 @@ map_init_emacs(EditLine *el) keymacro_add(el, buf, keymacro_map_cmd(el, EM_EXCHANGE_MARK), XK_CMD); tty_bind_char(el, 1); - term_bind_arrow(el); + terminal_bind_arrow(el); } @@ -1228,7 +1228,7 @@ map_print_all_keys(EditLine *el) (void) fprintf(el->el_outfile, "Multi-character bindings\n"); keymacro_print(el, STR("")); (void) fprintf(el->el_outfile, "Arrow key bindings\n"); - term_print_arrow(el, STR("")); + terminal_print_arrow(el, STR("")); } @@ -1315,7 +1315,7 @@ map_bind(EditLine *el, int argc, const Char **argv) } if (rem) { if (key) { - (void) term_clear_arrow(el, in); + (void) terminal_clear_arrow(el, in); return (-1); } if (in[1]) @@ -1328,7 +1328,7 @@ map_bind(EditLine *el, int argc, const Char **argv) } if (argv[argc] == NULL) { if (key) - term_print_arrow(el, in); + terminal_print_arrow(el, in); else map_print_key(el, map, in); return (0); @@ -1349,7 +1349,7 @@ map_bind(EditLine *el, int argc, const Char **argv) return (-1); } if (key) - term_set_arrow(el, in, keymacro_map_str(el, out), ntype); + terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype); else keymacro_add(el, in, keymacro_map_str(el, out), ntype); map[(unsigned char) *in] = ED_SEQUENCE_LEAD_IN; @@ -1363,7 +1363,7 @@ map_bind(EditLine *el, int argc, const Char **argv) return (-1); } if (key) - term_set_arrow(el, in, keymacro_map_str(el, out), ntype); + terminal_set_arrow(el, in, keymacro_map_str(el, out), ntype); else { if (in[1]) { keymacro_add(el, in, keymacro_map_cmd(el, cmd), ntype); diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c index 45b386428c7..17dbca40cb7 100644 --- a/lib/libedit/parse.c +++ b/lib/libedit/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.12 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: parse.c,v 1.13 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: parse.c,v 1.23 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -56,11 +56,11 @@ private const struct { int (*func)(EditLine *, int, const Char **); } cmds[] = { { STR("bind"), map_bind }, - { STR("echotc"), term_echotc }, + { STR("echotc"), terminal_echotc }, { STR("edit"), el_editmode }, { STR("history"), hist_command }, - { STR("telltc"), term_telltc }, - { STR("settc"), term_settc }, + { STR("telltc"), terminal_telltc }, + { STR("settc"), terminal_settc }, { STR("setty"), tty_stty }, { NULL, NULL } }; diff --git a/lib/libedit/prompt.c b/lib/libedit/prompt.c index f07470c4d36..092a000c271 100644 --- a/lib/libedit/prompt.c +++ b/lib/libedit/prompt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: prompt.c,v 1.9 2010/06/30 00:05:35 nicm Exp $ */ +/* $OpenBSD: prompt.c,v 1.10 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: prompt.c,v 1.18 2009/12/31 15:58:26 christos Exp $ */ /*- @@ -97,7 +97,7 @@ prompt_print(EditLine *el, int op) continue; } if (ignore) - term__putc(el, *p); + terminal__putc(el, *p); else re_putc(el, *p, 1); } diff --git a/lib/libedit/read.c b/lib/libedit/read.c index dccec9be36f..ea8b09fcc10 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.16 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.17 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: read.c,v 1.57 2010/07/21 18:18:52 christos Exp $ */ /*- @@ -221,8 +221,8 @@ FUN(el,push)(EditLine *el, const Char *str) return; ma->level--; } - term_beep(el); - term__flush(el); + terminal_beep(el); + terminal__flush(el); } @@ -382,7 +382,7 @@ FUN(el,getc)(EditLine *el, Char *cp) int num_read; c_macro_t *ma = &el->el_chared.c_macro; - term__flush(el); + terminal__flush(el); for (;;) { if (ma->level < 0) { if (!read_preread(el)) @@ -445,7 +445,7 @@ read_prepare(EditLine *el) re_refresh(el); /* print the prompt */ if (el->el_flags & UNBUFFERED) - term__flush(el); + terminal__flush(el); } protected void @@ -528,7 +528,7 @@ FUN(el,gets)(EditLine *el, int *nread) else cp = el->el_line.lastchar; - term__flush(el); + terminal__flush(el); while ((num = (*el->el_read.read_char)(el, cp)) == 1) { /* make sure there is space next character */ @@ -635,7 +635,7 @@ FUN(el,gets)(EditLine *el, int *nread) case CC_REFRESH_BEEP: re_refresh(el); - term_beep(el); + terminal_beep(el); break; case CC_NORM: /* normal char */ @@ -676,8 +676,8 @@ FUN(el,gets)(EditLine *el, int *nread) (void) fprintf(el->el_errfile, "*** editor ERROR ***\r\n\n"); #endif /* DEBUG_READ */ - term_beep(el); - term__flush(el); + terminal_beep(el); + terminal__flush(el); break; } el->el_state.argument = 1; @@ -687,7 +687,7 @@ FUN(el,gets)(EditLine *el, int *nread) break; } - term__flush(el); /* flush any buffered output */ + terminal__flush(el); /* flush any buffered output */ /* make sure the tty is set up correctly */ if ((el->el_flags & UNBUFFERED) == 0) { read_finish(el); diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index a28c813606c..82f18528bc7 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -1,5 +1,5 @@ -/* $OpenBSD: refresh.c,v 1.11 2010/06/30 00:05:35 nicm Exp $ */ -/* $NetBSD: refresh.c,v 1.35 2009/12/30 22:37:40 christos Exp $ */ +/* $OpenBSD: refresh.c,v 1.12 2016/01/30 00:06:39 schwarze Exp $ */ +/* $NetBSD: refresh.c,v 1.37 2011/07/29 23:44:45 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -97,8 +97,8 @@ re_nextline(EditLine *el) * We do this via pointer shuffling - it's safe in this case * and we avoid memcpy(). */ - if (el->el_refresh.r_cursor.v + 1 >= el->el_term.t_size.v) { - int i, lins = el->el_term.t_size.v; + if (el->el_refresh.r_cursor.v + 1 >= el->el_terminal.t_size.v) { + int i, lins = el->el_terminal.t_size.v; Char *firstline = el->el_vdisplay[0]; for(i = 1; i < lins; i++) @@ -109,9 +109,9 @@ re_nextline(EditLine *el) } else el->el_refresh.r_cursor.v++; - ELRE_ASSERT(el->el_refresh.r_cursor.v >= el->el_term.t_size.v, + ELRE_ASSERT(el->el_refresh.r_cursor.v >= el->el_terminal.t_size.v, (__F, "\r\nre_putc: overflow! r_cursor.v == %d > %d\r\n", - el->el_refresh.r_cursor.v, el->el_term.t_size.v), + el->el_refresh.r_cursor.v, el->el_terminal.t_size.v), abort()); } @@ -160,7 +160,7 @@ re_putc(EditLine *el, Int c, int shift) int i, w = Width(c); ELRE_DEBUG(1, (__F, "printing %5x '%c'\r\n", c, c)); - while (shift && (el->el_refresh.r_cursor.h + w > el->el_term.t_size.h)) + while (shift && (el->el_refresh.r_cursor.h + w > el->el_terminal.t_size.h)) re_putc(el, ' ', 1); el->el_vdisplay[el->el_refresh.r_cursor.v] @@ -175,9 +175,9 @@ re_putc(EditLine *el, Int c, int shift) return; el->el_refresh.r_cursor.h += w; /* advance to next place */ - if (el->el_refresh.r_cursor.h >= el->el_term.t_size.h) { + if (el->el_refresh.r_cursor.h >= el->el_terminal.t_size.h) { /* assure end of line */ - el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_term.t_size.h] + el->el_vdisplay[el->el_refresh.r_cursor.v][el->el_terminal.t_size.h] = '\0'; re_nextline(el); } @@ -229,7 +229,7 @@ re_refresh(EditLine *el) /* draw the current input buffer */ #if notyet - termsz = el->el_term.t_size.h * el->el_term.t_size.v; + termsz = el->el_terminal.t_size.h * el->el_terminal.t_size.v; if (el->el_line.lastchar - el->el_line.buffer > termsz) { /* * If line is longer than terminal, process only part @@ -238,8 +238,8 @@ re_refresh(EditLine *el) size_t rem = (el->el_line.lastchar-el->el_line.buffer)%termsz; st = el->el_line.lastchar - rem - - (termsz - (((rem / el->el_term.t_size.v) - 1) - * el->el_term.t_size.v)); + - (termsz - (((rem / el->el_terminal.t_size.v) - 1) + * el->el_terminal.t_size.v)); } else #endif st = el->el_line.buffer; @@ -252,7 +252,7 @@ re_refresh(EditLine *el) cur.v = el->el_refresh.r_cursor.v; /* handle being at a linebroken doublewidth char */ if (w > 1 && el->el_refresh.r_cursor.h + w > - el->el_term.t_size.h) { + el->el_terminal.t_size.h) { cur.h = 0; cur.v++; } @@ -264,7 +264,7 @@ re_refresh(EditLine *el) cur.h = el->el_refresh.r_cursor.h; cur.v = el->el_refresh.r_cursor.v; } - rhdiff = el->el_term.t_size.h - el->el_refresh.r_cursor.h - + rhdiff = el->el_terminal.t_size.h - el->el_refresh.r_cursor.h - el->el_rprompt.p_pos.h; if (el->el_rprompt.p_pos.h && !el->el_rprompt.p_pos.v && !el->el_refresh.r_cursor.v && rhdiff > 1) { @@ -287,7 +287,7 @@ re_refresh(EditLine *el) ELRE_DEBUG(1, (__F, "term.h=%d vcur.h=%d vcur.v=%d vdisplay[0]=\r\n:%80.80s:\r\n", - el->el_term.t_size.h, el->el_refresh.r_cursor.h, + el->el_terminal.t_size.h, el->el_refresh.r_cursor.h, el->el_refresh.r_cursor.v, ct_encode_string(el->el_vdisplay[0]))); ELRE_DEBUG(1, (__F, "updating %d lines.\r\n", el->el_refresh.r_newcv)); @@ -303,7 +303,7 @@ re_refresh(EditLine *el) * leftover stuff. */ re__copy_and_pad(el->el_display[i], el->el_vdisplay[i], - (size_t) el->el_term.t_size.h); + (size_t) el->el_terminal.t_size.h); } ELRE_DEBUG(1, (__F, "\r\nel->el_refresh.r_cursor.v=%d,el->el_refresh.r_oldcv=%d i=%d\r\n", @@ -311,12 +311,12 @@ re_refresh(EditLine *el) if (el->el_refresh.r_oldcv > el->el_refresh.r_newcv) for (; i <= el->el_refresh.r_oldcv; i++) { - term_move_to_line(el, i); - term_move_to_char(el, 0); + terminal_move_to_line(el, i); + terminal_move_to_char(el, 0); /* This Strlen should be safe even with MB_FILL_CHARs */ - term_clear_EOL(el, (int) Strlen(el->el_display[i])); + terminal_clear_EOL(el, (int) Strlen(el->el_display[i])); #ifdef DEBUG_REFRESH - term_overwrite(el, "C\b", (size_t)2); + terminal_overwrite(el, "C\b", (size_t)2); #endif /* DEBUG_REFRESH */ el->el_display[i][0] = '\0'; } @@ -326,8 +326,8 @@ re_refresh(EditLine *el) "\r\ncursor.h = %d, cursor.v = %d, cur.h = %d, cur.v = %d\r\n", el->el_refresh.r_cursor.h, el->el_refresh.r_cursor.v, cur.h, cur.v)); - term_move_to_line(el, cur.v); /* go to where the cursor is */ - term_move_to_char(el, cur.h); + terminal_move_to_line(el, cur.v); /* go to where the cursor is */ + terminal_move_to_char(el, cur.h); } @@ -338,10 +338,10 @@ protected void re_goto_bottom(EditLine *el) { - term_move_to_line(el, el->el_refresh.r_oldcv); - term__putc(el, '\n'); + terminal_move_to_line(el, el->el_refresh.r_oldcv); + terminal__putc(el, '\n'); re_clear_display(el); - term__flush(el); + terminal__flush(el); } @@ -464,7 +464,7 @@ re_clear_eol(EditLine *el, int fx, int sx, int diff) diff = sx; ELRE_DEBUG(1, (__F, "re_clear_eol %d\n", diff)); - term_clear_EOL(el, diff); + terminal_clear_EOL(el, diff); } /***************************************************************** @@ -711,7 +711,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * don't have to change the line, we don't move to it. el_cursor.h to * first diff char */ - term_move_to_line(el, i); + terminal_move_to_line(el, i); /* * at this point we have something like this: @@ -735,7 +735,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * if we have a net insert on the first difference, AND inserting the * net amount ((nsb-nfd) - (osb-ofd)) won't push the last useful * character (which is ne if nls != ne, otherwise is nse) off the edge - * of the screen (el->el_term.t_size.h) else we do the deletes first + * of the screen (el->el_terminal.t_size.h) else we do the deletes first * so that we keep everything we need to. */ @@ -757,13 +757,13 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * No insert or delete */ if ((nsb != nfd) && fx > 0 && - ((p - old) + fx <= el->el_term.t_size.h)) { + ((p - old) + fx <= el->el_terminal.t_size.h)) { ELRE_DEBUG(1, (__F, "first diff insert at %d...\r\n", nfd - new)); /* * Move to the first char to insert, where the first diff is. */ - term_move_to_char(el, (int)(nfd - new)); + terminal_move_to_char(el, (int)(nfd - new)); /* * Check if we have stuff to keep at end */ @@ -775,21 +775,21 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if (fx > 0) { ELRE_DEBUG(!EL_CAN_INSERT, (__F, "ERROR: cannot insert in early first diff\n")); - term_insertwrite(el, nfd, fx); + terminal_insertwrite(el, nfd, fx); re_insert(el, old, (int)(ofd - old), - el->el_term.t_size.h, nfd, fx); + el->el_terminal.t_size.h, nfd, fx); } /* * write (nsb-nfd) - fx chars of new starting at * (nfd + fx) */ len = (size_t) ((nsb - nfd) - fx); - term_overwrite(el, (nfd + fx), len); + terminal_overwrite(el, (nfd + fx), len); re__strncopy(ofd + fx, nfd + fx, len); } else { ELRE_DEBUG(1, (__F, "without anything to save\r\n")); len = (size_t)(nsb - nfd); - term_overwrite(el, nfd, len); + terminal_overwrite(el, nfd, len); re__strncopy(ofd, nfd, len); /* * Done @@ -802,7 +802,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) /* * move to the first char to delete where the first diff is */ - term_move_to_char(el, (int)(ofd - old)); + terminal_move_to_char(el, (int)(ofd - old)); /* * Check if we have stuff to save */ @@ -815,15 +815,15 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if (fx < 0) { ELRE_DEBUG(!EL_CAN_DELETE, (__F, "ERROR: cannot delete in first diff\n")); - term_deletechars(el, -fx); + terminal_deletechars(el, -fx); re_delete(el, old, (int)(ofd - old), - el->el_term.t_size.h, -fx); + el->el_terminal.t_size.h, -fx); } /* * write (nsb-nfd) chars of new starting at nfd */ len = (size_t) (nsb - nfd); - term_overwrite(el, nfd, len); + terminal_overwrite(el, nfd, len); re__strncopy(ofd, nfd, len); } else { @@ -832,7 +832,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) /* * write (nsb-nfd) chars of new starting at nfd */ - term_overwrite(el, nfd, (size_t)(nsb - nfd)); + terminal_overwrite(el, nfd, (size_t)(nsb - nfd)); re_clear_eol(el, fx, sx, (int)((oe - old) - (ne - new))); /* @@ -843,7 +843,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) } else fx = 0; - if (sx < 0 && (ose - old) + fx < el->el_term.t_size.h) { + if (sx < 0 && (ose - old) + fx < el->el_terminal.t_size.h) { ELRE_DEBUG(1, (__F, "second diff delete at %d...\r\n", (ose - old) + fx)); /* @@ -853,7 +853,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) * fx is the number of characters inserted (+) or deleted (-) */ - term_move_to_char(el, (int)((ose - old) + fx)); + terminal_move_to_char(el, (int)((ose - old) + fx)); /* * Check if we have stuff to save */ @@ -865,16 +865,16 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if (sx < 0) { ELRE_DEBUG(!EL_CAN_DELETE, (__F, "ERROR: cannot delete in second diff\n")); - term_deletechars(el, -sx); + terminal_deletechars(el, -sx); } /* * write (nls-nse) chars of new starting at nse */ - term_overwrite(el, nse, (size_t)(nls - nse)); + terminal_overwrite(el, nse, (size_t)(nls - nse)); } else { ELRE_DEBUG(1, (__F, "but with nothing left to save\r\n")); - term_overwrite(el, nse, (size_t)(nls - nse)); + terminal_overwrite(el, nse, (size_t)(nls - nse)); re_clear_eol(el, fx, sx, (int)((oe - old) - (ne - new))); } @@ -886,7 +886,7 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) ELRE_DEBUG(1, (__F, "late first diff insert at %d...\r\n", nfd - new)); - term_move_to_char(el, (int)(nfd - new)); + terminal_move_to_char(el, (int)(nfd - new)); /* * Check if we have stuff to keep at the end */ @@ -904,21 +904,21 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) */ ELRE_DEBUG(!EL_CAN_INSERT, (__F, "ERROR: cannot insert in late first diff\n")); - term_insertwrite(el, nfd, fx); + terminal_insertwrite(el, nfd, fx); re_insert(el, old, (int)(ofd - old), - el->el_term.t_size.h, nfd, fx); + el->el_terminal.t_size.h, nfd, fx); } /* * write (nsb-nfd) - fx chars of new starting at * (nfd + fx) */ len = (size_t) ((nsb - nfd) - fx); - term_overwrite(el, (nfd + fx), len); + terminal_overwrite(el, (nfd + fx), len); re__strncopy(ofd + fx, nfd + fx, len); } else { ELRE_DEBUG(1, (__F, "without anything to save\r\n")); len = (size_t) (nsb - nfd); - term_overwrite(el, nfd, len); + terminal_overwrite(el, nfd, len); re__strncopy(ofd, nfd, len); } } @@ -928,24 +928,24 @@ re_update_line(EditLine *el, Char *old, Char *new, int i) if (sx >= 0) { ELRE_DEBUG(1, (__F, "second diff insert at %d...\r\n", (int)(nse - new))); - term_move_to_char(el, (int)(nse - new)); + terminal_move_to_char(el, (int)(nse - new)); if (ols != oe) { ELRE_DEBUG(1, (__F, "with stuff to keep at end\r\n")); if (sx > 0) { /* insert sx chars of new starting at nse */ ELRE_DEBUG(!EL_CAN_INSERT, (__F, "ERROR: cannot insert in second diff\n")); - term_insertwrite(el, nse, sx); + terminal_insertwrite(el, nse, sx); } /* * write (nls-nse) - sx chars of new starting at * (nse + sx) */ - term_overwrite(el, (nse + sx), + terminal_overwrite(el, (nse + sx), (size_t)((nls - nse) - sx)); } else { ELRE_DEBUG(1, (__F, "without anything to save\r\n")); - term_overwrite(el, nse, (size_t)(nls - nse)); + terminal_overwrite(el, nse, (size_t)(nls - nse)); /* * No need to do a clear-to-end here because we were @@ -999,7 +999,7 @@ re_refresh_cursor(EditLine *el) /* first we must find where the cursor is... */ h = el->el_prompt.p_pos.h; v = el->el_prompt.p_pos.v; - th = el->el_term.t_size.h; /* optimize for speed */ + th = el->el_terminal.t_size.h; /* optimize for speed */ /* do input buffer to el->el_line.cursor */ for (cp = el->el_line.buffer; cp < el->el_line.cursor; cp++) { @@ -1036,9 +1036,9 @@ re_refresh_cursor(EditLine *el) } /* now go there */ - term_move_to_line(el, v); - term_move_to_char(el, h); - term__flush(el); + terminal_move_to_line(el, v); + terminal_move_to_char(el, h); + terminal__flush(el); } @@ -1049,16 +1049,16 @@ private void re_fastputc(EditLine *el, Int c) { int w = Width((Char)c); - while (w > 1 && el->el_cursor.h + w > el->el_term.t_size.h) + while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h) re_fastputc(el, ' '); - term__putc(el, c); + terminal__putc(el, c); el->el_display[el->el_cursor.v][el->el_cursor.h++] = c; while (--w > 0) el->el_display[el->el_cursor.v][el->el_cursor.h++] = MB_FILL_CHAR; - if (el->el_cursor.h >= el->el_term.t_size.h) { + if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* if we must overflow */ el->el_cursor.h = 0; @@ -1068,8 +1068,8 @@ re_fastputc(EditLine *el, Int c) * We do this via pointer shuffling - it's safe in this case * and we avoid memcpy(). */ - if (el->el_cursor.v + 1 >= el->el_term.t_size.v) { - int i, lins = el->el_term.t_size.v; + if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { + int i, lins = el->el_terminal.t_size.v; Char *firstline = el->el_display[0]; for(i = 1; i < lins; i++) @@ -1083,12 +1083,12 @@ re_fastputc(EditLine *el, Int c) } if (EL_HAS_AUTO_MARGINS) { if (EL_HAS_MAGIC_MARGINS) { - term__putc(el, ' '); - term__putc(el, '\b'); + terminal__putc(el, ' '); + terminal__putc(el, '\b'); } } else { - term__putc(el, '\r'); - term__putc(el, '\n'); + terminal__putc(el, '\r'); + terminal__putc(el, '\n'); } } } @@ -1110,7 +1110,7 @@ re_fastaddc(EditLine *el) re_refresh(el); /* too hard to handle */ return; } - rhdiff = el->el_term.t_size.h - el->el_cursor.h - + rhdiff = el->el_terminal.t_size.h - el->el_cursor.h - el->el_rprompt.p_pos.h; if (el->el_rprompt.p_pos.h && rhdiff < 3) { re_refresh(el); /* clear out rprompt if less than 1 char gap */ @@ -1133,7 +1133,7 @@ re_fastaddc(EditLine *el) break; } } - term__flush(el); + terminal__flush(el); } @@ -1147,7 +1147,7 @@ re_clear_display(EditLine *el) el->el_cursor.v = 0; el->el_cursor.h = 0; - for (i = 0; i < el->el_term.t_size.v; i++) + for (i = 0; i < el->el_terminal.t_size.v; i++) el->el_display[i][0] = '\0'; el->el_refresh.r_oldcv = 0; } @@ -1164,14 +1164,14 @@ re_clear_lines(EditLine *el) int i; for (i = el->el_refresh.r_oldcv; i >= 0; i--) { /* for each line on the screen */ - term_move_to_line(el, i); - term_move_to_char(el, 0); - term_clear_EOL(el, el->el_term.t_size.h); + terminal_move_to_line(el, i); + terminal_move_to_char(el, 0); + terminal_clear_EOL(el, el->el_terminal.t_size.h); } } else { - term_move_to_line(el, el->el_refresh.r_oldcv); + terminal_move_to_line(el, el->el_refresh.r_oldcv); /* go to last line */ - term__putc(el, '\r'); /* go to BOL */ - term__putc(el, '\n'); /* go to new line */ + terminal__putc(el, '\r'); /* go to BOL */ + terminal__putc(el, '\n'); /* go to new line */ } } diff --git a/lib/libedit/search.c b/lib/libedit/search.c index 9cd740e0e00..56cf3f8ebe2 100644 --- a/lib/libedit/search.c +++ b/lib/libedit/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.13 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: search.c,v 1.14 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: search.c,v 1.24 2010/04/15 00:57:33 christos Exp $ */ /*- @@ -248,7 +248,7 @@ ce_inc_search(EditLine *el, int dir) case ED_INSERT: case ED_DIGIT: if (el->el_search.patlen >= EL_BUFSIZ - LEN) - term_beep(el); + terminal_beep(el); else { el->el_search.patbuf[el->el_search.patlen++] = ch; @@ -273,7 +273,7 @@ ce_inc_search(EditLine *el, int dir) if (el->el_search.patlen > LEN) done++; else - term_beep(el); + terminal_beep(el); break; default: @@ -297,7 +297,7 @@ ce_inc_search(EditLine *el, int dir) *el->el_line.cursor != '\n') { if (el->el_search.patlen >= EL_BUFSIZ - LEN) { - term_beep(el); + terminal_beep(el); break; } el->el_search.patbuf[el->el_search.patlen++] = @@ -310,7 +310,7 @@ ce_inc_search(EditLine *el, int dir) re_refresh(el); break; } else if (isglob(*cp)) { - term_beep(el); + terminal_beep(el); break; } break; @@ -395,7 +395,7 @@ ce_inc_search(EditLine *el, int dir) el->el_search.patbuf[el->el_search.patlen] = '\0'; if (ret == CC_ERROR) { - term_beep(el); + terminal_beep(el); if (el->el_history.eventno != ohisteventno) { el->el_history.eventno = diff --git a/lib/libedit/sig.c b/lib/libedit/sig.c index 05562b8a3cc..7d8694a53cc 100644 --- a/lib/libedit/sig.c +++ b/lib/libedit/sig.c @@ -1,5 +1,5 @@ -/* $OpenBSD: sig.c,v 1.14 2014/10/17 06:07:50 deraadt Exp $ */ -/* $NetBSD: sig.c,v 1.15 2009/02/19 15:20:22 christos Exp $ */ +/* $OpenBSD: sig.c,v 1.15 2016/01/30 00:06:39 schwarze Exp $ */ +/* $NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -76,7 +76,7 @@ sig_handler(int signo) tty_rawmode(sel); if (ed_redisplay(sel, 0) == CC_REFRESH) re_refresh(sel); - term__flush(sel); + terminal__flush(sel); break; case SIGWINCH: @@ -141,7 +141,7 @@ protected void sig_end(EditLine *el) { - free((ptr_t) el->el_signal); + free(el->el_signal); el->el_signal = NULL; } diff --git a/lib/libedit/terminal.c b/lib/libedit/terminal.c index ae6caa5b7dd..a1ba9970dcb 100644 --- a/lib/libedit/terminal.c +++ b/lib/libedit/terminal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.c,v 1.2 2016/01/29 19:32:33 schwarze Exp $ */ +/* $OpenBSD: terminal.c,v 1.3 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: term.c,v 1.57 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -36,9 +36,9 @@ #include "config.h" /* - * term.c: Editor/termcap-curses interface - * We have to declare a static variable here, since the - * termcap putchar routine does not take an argument! + * terminal.c: Editor/termcap-curses interface + * We have to declare a static variable here, since the + * termcap putchar routine does not take an argument! */ #include <stdio.h> #include <signal.h> @@ -77,10 +77,10 @@ #define TC_BUFSIZE 2048 -#define GoodStr(a) (el->el_term.t_str[a] != NULL && \ - el->el_term.t_str[a][0] != '\0') -#define Str(a) el->el_term.t_str[a] -#define Val(a) el->el_term.t_val[a] +#define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \ + el->el_terminal.t_str[a][0] != '\0') +#define Str(a) el->el_terminal.t_str[a] +#define Val(a) el->el_terminal.t_val[a] #ifdef notdef private const struct { @@ -263,27 +263,28 @@ private const struct termcapval { }; /* do two or more of the attributes use me */ -private void term_setflags(EditLine *); -private int term_rebuffer_display(EditLine *); -private void term_free_display(EditLine *); -private int term_alloc_display(EditLine *); -private void term_alloc(EditLine *, const struct termcapstr *, const char *); -private void term_init_arrow(EditLine *); -private void term_reset_arrow(EditLine *); -private int term_putc(int); -private void term_tputs(EditLine *, const char *, int); +private void terminal_setflags(EditLine *); +private int terminal_rebuffer_display(EditLine *); +private void terminal_free_display(EditLine *); +private int terminal_alloc_display(EditLine *); +private void terminal_alloc(EditLine *, const struct termcapstr *, + const char *); +private void terminal_init_arrow(EditLine *); +private void terminal_reset_arrow(EditLine *); +private int terminal_putc(int); +private void terminal_tputs(EditLine *, const char *, int); #ifdef _REENTRANT -private pthread_mutex_t term_mutex = PTHREAD_MUTEX_INITIALIZER; +private pthread_mutex_t terminal_mutex = PTHREAD_MUTEX_INITIALIZER; #endif -private FILE *term_outfile = NULL; +private FILE *terminal_outfile = NULL; -/* term_setflags(): +/* terminal_setflags(): * Set the terminal capability flags */ private void -term_setflags(EditLine *el) +terminal_setflags(EditLine *el) { EL_FLAGS = 0; if (el->el_tty.t_tabs) @@ -324,81 +325,82 @@ term_setflags(EditLine *el) #endif /* DEBUG_SCREEN */ } -/* term_init(): +/* terminal_init(): * Initialize the terminal stuff */ protected int -term_init(EditLine *el) +terminal_init(EditLine *el) { - el->el_term.t_buf = (char *)malloc(TC_BUFSIZE); - if (el->el_term.t_buf == NULL) + el->el_terminal.t_buf = (char *)malloc(TC_BUFSIZE); + if (el->el_terminal.t_buf == NULL) goto fail; - el->el_term.t_cap = (char *)malloc(TC_BUFSIZE); - if (el->el_term.t_cap == NULL) + el->el_terminal.t_cap = (char *)malloc(TC_BUFSIZE); + if (el->el_terminal.t_cap == NULL) goto fail2; - el->el_term.t_fkey = reallocarray(NULL, A_K_NKEYS, sizeof(fkey_t)); - if (el->el_term.t_fkey == NULL) + el->el_terminal.t_fkey = reallocarray(NULL, A_K_NKEYS, + sizeof(*el->el_terminal.t_fkey)); + if (el->el_terminal.t_fkey == NULL) goto fail3; - el->el_term.t_loc = 0; - el->el_term.t_str = reallocarray(NULL, T_str, sizeof(char *)); - if (el->el_term.t_str == NULL) + el->el_terminal.t_loc = 0; + el->el_terminal.t_str = reallocarray(NULL, T_str, sizeof(char *)); + if (el->el_terminal.t_str == NULL) goto fail4; - (void) memset(el->el_term.t_str, 0, T_str * sizeof(char *)); - el->el_term.t_val = reallocarray(NULL, T_val, sizeof(int)); - if (el->el_term.t_val == NULL) + (void) memset(el->el_terminal.t_str, 0, T_str * sizeof(char *)); + el->el_terminal.t_val = reallocarray(NULL, T_val, sizeof(int)); + if (el->el_terminal.t_val == NULL) goto fail5; - (void) memset(el->el_term.t_val, 0, T_val * sizeof(int)); - (void) term_set(el, NULL); - term_init_arrow(el); + (void) memset(el->el_terminal.t_val, 0, T_val * sizeof(int)); + (void) terminal_set(el, NULL); + terminal_init_arrow(el); return (0); fail5: - free(el->el_term.t_str); - el->el_term.t_str = NULL; + free(el->el_terminal.t_str); + el->el_terminal.t_str = NULL; fail4: - free(el->el_term.t_fkey); - el->el_term.t_fkey = NULL; + free(el->el_terminal.t_fkey); + el->el_terminal.t_fkey = NULL; fail3: - free(el->el_term.t_cap); - el->el_term.t_cap = NULL; + free(el->el_terminal.t_cap); + el->el_terminal.t_cap = NULL; fail2: - free(el->el_term.t_buf); - el->el_term.t_buf = NULL; + free(el->el_terminal.t_buf); + el->el_terminal.t_buf = NULL; fail: return (-1); } -/* term_end(): +/* terminal_end(): * Clean up the terminal stuff */ protected void -term_end(EditLine *el) +terminal_end(EditLine *el) { - free((ptr_t) el->el_term.t_buf); - el->el_term.t_buf = NULL; - free((ptr_t) el->el_term.t_cap); - el->el_term.t_cap = NULL; - el->el_term.t_loc = 0; - free((ptr_t) el->el_term.t_str); - el->el_term.t_str = NULL; - free((ptr_t) el->el_term.t_val); - el->el_term.t_val = NULL; - free((ptr_t) el->el_term.t_fkey); - el->el_term.t_fkey = NULL; - term_free_display(el); + free(el->el_terminal.t_buf); + el->el_terminal.t_buf = NULL; + free(el->el_terminal.t_cap); + el->el_terminal.t_cap = NULL; + el->el_terminal.t_loc = 0; + free(el->el_terminal.t_str); + el->el_terminal.t_str = NULL; + free(el->el_terminal.t_val); + el->el_terminal.t_val = NULL; + free(el->el_terminal.t_fkey); + el->el_terminal.t_fkey = NULL; + terminal_free_display(el); } -/* term_alloc(): +/* terminal_alloc(): * Maintain a string pool for termcap strings */ private void -term_alloc(EditLine *el, const struct termcapstr *t, const char *cap) +terminal_alloc(EditLine *el, const struct termcapstr *t, const char *cap) { char termbuf[TC_BUFSIZE]; size_t tlen, clen; - char **tlist = el->el_term.t_str; + char **tlist = el->el_terminal.t_str; char **tmp, **str = &tlist[t - tstr]; if (cap == NULL || *cap == '\0') { @@ -420,11 +422,11 @@ term_alloc(EditLine *el, const struct termcapstr *t, const char *cap) /* * New string is longer; see if we have enough space to append */ - if (el->el_term.t_loc + 3 < TC_BUFSIZE) { - tlen = TC_BUFSIZE - el->el_term.t_loc; - (void) strlcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], - cap, tlen); - el->el_term.t_loc += (int)clen + 1; /* one for \0 */ + if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) { + tlen = TC_BUFSIZE - el->el_terminal.t_loc; + (void) strlcpy(*str = &el->el_terminal.t_buf[ + el->el_terminal.t_loc], cap, tlen); + el->el_terminal.t_loc += (int)clen + 1; /* one for \0 */ return; } /* @@ -440,48 +442,49 @@ term_alloc(EditLine *el, const struct termcapstr *t, const char *cap) continue; termbuf[tlen++] = '\0'; } - memcpy(el->el_term.t_buf, termbuf, TC_BUFSIZE); - el->el_term.t_loc = (int)tlen; - if (el->el_term.t_loc + 3 >= TC_BUFSIZE) { + memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE); + el->el_terminal.t_loc = (int)tlen; + if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) { (void) fprintf(el->el_errfile, "Out of termcap string space.\n"); return; } - tlen = TC_BUFSIZE - el->el_term.t_loc; - (void) strlcpy(*str = &el->el_term.t_buf[el->el_term.t_loc], cap, tlen); - el->el_term.t_loc += (int)clen + 1; /* one for \0 */ + tlen = TC_BUFSIZE - el->el_terminal.t_loc; + (void) strlcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc], + cap, tlen); + el->el_terminal.t_loc += (int)clen + 1; /* one for \0 */ return; } -/* term_rebuffer_display(): +/* terminal_rebuffer_display(): * Rebuffer the display after the screen changed size */ private int -term_rebuffer_display(EditLine *el) +terminal_rebuffer_display(EditLine *el) { - coord_t *c = &el->el_term.t_size; + coord_t *c = &el->el_terminal.t_size; - term_free_display(el); + terminal_free_display(el); c->h = Val(T_co); c->v = Val(T_li); - if (term_alloc_display(el) == -1) + if (terminal_alloc_display(el) == -1) return (-1); return (0); } -/* term_alloc_display(): +/* terminal_alloc_display(): * Allocate a new display. */ private int -term_alloc_display(EditLine *el) +terminal_alloc_display(EditLine *el) { int i, rv = -1; Char **b; - coord_t *c = &el->el_term.t_size; + coord_t *c = &el->el_terminal.t_size; b = reallocarray(NULL, c->v + 1, sizeof(*b)); if (b == NULL) @@ -516,16 +519,16 @@ term_alloc_display(EditLine *el) rv = 0; done: if (rv) - term_free_display(el); + terminal_free_display(el); return (rv); } -/* term_free_display(): +/* terminal_free_display(): * Free the display buffers */ private void -term_free_display(EditLine *el) +terminal_free_display(EditLine *el) { Char **b; Char **bufp; @@ -547,22 +550,23 @@ term_free_display(EditLine *el) } -/* term_move_to_line(): +/* terminal_move_to_line(): * move to line <where> (first line == 0) * as efficiently as possible */ protected void -term_move_to_line(EditLine *el, int where) +terminal_move_to_line(EditLine *el, int where) { int del; if (where == el->el_cursor.v) return; - if (where > el->el_term.t_size.v) { + if (where > el->el_terminal.t_size.v) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "term_move_to_line: where is ridiculous: %d\r\n", where); + "terminal_move_to_line: where is ridiculous: %d\r\n", + where); #endif /* DEBUG_SCREEN */ return; } @@ -570,7 +574,7 @@ term_move_to_line(EditLine *el, int where) while (del > 0) { if (EL_HAS_AUTO_MARGINS && el->el_display[el->el_cursor.v][0] != '\0') { - size_t h = el->el_term.t_size.h - 1; + size_t h = el->el_terminal.t_size.h - 1; #ifdef WIDECHAR for (; h > 0 && el->el_display[el->el_cursor.v][h] == @@ -579,21 +583,21 @@ term_move_to_line(EditLine *el, int where) continue; #endif /* move without newline */ - term_move_to_char(el, (int)h); - term_overwrite(el, &el->el_display + terminal_move_to_char(el, (int)h); + terminal_overwrite(el, &el->el_display [el->el_cursor.v][el->el_cursor.h], - (size_t)(el->el_term.t_size.h - + (size_t)(el->el_terminal.t_size.h - el->el_cursor.h)); /* updates Cursor */ del--; } else { if ((del > 1) && GoodStr(T_DO)) { - term_tputs(el, tgoto(Str(T_DO), del, + terminal_tputs(el, tgoto(Str(T_DO), del, del), del); del = 0; } else { for (; del > 0; del--) - term__putc(el, '\n'); + terminal__putc(el, '\n'); /* because the \n will become \r\n */ el->el_cursor.h = 0; } @@ -601,22 +605,22 @@ term_move_to_line(EditLine *el, int where) } } else { /* del < 0 */ if (GoodStr(T_UP) && (-del > 1 || !GoodStr(T_up))) - term_tputs(el, tgoto(Str(T_UP), -del, -del), -del); + terminal_tputs(el, tgoto(Str(T_UP), -del, -del), -del); else { if (GoodStr(T_up)) for (; del < 0; del++) - term_tputs(el, Str(T_up), 1); + terminal_tputs(el, Str(T_up), 1); } } el->el_cursor.v = where;/* now where is here */ } -/* term_move_to_char(): +/* terminal_move_to_char(): * Move to the character position specified */ protected void -term_move_to_char(EditLine *el, int where) +terminal_move_to_char(EditLine *el, int where) { int del, i; @@ -624,15 +628,16 @@ mc_again: if (where == el->el_cursor.h) return; - if (where > el->el_term.t_size.h) { + if (where > el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "term_move_to_char: where is riduculous: %d\r\n", where); + "terminal_move_to_char: where is riduculous: %d\r\n", + where); #endif /* DEBUG_SCREEN */ return; } if (!where) { /* if where is first column */ - term__putc(el, '\r'); /* do a CR */ + terminal__putc(el, '\r'); /* do a CR */ el->el_cursor.h = 0; return; } @@ -640,11 +645,12 @@ mc_again: if ((del < -4 || del > 4) && GoodStr(T_ch)) /* go there directly */ - term_tputs(el, tgoto(Str(T_ch), where, where), where); + terminal_tputs(el, tgoto(Str(T_ch), where, where), where); else { if (del > 0) { /* moving forward */ if ((del > 4) && GoodStr(T_RI)) - term_tputs(el, tgoto(Str(T_RI), del, del), del); + terminal_tputs(el, tgoto(Str(T_RI), del, del), + del); else { /* if I can do tabs, use them */ if (EL_CAN_TAB) { @@ -661,7 +667,8 @@ mc_again: (el->el_cursor.h & 0370); i < (where & ~0x7); i += 8) - term__putc(el, '\t'); + terminal__putc(el, + '\t'); /* then tab over */ el->el_cursor.h = where & ~0x7; } @@ -671,17 +678,17 @@ mc_again: * chars, so we do. */ /* - * NOTE THAT term_overwrite() WILL CHANGE + * NOTE THAT terminal_overwrite() WILL CHANGE * el->el_cursor.h!!! */ - term_overwrite(el, &el->el_display[ + terminal_overwrite(el, &el->el_display[ el->el_cursor.v][el->el_cursor.h], (size_t)(where - el->el_cursor.h)); } } else { /* del < 0 := moving backward */ if ((-del > 4) && GoodStr(T_LE)) - term_tputs(el, tgoto(Str(T_LE), -del, -del), + terminal_tputs(el, tgoto(Str(T_LE), -del, -del), -del); else { /* can't go directly there */ /* @@ -693,12 +700,12 @@ mc_again: (((unsigned int) where >> 3) + (where & 07))) : (-del > where)) { - term__putc(el, '\r'); /* do a CR */ + terminal__putc(el, '\r');/* do a CR */ el->el_cursor.h = 0; goto mc_again; /* and try again */ } for (i = 0; i < -del; i++) - term__putc(el, '\b'); + terminal__putc(el, '\b'); } } } @@ -706,31 +713,31 @@ mc_again: } -/* term_overwrite(): +/* terminal_overwrite(): * Overstrike num characters * Assumes MB_FILL_CHARs are present to keep the column count correct */ protected void -term_overwrite(EditLine *el, const Char *cp, size_t n) +terminal_overwrite(EditLine *el, const Char *cp, size_t n) { if (n == 0) return; - if (n > (size_t)el->el_term.t_size.h) { + if (n > (size_t)el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "term_overwrite: n is riduculous: %d\r\n", n); + "terminal_overwrite: n is riduculous: %d\r\n", n); #endif /* DEBUG_SCREEN */ return; } do { - /* term__putc() ignores any MB_FILL_CHARs */ - term__putc(el, *cp++); + /* terminal__putc() ignores any MB_FILL_CHARs */ + terminal__putc(el, *cp++); el->el_cursor.h++; } while (--n); - if (el->el_cursor.h >= el->el_term.t_size.h) { /* wrap? */ + if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */ if (EL_HAS_AUTO_MARGINS) { /* yes */ el->el_cursor.h = 0; el->el_cursor.v++; @@ -740,28 +747,28 @@ term_overwrite(EditLine *el, const Char *cp, size_t n) Char c; if ((c = el->el_display[el->el_cursor.v] [el->el_cursor.h]) != '\0') { - term_overwrite(el, &c, 1); + terminal_overwrite(el, &c, 1); #ifdef WIDECHAR while (el->el_display[el->el_cursor.v] [el->el_cursor.h] == MB_FILL_CHAR) el->el_cursor.h++; #endif } else { - term__putc(el, ' '); + terminal__putc(el, ' '); el->el_cursor.h = 1; } } } else /* no wrap, but cursor stays on screen */ - el->el_cursor.h = el->el_term.t_size.h - 1; + el->el_cursor.h = el->el_terminal.t_size.h - 1; } } -/* term_deletechars(): +/* terminal_deletechars(): * Delete num characters */ protected void -term_deletechars(EditLine *el, int num) +terminal_deletechars(EditLine *el, int num) { if (num <= 0) return; @@ -772,38 +779,38 @@ term_deletechars(EditLine *el, int num) #endif /* DEBUG_EDIT */ return; } - if (num > el->el_term.t_size.h) { + if (num > el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, - "term_deletechars: num is riduculous: %d\r\n", num); + "terminal_deletechars: num is riduculous: %d\r\n", num); #endif /* DEBUG_SCREEN */ return; } if (GoodStr(T_DC)) /* if I have multiple delete */ if ((num > 1) || !GoodStr(T_dc)) { /* if dc would be more * expen. */ - term_tputs(el, tgoto(Str(T_DC), num, num), num); + terminal_tputs(el, tgoto(Str(T_DC), num, num), num); return; } if (GoodStr(T_dm)) /* if I have delete mode */ - term_tputs(el, Str(T_dm), 1); + terminal_tputs(el, Str(T_dm), 1); if (GoodStr(T_dc)) /* else do one at a time */ while (num--) - term_tputs(el, Str(T_dc), 1); + terminal_tputs(el, Str(T_dc), 1); if (GoodStr(T_ed)) /* if I have delete mode */ - term_tputs(el, Str(T_ed), 1); + terminal_tputs(el, Str(T_ed), 1); } -/* term_insertwrite(): +/* terminal_insertwrite(): * Puts terminal in insert character mode or inserts num * characters in the line * Assumes MB_FILL_CHARs are present to keep column count correct */ protected void -term_insertwrite(EditLine *el, Char *cp, int num) +terminal_insertwrite(EditLine *el, Char *cp, int num) { if (num <= 0) return; @@ -813,7 +820,7 @@ term_insertwrite(EditLine *el, Char *cp, int num) #endif /* DEBUG_EDIT */ return; } - if (num > el->el_term.t_size.h) { + if (num > el->el_terminal.t_size.h) { #ifdef DEBUG_SCREEN (void) fprintf(el->el_errfile, "StartInsert: num is riduculous: %d\r\n", num); @@ -823,91 +830,91 @@ term_insertwrite(EditLine *el, Char *cp, int num) if (GoodStr(T_IC)) /* if I have multiple insert */ if ((num > 1) || !GoodStr(T_ic)) { /* if ic would be more expensive */ - term_tputs(el, tgoto(Str(T_IC), num, num), num); - term_overwrite(el, cp, (size_t)num); + terminal_tputs(el, tgoto(Str(T_IC), num, num), num); + terminal_overwrite(el, cp, (size_t)num); /* this updates el_cursor.h */ return; } if (GoodStr(T_im) && GoodStr(T_ei)) { /* if I have insert mode */ - term_tputs(el, Str(T_im), 1); + terminal_tputs(el, Str(T_im), 1); el->el_cursor.h += num; do - term__putc(el, *cp++); + terminal__putc(el, *cp++); while (--num); if (GoodStr(T_ip)) /* have to make num chars insert */ - term_tputs(el, Str(T_ip), 1); + terminal_tputs(el, Str(T_ip), 1); - term_tputs(el, Str(T_ei), 1); + terminal_tputs(el, Str(T_ei), 1); return; } do { if (GoodStr(T_ic)) /* have to make num chars insert */ - term_tputs(el, Str(T_ic), 1); + terminal_tputs(el, Str(T_ic), 1); - term__putc(el, *cp++); + terminal__putc(el, *cp++); el->el_cursor.h++; if (GoodStr(T_ip)) /* have to make num chars insert */ - term_tputs(el, Str(T_ip), 1); + terminal_tputs(el, Str(T_ip), 1); /* pad the inserted char */ } while (--num); } -/* term_clear_EOL(): +/* terminal_clear_EOL(): * clear to end of line. There are num characters to clear */ protected void -term_clear_EOL(EditLine *el, int num) +terminal_clear_EOL(EditLine *el, int num) { int i; if (EL_CAN_CEOL && GoodStr(T_ce)) - term_tputs(el, Str(T_ce), 1); + terminal_tputs(el, Str(T_ce), 1); else { for (i = 0; i < num; i++) - term__putc(el, ' '); + terminal__putc(el, ' '); el->el_cursor.h += num; /* have written num spaces */ } } -/* term_clear_screen(): +/* terminal_clear_screen(): * Clear the screen */ protected void -term_clear_screen(EditLine *el) +terminal_clear_screen(EditLine *el) { /* clear the whole screen and home */ if (GoodStr(T_cl)) /* send the clear screen code */ - term_tputs(el, Str(T_cl), Val(T_li)); + terminal_tputs(el, Str(T_cl), Val(T_li)); else if (GoodStr(T_ho) && GoodStr(T_cd)) { - term_tputs(el, Str(T_ho), Val(T_li)); /* home */ + terminal_tputs(el, Str(T_ho), Val(T_li)); /* home */ /* clear to bottom of screen */ - term_tputs(el, Str(T_cd), Val(T_li)); + terminal_tputs(el, Str(T_cd), Val(T_li)); } else { - term__putc(el, '\r'); - term__putc(el, '\n'); + terminal__putc(el, '\r'); + terminal__putc(el, '\n'); } } -/* term_beep(): +/* terminal_beep(): * Beep the way the terminal wants us */ protected void -term_beep(EditLine *el) +terminal_beep(EditLine *el) { if (GoodStr(T_bl)) /* what termcap says we should use */ - term_tputs(el, Str(T_bl), 1); + terminal_tputs(el, Str(T_bl), 1); else - term__putc(el, '\007'); /* an ASCII bell; ^G */ + terminal__putc(el, '\007'); /* an ASCII bell; ^G */ } @@ -919,24 +926,24 @@ protected void term_clear_to_bottom(EditLine *el) { if (GoodStr(T_cd)) - term_tputs(el, Str(T_cd), Val(T_li)); + terminal_tputs(el, Str(T_cd), Val(T_li)); else if (GoodStr(T_ce)) - term_tputs(el, Str(T_ce), Val(T_li)); + terminal_tputs(el, Str(T_ce), Val(T_li)); } #endif protected void -term_get(EditLine *el, const char **term) +terminal_get(EditLine *el, const char **term) { - *term = el->el_term.t_name; + *term = el->el_terminal.t_name; } -/* term_set(): +/* terminal_set(): * Read in the terminal capabilities from the requested terminal */ protected int -term_set(EditLine *el, const char *term) +terminal_set(EditLine *el, const char *term) { int i; char buf[TC_BUFSIZE]; @@ -961,9 +968,9 @@ term_set(EditLine *el, const char *term) if (strcmp(term, "emacs") == 0) el->el_flags |= EDIT_DISABLED; - memset(el->el_term.t_cap, 0, TC_BUFSIZE); + (void) memset(el->el_terminal.t_cap, 0, TC_BUFSIZE); - i = tgetent(el->el_term.t_cap, term); + i = tgetent(el->el_terminal.t_cap, term); if (i <= 0) { if (i == -1) @@ -978,7 +985,7 @@ term_set(EditLine *el, const char *term) Val(T_pt) = Val(T_km) = Val(T_li) = 0; Val(T_xt) = Val(T_MT); for (t = tstr; t->name != NULL; t++) - term_alloc(el, t, NULL); + terminal_alloc(el, t, NULL); } else { /* auto/magic margins */ Val(T_am) = tgetflag("am"); @@ -994,7 +1001,7 @@ term_set(EditLine *el, const char *term) Val(T_li) = tgetnum("li"); for (t = tstr; t->name != NULL; t++) { /* XXX: some systems' tgetstr needs non const */ - term_alloc(el, t, tgetstr(strchr(t->name, *t->name), + terminal_alloc(el, t, tgetstr(strchr(t->name, *t->name), &area)); } } @@ -1004,28 +1011,28 @@ term_set(EditLine *el, const char *term) if (Val(T_li) < 1) Val(T_li) = 24; - el->el_term.t_size.v = Val(T_co); - el->el_term.t_size.h = Val(T_li); + el->el_terminal.t_size.v = Val(T_co); + el->el_terminal.t_size.h = Val(T_li); - term_setflags(el); + terminal_setflags(el); /* get the correct window size */ - (void) term_get_size(el, &lins, &cols); - if (term_change_size(el, lins, cols) == -1) + (void) terminal_get_size(el, &lins, &cols); + if (terminal_change_size(el, lins, cols) == -1) return (-1); (void) sigprocmask(SIG_SETMASK, &oset, NULL); - term_bind_arrow(el); - el->el_term.t_name = term; + terminal_bind_arrow(el); + el->el_terminal.t_name = term; return (i <= 0 ? -1 : 0); } -/* term_get_size(): +/* terminal_get_size(): * Return the new window size in lines and cols, and * true if the size was changed. */ protected int -term_get_size(EditLine *el, int *lins, int *cols) +terminal_get_size(EditLine *el, int *lins, int *cols) { *cols = Val(T_co); @@ -1057,11 +1064,11 @@ term_get_size(EditLine *el, int *lins, int *cols) } -/* term_change_size(): +/* terminal_change_size(): * Change the size of the terminal */ protected int -term_change_size(EditLine *el, int lins, int cols) +terminal_change_size(EditLine *el, int lins, int cols) { /* * Just in case @@ -1070,20 +1077,20 @@ term_change_size(EditLine *el, int lins, int cols) Val(T_li) = (lins < 1) ? 24 : lins; /* re-make display buffers */ - if (term_rebuffer_display(el) == -1) + if (terminal_rebuffer_display(el) == -1) return (-1); re_clear_display(el); return (0); } -/* term_init_arrow(): +/* terminal_init_arrow(): * Initialize the arrow key bindings from termcap */ private void -term_init_arrow(EditLine *el) +terminal_init_arrow(EditLine *el) { - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; arrow[A_K_DN].name = STR("down"); arrow[A_K_DN].key = T_kd; @@ -1117,13 +1124,13 @@ term_init_arrow(EditLine *el) } -/* term_reset_arrow(): +/* terminal_reset_arrow(): * Reset arrow key bindings */ private void -term_reset_arrow(EditLine *el) +terminal_reset_arrow(EditLine *el) { - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; static const Char strA[] = {033, '[', 'A', '\0'}; static const Char strB[] = {033, '[', 'B', '\0'}; static const Char strC[] = {033, '[', 'C', '\0'}; @@ -1167,13 +1174,14 @@ term_reset_arrow(EditLine *el) } -/* term_set_arrow(): +/* terminal_set_arrow(): * Set an arrow key binding */ protected int -term_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, int type) +terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, + int type) { - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; int i; for (i = 0; i < A_K_NKEYS; i++) @@ -1186,13 +1194,13 @@ term_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun, int type) } -/* term_clear_arrow(): +/* terminal_clear_arrow(): * Clear an arrow key binding */ protected int -term_clear_arrow(EditLine *el, const Char *name) +terminal_clear_arrow(EditLine *el, const Char *name) { - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; int i; for (i = 0; i < A_K_NKEYS; i++) @@ -1204,14 +1212,14 @@ term_clear_arrow(EditLine *el, const Char *name) } -/* term_print_arrow(): +/* terminal_print_arrow(): * Print the arrow key bindings */ protected void -term_print_arrow(EditLine *el, const Char *name) +terminal_print_arrow(EditLine *el, const Char *name) { int i; - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; for (i = 0; i < A_K_NKEYS; i++) if (*name == '\0' || Strcmp(name, arrow[i].name) == 0) @@ -1221,33 +1229,33 @@ term_print_arrow(EditLine *el, const Char *name) } -/* term_bind_arrow(): +/* terminal_bind_arrow(): * Bind the arrow keys */ protected void -term_bind_arrow(EditLine *el) +terminal_bind_arrow(EditLine *el) { el_action_t *map; const el_action_t *dmap; int i, j; char *p; - fkey_t *arrow = el->el_term.t_fkey; + funckey_t *arrow = el->el_terminal.t_fkey; /* Check if the components needed are initialized */ - if (el->el_term.t_buf == NULL || el->el_map.key == NULL) + if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL) return; map = el->el_map.type == MAP_VI ? el->el_map.alt : el->el_map.key; dmap = el->el_map.type == MAP_VI ? el->el_map.vic : el->el_map.emacs; - term_reset_arrow(el); + terminal_reset_arrow(el); for (i = 0; i < A_K_NKEYS; i++) { Char wt_str[VISUAL_WIDTH_MAX]; Char *px; size_t n; - p = el->el_term.t_str[arrow[i].key]; + p = el->el_terminal.t_str[arrow[i].key]; if (!p || !*p) continue; for (n = 0; n < VISUAL_WIDTH_MAX && p[n]; ++n) @@ -1286,35 +1294,35 @@ term_bind_arrow(EditLine *el) } } -/* term_putc(): +/* terminal_putc(): * Add a character */ private int -term_putc(int c) +terminal_putc(int c) { - if (term_outfile == NULL) + if (terminal_outfile == NULL) return -1; - return fputc(c, term_outfile); + return fputc(c, terminal_outfile); } private void -term_tputs(EditLine *el, const char *cap, int affcnt) +terminal_tputs(EditLine *el, const char *cap, int affcnt) { #ifdef _REENTRANT - pthread_mutex_lock(&term_mutex); + pthread_mutex_lock(&terminal_mutex); #endif - term_outfile = el->el_outfile; - (void)tputs(cap, affcnt, term_putc); + terminal_outfile = el->el_outfile; + (void)tputs(cap, affcnt, terminal_putc); #ifdef _REENTRANT - pthread_mutex_unlock(&term_mutex); + pthread_mutex_unlock(&terminal_mutex); #endif } -/* term__putc(): +/* terminal__putc(): * Add a character */ protected int -term__putc(EditLine *el, Int c) +terminal__putc(EditLine *el, Int c) { char buf[MB_LEN_MAX +1]; ssize_t i; @@ -1327,36 +1335,36 @@ term__putc(EditLine *el, Int c) return fputs(buf, el->el_outfile); } -/* term__flush(): +/* terminal__flush(): * Flush output */ protected void -term__flush(EditLine *el) +terminal__flush(EditLine *el) { (void) fflush(el->el_outfile); } -/* term_writec(): +/* terminal_writec(): * Write the given character out, in a human readable form */ protected void -term_writec(EditLine *el, Int c) +terminal_writec(EditLine *el, Int c) { Char visbuf[VISUAL_WIDTH_MAX +1]; ssize_t vcnt = ct_visual_char(visbuf, VISUAL_WIDTH_MAX, c); visbuf[vcnt] = '\0'; - term_overwrite(el, visbuf, (size_t)vcnt); - term__flush(el); + terminal_overwrite(el, visbuf, (size_t)vcnt); + terminal__flush(el); } -/* term_telltc(): +/* terminal_telltc(): * Print the current termcap characteristics */ protected int /*ARGSUSED*/ -term_telltc(EditLine *el, int argc __attribute__((__unused__)), +terminal_telltc(EditLine *el, int argc __attribute__((__unused__)), const Char **argv __attribute__((__unused__))) { const struct termcapstr *t; @@ -1376,7 +1384,7 @@ term_telltc(EditLine *el, int argc __attribute__((__unused__)), (void) fprintf(el->el_outfile, "\tIt %s magic margins\n", EL_HAS_MAGIC_MARGINS ? "has" : "does not have"); - for (t = tstr, ts = el->el_term.t_str; t->name != NULL; t++, ts++) { + for (t = tstr, ts = el->el_terminal.t_str; t->name != NULL; t++, ts++) { const char *ub; if (*ts && **ts) { ub = ct_encode_string(ct_visual_string( @@ -1393,12 +1401,12 @@ term_telltc(EditLine *el, int argc __attribute__((__unused__)), } -/* term_settc(): +/* terminal_settc(): * Change the current terminal characteristics */ protected int /*ARGSUSED*/ -term_settc(EditLine *el, int argc __attribute__((__unused__)), +terminal_settc(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) { const struct termcapstr *ts; @@ -1421,8 +1429,8 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)), break; if (ts->name != NULL) { - term_alloc(el, ts, how); - term_setflags(el); + terminal_alloc(el, ts, how); + terminal_setflags(el); return 0; } /* @@ -1438,16 +1446,16 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)), if (tv == &tval[T_pt] || tv == &tval[T_km] || tv == &tval[T_am] || tv == &tval[T_xn]) { if (strcmp(how, "yes") == 0) - el->el_term.t_val[tv - tval] = 1; + el->el_terminal.t_val[tv - tval] = 1; else if (strcmp(how, "no") == 0) - el->el_term.t_val[tv - tval] = 0; + el->el_terminal.t_val[tv - tval] = 0; else { (void) fprintf(el->el_errfile, "" FSTR ": Bad value `%s'.\n", argv[0], how); return -1; } - term_setflags(el); - if (term_change_size(el, Val(T_li), Val(T_co)) == -1) + terminal_setflags(el); + if (terminal_change_size(el, Val(T_li), Val(T_co)) == -1) return -1; return 0; } else { @@ -1460,11 +1468,11 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)), "" FSTR ": Bad value `%s'.\n", argv[0], how); return -1; } - el->el_term.t_val[tv - tval] = (int) i; - el->el_term.t_size.v = Val(T_co); - el->el_term.t_size.h = Val(T_li); + el->el_terminal.t_val[tv - tval] = (int) i; + el->el_terminal.t_size.v = Val(T_co); + el->el_terminal.t_size.h = Val(T_li); if (tv == &tval[T_co] || tv == &tval[T_li]) - if (term_change_size(el, Val(T_li), Val(T_co)) + if (terminal_change_size(el, Val(T_li), Val(T_co)) == -1) return -1; return 0; @@ -1472,12 +1480,12 @@ term_settc(EditLine *el, int argc __attribute__((__unused__)), } -/* term_gettc(): +/* terminal_gettc(): * Get the current terminal characteristics */ protected int /*ARGSUSED*/ -term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) +terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) { const struct termcapstr *ts; const struct termcapval *tv; @@ -1498,7 +1506,7 @@ term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) break; if (ts->name != NULL) { - *(char **)how = el->el_term.t_str[ts - tstr]; + *(char **)how = el->el_terminal.t_str[ts - tstr]; return 0; } /* @@ -1515,23 +1523,23 @@ term_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv) tv == &tval[T_am] || tv == &tval[T_xn]) { static char yes[] = "yes"; static char no[] = "no"; - if (el->el_term.t_val[tv - tval]) + if (el->el_terminal.t_val[tv - tval]) *(char **)how = yes; else *(char **)how = no; return 0; } else { - *(int *)how = el->el_term.t_val[tv - tval]; + *(int *)how = el->el_terminal.t_val[tv - tval]; return 0; } } -/* term_echotc(): +/* terminal_echotc(): * Print the termcap string out with variable substitution */ protected int /*ARGSUSED*/ -term_echotc(EditLine *el, int argc __attribute__((__unused__)), +terminal_echotc(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) { char *cap, *scap; @@ -1610,7 +1618,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), for (t = tstr; t->name != NULL; t++) if (strcmp(t->name, ct_encode_string(*argv, &el->el_scratch)) == 0) { - scap = el->el_term.t_str[t - tstr]; + scap = el->el_terminal.t_str[t - tstr]; break; } if (t->name == NULL) { @@ -1667,7 +1675,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), *argv); return (-1); } - term_tputs(el, scap, 1); + terminal_tputs(el, scap, 1); break; case 1: argv++; @@ -1695,7 +1703,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), *argv); return (-1); } - term_tputs(el, tgoto(scap, arg_cols, arg_rows), 1); + terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), 1); break; default: /* This is wrong, but I will ignore it... */ @@ -1751,7 +1759,7 @@ term_echotc(EditLine *el, int argc __attribute__((__unused__)), *argv); return (-1); } - term_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows); + terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows); break; } return (0); diff --git a/lib/libedit/terminal.h b/lib/libedit/terminal.h index 0cee8b99184..fab7b103dd1 100644 --- a/lib/libedit/terminal.h +++ b/lib/libedit/terminal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: terminal.h,v 1.2 2016/01/29 19:32:34 schwarze Exp $ */ +/* $OpenBSD: terminal.h,v 1.3 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: term.h,v 1.21 2009/12/30 22:37:40 christos Exp $ */ /*- @@ -48,7 +48,7 @@ typedef struct { /* Symbolic function key bindings */ int key; /* Index in termcap table */ keymacro_value_t fun; /* Function bound to it */ int type; /* Type of function */ -} fkey_t; +} funckey_t; typedef struct { const char *t_name; /* the terminal name */ @@ -68,8 +68,8 @@ typedef struct { char **t_str; /* termcap strings */ int *t_val; /* termcap values */ char *t_cap; /* Termcap buffer */ - fkey_t *t_fkey; /* Array of keys */ -} el_term_t; + funckey_t *t_fkey; /* Array of keys */ +} el_terminal_t; /* * fKey indexes @@ -82,37 +82,36 @@ typedef struct { #define A_K_EN 5 #define A_K_NKEYS 6 -protected void term_move_to_line(EditLine *, int); -protected void term_move_to_char(EditLine *, int); -protected void term_clear_EOL(EditLine *, int); -protected void term_overwrite(EditLine *, const Char *, size_t); -protected void term_insertwrite(EditLine *, Char *, int); -protected void term_deletechars(EditLine *, int); -protected void term_clear_screen(EditLine *); -protected void term_beep(EditLine *); -protected int term_change_size(EditLine *, int, int); -protected int term_get_size(EditLine *, int *, int *); -protected int term_init(EditLine *); -protected void term_bind_arrow(EditLine *); -protected void term_print_arrow(EditLine *, const Char *); -protected int term_clear_arrow(EditLine *, const Char *); -protected int term_set_arrow(EditLine *, const Char *, keymacro_value_t *, - int); -protected void term_end(EditLine *); -protected void term_get(EditLine *, const char **); -protected int term_set(EditLine *, const char *); -protected int term_settc(EditLine *, int, const Char **); -protected int term_gettc(EditLine *, int, char **); -protected int term_telltc(EditLine *, int, const Char **); -protected int term_echotc(EditLine *, int, const Char **); -protected void term_writec(EditLine *, Int); -protected int term__putc(EditLine *, Int); -protected void term__flush(EditLine *); +protected void terminal_move_to_line(EditLine *, int); +protected void terminal_move_to_char(EditLine *, int); +protected void terminal_clear_EOL(EditLine *, int); +protected void terminal_overwrite(EditLine *, const Char *, size_t); +protected void terminal_insertwrite(EditLine *, Char *, int); +protected void terminal_deletechars(EditLine *, int); +protected void terminal_clear_screen(EditLine *); +protected void terminal_beep(EditLine *); +protected int terminal_change_size(EditLine *, int, int); +protected int terminal_get_size(EditLine *, int *, int *); +protected int terminal_init(EditLine *); +protected void terminal_bind_arrow(EditLine *); +protected void terminal_print_arrow(EditLine *, const Char *); +protected int terminal_clear_arrow(EditLine *, const Char *); +protected int terminal_set_arrow(EditLine *, const Char *, keymacro_value_t *, int); +protected void terminal_end(EditLine *); +protected void terminal_get(EditLine *, const char **); +protected int terminal_set(EditLine *, const char *); +protected int terminal_settc(EditLine *, int, const Char **); +protected int terminal_gettc(EditLine *, int, char **); +protected int terminal_telltc(EditLine *, int, const Char **); +protected int terminal_echotc(EditLine *, int, const Char **); +protected void terminal_writec(EditLine *, Int); +protected int terminal__putc(EditLine *, Int); +protected void terminal__flush(EditLine *); /* * Easy access macros */ -#define EL_FLAGS (el)->el_term.t_flags +#define EL_FLAGS (el)->el_terminal.t_flags #define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT) #define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE) diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c index 962baaa6829..34458939d20 100644 --- a/lib/libedit/tty.c +++ b/lib/libedit/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.15 2016/01/29 19:32:34 schwarze Exp $ */ +/* $OpenBSD: tty.c,v 1.16 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: tty.c,v 1.34 2011/01/27 23:11:40 christos Exp $ */ /*- @@ -1196,7 +1196,8 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv) cu = strlen(m->m_name) + (x != '\0') + 1; - if (len + cu >= (size_t)el->el_term.t_size.h) { + if (len + cu >= + (size_t)el->el_terminal.t_size.h) { (void) fprintf(el->el_outfile, "\n%*s", (int)st, ""); len = st + cu; diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index a960e4290f6..475fdd33c09 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vi.c,v 1.12 2014/10/17 06:07:50 deraadt Exp $ */ +/* $OpenBSD: vi.c,v 1.13 2016/01/30 00:06:39 schwarze Exp $ */ /* $NetBSD: vi.c,v 1.33 2011/02/17 16:44:48 joerg Exp $ */ /*- @@ -601,14 +601,14 @@ vi_list_or_eof(EditLine *el, Int c) if (el->el_line.cursor == el->el_line.lastchar) { if (el->el_line.cursor == el->el_line.buffer) { - term_writec(el, c); /* then do a EOF */ + terminal_writec(el, c); /* then do a EOF */ return (CC_EOF); } else { /* * Here we could list completions, but it is an * error right now */ - term_beep(el); + terminal_beep(el); return (CC_ERROR); } } else { @@ -620,7 +620,7 @@ vi_list_or_eof(EditLine *el, Int c) /* * Just complain for now. */ - term_beep(el); + terminal_beep(el); return (CC_ERROR); #endif } |