diff src/libvterm/src/screen.c @ 20518:a4652d7ec99f v8.2.0813

patch 8.2.0813: libvterm code is slightly different from upstream Commit: https://github.com/vim/vim/commit/591cec8366e87a172495c362477cbf5de8d399f0 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 22:06:06 2020 +0200 patch 8.2.0813: libvterm code is slightly different from upstream Problem: libvterm code is slightly different from upstream. Solution: Use upstream text to avoid future merge problems. Mainly comment style changes.
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 22:15:04 +0200
parents 03826c672315
children 88cec48503b8
line wrap: on
line diff
--- a/src/libvterm/src/screen.c
+++ b/src/libvterm/src/screen.c
@@ -10,10 +10,10 @@
 #define UNICODE_SPACE 0x20
 #define UNICODE_LINEFEED 0x0a
 
-// State of the pen at some moment in time, also used in a cell
+/* State of the pen at some moment in time, also used in a cell */
 typedef struct
 {
-  // After the bitfield
+  /* After the bitfield */
   VTermColor   fg, bg;
 
   unsigned int bold      : 1;
@@ -23,15 +23,15 @@ typedef struct
   unsigned int reverse   : 1;
   unsigned int conceal   : 1;
   unsigned int strike    : 1;
-  unsigned int font      : 4; // 0 to 9
+  unsigned int font      : 4; /* 0 to 9 */
 
-  // Extra state storage that isn't strictly pen-related
+  /* 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)
+  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
+/* Internal representation of a screen cell */
 typedef struct
 {
   uint32_t chars[VTERM_MAX_CHARS_PER_CELL];
@@ -47,7 +47,7 @@ struct VTermScreen
   void *cbdata;
 
   VTermDamageSize damage_merge;
-  // start_row == -1 => no damage
+  /* start_row == -1 => no damage */
   VTermRect damaged;
   VTermRect pending_scrollrect;
   int pending_scroll_downward, pending_scroll_rightward;
@@ -56,13 +56,13 @@ struct VTermScreen
   int cols;
   int global_reverse;
 
-  // Primary and Altscreen. buffers[1] is lazily allocated as needed
+  /* Primary and Altscreen. buffers[1] is lazily allocated as needed */
   ScreenCell *buffers[2];
 
-  // buffer will == buffers[0] or buffers[1], depending on altscreen
+  /* buffer will == buffers[0] or buffers[1], depending on altscreen */
   ScreenCell *buffer;
 
-  // buffer for a single screen row used in scrollback storage callbacks
+  /* buffer for a single screen row used in scrollback storage callbacks */
   VTermScreenCell *sb_buffer;
 
   ScreenPen pen;
@@ -106,13 +106,13 @@ static void damagerect(VTermScreen *scre
 
   switch(screen->damage_merge) {
   case VTERM_DAMAGE_CELL:
-    // Always emit damage event
+    /* 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
+    /* 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);
@@ -140,7 +140,7 @@ static void damagerect(VTermScreen *scre
 
   case VTERM_DAMAGE_SCREEN:
   case VTERM_DAMAGE_SCROLL:
-    // Never emit damage event
+    /* Never emit damage event */
     if(screen->damaged.start_row == -1)
       screen->damaged = rect;
     else {
@@ -355,14 +355,15 @@ static int scrollrect(VTermRect rect, in
     return 1;
 
   if(rect_contains(&rect, &screen->damaged)) {
-    // Scroll region entirely contains the damage; just move it
+    /* 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.
+  /* 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) {
@@ -454,8 +455,9 @@ static int settermprop(VTermProp prop, V
       return 0;
 
     screen->buffer = val->boolean ? screen->buffers[BUFIDX_ALTSCREEN] : screen->buffers[BUFIDX_PRIMARY];
-    // only send a damage event on disable; because during enable there's an
-    // erase that sends a damage anyway
+    /* 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;
@@ -464,7 +466,7 @@ static int settermprop(VTermProp prop, V
     damagescreen(screen);
     break;
   default:
-    ; // ignore
+    ; /* ignore */
   }
 
   if(screen->callbacks && screen->callbacks->settermprop)
@@ -491,7 +493,7 @@ static void resize_buffer(VTermScreen *s
   ScreenCell *old_buffer = screen->buffers[bufidx];
   ScreenCell *new_buffer = vterm_allocator_malloc(screen->vt, sizeof(ScreenCell) * new_rows * new_cols);
 
-  /* Find the final row of old buffer content */
+  // Find the final row of old buffer content
   int old_row = old_rows - 1;
   int new_row = new_rows - 1;
   int col;
@@ -573,10 +575,8 @@ static void resize_buffer(VTermScreen *s
     memmove(&new_buffer[0], &new_buffer[(new_row + 1) * new_cols], moverows * new_cols * sizeof(ScreenCell));
 
     for(new_row = moverows; new_row < new_rows; new_row++)
-    {
       for(col = 0; col < new_cols; col++)
         clearcell(screen, &new_buffer[new_row * new_cols + col]);
-    }
   }
 
   vterm_allocator_free(screen->vt, old_buffer);
@@ -729,6 +729,7 @@ INTERNAL void vterm_screen_free(VTermScr
     vterm_allocator_free(screen->vt, screen->buffers[BUFIDX_ALTSCREEN]);
 
   vterm_allocator_free(screen->vt, screen->sb_buffer);
+
   vterm_allocator_free(screen->vt, screen);
 }
 
@@ -802,7 +803,7 @@ size_t vterm_screen_get_text(const VTerm
   return _get_chars(screen, 1, str, len, rect);
 }
 
-// Copy internal to external representation of a screen cell
+/* 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);
@@ -860,7 +861,7 @@ int vterm_screen_get_cell(const VTermScr
 
 int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos)
 {
-  // This cell is EOL if this and every cell to the right is black
+  /* 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)