Lines Matching refs:el

77 #include "el.h"
88 #define GoodStr(a) (el->el_terminal.t_str[a] != NULL && \
89 el->el_terminal.t_str[a][0] != '\0')
90 #define Str(a) el->el_terminal.t_str[a]
91 #define Val(a) el->el_terminal.t_val[a]
225 terminal_setflags(EditLine *el)
228 if (el->el_tty.t_tabs)
252 (void) fprintf(el->el_errfile,
254 (void) fprintf(el->el_errfile,
258 (void) fprintf(el->el_errfile, "no clear EOL capability.\n");
260 (void) fprintf(el->el_errfile, "no delete char capability.\n");
262 (void) fprintf(el->el_errfile, "no insert char capability.\n");
270 terminal_init(EditLine *el)
273 el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
274 sizeof(*el->el_terminal.t_buf));
275 if (el->el_terminal.t_buf == NULL)
277 el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
278 sizeof(*el->el_terminal.t_cap));
279 if (el->el_terminal.t_cap == NULL)
281 el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
282 sizeof(*el->el_terminal.t_fkey));
283 if (el->el_terminal.t_fkey == NULL)
285 el->el_terminal.t_loc = 0;
286 el->el_terminal.t_str = el_malloc(T_str *
287 sizeof(*el->el_terminal.t_str));
288 if (el->el_terminal.t_str == NULL)
290 (void) memset(el->el_terminal.t_str, 0, T_str *
291 sizeof(*el->el_terminal.t_str));
292 el->el_terminal.t_val = el_malloc(T_val *
293 sizeof(*el->el_terminal.t_val));
294 if (el->el_terminal.t_val == NULL)
296 (void) memset(el->el_terminal.t_val, 0, T_val *
297 sizeof(*el->el_terminal.t_val));
298 (void) terminal_set(el, NULL);
299 terminal_init_arrow(el);
302 free(el->el_terminal.t_str);
303 el->el_terminal.t_str = NULL;
305 free(el->el_terminal.t_fkey);
306 el->el_terminal.t_fkey = NULL;
308 free(el->el_terminal.t_cap);
309 el->el_terminal.t_cap = NULL;
311 free(el->el_terminal.t_buf);
312 el->el_terminal.t_buf = NULL;
321 terminal_end(EditLine *el)
324 el_free(el->el_terminal.t_buf);
325 el->el_terminal.t_buf = NULL;
326 el_free(el->el_terminal.t_cap);
327 el->el_terminal.t_cap = NULL;
328 el->el_terminal.t_loc = 0;
329 el_free(el->el_terminal.t_str);
330 el->el_terminal.t_str = NULL;
331 el_free(el->el_terminal.t_val);
332 el->el_terminal.t_val = NULL;
333 el_free(el->el_terminal.t_fkey);
334 el->el_terminal.t_fkey = NULL;
335 terminal_free_display(el);
343 terminal_alloc(EditLine *el, const struct termcapstr *t, const char *cap)
347 char **tlist = el->el_terminal.t_str;
370 if (el->el_terminal.t_loc + 3 < TC_BUFSIZE) {
372 (void) strcpy(*str = &el->el_terminal.t_buf[
373 el->el_terminal.t_loc], cap);
374 el->el_terminal.t_loc += clen + 1; /* one for \0 */
390 memcpy(el->el_terminal.t_buf, termbuf, TC_BUFSIZE);
391 el->el_terminal.t_loc = tlen;
392 if (el->el_terminal.t_loc + 3 >= TC_BUFSIZE) {
393 (void) fprintf(el->el_errfile,
398 (void) strcpy(*str = &el->el_terminal.t_buf[el->el_terminal.t_loc],
400 el->el_terminal.t_loc += (size_t)clen + 1; /* one for \0 */
409 terminal_rebuffer_display(EditLine *el)
411 coord_t *c = &el->el_terminal.t_size;
413 terminal_free_display(el);
418 if (terminal_alloc_display(el) == -1)
428 terminal_alloc_display(EditLine *el)
432 coord_t *c = &el->el_terminal.t_size;
447 el->el_display = b;
462 el->el_vdisplay = b;
465 terminal_free_display(el);
474 terminal_free_display(EditLine *el)
479 b = el->el_display;
480 el->el_display = NULL;
486 b = el->el_vdisplay;
487 el->el_vdisplay = NULL;
501 terminal_move_to_line(EditLine *el, int where)
505 if (where == el->el_cursor.v)
508 if (where > el->el_terminal.t_size.v) {
510 (void) fprintf(el->el_errfile,
515 if ((del = where - el->el_cursor.v) > 0) {
518 el->el_display[el->el_cursor.v][0] != '\0') {
520 (el->el_terminal.t_size.h - 1);
523 el->el_display[el->el_cursor.v][h] ==
529 terminal_move_to_char(el, (int)h);
530 terminal_overwrite(el, &el->el_display
531 [el->el_cursor.v][el->el_cursor.h],
532 (size_t)(el->el_terminal.t_size.h -
533 el->el_cursor.h));
538 terminal_tputs(el, tgoto(Str(T_DO), del,
543 terminal__putc(el, '\n');
545 el->el_cursor.h = 0;
551 terminal_tputs(el, tgoto(Str(T_UP), -del, -del), -del);
555 terminal_tputs(el, Str(T_up), 1);
558 el->el_cursor.v = where;/* now where is here */
566 terminal_move_to_char(EditLine *el, int where)
571 if (where == el->el_cursor.h)
574 if (where > el->el_terminal.t_size.h) {
576 (void) fprintf(el->el_errfile,
582 terminal__putc(el, '\r'); /* do a CR */
583 el->el_cursor.h = 0;
586 del = where - el->el_cursor.h;
590 terminal_tputs(el, tgoto(Str(T_ch), where, where), where);
594 terminal_tputs(el, tgoto(Str(T_RI), del, del),
599 if ((el->el_cursor.h & 0370) !=
602 && (el->el_display[
603 el->el_cursor.v][where & 0370] !=
609 (el->el_cursor.h & 0370);
612 terminal__putc(el,
615 el->el_cursor.h = where & ~0x7;
624 * el->el_cursor.h!!!
626 terminal_overwrite(el, &el->el_display[
627 el->el_cursor.v][el->el_cursor.h],
628 (size_t)(where - el->el_cursor.h));
633 terminal_tputs(el, tgoto(Str(T_LE), -del, -del),
645 terminal__putc(el, '\r');/* do a CR */
646 el->el_cursor.h = 0;
650 terminal__putc(el, '\b');
654 el->el_cursor.h = where; /* now where is here */
663 terminal_overwrite(EditLine *el, const Char *cp, size_t n)
668 if (n > (size_t)el->el_terminal.t_size.h) {
670 (void) fprintf(el->el_errfile,
678 terminal__putc(el, *cp++);
679 el->el_cursor.h++;
682 if (el->el_cursor.h >= el->el_terminal.t_size.h) { /* wrap? */
684 el->el_cursor.h = 0;
685 el->el_cursor.v++;
690 if ((c = el->el_display[el->el_cursor.v]
691 [el->el_cursor.h]) != '\0') {
692 terminal_overwrite(el, &c, (size_t)1);
694 while (el->el_display[el->el_cursor.v]
695 [el->el_cursor.h] == MB_FILL_CHAR)
696 el->el_cursor.h++;
699 terminal__putc(el, ' ');
700 el->el_cursor.h = 1;
704 el->el_cursor.h = el->el_terminal.t_size.h - 1;
713 terminal_deletechars(EditLine *el, int num)
720 (void) fprintf(el->el_errfile, " ERROR: cannot delete \n");
724 if (num > el->el_terminal.t_size.h) {
726 (void) fprintf(el->el_errfile,
734 terminal_tputs(el, tgoto(Str(T_DC), num, num), num);
738 terminal_tputs(el, Str(T_dm), 1);
742 terminal_tputs(el, Str(T_dc), 1);
745 terminal_tputs(el, Str(T_ed), 1);
755 terminal_insertwrite(EditLine *el, Char *cp, int num)
761 (void) fprintf(el->el_errfile, " ERROR: cannot insert \n");
765 if (num > el->el_terminal.t_size.h) {
767 (void) fprintf(el->el_errfile,
775 terminal_tputs(el, tgoto(Str(T_IC), num, num), num);
776 terminal_overwrite(el, cp, (size_t)num);
781 terminal_tputs(el, Str(T_im), 1);
783 el->el_cursor.h += num;
785 terminal__putc(el, *cp++);
789 terminal_tputs(el, Str(T_ip), 1);
791 terminal_tputs(el, Str(T_ei), 1);
796 terminal_tputs(el, Str(T_ic), 1);
798 terminal__putc(el, *cp++);
800 el->el_cursor.h++;
803 terminal_tputs(el, Str(T_ip), 1);
814 terminal_clear_EOL(EditLine *el, int num)
819 terminal_tputs(el, Str(T_ce), 1);
822 terminal__putc(el, ' ');
823 el->el_cursor.h += num; /* have written num spaces */
832 terminal_clear_screen(EditLine *el)
837 terminal_tputs(el, Str(T_cl), Val(T_li));
839 terminal_tputs(el, Str(T_ho), Val(T_li)); /* home */
841 terminal_tputs(el, Str(T_cd), Val(T_li));
843 terminal__putc(el, '\r');
844 terminal__putc(el, '\n');
853 terminal_beep(EditLine *el)
857 terminal_tputs(el, Str(T_bl), 1);
859 terminal__putc(el, '\007'); /* an ASCII bell; ^G */
864 terminal_get(EditLine *el, const char **term)
866 *term = el->el_terminal.t_name;
874 terminal_set(EditLine *el, const char *term)
897 el->el_flags |= EDIT_DISABLED;
899 (void) memset(el->el_terminal.t_cap, 0, TC_BUFSIZE);
901 i = tgetent(el->el_terminal.t_cap, term);
905 (void) fprintf(el->el_errfile,
908 (void) fprintf(el->el_errfile,
910 (void) fprintf(el->el_errfile,
916 terminal_alloc(el, t, NULL);
932 terminal_alloc(el, t, tgetstr(strchr(t->name, *t->name),
942 el->el_terminal.t_size.v = Val(T_co);
943 el->el_terminal.t_size.h = Val(T_li);
945 terminal_setflags(el);
948 (void) terminal_get_size(el, &lins, &cols);
949 if (terminal_change_size(el, lins, cols) == -1)
952 terminal_bind_arrow(el);
953 el->el_terminal.t_name = term;
963 terminal_get_size(EditLine *el, int *lins, int *cols)
972 if (ioctl(el->el_infd, TIOCGWINSZ, &ws) != -1) {
983 if (ioctl(el->el_infd, TIOCGSIZE, &ts) != -1) {
999 terminal_change_size(EditLine *el, int lins, int cols)
1008 if (terminal_rebuffer_display(el) == -1)
1010 re_clear_display(el);
1019 terminal_init_arrow(EditLine *el)
1021 funckey_t *arrow = el->el_terminal.t_fkey;
1064 terminal_reset_arrow(EditLine *el)
1066 funckey_t *arrow = el->el_terminal.t_fkey;
1080 keymacro_add(el, strA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1081 keymacro_add(el, strB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1082 keymacro_add(el, strC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1083 keymacro_add(el, strD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1084 keymacro_add(el, strH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1085 keymacro_add(el, strF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1086 keymacro_add(el, stOA, &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1087 keymacro_add(el, stOB, &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1088 keymacro_add(el, stOC, &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1089 keymacro_add(el, stOD, &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1090 keymacro_add(el, stOH, &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1091 keymacro_add(el, stOF, &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1093 if (el->el_map.type != MAP_VI)
1095 keymacro_add(el, &strA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1096 keymacro_add(el, &strB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1097 keymacro_add(el, &strC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1098 keymacro_add(el, &strD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1099 keymacro_add(el, &strH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1100 keymacro_add(el, &strF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1101 keymacro_add(el, &stOA[1], &arrow[A_K_UP].fun, arrow[A_K_UP].type);
1102 keymacro_add(el, &stOB[1], &arrow[A_K_DN].fun, arrow[A_K_DN].type);
1103 keymacro_add(el, &stOC[1], &arrow[A_K_RT].fun, arrow[A_K_RT].type);
1104 keymacro_add(el, &stOD[1], &arrow[A_K_LT].fun, arrow[A_K_LT].type);
1105 keymacro_add(el, &stOH[1], &arrow[A_K_HO].fun, arrow[A_K_HO].type);
1106 keymacro_add(el, &stOF[1], &arrow[A_K_EN].fun, arrow[A_K_EN].type);
1114 terminal_set_arrow(EditLine *el, const Char *name, keymacro_value_t *fun,
1117 funckey_t *arrow = el->el_terminal.t_fkey;
1134 terminal_clear_arrow(EditLine *el, const Char *name)
1136 funckey_t *arrow = el->el_terminal.t_fkey;
1152 terminal_print_arrow(EditLine *el, const Char *name)
1155 funckey_t *arrow = el->el_terminal.t_fkey;
1160 keymacro_kprint(el, arrow[i].name,
1169 terminal_bind_arrow(EditLine *el)
1175 funckey_t *arrow = el->el_terminal.t_fkey;
1178 if (el->el_terminal.t_buf == NULL || el->el_map.key == NULL)
1181 map = el->el_map.type == MAP_VI ? el->el_map.alt : el->el_map.key;
1182 dmap = el->el_map.type == MAP_VI ? el->el_map.vic : el->el_map.emacs;
1184 terminal_reset_arrow(el);
1191 p = el->el_terminal.t_str[arrow[i].key];
1211 keymacro_clear(el, map, px);
1215 keymacro_add(el, px, &arrow[i].fun,
1219 keymacro_clear(el, map, px);
1223 keymacro_add(el, px, &arrow[i].fun,
1242 terminal_tputs(EditLine *el, const char *cap, int affcnt)
1247 terminal_outfile = el->el_outfile;
1258 terminal__putc(EditLine *el, wint_t c)
1268 return fputs(buf, el->el_outfile);
1275 terminal__flush(EditLine *el)
1278 (void) fflush(el->el_outfile);
1285 terminal_writec(EditLine *el, wint_t c)
1292 terminal_overwrite(el, visbuf, (size_t)vcnt);
1293 terminal__flush(el);
1302 terminal_telltc(EditLine *el, int argc __attribute__((__unused__)),
1308 (void) fprintf(el->el_outfile, "\n\tYour terminal has the\n");
1309 (void) fprintf(el->el_outfile, "\tfollowing characteristics:\n\n");
1310 (void) fprintf(el->el_outfile, "\tIt has %d columns and %d lines\n",
1312 (void) fprintf(el->el_outfile,
1314 (void) fprintf(el->el_outfile,
1316 (void) fprintf(el->el_outfile, "\tIt %s automatic margins\n",
1319 (void) fprintf(el->el_outfile, "\tIt %s magic margins\n",
1322 for (t = tstr, ts = el->el_terminal.t_str; t->name != NULL; t++, ts++) {
1326 ct_decode_string(*ts, &el->el_scratch)),
1327 &el->el_scratch);
1331 (void) fprintf(el->el_outfile, "\t%25s (%s) == %s\n",
1334 (void) fputc('\n', el->el_outfile);
1344 terminal_settc(EditLine *el, int argc __attribute__((__unused__)),
1354 strncpy(what, ct_encode_string(argv[1], &el->el_scratch), sizeof(what));
1356 strncpy(how, ct_encode_string(argv[2], &el->el_scratch), sizeof(how));
1367 terminal_alloc(el, ts, how);
1368 terminal_setflags(el);
1384 el->el_terminal.t_val[tv - tval] = 1;
1386 el->el_terminal.t_val[tv - tval] = 0;
1388 (void) fprintf(el->el_errfile,
1392 terminal_setflags(el);
1393 if (terminal_change_size(el, Val(T_li), Val(T_co)) == -1)
1402 (void) fprintf(el->el_errfile,
1406 el->el_terminal.t_val[tv - tval] = (int) i;
1407 el->el_terminal.t_size.v = Val(T_co);
1408 el->el_terminal.t_size.h = Val(T_li);
1410 if (terminal_change_size(el, Val(T_li), Val(T_co))
1423 terminal_gettc(EditLine *el, int argc __attribute__((__unused__)), char **argv)
1444 *(char **)how = el->el_terminal.t_str[ts - tstr];
1461 if (el->el_terminal.t_val[tv - tval])
1467 *(int *)how = el->el_terminal.t_val[tv - tval];
1477 terminal_echotc(EditLine *el, int argc __attribute__((__unused__)),
1513 (void) fprintf(el->el_outfile, fmts, EL_CAN_TAB ? "yes" : "no");
1516 (void) fprintf(el->el_outfile, fmts, Val(T_km) ? "yes" : "no");
1519 (void) fprintf(el->el_outfile, fmts, EL_HAS_MAGIC_MARGINS ?
1523 (void) fprintf(el->el_outfile, fmts, EL_HAS_AUTO_MARGINS ?
1527 (void) fprintf(el->el_outfile, fmtd, (int)el->el_tty.t_speed);
1531 (void) fprintf(el->el_outfile, fmtd, Val(T_li));
1534 (void) fprintf(el->el_outfile, fmtd, Val(T_co));
1543 ct_encode_string(*argv, &el->el_scratch)) == 0) {
1544 scap = el->el_terminal.t_str[t - tstr];
1549 scap = tgetstr(ct_encode_string(*argv, &el->el_scratch), &area);
1553 (void) fprintf(el->el_errfile,
1584 (void) fprintf(el->el_errfile,
1596 (void) fprintf(el->el_errfile,
1601 terminal_tputs(el, scap, 1);
1607 (void) fprintf(el->el_errfile,
1615 (void) fprintf(el->el_errfile,
1624 (void) fprintf(el->el_errfile,
1629 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), 1);
1634 (void) fprintf(el->el_errfile,
1642 (void) fprintf(el->el_errfile,
1649 (void) fprintf(el->el_errfile,
1658 (void) fprintf(el->el_errfile,
1665 (void) fprintf(el->el_errfile,
1673 (void) fprintf(el->el_errfile,
1680 (void) fprintf(el->el_errfile,
1685 terminal_tputs(el, tgoto(scap, arg_cols, arg_rows), arg_rows);