re_fastputc(): * Add a character fast. */
| 1052 | * Add a character fast. |
| 1053 | */ |
| 1054 | private void |
| 1055 | re_fastputc(EditLine *el, Int c) |
| 1056 | { |
| 1057 | int w = Width((Char)c); |
| 1058 | while (w > 1 && el->el_cursor.h + w > el->el_terminal.t_size.h) |
| 1059 | re_fastputc(el, ' '); |
| 1060 | |
| 1061 | terminal__putc(el, c); |
| 1062 | el->el_display[el->el_cursor.v][el->el_cursor.h++] = c; |
| 1063 | while (--w > 0) |
| 1064 | el->el_display[el->el_cursor.v][el->el_cursor.h++] |
| 1065 | = MB_FILL_CHAR; |
| 1066 | |
| 1067 | if (el->el_cursor.h >= el->el_terminal.t_size.h) { |
| 1068 | /* if we must overflow */ |
| 1069 | el->el_cursor.h = 0; |
| 1070 | |
| 1071 | /* |
| 1072 | * If we would overflow (input is longer than terminal size), |
| 1073 | * emulate scroll by dropping first line and shuffling the rest. |
| 1074 | * We do this via pointer shuffling - it's safe in this case |
| 1075 | * and we avoid memcpy(). |
| 1076 | */ |
| 1077 | if (el->el_cursor.v + 1 >= el->el_terminal.t_size.v) { |
| 1078 | int i, lins = el->el_terminal.t_size.v; |
| 1079 | Char *firstline = el->el_display[0]; |
| 1080 | |
| 1081 | for(i = 1; i < lins; i++) |
| 1082 | el->el_display[i - 1] = el->el_display[i]; |
| 1083 | |
| 1084 | re__copy_and_pad(firstline, STR(""), (size_t)0); |
| 1085 | el->el_display[i - 1] = firstline; |
| 1086 | } else { |
| 1087 | el->el_cursor.v++; |
| 1088 | el->el_refresh.r_oldcv++; |
| 1089 | } |
| 1090 | if (EL_HAS_AUTO_MARGINS) { |
| 1091 | if (EL_HAS_MAGIC_MARGINS) { |
| 1092 | terminal__putc(el, ' '); |
| 1093 | terminal__putc(el, '\b'); |
| 1094 | } |
| 1095 | } else { |
| 1096 | terminal__putc(el, '\r'); |
| 1097 | terminal__putc(el, '\n'); |
| 1098 | } |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | |
| 1103 | /* re_fastaddc(): |
no test coverage detected