To: vim_dev@googlegroups.com Subject: Patch 8.1.2128 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2128 Problem: Renamed libvterm sources makes merging difficult. Solution: Rename back to the original name and only rename the .o files. Also clean the libvterm build artifacts. (James McCoy, closes #5027) Files: src/libvterm/src/termmouse.c, src/libvterm/src/mouse.c, src/libvterm/src/termscreen.c, src/libvterm/src/screen.c, src/Makefile, src/configure.ac, src/auto/configure, src/Make_cyg_ming.mak, src/Make_mvc.mak *** ../vim-8.1.2127/src/libvterm/src/termmouse.c 2019-09-21 20:46:14.724275765 +0200 --- src/libvterm/src/termmouse.c 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,98 **** - #include "vterm_internal.h" - - #include "utf8.h" - - static void output_mouse(VTermState *state, int code, int pressed, int modifiers, int col, int row) - { - modifiers <<= 2; - - switch(state->mouse_protocol) { - case MOUSE_X10: - if(col + 0x21 > 0xff) - col = 0xff - 0x21; - if(row + 0x21 > 0xff) - row = 0xff - 0x21; - - if(!pressed) - code = 3; - - vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%c%c%c", - (code | modifiers) + 0x20, col + 0x21, row + 0x21); - break; - - case MOUSE_UTF8: - { - char utf8[18]; size_t len = 0; - - if(!pressed) - code = 3; - - len += fill_utf8((code | modifiers) + 0x20, utf8 + len); - len += fill_utf8(col + 0x21, utf8 + len); - len += fill_utf8(row + 0x21, utf8 + len); - utf8[len] = 0; - - vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%s", utf8); - } - break; - - case MOUSE_SGR: - vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "<%d;%d;%d%c", - code | modifiers, col + 1, row + 1, pressed ? 'M' : 'm'); - break; - - case MOUSE_RXVT: - if(!pressed) - code = 3; - - vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%d;%d;%dM", - code | modifiers, col + 1, row + 1); - break; - } - } - - void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod) - { - VTermState *state = vt->state; - - if(col == state->mouse_col && row == state->mouse_row) - return; - - state->mouse_col = col; - state->mouse_row = row; - - if((state->mouse_flags & MOUSE_WANT_DRAG && state->mouse_buttons) || - (state->mouse_flags & MOUSE_WANT_MOVE)) { - int button = state->mouse_buttons & MOUSE_BUTTON_LEFT ? 1 : - state->mouse_buttons & MOUSE_BUTTON_MIDDLE ? 2 : - state->mouse_buttons & MOUSE_BUTTON_RIGHT ? 3 : 4; - output_mouse(state, button-1 + 0x20, 1, mod, col, row); - } - } - - void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod) - { - VTermState *state = vt->state; - - int old_buttons = state->mouse_buttons; - - if(button > 0 && button <= 3) { - if(pressed) - state->mouse_buttons |= (1 << (button-1)); - else - state->mouse_buttons &= ~(1 << (button-1)); - } - - // Most of the time we don't get button releases from 4/5 - if(state->mouse_buttons == old_buttons && button < 4) - return; - if (!(state->mouse_flags & MOUSE_WANT_CLICK)) - return; - - if(button < 4) { - output_mouse(state, button-1, pressed, mod, state->mouse_col, state->mouse_row); - } - else if(button < 6) { - output_mouse(state, button-4 + 0x40, pressed, mod, state->mouse_col, state->mouse_row); - } - } --- 0 ---- *** ../vim-8.1.2127/src/libvterm/src/mouse.c 2019-10-10 13:21:28.479963210 +0200 --- src/libvterm/src/mouse.c 2019-09-21 20:13:48.597908408 +0200 *************** *** 0 **** --- 1,98 ---- + #include "vterm_internal.h" + + #include "utf8.h" + + static void output_mouse(VTermState *state, int code, int pressed, int modifiers, int col, int row) + { + modifiers <<= 2; + + switch(state->mouse_protocol) { + case MOUSE_X10: + if(col + 0x21 > 0xff) + col = 0xff - 0x21; + if(row + 0x21 > 0xff) + row = 0xff - 0x21; + + if(!pressed) + code = 3; + + vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%c%c%c", + (code | modifiers) + 0x20, col + 0x21, row + 0x21); + break; + + case MOUSE_UTF8: + { + char utf8[18]; size_t len = 0; + + if(!pressed) + code = 3; + + len += fill_utf8((code | modifiers) + 0x20, utf8 + len); + len += fill_utf8(col + 0x21, utf8 + len); + len += fill_utf8(row + 0x21, utf8 + len); + utf8[len] = 0; + + vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "M%s", utf8); + } + break; + + case MOUSE_SGR: + vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "<%d;%d;%d%c", + code | modifiers, col + 1, row + 1, pressed ? 'M' : 'm'); + break; + + case MOUSE_RXVT: + if(!pressed) + code = 3; + + vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%d;%d;%dM", + code | modifiers, col + 1, row + 1); + break; + } + } + + void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod) + { + VTermState *state = vt->state; + + if(col == state->mouse_col && row == state->mouse_row) + return; + + state->mouse_col = col; + state->mouse_row = row; + + if((state->mouse_flags & MOUSE_WANT_DRAG && state->mouse_buttons) || + (state->mouse_flags & MOUSE_WANT_MOVE)) { + int button = state->mouse_buttons & MOUSE_BUTTON_LEFT ? 1 : + state->mouse_buttons & MOUSE_BUTTON_MIDDLE ? 2 : + state->mouse_buttons & MOUSE_BUTTON_RIGHT ? 3 : 4; + output_mouse(state, button-1 + 0x20, 1, mod, col, row); + } + } + + void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod) + { + VTermState *state = vt->state; + + int old_buttons = state->mouse_buttons; + + if(button > 0 && button <= 3) { + if(pressed) + state->mouse_buttons |= (1 << (button-1)); + else + state->mouse_buttons &= ~(1 << (button-1)); + } + + // Most of the time we don't get button releases from 4/5 + if(state->mouse_buttons == old_buttons && button < 4) + return; + if (!(state->mouse_flags & MOUSE_WANT_CLICK)) + return; + + if(button < 4) { + output_mouse(state, button-1, pressed, mod, state->mouse_col, state->mouse_row); + } + else if(button < 6) { + output_mouse(state, button-4 + 0x40, pressed, mod, state->mouse_col, state->mouse_row); + } + } *** ../vim-8.1.2127/src/libvterm/src/termscreen.c 2019-09-25 22:14:26.694530926 +0200 --- src/libvterm/src/termscreen.c 1970-01-01 01:00:00.000000000 +0100 *************** *** 1,958 **** - #include "vterm_internal.h" - - // vim: set sw=2 : - #include - #include - - #include "rect.h" - #include "utf8.h" - - #define UNICODE_SPACE 0x20 - #define UNICODE_LINEFEED 0x0a - - // State of the pen at some moment in time, also used in a cell - typedef struct - { - // After the bitfield - VTermColor fg, bg; - - unsigned int bold : 1; - unsigned int underline : 2; - unsigned int italic : 1; - unsigned int blink : 1; - unsigned int reverse : 1; - unsigned int strike : 1; - unsigned int font : 4; // 0 to 9 - - // Extra state storage that isn't strictly pen-related - unsigned int protected_cell : 1; - unsigned int dwl : 1; // on a DECDWL or DECDHL line - unsigned int dhl : 2; // on a DECDHL line (1=top 2=bottom) - } ScreenPen; - - // Internal representation of a screen cell - typedef struct - { - uint32_t chars[VTERM_MAX_CHARS_PER_CELL]; - ScreenPen pen; - } ScreenCell; - - static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell); - - struct VTermScreen - { - VTerm *vt; - VTermState *state; - - const VTermScreenCallbacks *callbacks; - void *cbdata; - - VTermDamageSize damage_merge; - // start_row == -1 => no damage - VTermRect damaged; - VTermRect pending_scrollrect; - int pending_scroll_downward, pending_scroll_rightward; - - int rows; - int cols; - int global_reverse; - - // Primary and Altscreen. buffers[1] is lazily allocated as needed - ScreenCell *buffers[2]; - - // buffer will == buffers[0] or buffers[1], depending on altscreen - ScreenCell *buffer; - - // buffer for a single screen row used in scrollback storage callbacks - VTermScreenCell *sb_buffer; - - ScreenPen pen; - }; - - static ScreenCell *getcell(const VTermScreen *screen, int row, int col) - { - if(row < 0 || row >= screen->rows) - return NULL; - if(col < 0 || col >= screen->cols) - return NULL; - if (screen->buffer == NULL) - return NULL; - return screen->buffer + (screen->cols * row) + col; - } - - static ScreenCell *realloc_buffer(VTermScreen *screen, ScreenCell *buffer, int new_rows, int new_cols) - { - ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); - int row, col; - - if (new_buffer == NULL) - return NULL; - for(row = 0; row < new_rows; row++) { - for(col = 0; col < new_cols; col++) { - ScreenCell *new_cell = new_buffer + row*new_cols + col; - - if(buffer && row < screen->rows && col < screen->cols) - *new_cell = buffer[row * screen->cols + col]; - else { - new_cell->chars[0] = 0; - new_cell->pen = screen->pen; - } - } - } - - vterm_allocator_free(screen->vt, buffer); - - return new_buffer; - } - - static void damagerect(VTermScreen *screen, VTermRect rect) - { - VTermRect emit; - - switch(screen->damage_merge) { - case VTERM_DAMAGE_CELL: - // Always emit damage event - emit = rect; - break; - - case VTERM_DAMAGE_ROW: - // Emit damage longer than one row. Try to merge with existing damage in - // the same row - if(rect.end_row > rect.start_row + 1) { - // Bigger than 1 line - flush existing, emit this - vterm_screen_flush_damage(screen); - emit = rect; - } - else if(screen->damaged.start_row == -1) { - // None stored yet - screen->damaged = rect; - return; - } - else if(rect.start_row == screen->damaged.start_row) { - // Merge with the stored line - if(screen->damaged.start_col > rect.start_col) - screen->damaged.start_col = rect.start_col; - if(screen->damaged.end_col < rect.end_col) - screen->damaged.end_col = rect.end_col; - return; - } - else { - // Emit the currently stored line, store a new one - emit = screen->damaged; - screen->damaged = rect; - } - break; - - case VTERM_DAMAGE_SCREEN: - case VTERM_DAMAGE_SCROLL: - // Never emit damage event - if(screen->damaged.start_row == -1) - screen->damaged = rect; - else { - rect_expand(&screen->damaged, &rect); - } - return; - - default: - DEBUG_LOG1("TODO: Maybe merge damage for level %d\n", screen->damage_merge); - return; - } - - if(screen->callbacks && screen->callbacks->damage) - (*screen->callbacks->damage)(emit, screen->cbdata); - } - - static void damagescreen(VTermScreen *screen) - { - VTermRect rect = {0,0,0,0}; - rect.end_row = screen->rows; - rect.end_col = screen->cols; - - damagerect(screen, rect); - } - - static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user) - { - int i; - int col; - VTermRect rect; - - VTermScreen *screen = user; - ScreenCell *cell = getcell(screen, pos.row, pos.col); - - if(!cell) - return 0; - - for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++) { - cell->chars[i] = info->chars[i]; - cell->pen = screen->pen; - } - if(i < VTERM_MAX_CHARS_PER_CELL) - cell->chars[i] = 0; - - for(col = 1; col < info->width; col++) - getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1; - - rect.start_row = pos.row; - rect.end_row = pos.row+1; - rect.start_col = pos.col; - rect.end_col = pos.col+info->width; - - cell->pen.protected_cell = info->protected_cell; - cell->pen.dwl = info->dwl; - cell->pen.dhl = info->dhl; - - damagerect(screen, rect); - - return 1; - } - - static int moverect_internal(VTermRect dest, VTermRect src, void *user) - { - VTermScreen *screen = user; - - if(screen->callbacks && screen->callbacks->sb_pushline && - dest.start_row == 0 && dest.start_col == 0 && // starts top-left corner - dest.end_col == screen->cols && // full width - screen->buffer == screen->buffers[0]) { // not altscreen - VTermPos pos; - for(pos.row = 0; pos.row < src.start_row; pos.row++) { - for(pos.col = 0; pos.col < screen->cols; pos.col++) - (void)vterm_screen_get_cell(screen, pos, screen->sb_buffer + pos.col); - - (screen->callbacks->sb_pushline)(screen->cols, screen->sb_buffer, screen->cbdata); - } - } - - { - int cols = src.end_col - src.start_col; - int downward = src.start_row - dest.start_row; - int init_row, test_row, inc_row; - int row; - - if(downward < 0) { - init_row = dest.end_row - 1; - test_row = dest.start_row - 1; - inc_row = -1; - } - else { - init_row = dest.start_row; - test_row = dest.end_row; - inc_row = +1; - } - - for(row = init_row; row != test_row; row += inc_row) - memmove(getcell(screen, row, dest.start_col), - getcell(screen, row + downward, src.start_col), - cols * sizeof(ScreenCell)); - } - - return 1; - } - - static int moverect_user(VTermRect dest, VTermRect src, void *user) - { - VTermScreen *screen = user; - - if(screen->callbacks && screen->callbacks->moverect) { - if(screen->damage_merge != VTERM_DAMAGE_SCROLL) - // Avoid an infinite loop - vterm_screen_flush_damage(screen); - - if((*screen->callbacks->moverect)(dest, src, screen->cbdata)) - return 1; - } - - damagerect(screen, dest); - - return 1; - } - - static int erase_internal(VTermRect rect, int selective, void *user) - { - VTermScreen *screen = user; - int row, col; - - for(row = rect.start_row; row < screen->state->rows && row < rect.end_row; row++) { - const VTermLineInfo *info = vterm_state_get_lineinfo(screen->state, row); - - for(col = rect.start_col; col < rect.end_col; col++) { - ScreenCell *cell = getcell(screen, row, col); - - if(selective && cell->pen.protected_cell) - continue; - - cell->chars[0] = 0; - cell->pen = screen->pen; - cell->pen.dwl = info->doublewidth; - cell->pen.dhl = info->doubleheight; - } - } - - return 1; - } - - static int erase_user(VTermRect rect, int selective UNUSED, void *user) - { - VTermScreen *screen = user; - - damagerect(screen, rect); - - return 1; - } - - static int erase(VTermRect rect, int selective, void *user) - { - erase_internal(rect, selective, user); - return erase_user(rect, 0, user); - } - - static int scrollrect(VTermRect rect, int downward, int rightward, void *user) - { - VTermScreen *screen = user; - - if(screen->damage_merge != VTERM_DAMAGE_SCROLL) { - vterm_scroll_rect(rect, downward, rightward, - moverect_internal, erase_internal, screen); - - vterm_screen_flush_damage(screen); - - vterm_scroll_rect(rect, downward, rightward, - moverect_user, erase_user, screen); - - return 1; - } - - if(screen->damaged.start_row != -1 && - !rect_intersects(&rect, &screen->damaged)) { - vterm_screen_flush_damage(screen); - } - - if(screen->pending_scrollrect.start_row == -1) { - screen->pending_scrollrect = rect; - screen->pending_scroll_downward = downward; - screen->pending_scroll_rightward = rightward; - } - else if(rect_equal(&screen->pending_scrollrect, &rect) && - ((screen->pending_scroll_downward == 0 && downward == 0) || - (screen->pending_scroll_rightward == 0 && rightward == 0))) { - screen->pending_scroll_downward += downward; - screen->pending_scroll_rightward += rightward; - } - else { - vterm_screen_flush_damage(screen); - - screen->pending_scrollrect = rect; - screen->pending_scroll_downward = downward; - screen->pending_scroll_rightward = rightward; - } - - vterm_scroll_rect(rect, downward, rightward, - moverect_internal, erase_internal, screen); - - if(screen->damaged.start_row == -1) - return 1; - - if(rect_contains(&rect, &screen->damaged)) { - // Scroll region entirely contains the damage; just move it - vterm_rect_move(&screen->damaged, -downward, -rightward); - rect_clip(&screen->damaged, &rect); - } - // There are a number of possible cases here, but lets restrict this to only - // the common case where we might actually gain some performance by - // optimising it. Namely, a vertical scroll that neatly cuts the damage - // region in half. - else if(rect.start_col <= screen->damaged.start_col && - rect.end_col >= screen->damaged.end_col && - rightward == 0) { - if(screen->damaged.start_row >= rect.start_row && - screen->damaged.start_row < rect.end_row) { - screen->damaged.start_row -= downward; - if(screen->damaged.start_row < rect.start_row) - screen->damaged.start_row = rect.start_row; - if(screen->damaged.start_row > rect.end_row) - screen->damaged.start_row = rect.end_row; - } - if(screen->damaged.end_row >= rect.start_row && - screen->damaged.end_row < rect.end_row) { - screen->damaged.end_row -= downward; - if(screen->damaged.end_row < rect.start_row) - screen->damaged.end_row = rect.start_row; - if(screen->damaged.end_row > rect.end_row) - screen->damaged.end_row = rect.end_row; - } - } - else { - DEBUG_LOG2("TODO: Just flush and redo damaged=" STRFrect " rect=" STRFrect "\n", - ARGSrect(screen->damaged), ARGSrect(rect)); - } - - return 1; - } - - static int movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user) - { - VTermScreen *screen = user; - - if(screen->callbacks && screen->callbacks->movecursor) - return (*screen->callbacks->movecursor)(pos, oldpos, visible, screen->cbdata); - - return 0; - } - - static int setpenattr(VTermAttr attr, VTermValue *val, void *user) - { - VTermScreen *screen = user; - - switch(attr) { - case VTERM_ATTR_BOLD: - screen->pen.bold = val->boolean; - return 1; - case VTERM_ATTR_UNDERLINE: - screen->pen.underline = val->number; - return 1; - case VTERM_ATTR_ITALIC: - screen->pen.italic = val->boolean; - return 1; - case VTERM_ATTR_BLINK: - screen->pen.blink = val->boolean; - return 1; - case VTERM_ATTR_REVERSE: - screen->pen.reverse = val->boolean; - return 1; - case VTERM_ATTR_STRIKE: - screen->pen.strike = val->boolean; - return 1; - case VTERM_ATTR_FONT: - screen->pen.font = val->number; - return 1; - case VTERM_ATTR_FOREGROUND: - screen->pen.fg = val->color; - return 1; - case VTERM_ATTR_BACKGROUND: - screen->pen.bg = val->color; - return 1; - - case VTERM_N_ATTRS: - return 0; - } - - return 0; - } - - static int settermprop(VTermProp prop, VTermValue *val, void *user) - { - VTermScreen *screen = user; - - switch(prop) { - case VTERM_PROP_ALTSCREEN: - if(val->boolean && !screen->buffers[1]) - return 0; - - screen->buffer = val->boolean ? screen->buffers[1] : screen->buffers[0]; - // only send a damage event on disable; because during enable there's an - // erase that sends a damage anyway - if(!val->boolean) - damagescreen(screen); - break; - case VTERM_PROP_REVERSE: - screen->global_reverse = val->boolean; - damagescreen(screen); - break; - default: - ; // ignore - } - - if(screen->callbacks && screen->callbacks->settermprop) - return (*screen->callbacks->settermprop)(prop, val, screen->cbdata); - - return 1; - } - - static int bell(void *user) - { - VTermScreen *screen = user; - - if(screen->callbacks && screen->callbacks->bell) - return (*screen->callbacks->bell)(screen->cbdata); - - return 0; - } - - static int resize(int new_rows, int new_cols, VTermPos *delta, void *user) - { - VTermScreen *screen = user; - - int is_altscreen = (screen->buffers[1] && screen->buffer == screen->buffers[1]); - - int old_rows = screen->rows; - int old_cols = screen->cols; - int first_blank_row; - - if(!is_altscreen && new_rows < old_rows) { - // Fewer rows - determine if we're going to scroll at all, and if so, push - // those lines to scrollback - VTermPos pos = { 0, 0 }; - VTermPos cursor = screen->state->pos; - // Find the first blank row after the cursor. - for(pos.row = old_rows - 1; pos.row >= new_rows; pos.row--) - if(!vterm_screen_is_eol(screen, pos) || cursor.row == pos.row) - break; - - first_blank_row = pos.row + 1; - if(first_blank_row > new_rows) { - VTermRect rect = {0,0,0,0}; - rect.end_row = old_rows; - rect.end_col = old_cols; - scrollrect(rect, first_blank_row - new_rows, 0, user); - vterm_screen_flush_damage(screen); - - delta->row -= first_blank_row - new_rows; - } - } - - screen->buffers[0] = realloc_buffer(screen, screen->buffers[0], new_rows, new_cols); - if(screen->buffers[1]) - screen->buffers[1] = realloc_buffer(screen, screen->buffers[1], new_rows, new_cols); - - screen->buffer = is_altscreen ? screen->buffers[1] : screen->buffers[0]; - - screen->rows = new_rows; - screen->cols = new_cols; - - vterm_allocator_free(screen->vt, screen->sb_buffer); - - screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols); - - if(new_cols > old_cols) { - VTermRect rect; - rect.start_row = 0; - rect.end_row = old_rows; - rect.start_col = old_cols; - rect.end_col = new_cols; - damagerect(screen, rect); - } - - if(new_rows > old_rows) { - if(!is_altscreen && screen->callbacks && screen->callbacks->sb_popline) { - int rows = new_rows - old_rows; - while(rows) { - VTermRect rect = {0,0,0,0}; - VTermPos pos = { 0, 0 }; - if(!(screen->callbacks->sb_popline(screen->cols, screen->sb_buffer, screen->cbdata))) - break; - - rect.end_row = screen->rows; - rect.end_col = screen->cols; - scrollrect(rect, -1, 0, user); - - for(pos.col = 0; pos.col < screen->cols; pos.col += screen->sb_buffer[pos.col].width) - vterm_screen_set_cell(screen, pos, screen->sb_buffer + pos.col); - - rect.end_row = 1; - damagerect(screen, rect); - - vterm_screen_flush_damage(screen); - - rows--; - delta->row++; - } - } - - { - VTermRect rect; - rect.start_row = old_rows; - rect.end_row = new_rows; - rect.start_col = 0; - rect.end_col = new_cols; - damagerect(screen, rect); - } - } - - if(screen->callbacks && screen->callbacks->resize) - return (*screen->callbacks->resize)(new_rows, new_cols, screen->cbdata); - - return 1; - } - - static int setlineinfo(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user) - { - VTermScreen *screen = user; - int col; - VTermRect rect; - - if(newinfo->doublewidth != oldinfo->doublewidth || - newinfo->doubleheight != oldinfo->doubleheight) { - for(col = 0; col < screen->cols; col++) { - ScreenCell *cell = getcell(screen, row, col); - cell->pen.dwl = newinfo->doublewidth; - cell->pen.dhl = newinfo->doubleheight; - } - - rect.start_row = row; - rect.end_row = row + 1; - rect.start_col = 0; - rect.end_col = newinfo->doublewidth ? screen->cols / 2 : screen->cols; - damagerect(screen, rect); - - if(newinfo->doublewidth) { - rect.start_col = screen->cols / 2; - rect.end_col = screen->cols; - - erase_internal(rect, 0, user); - } - } - - return 1; - } - - static VTermStateCallbacks state_cbs = { - &putglyph, // putglyph - &movecursor, // movecursor - &scrollrect, // scrollrect - NULL, // moverect - &erase, // erase - NULL, // initpen - &setpenattr, // setpenattr - &settermprop, // settermprop - &bell, // bell - &resize, // resize - &setlineinfo // setlineinfo - }; - - /* - * Allocate a new screen and return it. - * Return NULL when out of memory. - */ - static VTermScreen *screen_new(VTerm *vt) - { - VTermState *state = vterm_obtain_state(vt); - VTermScreen *screen; - int rows, cols; - - if (state == NULL) - return NULL; - screen = vterm_allocator_malloc(vt, sizeof(VTermScreen)); - if (screen == NULL) - return NULL; - - vterm_get_size(vt, &rows, &cols); - - screen->vt = vt; - screen->state = state; - - screen->damage_merge = VTERM_DAMAGE_CELL; - screen->damaged.start_row = -1; - screen->pending_scrollrect.start_row = -1; - - screen->rows = rows; - screen->cols = cols; - - screen->callbacks = NULL; - screen->cbdata = NULL; - - screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols); - screen->buffer = screen->buffers[0]; - screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols); - if (screen->buffer == NULL || screen->sb_buffer == NULL) - { - vterm_screen_free(screen); - return NULL; - } - - vterm_state_set_callbacks(screen->state, &state_cbs, screen); - - return screen; - } - - INTERNAL void vterm_screen_free(VTermScreen *screen) - { - vterm_allocator_free(screen->vt, screen->buffers[0]); - vterm_allocator_free(screen->vt, screen->buffers[1]); - vterm_allocator_free(screen->vt, screen->sb_buffer); - vterm_allocator_free(screen->vt, screen); - } - - void vterm_screen_reset(VTermScreen *screen, int hard) - { - screen->damaged.start_row = -1; - screen->pending_scrollrect.start_row = -1; - vterm_state_reset(screen->state, hard); - vterm_screen_flush_damage(screen); - } - - static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer, size_t len, const VTermRect rect) - { - size_t outpos = 0; - int padding = 0; - int row, col; - - #define PUT(c) \ - if(utf8) { \ - size_t thislen = utf8_seqlen(c); \ - if(buffer && outpos + thislen <= len) \ - outpos += fill_utf8((c), (char *)buffer + outpos); \ - else \ - outpos += thislen; \ - } \ - else { \ - if(buffer && outpos + 1 <= len) \ - ((uint32_t*)buffer)[outpos++] = (c); \ - else \ - outpos++; \ - } - - for(row = rect.start_row; row < rect.end_row; row++) { - for(col = rect.start_col; col < rect.end_col; col++) { - ScreenCell *cell = getcell(screen, row, col); - int i; - - if(cell->chars[0] == 0) - // Erased cell, might need a space - padding++; - else if(cell->chars[0] == (uint32_t)-1) - // Gap behind a double-width char, do nothing - ; - else { - while(padding) { - PUT(UNICODE_SPACE); - padding--; - } - for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) { - PUT(cell->chars[i]); - } - } - } - - if(row < rect.end_row - 1) { - PUT(UNICODE_LINEFEED); - padding = 0; - } - } - - return outpos; - } - - size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect) - { - return _get_chars(screen, 0, chars, len, rect); - } - - size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect) - { - return _get_chars(screen, 1, str, len, rect); - } - - // Copy internal to external representation of a screen cell - int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell) - { - ScreenCell *intcell = getcell(screen, pos.row, pos.col); - int i; - - if(!intcell) - return 0; - - for(i = 0; ; i++) { - cell->chars[i] = intcell->chars[i]; - if(!intcell->chars[i]) - break; - } - - cell->attrs.bold = intcell->pen.bold; - cell->attrs.underline = intcell->pen.underline; - cell->attrs.italic = intcell->pen.italic; - cell->attrs.blink = intcell->pen.blink; - cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse; - cell->attrs.strike = intcell->pen.strike; - cell->attrs.font = intcell->pen.font; - - cell->attrs.dwl = intcell->pen.dwl; - cell->attrs.dhl = intcell->pen.dhl; - - cell->fg = intcell->pen.fg; - cell->bg = intcell->pen.bg; - - if(vterm_get_special_pty_type() == 2) { - /* Get correct cell width from cell information contained in line buffer */ - if(pos.col < (screen->cols - 1) && - getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) { - if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) { - getcell(screen, pos.row, pos.col)->chars[0] = 0; - cell->width = 2; - } else if(getcell(screen, pos.row, pos.col)->chars[0] == 0) { - getcell(screen, pos.row, pos.col + 1)->chars[0] = 0; - cell->width = 1; - } else { - cell->width = 2; - } - } else - cell->width = 1; - } else { - if(pos.col < (screen->cols - 1) && - getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) - cell->width = 2; - else - cell->width = 1; - } - - return 1; - } - - // Copy external to internal representation of a screen cell - /* static because it's only used internally for sb_popline during resize */ - static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell) - { - ScreenCell *intcell = getcell(screen, pos.row, pos.col); - int i; - - if(!intcell) - return 0; - - for(i = 0; ; i++) { - intcell->chars[i] = cell->chars[i]; - if(!cell->chars[i]) - break; - } - - intcell->pen.bold = cell->attrs.bold; - intcell->pen.underline = cell->attrs.underline; - intcell->pen.italic = cell->attrs.italic; - intcell->pen.blink = cell->attrs.blink; - intcell->pen.reverse = cell->attrs.reverse ^ screen->global_reverse; - intcell->pen.strike = cell->attrs.strike; - intcell->pen.font = cell->attrs.font; - - intcell->pen.fg = cell->fg; - intcell->pen.bg = cell->bg; - - if(cell->width == 2) - getcell(screen, pos.row, pos.col + 1)->chars[0] = (uint32_t)-1; - - return 1; - } - - int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos) - { - // This cell is EOL if this and every cell to the right is black - for(; pos.col < screen->cols; pos.col++) { - ScreenCell *cell = getcell(screen, pos.row, pos.col); - if(cell->chars[0] != 0) - return 0; - } - - return 1; - } - - VTermScreen *vterm_obtain_screen(VTerm *vt) - { - if(!vt->screen) - vt->screen = screen_new(vt); - return vt->screen; - } - - void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen) - { - - if(!screen->buffers[1] && altscreen) { - int rows, cols; - vterm_get_size(screen->vt, &rows, &cols); - - screen->buffers[1] = realloc_buffer(screen, NULL, rows, cols); - } - } - - void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user) - { - screen->callbacks = callbacks; - screen->cbdata = user; - } - - void *vterm_screen_get_cbdata(VTermScreen *screen) - { - return screen->cbdata; - } - - void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user) - { - vterm_state_set_unrecognised_fallbacks(screen->state, fallbacks, user); - } - - void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen) - { - return vterm_state_get_unrecognised_fbdata(screen->state); - } - - void vterm_screen_flush_damage(VTermScreen *screen) - { - if(screen->pending_scrollrect.start_row != -1) { - vterm_scroll_rect(screen->pending_scrollrect, screen->pending_scroll_downward, screen->pending_scroll_rightward, - moverect_user, erase_user, screen); - - screen->pending_scrollrect.start_row = -1; - } - - if(screen->damaged.start_row != -1) { - if(screen->callbacks && screen->callbacks->damage) - (*screen->callbacks->damage)(screen->damaged, screen->cbdata); - - screen->damaged.start_row = -1; - } - } - - void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size) - { - vterm_screen_flush_damage(screen); - screen->damage_merge = size; - } - - static int attrs_differ(VTermAttrMask attrs, ScreenCell *a, ScreenCell *b) - { - if((attrs & VTERM_ATTR_BOLD_MASK) && (a->pen.bold != b->pen.bold)) - return 1; - if((attrs & VTERM_ATTR_UNDERLINE_MASK) && (a->pen.underline != b->pen.underline)) - return 1; - if((attrs & VTERM_ATTR_ITALIC_MASK) && (a->pen.italic != b->pen.italic)) - return 1; - if((attrs & VTERM_ATTR_BLINK_MASK) && (a->pen.blink != b->pen.blink)) - return 1; - if((attrs & VTERM_ATTR_REVERSE_MASK) && (a->pen.reverse != b->pen.reverse)) - return 1; - if((attrs & VTERM_ATTR_STRIKE_MASK) && (a->pen.strike != b->pen.strike)) - return 1; - if((attrs & VTERM_ATTR_FONT_MASK) && (a->pen.font != b->pen.font)) - return 1; - if((attrs & VTERM_ATTR_FOREGROUND_MASK) && !vterm_color_equal(a->pen.fg, b->pen.fg)) - return 1; - if((attrs & VTERM_ATTR_BACKGROUND_MASK) && !vterm_color_equal(a->pen.bg, b->pen.bg)) - return 1; - - return 0; - } - - int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs) - { - int col; - - ScreenCell *target = getcell(screen, pos.row, pos.col); - - // TODO: bounds check - extent->start_row = pos.row; - extent->end_row = pos.row + 1; - - if(extent->start_col < 0) - extent->start_col = 0; - if(extent->end_col < 0) - extent->end_col = screen->cols; - - for(col = pos.col - 1; col >= extent->start_col; col--) - if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) - break; - extent->start_col = col + 1; - - for(col = pos.col + 1; col < extent->end_col; col++) - if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) - break; - extent->end_col = col - 1; - - return 1; - } --- 0 ---- *** ../vim-8.1.2127/src/libvterm/src/screen.c 2019-10-10 13:21:28.487963171 +0200 --- src/libvterm/src/screen.c 2019-09-25 21:54:58.080071987 +0200 *************** *** 0 **** --- 1,958 ---- + #include "vterm_internal.h" + + // vim: set sw=2 : + #include + #include + + #include "rect.h" + #include "utf8.h" + + #define UNICODE_SPACE 0x20 + #define UNICODE_LINEFEED 0x0a + + // State of the pen at some moment in time, also used in a cell + typedef struct + { + // After the bitfield + VTermColor fg, bg; + + unsigned int bold : 1; + unsigned int underline : 2; + unsigned int italic : 1; + unsigned int blink : 1; + unsigned int reverse : 1; + unsigned int strike : 1; + unsigned int font : 4; // 0 to 9 + + // Extra state storage that isn't strictly pen-related + unsigned int protected_cell : 1; + unsigned int dwl : 1; // on a DECDWL or DECDHL line + unsigned int dhl : 2; // on a DECDHL line (1=top 2=bottom) + } ScreenPen; + + // Internal representation of a screen cell + typedef struct + { + uint32_t chars[VTERM_MAX_CHARS_PER_CELL]; + ScreenPen pen; + } ScreenCell; + + static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell); + + struct VTermScreen + { + VTerm *vt; + VTermState *state; + + const VTermScreenCallbacks *callbacks; + void *cbdata; + + VTermDamageSize damage_merge; + // start_row == -1 => no damage + VTermRect damaged; + VTermRect pending_scrollrect; + int pending_scroll_downward, pending_scroll_rightward; + + int rows; + int cols; + int global_reverse; + + // Primary and Altscreen. buffers[1] is lazily allocated as needed + ScreenCell *buffers[2]; + + // buffer will == buffers[0] or buffers[1], depending on altscreen + ScreenCell *buffer; + + // buffer for a single screen row used in scrollback storage callbacks + VTermScreenCell *sb_buffer; + + ScreenPen pen; + }; + + static ScreenCell *getcell(const VTermScreen *screen, int row, int col) + { + if(row < 0 || row >= screen->rows) + return NULL; + if(col < 0 || col >= screen->cols) + return NULL; + if (screen->buffer == NULL) + return NULL; + return screen->buffer + (screen->cols * row) + col; + } + + static ScreenCell *realloc_buffer(VTermScreen *screen, ScreenCell *buffer, int new_rows, int new_cols) + { + ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); + int row, col; + + if (new_buffer == NULL) + return NULL; + for(row = 0; row < new_rows; row++) { + for(col = 0; col < new_cols; col++) { + ScreenCell *new_cell = new_buffer + row*new_cols + col; + + if(buffer && row < screen->rows && col < screen->cols) + *new_cell = buffer[row * screen->cols + col]; + else { + new_cell->chars[0] = 0; + new_cell->pen = screen->pen; + } + } + } + + vterm_allocator_free(screen->vt, buffer); + + return new_buffer; + } + + static void damagerect(VTermScreen *screen, VTermRect rect) + { + VTermRect emit; + + switch(screen->damage_merge) { + case VTERM_DAMAGE_CELL: + // Always emit damage event + emit = rect; + break; + + case VTERM_DAMAGE_ROW: + // Emit damage longer than one row. Try to merge with existing damage in + // the same row + if(rect.end_row > rect.start_row + 1) { + // Bigger than 1 line - flush existing, emit this + vterm_screen_flush_damage(screen); + emit = rect; + } + else if(screen->damaged.start_row == -1) { + // None stored yet + screen->damaged = rect; + return; + } + else if(rect.start_row == screen->damaged.start_row) { + // Merge with the stored line + if(screen->damaged.start_col > rect.start_col) + screen->damaged.start_col = rect.start_col; + if(screen->damaged.end_col < rect.end_col) + screen->damaged.end_col = rect.end_col; + return; + } + else { + // Emit the currently stored line, store a new one + emit = screen->damaged; + screen->damaged = rect; + } + break; + + case VTERM_DAMAGE_SCREEN: + case VTERM_DAMAGE_SCROLL: + // Never emit damage event + if(screen->damaged.start_row == -1) + screen->damaged = rect; + else { + rect_expand(&screen->damaged, &rect); + } + return; + + default: + DEBUG_LOG1("TODO: Maybe merge damage for level %d\n", screen->damage_merge); + return; + } + + if(screen->callbacks && screen->callbacks->damage) + (*screen->callbacks->damage)(emit, screen->cbdata); + } + + static void damagescreen(VTermScreen *screen) + { + VTermRect rect = {0,0,0,0}; + rect.end_row = screen->rows; + rect.end_col = screen->cols; + + damagerect(screen, rect); + } + + static int putglyph(VTermGlyphInfo *info, VTermPos pos, void *user) + { + int i; + int col; + VTermRect rect; + + VTermScreen *screen = user; + ScreenCell *cell = getcell(screen, pos.row, pos.col); + + if(!cell) + return 0; + + for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && info->chars[i]; i++) { + cell->chars[i] = info->chars[i]; + cell->pen = screen->pen; + } + if(i < VTERM_MAX_CHARS_PER_CELL) + cell->chars[i] = 0; + + for(col = 1; col < info->width; col++) + getcell(screen, pos.row, pos.col + col)->chars[0] = (uint32_t)-1; + + rect.start_row = pos.row; + rect.end_row = pos.row+1; + rect.start_col = pos.col; + rect.end_col = pos.col+info->width; + + cell->pen.protected_cell = info->protected_cell; + cell->pen.dwl = info->dwl; + cell->pen.dhl = info->dhl; + + damagerect(screen, rect); + + return 1; + } + + static int moverect_internal(VTermRect dest, VTermRect src, void *user) + { + VTermScreen *screen = user; + + if(screen->callbacks && screen->callbacks->sb_pushline && + dest.start_row == 0 && dest.start_col == 0 && // starts top-left corner + dest.end_col == screen->cols && // full width + screen->buffer == screen->buffers[0]) { // not altscreen + VTermPos pos; + for(pos.row = 0; pos.row < src.start_row; pos.row++) { + for(pos.col = 0; pos.col < screen->cols; pos.col++) + (void)vterm_screen_get_cell(screen, pos, screen->sb_buffer + pos.col); + + (screen->callbacks->sb_pushline)(screen->cols, screen->sb_buffer, screen->cbdata); + } + } + + { + int cols = src.end_col - src.start_col; + int downward = src.start_row - dest.start_row; + int init_row, test_row, inc_row; + int row; + + if(downward < 0) { + init_row = dest.end_row - 1; + test_row = dest.start_row - 1; + inc_row = -1; + } + else { + init_row = dest.start_row; + test_row = dest.end_row; + inc_row = +1; + } + + for(row = init_row; row != test_row; row += inc_row) + memmove(getcell(screen, row, dest.start_col), + getcell(screen, row + downward, src.start_col), + cols * sizeof(ScreenCell)); + } + + return 1; + } + + static int moverect_user(VTermRect dest, VTermRect src, void *user) + { + VTermScreen *screen = user; + + if(screen->callbacks && screen->callbacks->moverect) { + if(screen->damage_merge != VTERM_DAMAGE_SCROLL) + // Avoid an infinite loop + vterm_screen_flush_damage(screen); + + if((*screen->callbacks->moverect)(dest, src, screen->cbdata)) + return 1; + } + + damagerect(screen, dest); + + return 1; + } + + static int erase_internal(VTermRect rect, int selective, void *user) + { + VTermScreen *screen = user; + int row, col; + + for(row = rect.start_row; row < screen->state->rows && row < rect.end_row; row++) { + const VTermLineInfo *info = vterm_state_get_lineinfo(screen->state, row); + + for(col = rect.start_col; col < rect.end_col; col++) { + ScreenCell *cell = getcell(screen, row, col); + + if(selective && cell->pen.protected_cell) + continue; + + cell->chars[0] = 0; + cell->pen = screen->pen; + cell->pen.dwl = info->doublewidth; + cell->pen.dhl = info->doubleheight; + } + } + + return 1; + } + + static int erase_user(VTermRect rect, int selective UNUSED, void *user) + { + VTermScreen *screen = user; + + damagerect(screen, rect); + + return 1; + } + + static int erase(VTermRect rect, int selective, void *user) + { + erase_internal(rect, selective, user); + return erase_user(rect, 0, user); + } + + static int scrollrect(VTermRect rect, int downward, int rightward, void *user) + { + VTermScreen *screen = user; + + if(screen->damage_merge != VTERM_DAMAGE_SCROLL) { + vterm_scroll_rect(rect, downward, rightward, + moverect_internal, erase_internal, screen); + + vterm_screen_flush_damage(screen); + + vterm_scroll_rect(rect, downward, rightward, + moverect_user, erase_user, screen); + + return 1; + } + + if(screen->damaged.start_row != -1 && + !rect_intersects(&rect, &screen->damaged)) { + vterm_screen_flush_damage(screen); + } + + if(screen->pending_scrollrect.start_row == -1) { + screen->pending_scrollrect = rect; + screen->pending_scroll_downward = downward; + screen->pending_scroll_rightward = rightward; + } + else if(rect_equal(&screen->pending_scrollrect, &rect) && + ((screen->pending_scroll_downward == 0 && downward == 0) || + (screen->pending_scroll_rightward == 0 && rightward == 0))) { + screen->pending_scroll_downward += downward; + screen->pending_scroll_rightward += rightward; + } + else { + vterm_screen_flush_damage(screen); + + screen->pending_scrollrect = rect; + screen->pending_scroll_downward = downward; + screen->pending_scroll_rightward = rightward; + } + + vterm_scroll_rect(rect, downward, rightward, + moverect_internal, erase_internal, screen); + + if(screen->damaged.start_row == -1) + return 1; + + if(rect_contains(&rect, &screen->damaged)) { + // Scroll region entirely contains the damage; just move it + vterm_rect_move(&screen->damaged, -downward, -rightward); + rect_clip(&screen->damaged, &rect); + } + // There are a number of possible cases here, but lets restrict this to only + // the common case where we might actually gain some performance by + // optimising it. Namely, a vertical scroll that neatly cuts the damage + // region in half. + else if(rect.start_col <= screen->damaged.start_col && + rect.end_col >= screen->damaged.end_col && + rightward == 0) { + if(screen->damaged.start_row >= rect.start_row && + screen->damaged.start_row < rect.end_row) { + screen->damaged.start_row -= downward; + if(screen->damaged.start_row < rect.start_row) + screen->damaged.start_row = rect.start_row; + if(screen->damaged.start_row > rect.end_row) + screen->damaged.start_row = rect.end_row; + } + if(screen->damaged.end_row >= rect.start_row && + screen->damaged.end_row < rect.end_row) { + screen->damaged.end_row -= downward; + if(screen->damaged.end_row < rect.start_row) + screen->damaged.end_row = rect.start_row; + if(screen->damaged.end_row > rect.end_row) + screen->damaged.end_row = rect.end_row; + } + } + else { + DEBUG_LOG2("TODO: Just flush and redo damaged=" STRFrect " rect=" STRFrect "\n", + ARGSrect(screen->damaged), ARGSrect(rect)); + } + + return 1; + } + + static int movecursor(VTermPos pos, VTermPos oldpos, int visible, void *user) + { + VTermScreen *screen = user; + + if(screen->callbacks && screen->callbacks->movecursor) + return (*screen->callbacks->movecursor)(pos, oldpos, visible, screen->cbdata); + + return 0; + } + + static int setpenattr(VTermAttr attr, VTermValue *val, void *user) + { + VTermScreen *screen = user; + + switch(attr) { + case VTERM_ATTR_BOLD: + screen->pen.bold = val->boolean; + return 1; + case VTERM_ATTR_UNDERLINE: + screen->pen.underline = val->number; + return 1; + case VTERM_ATTR_ITALIC: + screen->pen.italic = val->boolean; + return 1; + case VTERM_ATTR_BLINK: + screen->pen.blink = val->boolean; + return 1; + case VTERM_ATTR_REVERSE: + screen->pen.reverse = val->boolean; + return 1; + case VTERM_ATTR_STRIKE: + screen->pen.strike = val->boolean; + return 1; + case VTERM_ATTR_FONT: + screen->pen.font = val->number; + return 1; + case VTERM_ATTR_FOREGROUND: + screen->pen.fg = val->color; + return 1; + case VTERM_ATTR_BACKGROUND: + screen->pen.bg = val->color; + return 1; + + case VTERM_N_ATTRS: + return 0; + } + + return 0; + } + + static int settermprop(VTermProp prop, VTermValue *val, void *user) + { + VTermScreen *screen = user; + + switch(prop) { + case VTERM_PROP_ALTSCREEN: + if(val->boolean && !screen->buffers[1]) + return 0; + + screen->buffer = val->boolean ? screen->buffers[1] : screen->buffers[0]; + // only send a damage event on disable; because during enable there's an + // erase that sends a damage anyway + if(!val->boolean) + damagescreen(screen); + break; + case VTERM_PROP_REVERSE: + screen->global_reverse = val->boolean; + damagescreen(screen); + break; + default: + ; // ignore + } + + if(screen->callbacks && screen->callbacks->settermprop) + return (*screen->callbacks->settermprop)(prop, val, screen->cbdata); + + return 1; + } + + static int bell(void *user) + { + VTermScreen *screen = user; + + if(screen->callbacks && screen->callbacks->bell) + return (*screen->callbacks->bell)(screen->cbdata); + + return 0; + } + + static int resize(int new_rows, int new_cols, VTermPos *delta, void *user) + { + VTermScreen *screen = user; + + int is_altscreen = (screen->buffers[1] && screen->buffer == screen->buffers[1]); + + int old_rows = screen->rows; + int old_cols = screen->cols; + int first_blank_row; + + if(!is_altscreen && new_rows < old_rows) { + // Fewer rows - determine if we're going to scroll at all, and if so, push + // those lines to scrollback + VTermPos pos = { 0, 0 }; + VTermPos cursor = screen->state->pos; + // Find the first blank row after the cursor. + for(pos.row = old_rows - 1; pos.row >= new_rows; pos.row--) + if(!vterm_screen_is_eol(screen, pos) || cursor.row == pos.row) + break; + + first_blank_row = pos.row + 1; + if(first_blank_row > new_rows) { + VTermRect rect = {0,0,0,0}; + rect.end_row = old_rows; + rect.end_col = old_cols; + scrollrect(rect, first_blank_row - new_rows, 0, user); + vterm_screen_flush_damage(screen); + + delta->row -= first_blank_row - new_rows; + } + } + + screen->buffers[0] = realloc_buffer(screen, screen->buffers[0], new_rows, new_cols); + if(screen->buffers[1]) + screen->buffers[1] = realloc_buffer(screen, screen->buffers[1], new_rows, new_cols); + + screen->buffer = is_altscreen ? screen->buffers[1] : screen->buffers[0]; + + screen->rows = new_rows; + screen->cols = new_cols; + + vterm_allocator_free(screen->vt, screen->sb_buffer); + + screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * new_cols); + + if(new_cols > old_cols) { + VTermRect rect; + rect.start_row = 0; + rect.end_row = old_rows; + rect.start_col = old_cols; + rect.end_col = new_cols; + damagerect(screen, rect); + } + + if(new_rows > old_rows) { + if(!is_altscreen && screen->callbacks && screen->callbacks->sb_popline) { + int rows = new_rows - old_rows; + while(rows) { + VTermRect rect = {0,0,0,0}; + VTermPos pos = { 0, 0 }; + if(!(screen->callbacks->sb_popline(screen->cols, screen->sb_buffer, screen->cbdata))) + break; + + rect.end_row = screen->rows; + rect.end_col = screen->cols; + scrollrect(rect, -1, 0, user); + + for(pos.col = 0; pos.col < screen->cols; pos.col += screen->sb_buffer[pos.col].width) + vterm_screen_set_cell(screen, pos, screen->sb_buffer + pos.col); + + rect.end_row = 1; + damagerect(screen, rect); + + vterm_screen_flush_damage(screen); + + rows--; + delta->row++; + } + } + + { + VTermRect rect; + rect.start_row = old_rows; + rect.end_row = new_rows; + rect.start_col = 0; + rect.end_col = new_cols; + damagerect(screen, rect); + } + } + + if(screen->callbacks && screen->callbacks->resize) + return (*screen->callbacks->resize)(new_rows, new_cols, screen->cbdata); + + return 1; + } + + static int setlineinfo(int row, const VTermLineInfo *newinfo, const VTermLineInfo *oldinfo, void *user) + { + VTermScreen *screen = user; + int col; + VTermRect rect; + + if(newinfo->doublewidth != oldinfo->doublewidth || + newinfo->doubleheight != oldinfo->doubleheight) { + for(col = 0; col < screen->cols; col++) { + ScreenCell *cell = getcell(screen, row, col); + cell->pen.dwl = newinfo->doublewidth; + cell->pen.dhl = newinfo->doubleheight; + } + + rect.start_row = row; + rect.end_row = row + 1; + rect.start_col = 0; + rect.end_col = newinfo->doublewidth ? screen->cols / 2 : screen->cols; + damagerect(screen, rect); + + if(newinfo->doublewidth) { + rect.start_col = screen->cols / 2; + rect.end_col = screen->cols; + + erase_internal(rect, 0, user); + } + } + + return 1; + } + + static VTermStateCallbacks state_cbs = { + &putglyph, // putglyph + &movecursor, // movecursor + &scrollrect, // scrollrect + NULL, // moverect + &erase, // erase + NULL, // initpen + &setpenattr, // setpenattr + &settermprop, // settermprop + &bell, // bell + &resize, // resize + &setlineinfo // setlineinfo + }; + + /* + * Allocate a new screen and return it. + * Return NULL when out of memory. + */ + static VTermScreen *screen_new(VTerm *vt) + { + VTermState *state = vterm_obtain_state(vt); + VTermScreen *screen; + int rows, cols; + + if (state == NULL) + return NULL; + screen = vterm_allocator_malloc(vt, sizeof(VTermScreen)); + if (screen == NULL) + return NULL; + + vterm_get_size(vt, &rows, &cols); + + screen->vt = vt; + screen->state = state; + + screen->damage_merge = VTERM_DAMAGE_CELL; + screen->damaged.start_row = -1; + screen->pending_scrollrect.start_row = -1; + + screen->rows = rows; + screen->cols = cols; + + screen->callbacks = NULL; + screen->cbdata = NULL; + + screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols); + screen->buffer = screen->buffers[0]; + screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols); + if (screen->buffer == NULL || screen->sb_buffer == NULL) + { + vterm_screen_free(screen); + return NULL; + } + + vterm_state_set_callbacks(screen->state, &state_cbs, screen); + + return screen; + } + + INTERNAL void vterm_screen_free(VTermScreen *screen) + { + vterm_allocator_free(screen->vt, screen->buffers[0]); + vterm_allocator_free(screen->vt, screen->buffers[1]); + vterm_allocator_free(screen->vt, screen->sb_buffer); + vterm_allocator_free(screen->vt, screen); + } + + void vterm_screen_reset(VTermScreen *screen, int hard) + { + screen->damaged.start_row = -1; + screen->pending_scrollrect.start_row = -1; + vterm_state_reset(screen->state, hard); + vterm_screen_flush_damage(screen); + } + + static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer, size_t len, const VTermRect rect) + { + size_t outpos = 0; + int padding = 0; + int row, col; + + #define PUT(c) \ + if(utf8) { \ + size_t thislen = utf8_seqlen(c); \ + if(buffer && outpos + thislen <= len) \ + outpos += fill_utf8((c), (char *)buffer + outpos); \ + else \ + outpos += thislen; \ + } \ + else { \ + if(buffer && outpos + 1 <= len) \ + ((uint32_t*)buffer)[outpos++] = (c); \ + else \ + outpos++; \ + } + + for(row = rect.start_row; row < rect.end_row; row++) { + for(col = rect.start_col; col < rect.end_col; col++) { + ScreenCell *cell = getcell(screen, row, col); + int i; + + if(cell->chars[0] == 0) + // Erased cell, might need a space + padding++; + else if(cell->chars[0] == (uint32_t)-1) + // Gap behind a double-width char, do nothing + ; + else { + while(padding) { + PUT(UNICODE_SPACE); + padding--; + } + for(i = 0; i < VTERM_MAX_CHARS_PER_CELL && cell->chars[i]; i++) { + PUT(cell->chars[i]); + } + } + } + + if(row < rect.end_row - 1) { + PUT(UNICODE_LINEFEED); + padding = 0; + } + } + + return outpos; + } + + size_t vterm_screen_get_chars(const VTermScreen *screen, uint32_t *chars, size_t len, const VTermRect rect) + { + return _get_chars(screen, 0, chars, len, rect); + } + + size_t vterm_screen_get_text(const VTermScreen *screen, char *str, size_t len, const VTermRect rect) + { + return _get_chars(screen, 1, str, len, rect); + } + + // Copy internal to external representation of a screen cell + int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCell *cell) + { + ScreenCell *intcell = getcell(screen, pos.row, pos.col); + int i; + + if(!intcell) + return 0; + + for(i = 0; ; i++) { + cell->chars[i] = intcell->chars[i]; + if(!intcell->chars[i]) + break; + } + + cell->attrs.bold = intcell->pen.bold; + cell->attrs.underline = intcell->pen.underline; + cell->attrs.italic = intcell->pen.italic; + cell->attrs.blink = intcell->pen.blink; + cell->attrs.reverse = intcell->pen.reverse ^ screen->global_reverse; + cell->attrs.strike = intcell->pen.strike; + cell->attrs.font = intcell->pen.font; + + cell->attrs.dwl = intcell->pen.dwl; + cell->attrs.dhl = intcell->pen.dhl; + + cell->fg = intcell->pen.fg; + cell->bg = intcell->pen.bg; + + if(vterm_get_special_pty_type() == 2) { + /* Get correct cell width from cell information contained in line buffer */ + if(pos.col < (screen->cols - 1) && + getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) { + if(getcell(screen, pos.row, pos.col)->chars[0] == 0x20) { + getcell(screen, pos.row, pos.col)->chars[0] = 0; + cell->width = 2; + } else if(getcell(screen, pos.row, pos.col)->chars[0] == 0) { + getcell(screen, pos.row, pos.col + 1)->chars[0] = 0; + cell->width = 1; + } else { + cell->width = 2; + } + } else + cell->width = 1; + } else { + if(pos.col < (screen->cols - 1) && + getcell(screen, pos.row, pos.col + 1)->chars[0] == (uint32_t)-1) + cell->width = 2; + else + cell->width = 1; + } + + return 1; + } + + // Copy external to internal representation of a screen cell + /* static because it's only used internally for sb_popline during resize */ + static int vterm_screen_set_cell(VTermScreen *screen, VTermPos pos, const VTermScreenCell *cell) + { + ScreenCell *intcell = getcell(screen, pos.row, pos.col); + int i; + + if(!intcell) + return 0; + + for(i = 0; ; i++) { + intcell->chars[i] = cell->chars[i]; + if(!cell->chars[i]) + break; + } + + intcell->pen.bold = cell->attrs.bold; + intcell->pen.underline = cell->attrs.underline; + intcell->pen.italic = cell->attrs.italic; + intcell->pen.blink = cell->attrs.blink; + intcell->pen.reverse = cell->attrs.reverse ^ screen->global_reverse; + intcell->pen.strike = cell->attrs.strike; + intcell->pen.font = cell->attrs.font; + + intcell->pen.fg = cell->fg; + intcell->pen.bg = cell->bg; + + if(cell->width == 2) + getcell(screen, pos.row, pos.col + 1)->chars[0] = (uint32_t)-1; + + return 1; + } + + int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos) + { + // This cell is EOL if this and every cell to the right is black + for(; pos.col < screen->cols; pos.col++) { + ScreenCell *cell = getcell(screen, pos.row, pos.col); + if(cell->chars[0] != 0) + return 0; + } + + return 1; + } + + VTermScreen *vterm_obtain_screen(VTerm *vt) + { + if(!vt->screen) + vt->screen = screen_new(vt); + return vt->screen; + } + + void vterm_screen_enable_altscreen(VTermScreen *screen, int altscreen) + { + + if(!screen->buffers[1] && altscreen) { + int rows, cols; + vterm_get_size(screen->vt, &rows, &cols); + + screen->buffers[1] = realloc_buffer(screen, NULL, rows, cols); + } + } + + void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user) + { + screen->callbacks = callbacks; + screen->cbdata = user; + } + + void *vterm_screen_get_cbdata(VTermScreen *screen) + { + return screen->cbdata; + } + + void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user) + { + vterm_state_set_unrecognised_fallbacks(screen->state, fallbacks, user); + } + + void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen) + { + return vterm_state_get_unrecognised_fbdata(screen->state); + } + + void vterm_screen_flush_damage(VTermScreen *screen) + { + if(screen->pending_scrollrect.start_row != -1) { + vterm_scroll_rect(screen->pending_scrollrect, screen->pending_scroll_downward, screen->pending_scroll_rightward, + moverect_user, erase_user, screen); + + screen->pending_scrollrect.start_row = -1; + } + + if(screen->damaged.start_row != -1) { + if(screen->callbacks && screen->callbacks->damage) + (*screen->callbacks->damage)(screen->damaged, screen->cbdata); + + screen->damaged.start_row = -1; + } + } + + void vterm_screen_set_damage_merge(VTermScreen *screen, VTermDamageSize size) + { + vterm_screen_flush_damage(screen); + screen->damage_merge = size; + } + + static int attrs_differ(VTermAttrMask attrs, ScreenCell *a, ScreenCell *b) + { + if((attrs & VTERM_ATTR_BOLD_MASK) && (a->pen.bold != b->pen.bold)) + return 1; + if((attrs & VTERM_ATTR_UNDERLINE_MASK) && (a->pen.underline != b->pen.underline)) + return 1; + if((attrs & VTERM_ATTR_ITALIC_MASK) && (a->pen.italic != b->pen.italic)) + return 1; + if((attrs & VTERM_ATTR_BLINK_MASK) && (a->pen.blink != b->pen.blink)) + return 1; + if((attrs & VTERM_ATTR_REVERSE_MASK) && (a->pen.reverse != b->pen.reverse)) + return 1; + if((attrs & VTERM_ATTR_STRIKE_MASK) && (a->pen.strike != b->pen.strike)) + return 1; + if((attrs & VTERM_ATTR_FONT_MASK) && (a->pen.font != b->pen.font)) + return 1; + if((attrs & VTERM_ATTR_FOREGROUND_MASK) && !vterm_color_equal(a->pen.fg, b->pen.fg)) + return 1; + if((attrs & VTERM_ATTR_BACKGROUND_MASK) && !vterm_color_equal(a->pen.bg, b->pen.bg)) + return 1; + + return 0; + } + + int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent, VTermPos pos, VTermAttrMask attrs) + { + int col; + + ScreenCell *target = getcell(screen, pos.row, pos.col); + + // TODO: bounds check + extent->start_row = pos.row; + extent->end_row = pos.row + 1; + + if(extent->start_col < 0) + extent->start_col = 0; + if(extent->end_col < 0) + extent->end_col = screen->cols; + + for(col = pos.col - 1; col >= extent->start_col; col--) + if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) + break; + extent->start_col = col + 1; + + for(col = pos.col + 1; col < extent->end_col; col++) + if(attrs_differ(attrs, target, getcell(screen, pos.row, col))) + break; + extent->end_col = col - 1; + + return 1; + } *** ../vim-8.1.2127/src/Makefile 2019-10-09 22:52:48.992043788 +0200 --- src/Makefile 2019-10-10 13:20:18.540304853 +0200 *************** *** 2860,2865 **** --- 2862,2868 ---- -rm -f runtime pixmaps -rm -rf $(APPDIR) -rm -rf mzscheme_base.c + -rm -rf libvterm/.libs libterm/t/.libs libvterm/src/*.o libvterm/src/*.lo libvterm/t/*.o libvterm/t/*.lo libvterm/t/harness libvterm/libvterm.la if test -d $(PODIR); then \ cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) clean; \ fi *************** *** 3453,3488 **** Makefile: @echo The name of the makefile MUST be "Makefile" (with capital M)!!!! CCCTERM = $(CCC_NF) $(VTERM_CFLAGS) $(ALL_CFLAGS) -DINLINE="" \ -DVSNPRINTF=vim_vsnprintf \ -DIS_COMBINING_FUNCTION=utf_iscomposing_uint \ -DWCWIDTH_FUNCTION=utf_uint2cells ! objects/encoding.o: libvterm/src/encoding.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/encoding.c ! objects/keyboard.o: libvterm/src/keyboard.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/keyboard.c ! objects/termmouse.o: libvterm/src/termmouse.c $(TERM_DEPS) ! $(CCCTERM) -o $@ libvterm/src/termmouse.c ! objects/parser.o: libvterm/src/parser.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/parser.c ! objects/pen.o: libvterm/src/pen.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/pen.c ! objects/termscreen.o: libvterm/src/termscreen.c $(TERM_DEPS) ! $(CCCTERM) -o $@ libvterm/src/termscreen.c ! objects/state.o: libvterm/src/state.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/state.c ! objects/unicode.o: libvterm/src/unicode.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/unicode.c ! objects/vterm.o: libvterm/src/vterm.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/vterm.c CCCDIFF = $(CCC_NF) $(ALL_CFLAGS) --- 3456,3494 ---- Makefile: @echo The name of the makefile MUST be "Makefile" (with capital M)!!!! + # Build rules for libvterm. Putting them here allows for adding compilation + # options specific for Vim. Since the .o files go into objects/ we do need to + # prefix vterm_ to avoid name clashes. CCCTERM = $(CCC_NF) $(VTERM_CFLAGS) $(ALL_CFLAGS) -DINLINE="" \ -DVSNPRINTF=vim_vsnprintf \ -DIS_COMBINING_FUNCTION=utf_iscomposing_uint \ -DWCWIDTH_FUNCTION=utf_uint2cells ! objects/vterm_encoding.o: libvterm/src/encoding.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/encoding.c ! objects/vterm_keyboard.o: libvterm/src/keyboard.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/keyboard.c ! objects/vterm_mouse.o: libvterm/src/mouse.c $(TERM_DEPS) ! $(CCCTERM) -o $@ libvterm/src/mouse.c ! objects/vterm_parser.o: libvterm/src/parser.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/parser.c ! objects/vterm_pen.o: libvterm/src/pen.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/pen.c ! objects/vterm_screen.o: libvterm/src/screen.c $(TERM_DEPS) ! $(CCCTERM) -o $@ libvterm/src/screen.c ! objects/vterm_state.o: libvterm/src/state.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/state.c ! objects/vterm_unicode.o: libvterm/src/unicode.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/unicode.c ! objects/vterm_vterm.o: libvterm/src/vterm.c $(TERM_DEPS) $(CCCTERM) -o $@ libvterm/src/vterm.c CCCDIFF = $(CCC_NF) $(ALL_CFLAGS) *************** *** 4111,4137 **** proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto.h globals.h objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c ! objects/encoding.o: libvterm/src/encoding.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/encoding/DECdrawing.inc libvterm/src/encoding/uk.inc ! objects/keyboard.o: libvterm/src/keyboard.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h ! objects/termmouse.o: libvterm/src/termmouse.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h ! objects/parser.o: libvterm/src/parser.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/pen.o: libvterm/src/pen.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/state.o: libvterm/src/state.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/termscreen.o: libvterm/src/termscreen.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/rect.h libvterm/src/utf8.h ! objects/unicode.o: libvterm/src/unicode.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/vterm.o: libvterm/src/vterm.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h objects/xdiffi.o: xdiff/xdiffi.c xdiff/xinclude.h auto/config.h \ --- 4117,4143 ---- proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ proto.h globals.h objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c ! objects/vterm_encoding.o: libvterm/src/encoding.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/encoding/DECdrawing.inc libvterm/src/encoding/uk.inc ! objects/vterm_keyboard.o: libvterm/src/keyboard.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h ! objects/vterm_mouse.o: libvterm/src/mouse.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h ! objects/vterm_parser.o: libvterm/src/parser.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/vterm_pen.o: libvterm/src/pen.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/vterm_state.o: libvterm/src/state.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/vterm_screen.o: libvterm/src/screen.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/rect.h libvterm/src/utf8.h ! objects/vterm_unicode.o: libvterm/src/unicode.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h ! objects/vterm_vterm.o: libvterm/src/vterm.c libvterm/src/vterm_internal.h \ libvterm/include/vterm.h libvterm/include/vterm_keycodes.h \ libvterm/src/utf8.h objects/xdiffi.o: xdiff/xdiffi.c xdiff/xinclude.h auto/config.h \ *** ../vim-8.1.2127/src/configure.ac 2019-09-21 20:46:14.720275786 +0200 --- src/configure.ac 2019-10-10 13:06:48.047447387 +0200 *************** *** 2104,2112 **** fi if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then AC_DEFINE(FEAT_TERMINAL) ! TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/termscreen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c" AC_SUBST(TERM_SRC) ! TERM_OBJ="objects/encoding.o objects/keyboard.o objects/termmouse.o objects/parser.o objects/pen.o objects/termscreen.o objects/state.o objects/unicode.o objects/vterm.o" AC_SUBST(TERM_OBJ) fi --- 2104,2112 ---- fi if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then AC_DEFINE(FEAT_TERMINAL) ! TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/creen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c" AC_SUBST(TERM_SRC) ! TERM_OBJ="objects/vterm_encoding.o objects/vterm_keyboard.o objects/vterm_mouse.o objects/vterm_parser.o objects/vterm_pen.o objects/vterm_screen.o objects/vterm_state.o objects/vterm_unicode.o objects/vterm_vterm.o" AC_SUBST(TERM_OBJ) fi *** ../vim-8.1.2127/src/auto/configure 2019-09-21 20:46:14.720275786 +0200 --- src/auto/configure 2019-10-10 13:18:35.212715413 +0200 *************** *** 7907,7915 **** if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then $as_echo "#define FEAT_TERMINAL 1" >>confdefs.h ! TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/termscreen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c" ! TERM_OBJ="objects/encoding.o objects/keyboard.o objects/termmouse.o objects/parser.o objects/pen.o objects/termscreen.o objects/state.o objects/unicode.o objects/vterm.o" fi --- 7907,7915 ---- if test "$enable_terminal" = "yes" -a "$enable_channel" = "yes"; then $as_echo "#define FEAT_TERMINAL 1" >>confdefs.h ! TERM_SRC="libvterm/src/encoding.c libvterm/src/keyboard.c libvterm/src/mouse.c libvterm/src/parser.c libvterm/src/pen.c libvterm/src/creen.c libvterm/src/state.c libvterm/src/unicode.c libvterm/src/vterm.c" ! TERM_OBJ="objects/vterm_encoding.o objects/vterm_keyboard.o objects/vterm_mouse.o objects/vterm_parser.o objects/vterm_pen.o objects/vterm_screen.o objects/vterm_state.o objects/vterm_unicode.o objects/vterm_vterm.o" fi *** ../vim-8.1.2127/src/Make_cyg_ming.mak 2019-10-09 22:52:48.988043810 +0200 --- src/Make_cyg_ming.mak 2019-10-10 13:11:15.770417298 +0200 *************** *** 869,883 **** ifeq ($(TERMINAL),yes) OBJ += $(OUTDIR)/terminal.o \ ! $(OUTDIR)/encoding.o \ ! $(OUTDIR)/keyboard.o \ ! $(OUTDIR)/termmouse.o \ ! $(OUTDIR)/parser.o \ ! $(OUTDIR)/pen.o \ ! $(OUTDIR)/termscreen.o \ ! $(OUTDIR)/state.o \ ! $(OUTDIR)/unicode.o \ ! $(OUTDIR)/vterm.o endif ifeq ($(SOUND),yes) --- 869,883 ---- ifeq ($(TERMINAL),yes) OBJ += $(OUTDIR)/terminal.o \ ! $(OUTDIR)/vterm_encoding.o \ ! $(OUTDIR)/vterm_keyboard.o \ ! $(OUTDIR)/vterm_mouse.o \ ! $(OUTDIR)/vterm_parser.o \ ! $(OUTDIR)/vterm_pen.o \ ! $(OUTDIR)/vterm_screen.o \ ! $(OUTDIR)/vterm_state.o \ ! $(OUTDIR)/vterm_unicode.o \ ! $(OUTDIR)/vterm_vterm.o endif ifeq ($(SOUND),yes) *************** *** 1206,1212 **** -DWCWIDTH_FUNCTION=utf_uint2cells \ -DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type ! $(OUTDIR)/%.o : libvterm/src/%.c $(TERM_DEPS) $(CCCTERM) $< -o $@ --- 1206,1212 ---- -DWCWIDTH_FUNCTION=utf_uint2cells \ -DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type ! $(OUTDIR)/vterm_%.o : libvterm/src/%.c $(TERM_DEPS) $(CCCTERM) $< -o $@ *** ../vim-8.1.2127/src/Make_mvc.mak 2019-10-09 22:52:48.988043810 +0200 --- src/Make_mvc.mak 2019-10-10 13:17:47.008902493 +0200 *************** *** 363,377 **** !if "$(TERMINAL)" == "yes" TERM_OBJ = \ $(OBJDIR)/terminal.obj \ ! $(OBJDIR)/encoding.obj \ ! $(OBJDIR)/keyboard.obj \ ! $(OBJDIR)/termmouse.obj \ ! $(OBJDIR)/parser.obj \ ! $(OBJDIR)/pen.obj \ ! $(OBJDIR)/termscreen.obj \ ! $(OBJDIR)/state.obj \ ! $(OBJDIR)/unicode.obj \ ! $(OBJDIR)/vterm.obj TERM_DEFS = -DFEAT_TERMINAL TERM_DEPS = \ libvterm/include/vterm.h \ --- 363,377 ---- !if "$(TERMINAL)" == "yes" TERM_OBJ = \ $(OBJDIR)/terminal.obj \ ! $(OBJDIR)/vterm_encoding.obj \ ! $(OBJDIR)/vterm_keyboard.obj \ ! $(OBJDIR)/vterm_mouse.obj \ ! $(OBJDIR)/vterm_parser.obj \ ! $(OBJDIR)/vterm_pen.obj \ ! $(OBJDIR)/vterm_screen.obj \ ! $(OBJDIR)/vterm_state.obj \ ! $(OBJDIR)/vterm_unicode.obj \ ! $(OBJDIR)/vterm_vterm.obj TERM_DEFS = -DFEAT_TERMINAL TERM_DEPS = \ libvterm/include/vterm.h \ *************** *** 1743,1769 **** -DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type \ -D_CRT_SECURE_NO_WARNINGS ! # Create a default rule for libvterm. ! {libvterm/src/}.c{$(OUTDIR)/}.obj:: ! $(CCCTERM) -Fo$(OUTDIR)/ $< ! $(OUTDIR)/encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS) ! $(OUTDIR)/keyboard.obj: $(OUTDIR) libvterm/src/keyboard.c $(TERM_DEPS) ! $(OUTDIR)/termmouse.obj: $(OUTDIR) libvterm/src/termmouse.c $(TERM_DEPS) ! $(OUTDIR)/parser.obj: $(OUTDIR) libvterm/src/parser.c $(TERM_DEPS) ! $(OUTDIR)/pen.obj: $(OUTDIR) libvterm/src/pen.c $(TERM_DEPS) ! $(OUTDIR)/termscreen.obj: $(OUTDIR) libvterm/src/termscreen.c $(TERM_DEPS) ! $(OUTDIR)/state.obj: $(OUTDIR) libvterm/src/state.c $(TERM_DEPS) ! $(OUTDIR)/unicode.obj: $(OUTDIR) libvterm/src/unicode.c $(TERM_DEPS) ! ! $(OUTDIR)/vterm.obj: $(OUTDIR) libvterm/src/vterm.c $(TERM_DEPS) # $CFLAGS may contain backslashes and double quotes, escape them both. --- 1743,1774 ---- -DGET_SPECIAL_PTY_TYPE_FUNCTION=get_special_pty_type \ -D_CRT_SECURE_NO_WARNINGS ! $(OUTDIR)/vterm_encoding.obj: $(OUTDIR) libvterm/src/encoding.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_keyboard.obj: $(OUTDIR) libvterm/src/keyboard.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_mouse.obj: $(OUTDIR) libvterm/src/mouse.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_parser.obj: $(OUTDIR) libvterm/src/parser.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_pen.obj: $(OUTDIR) libvterm/src/pen.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_screen.obj: $(OUTDIR) libvterm/src/screen.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_state.obj: $(OUTDIR) libvterm/src/state.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_unicode.obj: $(OUTDIR) libvterm/src/unicode.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< ! $(OUTDIR)/vterm_vterm.obj: $(OUTDIR) libvterm/src/vterm.c $(TERM_DEPS) ! $(CCCTERM) /Fo$@ $< # $CFLAGS may contain backslashes and double quotes, escape them both. *** ../vim-8.1.2127/src/version.c 2019-10-09 22:52:49.000043746 +0200 --- src/version.c 2019-10-10 13:08:28.795060631 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 2128, /**/ -- BEDEVERE: Oooooh! LAUNCELOT: No "Aaaaarrrrrrggghhh ... " at the back of the throat. BEDEVERE: No! "Oooooh!" in surprise and alarm! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///