@@ -128,6 +128,14 @@ StlClickDefinition *tab_page_click_defs = NULL;
128
128
129
129
long tab_page_click_defs_size = 0 ;
130
130
131
+ /// The last handle that was assigned to a ScreenGrid. 1 is reserved for
132
+ /// the default_grid.
133
+ /// TODO(utkarshme): Numbers can be recycled after grid destruction.
134
+ static int last_handle = 1 ;
135
+
136
+ /// Whether to call "ui_call_grid_resize" in win_grid_alloc
137
+ static int send_grid_resize ;
138
+
131
139
#ifdef INCLUDE_GENERATED_DECLARATIONS
132
140
# include "screen.c.generated.h"
133
141
#endif
@@ -422,6 +430,7 @@ void update_screen(int type)
422
430
win_redr_status (wp );
423
431
}
424
432
}
433
+ send_grid_resize = false;
425
434
end_search_hl ();
426
435
// May need to redraw the popup menu.
427
436
if (pum_drawn ()) {
@@ -656,7 +665,7 @@ static void win_update(win_T *wp)
656
665
657
666
type = wp -> w_redr_type ;
658
667
659
- window_grid_alloc (wp , false);
668
+ win_grid_alloc (wp , false);
660
669
661
670
if (type == NOT_VALID ) {
662
671
wp -> w_redr_status = TRUE;
@@ -2223,7 +2232,7 @@ win_line (
2223
2232
row = startrow ;
2224
2233
2225
2234
// allocate window grid if not already
2226
- window_grid_alloc (wp , true);
2235
+ win_grid_alloc (wp , true);
2227
2236
2228
2237
/*
2229
2238
* To speed up the loop below, set extra_check when there is linebreak,
@@ -5833,18 +5842,28 @@ int screen_valid(int doclear)
5833
5842
/// (re)allocate a window grid if size changed
5834
5843
/// If "doclear" is true, clear the screen if resized.
5835
5844
// TODO(utkarshme): Think of a better name, place
5836
- void window_grid_alloc (win_T * wp , int doclear )
5845
+ void win_grid_alloc (win_T * wp , int doclear )
5837
5846
{
5838
- if (wp -> w_grid .ScreenLines != NULL
5839
- && wp -> w_grid .Rows == wp -> w_height
5840
- && wp -> w_grid .Columns == wp -> w_width ) {
5841
- return ;
5842
- }
5847
+ if (wp -> w_grid .ScreenLines == NULL
5848
+ || wp -> w_grid .Rows != wp -> w_height
5849
+ || wp -> w_grid .Columns != wp -> w_width ) {
5850
+ grid_alloc (& wp -> w_grid , wp -> w_height , wp -> w_width , doclear );
5851
+
5852
+ // only assign a grid handle if not already
5853
+ if (wp -> w_grid .handle == 0 ) {
5854
+ wp -> w_grid .handle = ++ last_handle ;
5855
+ }
5856
+
5857
+ wp -> w_grid .OffsetRow = wp -> w_winrow ;
5858
+ wp -> w_grid .OffsetColumn = wp -> w_wincol ;
5843
5859
5844
- grid_alloc (& wp -> w_grid , wp -> w_height , wp -> w_width , doclear );
5860
+ wp -> w_grid .was_resized = true;
5861
+ }
5845
5862
5846
- wp -> w_grid .OffsetRow = wp -> w_winrow ;
5847
- wp -> w_grid .OffsetColumn = wp -> w_wincol ;
5863
+ if (send_grid_resize || wp -> w_grid .was_resized ) {
5864
+ ui_call_grid_resize (wp -> w_grid .handle , wp -> w_grid .Columns , wp -> w_grid .Rows );
5865
+ wp -> w_grid .was_resized = false;
5866
+ }
5848
5867
}
5849
5868
5850
5869
/*
@@ -5938,6 +5957,7 @@ void screenalloc(bool doclear)
5938
5957
5939
5958
default_grid .OffsetRow = 0 ;
5940
5959
default_grid .OffsetColumn = 0 ;
5960
+ default_grid .handle = 1 ;
5941
5961
5942
5962
must_redraw = CLEAR ; /* need to clear the screen later */
5943
5963
if (doclear )
@@ -5962,7 +5982,7 @@ void screenalloc(bool doclear)
5962
5982
void grid_alloc (ScreenGrid * grid , int rows , int columns , bool copy )
5963
5983
{
5964
5984
int new_row , old_row ;
5965
- ScreenGrid new = { 0 } ;
5985
+ ScreenGrid new = * grid ;
5966
5986
5967
5987
size_t ncells = (size_t )((rows + 1 ) * columns );
5968
5988
new .ScreenLines = xmalloc (ncells * sizeof (schar_T ));
@@ -6249,7 +6269,7 @@ int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end,
6249
6269
}
6250
6270
}
6251
6271
6252
- ui_call_grid_scroll (1 , row , end , col , col + width , - line_count , 0 );
6272
+ ui_call_grid_scroll (grid -> handle , row , end , col , col + width , - line_count , 0 );
6253
6273
6254
6274
return OK ;
6255
6275
}
@@ -6301,7 +6321,7 @@ int grid_del_lines(ScreenGrid *grid, int row, int line_count, int end,
6301
6321
}
6302
6322
}
6303
6323
6304
- ui_call_grid_scroll (1 , row , end , col , col + width , line_count , 0 );
6324
+ ui_call_grid_scroll (grid -> handle , row , end , col , col + width , line_count , 0 );
6305
6325
6306
6326
return OK ;
6307
6327
}
@@ -7054,6 +7074,8 @@ void screen_resize(int width, int height)
7054
7074
default_grid .Rows = screen_Rows ;
7055
7075
default_grid .Columns = screen_Columns ;
7056
7076
7077
+ send_grid_resize = true;
7078
+
7057
7079
/* The window layout used to be adjusted here, but it now happens in
7058
7080
* screenalloc() (also invoked from screenclear()). That is because the
7059
7081
* "busy" check above may skip this, but not screenalloc(). */
0 commit comments