Mercurial > vim
comparison src/libvterm/src/screen.c @ 30876:2d2758ffd959 v9.0.0772
patch 9.0.0772: the libvterm code is outdated
Commit: https://github.com/vim/vim/commit/501e77766cd30d8f4bfeb04a67aff1865b5f5a41
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Oct 16 14:35:46 2022 +0100
patch 9.0.0772: the libvterm code is outdated
Problem: The libvterm code is outdated.
Solution: Include libvterm changes from revision 790 to 801.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Oct 2022 15:45:04 +0200 |
parents | 66618893eb2a |
children | 82336c3b679d |
comparison
equal
deleted
inserted
replaced
30875:3295247d97a5 | 30876:2d2758ffd959 |
---|---|
500 { | 500 { |
501 int old_rows = screen->rows; | 501 int old_rows = screen->rows; |
502 int old_cols = screen->cols; | 502 int old_cols = screen->cols; |
503 | 503 |
504 ScreenCell *old_buffer = screen->buffers[bufidx]; | 504 ScreenCell *old_buffer = screen->buffers[bufidx]; |
505 VTermLineInfo *old_lineinfo = statefields->lineinfos[bufidx]; | |
506 | |
505 ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); | 507 ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols); |
508 VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows); | |
506 | 509 |
507 // Find the final row of old buffer content | 510 // Find the final row of old buffer content |
508 int old_row = old_rows - 1; | 511 int old_row = old_rows - 1; |
509 int new_row = new_rows - 1; | 512 int new_row = new_rows - 1; |
510 int col; | 513 int col; |
512 while(new_row >= 0 && old_row >= 0) { | 515 while(new_row >= 0 && old_row >= 0) { |
513 for(col = 0; col < old_cols && col < new_cols; col++) | 516 for(col = 0; col < old_cols && col < new_cols; col++) |
514 new_buffer[new_row * new_cols + col] = old_buffer[old_row * old_cols + col]; | 517 new_buffer[new_row * new_cols + col] = old_buffer[old_row * old_cols + col]; |
515 for( ; col < new_cols; col++) | 518 for( ; col < new_cols; col++) |
516 clearcell(screen, &new_buffer[new_row * new_cols + col]); | 519 clearcell(screen, &new_buffer[new_row * new_cols + col]); |
520 | |
521 new_lineinfo[new_row] = old_lineinfo[old_row]; | |
517 | 522 |
518 old_row--; | 523 old_row--; |
519 new_row--; | 524 new_row--; |
520 | 525 |
521 if(new_row < 0 && old_row >= 0 && | 526 if(new_row < 0 && old_row >= 0 && |
582 | 587 |
583 if(new_row >= 0) { | 588 if(new_row >= 0) { |
584 /* Scroll new rows back up to the top and fill in blanks at the bottom */ | 589 /* Scroll new rows back up to the top and fill in blanks at the bottom */ |
585 int moverows = new_rows - new_row - 1; | 590 int moverows = new_rows - new_row - 1; |
586 memmove(&new_buffer[0], &new_buffer[(new_row + 1) * new_cols], moverows * new_cols * sizeof(ScreenCell)); | 591 memmove(&new_buffer[0], &new_buffer[(new_row + 1) * new_cols], moverows * new_cols * sizeof(ScreenCell)); |
587 | 592 memmove(&new_lineinfo[0], &new_lineinfo[new_row + 1], moverows * sizeof(new_lineinfo[0])); |
588 for(new_row = moverows; new_row < new_rows; new_row++) | 593 |
594 for(new_row = moverows; new_row < new_rows; new_row++) { | |
589 for(col = 0; col < new_cols; col++) | 595 for(col = 0; col < new_cols; col++) |
590 clearcell(screen, &new_buffer[new_row * new_cols + col]); | 596 clearcell(screen, &new_buffer[new_row * new_cols + col]); |
597 new_lineinfo[new_row] = (VTermLineInfo){ 0 }; | |
598 } | |
591 } | 599 } |
592 | 600 |
593 vterm_allocator_free(screen->vt, old_buffer); | 601 vterm_allocator_free(screen->vt, old_buffer); |
594 screen->buffers[bufidx] = new_buffer; | 602 screen->buffers[bufidx] = new_buffer; |
603 | |
604 vterm_allocator_free(screen->vt, old_lineinfo); | |
605 statefields->lineinfos[bufidx] = new_lineinfo; | |
595 | 606 |
596 return; | 607 return; |
597 | 608 |
598 /* REFLOW TODO: | 609 /* REFLOW TODO: |
599 * Handle delta. Probably needs to be a full cursorpos that we edit | 610 * Handle delta. Probably needs to be a full cursorpos that we edit |
604 { | 615 { |
605 VTermScreen *screen = user; | 616 VTermScreen *screen = user; |
606 | 617 |
607 int altscreen_active = (screen->buffers[BUFIDX_ALTSCREEN] && screen->buffer == screen->buffers[BUFIDX_ALTSCREEN]); | 618 int altscreen_active = (screen->buffers[BUFIDX_ALTSCREEN] && screen->buffer == screen->buffers[BUFIDX_ALTSCREEN]); |
608 | 619 |
620 int old_rows = screen->rows; | |
609 int old_cols = screen->cols; | 621 int old_cols = screen->cols; |
610 | 622 |
611 if(new_cols > old_cols) { | 623 if(new_cols > old_cols) { |
612 /* Ensure that ->sb_buffer is large enough for a new or and old row */ | 624 /* Ensure that ->sb_buffer is large enough for a new or and old row */ |
613 if(screen->sb_buffer) | 625 if(screen->sb_buffer) |
617 } | 629 } |
618 | 630 |
619 resize_buffer(screen, 0, new_rows, new_cols, !altscreen_active, fields); | 631 resize_buffer(screen, 0, new_rows, new_cols, !altscreen_active, fields); |
620 if(screen->buffers[BUFIDX_ALTSCREEN]) | 632 if(screen->buffers[BUFIDX_ALTSCREEN]) |
621 resize_buffer(screen, 1, new_rows, new_cols, altscreen_active, fields); | 633 resize_buffer(screen, 1, new_rows, new_cols, altscreen_active, fields); |
634 else if(new_rows != old_rows) { | |
635 /* We don't need a full resize of the altscreen because it isn't enabled | |
636 * but we should at least keep the lineinfo the right size */ | |
637 vterm_allocator_free(screen->vt, fields->lineinfos[BUFIDX_ALTSCREEN]); | |
638 | |
639 VTermLineInfo *new_lineinfo = vterm_allocator_malloc(screen->vt, sizeof(new_lineinfo[0]) * new_rows); | |
640 for(int row = 0; row < new_rows; row++) | |
641 new_lineinfo[row] = (VTermLineInfo){ 0 }; | |
642 | |
643 fields->lineinfos[BUFIDX_ALTSCREEN] = new_lineinfo; | |
644 } | |
622 | 645 |
623 screen->buffer = altscreen_active ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY]; | 646 screen->buffer = altscreen_active ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY]; |
624 | 647 |
625 screen->rows = new_rows; | 648 screen->rows = new_rows; |
626 screen->cols = new_cols; | 649 screen->cols = new_cols; |