MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / re_refresh_cursor

Function re_refresh_cursor

extern/editline/src/refresh.c:991–1048  ·  view source on GitHub ↗

re_refresh_cursor(): * Move to the new cursor position */

Source from the content-addressed store, hash-verified

989 * Move to the new cursor position
990 */
991protected void
992re_refresh_cursor(EditLine *el)
993{
994 Char *cp;
995 int h, v, th, w;
996
997 if (el->el_line.cursor >= el->el_line.lastchar) {
998 if (el->el_map.current == el->el_map.alt
999 && el->el_line.lastchar != el->el_line.buffer)
1000 el->el_line.cursor = el->el_line.lastchar - 1;
1001 else
1002 el->el_line.cursor = el->el_line.lastchar;
1003 }
1004
1005 /* first we must find where the cursor is... */
1006 h = el->el_prompt.p_pos.h;
1007 v = el->el_prompt.p_pos.v;
1008 th = el->el_terminal.t_size.h; /* optimize for speed */
1009
1010 /* do input buffer to el->el_line.cursor */
1011 for (cp = el->el_line.buffer; cp < el->el_line.cursor; cp++) {
1012 switch (ct_chr_class(*cp)) {
1013 case CHTYPE_NL: /* handle newline in data part too */
1014 h = 0;
1015 v++;
1016 break;
1017 case CHTYPE_TAB: /* if a tab, to next tab stop */
1018 while (++h & 07)
1019 continue;
1020 break;
1021 default:
1022 w = Width(*cp);
1023 if (w > 1 && h + w > th) { /* won't fit on line */
1024 h = 0;
1025 v++;
1026 }
1027 h += ct_visual_width(*cp);
1028 break;
1029 }
1030
1031 if (h >= th) { /* check, extra long tabs picked up here also */
1032 h -= th;
1033 v++;
1034 }
1035 }
1036 /* if we have a next character, and it's a doublewidth one, we need to
1037 * check whether we need to linebreak for it to fit */
1038 if (cp < el->el_line.lastchar && (w = Width(*cp)) > 1)
1039 if (h + w > th) {
1040 h = 0;
1041 v++;
1042 }
1043
1044 /* now go there */
1045 terminal_move_to_line(el, v);
1046 terminal_move_to_char(el, h);
1047 terminal__flush(el);
1048}

Callers 2

cv_delfiniFunction · 0.85
FUN(el,gets)Function · 0.85

Calls 6

ct_chr_classFunction · 0.85
WidthFunction · 0.85
ct_visual_widthFunction · 0.85
terminal_move_to_lineFunction · 0.85
terminal_move_to_charFunction · 0.85
terminal__flushFunction · 0.85

Tested by

no test coverage detected