39
39
*
40
40
* TODO:
41
41
* - patch to use GUI or cterm colors for vterm. Yasuhiro, #2067
42
- * - when Normal background is not white or black, going to Terminal-Normal
43
- * mode does not clear correctly. Use the terminal background color to erase
44
- * the background.
45
42
* - patch to add tmap, jakalope (Jacob Askeland) #2073
46
43
* - Redirecting output does not work on MS-Windows.
47
44
* - implement term_setsize()
@@ -130,6 +127,7 @@ struct terminal_S {
130
127
131
128
garray_T tl_scrollback ;
132
129
int tl_scrollback_scrolled ;
130
+ cellattr_T tl_default_color ;
133
131
134
132
VTermPos tl_cursor_pos ;
135
133
int tl_cursor_visible ;
@@ -2321,6 +2319,7 @@ term_change_in_curbuf(void)
2321
2319
2322
2320
/*
2323
2321
* Get the screen attribute for a position in the buffer.
2322
+ * Use a zero "lnum" to get the default background color.
2324
2323
*/
2325
2324
int
2326
2325
term_get_attr (buf_T * buf , linenr_T lnum , int col )
@@ -2329,12 +2328,16 @@ term_get_attr(buf_T *buf, linenr_T lnum, int col)
2329
2328
sb_line_T * line ;
2330
2329
cellattr_T * cellattr ;
2331
2330
2332
- if (lnum > term -> tl_scrollback .ga_len )
2333
- return 0 ;
2334
- line = (sb_line_T * )term -> tl_scrollback .ga_data + lnum - 1 ;
2335
- if (col >= line -> sb_cols )
2336
- return 0 ;
2337
- cellattr = line -> sb_cells + col ;
2331
+ if (lnum == 0 || lnum > term -> tl_scrollback .ga_len )
2332
+ cellattr = & term -> tl_default_color ;
2333
+ else
2334
+ {
2335
+ line = (sb_line_T * )term -> tl_scrollback .ga_data + lnum - 1 ;
2336
+ if (col >= line -> sb_cols )
2337
+ cellattr = & term -> tl_default_color ;
2338
+ else
2339
+ cellattr = line -> sb_cells + col ;
2340
+ }
2338
2341
return cell2attr (cellattr -> attrs , cellattr -> fg , cellattr -> bg );
2339
2342
}
2340
2343
@@ -2347,6 +2350,8 @@ create_vterm(term_T *term, int rows, int cols)
2347
2350
VTerm * vterm ;
2348
2351
VTermScreen * screen ;
2349
2352
VTermValue value ;
2353
+ VTermColor * fg , * bg ;
2354
+ int fgval , bgval ;
2350
2355
2351
2356
vterm = vterm_new (rows , cols );
2352
2357
term -> tl_vterm = vterm ;
@@ -2357,14 +2362,23 @@ create_vterm(term_T *term, int rows, int cols)
2357
2362
2358
2363
/* Vterm uses a default black background. Set it to white when
2359
2364
* 'background' is "light". */
2365
+ vim_memset (& term -> tl_default_color .attrs , 0 , sizeof (VTermScreenCellAttrs ));
2366
+ term -> tl_default_color .width = 1 ;
2367
+ fg = & term -> tl_default_color .fg ;
2368
+ bg = & term -> tl_default_color .bg ;
2360
2369
if (* p_bg == 'l' )
2361
2370
{
2362
- VTermColor fg , bg ;
2363
-
2364
- fg .red = fg .green = fg .blue = 0 ;
2365
- bg .red = bg .green = bg .blue = 255 ;
2366
- vterm_state_set_default_colors (vterm_obtain_state (vterm ), & fg , & bg );
2371
+ fgval = 0 ;
2372
+ bgval = 255 ;
2373
+ }
2374
+ else
2375
+ {
2376
+ fgval = 255 ;
2377
+ bgval = 0 ;
2367
2378
}
2379
+ fg -> red = fg -> green = fg -> blue = fgval ;
2380
+ bg -> red = bg -> green = bg -> blue = bgval ;
2381
+ vterm_state_set_default_colors (vterm_obtain_state (vterm ), fg , bg );
2368
2382
2369
2383
/* Required to initialize most things. */
2370
2384
vterm_screen_reset (screen , 1 /* hard */ );
0 commit comments