@@ -34,7 +34,7 @@ use crate::panes::link_handler::LinkHandler;
34
34
use crate :: panes:: search:: SearchResult ;
35
35
use crate :: panes:: selection:: Selection ;
36
36
use crate :: panes:: terminal_character:: {
37
- AnsiCode , CharacterStyles , CharsetIndex , Cursor , CursorShape , StandardCharset ,
37
+ AnsiCode , CharsetIndex , Cursor , CursorShape , RcCharacterStyles , StandardCharset ,
38
38
TerminalCharacter , EMPTY_TERMINAL_CHARACTER ,
39
39
} ;
40
40
use crate :: ui:: components:: UiComponentParser ;
@@ -513,7 +513,7 @@ impl Grid {
513
513
pub fn update_line_for_rendering ( & mut self , line_index : usize ) {
514
514
self . output_buffer . update_line ( line_index) ;
515
515
}
516
- pub fn advance_to_next_tabstop ( & mut self , styles : CharacterStyles ) {
516
+ pub fn advance_to_next_tabstop ( & mut self , styles : RcCharacterStyles ) {
517
517
let next_tabstop = self
518
518
. horizontal_tabstops
519
519
. iter ( )
@@ -1186,7 +1186,7 @@ impl Grid {
1186
1186
self . viewport . remove ( scroll_region_bottom) ;
1187
1187
}
1188
1188
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
1189
- pad_character. styles = self . cursor . pending_styles ;
1189
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
1190
1190
let columns = VecDeque :: from ( vec ! [ pad_character; self . width] ) ;
1191
1191
self . viewport
1192
1192
. insert ( scroll_region_top, Row :: from_columns ( columns) . canonical ( ) ) ;
@@ -1202,7 +1202,7 @@ impl Grid {
1202
1202
{
1203
1203
self . pad_lines_until ( scroll_region_bottom, EMPTY_TERMINAL_CHARACTER ) ;
1204
1204
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
1205
- pad_character. styles = self . cursor . pending_styles ;
1205
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
1206
1206
for _ in 0 ..count {
1207
1207
self . viewport . remove ( scroll_region_top) ;
1208
1208
let columns = VecDeque :: from ( vec ! [ pad_character. clone( ) ; self . width] ) ;
@@ -1246,14 +1246,14 @@ impl Grid {
1246
1246
}
1247
1247
1248
1248
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
1249
- pad_character. styles = self . cursor . pending_styles ;
1249
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
1250
1250
let columns = VecDeque :: from ( vec ! [ pad_character; self . width] ) ;
1251
1251
self . viewport . push ( Row :: from_columns ( columns) . canonical ( ) ) ;
1252
1252
self . selection . move_up ( 1 ) ;
1253
1253
} else {
1254
1254
self . viewport . remove ( scroll_region_top) ;
1255
1255
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
1256
- pad_character. styles = self . cursor . pending_styles ;
1256
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
1257
1257
let columns = VecDeque :: from ( vec ! [ pad_character; self . width] ) ;
1258
1258
if self . viewport . len ( ) >= scroll_region_bottom {
1259
1259
self . viewport
@@ -1562,7 +1562,7 @@ impl Grid {
1562
1562
let bottom_line_index = bottom_line_index. unwrap_or ( self . height ) ;
1563
1563
self . scroll_region = Some ( ( top_line_index, bottom_line_index) ) ;
1564
1564
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
1565
- pad_character. styles = self . cursor . pending_styles ;
1565
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
1566
1566
self . move_cursor_to ( 0 , 0 , pad_character) ; // DECSTBM moves the cursor to column 1 line 1 of the page
1567
1567
}
1568
1568
pub fn clear_scroll_region ( & mut self ) {
@@ -1634,7 +1634,7 @@ impl Grid {
1634
1634
let pad_character = EMPTY_TERMINAL_CHARACTER ;
1635
1635
self . pad_current_line_until ( self . cursor . x , pad_character) ;
1636
1636
}
1637
- pub fn replace_with_empty_chars ( & mut self , count : usize , empty_char_style : CharacterStyles ) {
1637
+ pub fn replace_with_empty_chars ( & mut self , count : usize , empty_char_style : RcCharacterStyles ) {
1638
1638
let mut empty_character = EMPTY_TERMINAL_CHARACTER ;
1639
1639
empty_character. styles = empty_char_style;
1640
1640
let pad_until = std:: cmp:: min ( self . width , self . cursor . x + count) ;
@@ -1646,7 +1646,7 @@ impl Grid {
1646
1646
self . output_buffer . update_line ( self . cursor . y ) ;
1647
1647
}
1648
1648
}
1649
- fn erase_characters ( & mut self , count : usize , empty_char_style : CharacterStyles ) {
1649
+ fn erase_characters ( & mut self , count : usize , empty_char_style : RcCharacterStyles ) {
1650
1650
let mut empty_character = EMPTY_TERMINAL_CHARACTER ;
1651
1651
empty_character. styles = empty_char_style;
1652
1652
if let Some ( current_row) = self . viewport . get_mut ( self . cursor . y ) {
@@ -2144,7 +2144,7 @@ impl Perform for Grid {
2144
2144
fn print ( & mut self , c : char ) {
2145
2145
let c = self . cursor . charsets [ self . active_charset ] . map ( c) ;
2146
2146
2147
- let terminal_character = TerminalCharacter :: new_styled ( c, self . cursor . pending_styles ) ;
2147
+ let terminal_character = TerminalCharacter :: new_styled ( c, self . cursor . pending_styles . clone ( ) ) ;
2148
2148
self . set_preceding_character ( terminal_character. clone ( ) ) ;
2149
2149
self . add_character ( terminal_character) ;
2150
2150
}
@@ -2160,7 +2160,7 @@ impl Perform for Grid {
2160
2160
} ,
2161
2161
9 => {
2162
2162
// tab
2163
- self . advance_to_next_tabstop ( self . cursor . pending_styles ) ;
2163
+ self . advance_to_next_tabstop ( self . cursor . pending_styles . clone ( ) ) ;
2164
2164
} ,
2165
2165
10 | 11 | 12 => {
2166
2166
// 0a, newline
@@ -2288,8 +2288,9 @@ impl Perform for Grid {
2288
2288
if params. len ( ) < 3 {
2289
2289
return ;
2290
2290
}
2291
- self . cursor . pending_styles . link_anchor =
2292
- self . link_handler . borrow_mut ( ) . dispatch_osc8 ( params) ;
2291
+ self . cursor . pending_styles . update ( |styles| {
2292
+ styles. link_anchor = self . link_handler . borrow_mut ( ) . dispatch_osc8 ( params)
2293
+ } )
2293
2294
} ,
2294
2295
2295
2296
// Get/set Foreground (b"10") or background (b"11") colors
@@ -2442,7 +2443,9 @@ impl Perform for Grid {
2442
2443
if intermediates. is_empty ( ) {
2443
2444
self . cursor
2444
2445
. pending_styles
2445
- . add_style_from_ansi_params ( & mut params_iter) ;
2446
+ . update ( |styles| {
2447
+ styles. add_style_from_ansi_params ( & mut params_iter)
2448
+ } )
2446
2449
}
2447
2450
} else if c == 'C' || c == 'a' {
2448
2451
// move cursor forward
@@ -2453,7 +2456,9 @@ impl Perform for Grid {
2453
2456
if let Some ( clear_type) = params_iter. next ( ) . map ( |param| param[ 0 ] ) {
2454
2457
let mut char_to_replace = EMPTY_TERMINAL_CHARACTER ;
2455
2458
if let Some ( background_color) = self . cursor . pending_styles . background {
2456
- char_to_replace. styles . background = Some ( background_color) ;
2459
+ char_to_replace. styles . update ( |styles| {
2460
+ styles. background = Some ( background_color)
2461
+ } ) ;
2457
2462
}
2458
2463
if clear_type == 0 {
2459
2464
self . replace_characters_in_line_after_cursor ( char_to_replace) ;
@@ -2467,7 +2472,9 @@ impl Perform for Grid {
2467
2472
// clear all (0 => below, 1 => above, 2 => all, 3 => saved)
2468
2473
let mut char_to_replace = EMPTY_TERMINAL_CHARACTER ;
2469
2474
if let Some ( background_color) = self . cursor . pending_styles . background {
2470
- char_to_replace. styles . background = Some ( background_color) ;
2475
+ char_to_replace. styles . update ( |styles| {
2476
+ styles. background = Some ( background_color)
2477
+ } ) ;
2471
2478
}
2472
2479
if let Some ( clear_type) = params_iter. next ( ) . map ( |param| param[ 0 ] ) {
2473
2480
if clear_type == 0 {
@@ -2729,13 +2736,13 @@ impl Perform for Grid {
2729
2736
// delete lines if currently inside scroll region
2730
2737
let line_count_to_delete = next_param_or ( 1 ) ;
2731
2738
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
2732
- pad_character. styles = self . cursor . pending_styles ;
2739
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
2733
2740
self . delete_lines_in_scroll_region ( line_count_to_delete, pad_character) ;
2734
2741
} else if c == 'L' {
2735
2742
// insert blank lines if inside scroll region
2736
2743
let line_count_to_add = next_param_or ( 1 ) ;
2737
2744
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
2738
- pad_character. styles = self . cursor . pending_styles ;
2745
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
2739
2746
self . add_empty_lines_in_scroll_region ( line_count_to_add, pad_character) ;
2740
2747
} else if c == 'G' || c == '`' {
2741
2748
let column = next_param_or ( 1 ) . saturating_sub ( 1 ) ;
@@ -2756,11 +2763,11 @@ impl Perform for Grid {
2756
2763
} else if c == 'P' {
2757
2764
// erase characters
2758
2765
let count = next_param_or ( 1 ) ;
2759
- self . erase_characters ( count, self . cursor . pending_styles ) ;
2766
+ self . erase_characters ( count, self . cursor . pending_styles . clone ( ) ) ;
2760
2767
} else if c == 'X' {
2761
2768
// erase characters and replace with empty characters of current style
2762
2769
let count = next_param_or ( 1 ) ;
2763
- self . replace_with_empty_chars ( count, self . cursor . pending_styles ) ;
2770
+ self . replace_with_empty_chars ( count, self . cursor . pending_styles . clone ( ) ) ;
2764
2771
} else if c == 'T' {
2765
2772
/*
2766
2773
* 124 54 T SD
@@ -2817,7 +2824,7 @@ impl Perform for Grid {
2817
2824
let count = next_param_or ( 1 ) ;
2818
2825
for _ in 0 ..count {
2819
2826
let mut pad_character = EMPTY_TERMINAL_CHARACTER ;
2820
- pad_character. styles = self . cursor . pending_styles ;
2827
+ pad_character. styles = self . cursor . pending_styles . clone ( ) ;
2821
2828
self . add_character_at_cursor_position ( pad_character, true ) ;
2822
2829
}
2823
2830
} else if c == 'b' {
@@ -2839,7 +2846,7 @@ impl Perform for Grid {
2839
2846
self . move_cursor_to_beginning_of_line ( ) ;
2840
2847
} else if c == 'I' {
2841
2848
for _ in 0 ..next_param_or ( 1 ) {
2842
- self . advance_to_next_tabstop ( self . cursor . pending_styles ) ;
2849
+ self . advance_to_next_tabstop ( self . cursor . pending_styles . clone ( ) ) ;
2843
2850
}
2844
2851
} else if c == 'q' {
2845
2852
let first_intermediate_is_space = matches ! ( intermediates. get( 0 ) , Some ( b' ' ) ) ;
0 commit comments