@@ -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 , true); // any popup menu will be redrawn below
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 ()) {
@@ -661,7 +670,7 @@ static void win_update(win_T *wp)
661
670
662
671
type = wp -> w_redr_type ;
663
672
664
- window_grid_alloc (wp , false);
673
+ win_grid_alloc (wp , false);
665
674
666
675
if (type == NOT_VALID ) {
667
676
wp -> w_redr_status = TRUE;
@@ -2235,7 +2244,7 @@ win_line (
2235
2244
row = startrow ;
2236
2245
2237
2246
// allocate window grid if not already
2238
- window_grid_alloc (wp , true);
2247
+ win_grid_alloc (wp , true);
2239
2248
2240
2249
/*
2241
2250
* To speed up the loop below, set extra_check when there is linebreak,
@@ -5849,18 +5858,28 @@ int screen_valid(int doclear)
5849
5858
/// (re)allocate a window grid if size changed
5850
5859
/// If "doclear" is true, clear the screen if resized.
5851
5860
// TODO(utkarshme): Think of a better name, place
5852
- void window_grid_alloc (win_T * wp , int doclear )
5861
+ void win_grid_alloc (win_T * wp , int doclear )
5853
5862
{
5854
- if (wp -> w_grid .ScreenLines != NULL
5855
- && wp -> w_grid .Rows == wp -> w_height
5856
- && wp -> w_grid .Columns == wp -> w_width ) {
5857
- return ;
5858
- }
5863
+ if (wp -> w_grid .ScreenLines == NULL
5864
+ || wp -> w_grid .Rows != wp -> w_height
5865
+ || wp -> w_grid .Columns != wp -> w_width ) {
5866
+ grid_alloc (& wp -> w_grid , wp -> w_height , wp -> w_width , doclear );
5867
+
5868
+ // only assign a grid handle if not already
5869
+ if (wp -> w_grid .handle == 0 ) {
5870
+ wp -> w_grid .handle = ++ last_handle ;
5871
+ }
5872
+
5873
+ wp -> w_grid .OffsetRow = wp -> w_winrow ;
5874
+ wp -> w_grid .OffsetColumn = wp -> w_wincol ;
5859
5875
5860
- grid_alloc (& wp -> w_grid , wp -> w_height , wp -> w_width , doclear );
5876
+ wp -> w_grid .was_resized = true;
5877
+ }
5861
5878
5862
- wp -> w_grid .OffsetRow = wp -> w_winrow ;
5863
- wp -> w_grid .OffsetColumn = wp -> w_wincol ;
5879
+ if (send_grid_resize || wp -> w_grid .was_resized ) {
5880
+ ui_call_grid_resize (wp -> w_grid .handle , wp -> w_grid .Columns , wp -> w_grid .Rows );
5881
+ wp -> w_grid .was_resized = false;
5882
+ }
5864
5883
}
5865
5884
5866
5885
/*
@@ -5954,6 +5973,7 @@ void screenalloc(bool doclear)
5954
5973
5955
5974
default_grid .OffsetRow = 0 ;
5956
5975
default_grid .OffsetColumn = 0 ;
5976
+ default_grid .handle = 1 ;
5957
5977
5958
5978
must_redraw = CLEAR ; /* need to clear the screen later */
5959
5979
if (doclear )
@@ -5978,7 +5998,7 @@ void screenalloc(bool doclear)
5978
5998
void grid_alloc (ScreenGrid * grid , int rows , int columns , bool copy )
5979
5999
{
5980
6000
int new_row , old_row ;
5981
- ScreenGrid new = { 0 } ;
6001
+ ScreenGrid new = * grid ;
5982
6002
5983
6003
size_t ncells = (size_t )((rows + 1 ) * columns );
5984
6004
new .ScreenLines = xmalloc (ncells * sizeof (schar_T ));
@@ -6265,7 +6285,7 @@ int grid_ins_lines(ScreenGrid *grid, int row, int line_count, int end,
6265
6285
}
6266
6286
}
6267
6287
6268
- ui_call_grid_scroll (1 , row , end , col , col + width , - line_count , 0 );
6288
+ ui_call_grid_scroll (grid -> handle , row , end , col , col + width , - line_count , 0 );
6269
6289
6270
6290
return OK ;
6271
6291
}
@@ -6317,7 +6337,7 @@ int grid_del_lines(ScreenGrid *grid, int row, int line_count, int end,
6317
6337
}
6318
6338
}
6319
6339
6320
- ui_call_grid_scroll (1 , row , end , col , col + width , line_count , 0 );
6340
+ ui_call_grid_scroll (grid -> handle , row , end , col , col + width , line_count , 0 );
6321
6341
6322
6342
return OK ;
6323
6343
}
@@ -7070,6 +7090,8 @@ void screen_resize(int width, int height)
7070
7090
default_grid .Rows = screen_Rows ;
7071
7091
default_grid .Columns = screen_Columns ;
7072
7092
7093
+ send_grid_resize = true;
7094
+
7073
7095
/* The window layout used to be adjusted here, but it now happens in
7074
7096
* screenalloc() (also invoked from screenclear()). That is because the
7075
7097
* "busy" check above may skip this, but not screenalloc(). */
0 commit comments