11use i18n_embed_fl:: fl;
2- use icy_engine:: { Position , ScreenMode , Size , TerminalScrolling } ;
2+ use icy_engine:: { KittyKeyboardState , Position , ScreenMode , Size , TerminalScrolling } ;
33use icy_engine_gui:: dialog_wrapper;
44use icy_engine_gui:: settings:: effect_box;
55use icy_engine_gui:: ui:: {
@@ -27,6 +27,24 @@ fn yes_no(value: bool) -> &'static str {
2727 }
2828}
2929
30+ /// Decoded progressive-enhancement bits, e.g. `Disambiguate+EventTypes`.
31+ fn kitty_flags_names ( flags : u8 ) -> String {
32+ const NAMES : [ ( u8 , & str ) ; 5 ] = [
33+ ( KittyKeyboardState :: DISAMBIGUATE , "Disambiguate" ) ,
34+ ( KittyKeyboardState :: REPORT_EVENT_TYPES , "EventTypes" ) ,
35+ ( KittyKeyboardState :: REPORT_ALTERNATE_KEYS , "AlternateKeys" ) ,
36+ ( KittyKeyboardState :: REPORT_ALL_KEYS , "AllKeys" ) ,
37+ ( KittyKeyboardState :: REPORT_ASSOCIATED_TEXT , "AssociatedText" ) ,
38+ ] ;
39+
40+ let active: Vec < & str > = NAMES . iter ( ) . filter ( |( bit, _) | flags & bit != 0 ) . map ( |( _, name) | * name) . collect ( ) ;
41+ if active. is_empty ( ) {
42+ "None" . to_string ( )
43+ } else {
44+ active. join ( "+" )
45+ }
46+ }
47+
3048/// Result from the terminal info dialog when applying settings
3149#[ derive( Debug , Clone ) ]
3250pub struct TerminalSettingsResult {
@@ -64,13 +82,18 @@ pub struct TerminalInfo {
6482 pub mouse_focus_events : bool ,
6583 pub alternate_scroll : bool ,
6684 pub kitty_flags : u8 ,
85+ pub kitty_stack_depth : usize ,
6786 pub sixel_at_cursor : bool ,
6887 pub sixel_shared_palette : bool ,
6988 pub jxl_supported : bool ,
7089 pub audio_apc_supported : bool ,
7190 pub opus_supported : bool ,
7291 pub audio_active_channels : u32 ,
7392 pub lf_expand : bool ,
93+ pub bracketed_paste : bool ,
94+ pub synchronized_output : bool ,
95+ pub origin_within_margins : bool ,
96+ pub dec_left_right_margins : bool ,
7497 pub inverse_mode : bool ,
7598 pub ice_colors : bool ,
7699 pub baud_emulation : BaudEmulation ,
@@ -101,13 +124,18 @@ impl Default for TerminalInfo {
101124 mouse_focus_events : false ,
102125 alternate_scroll : false ,
103126 kitty_flags : 0 ,
127+ kitty_stack_depth : 0 ,
104128 sixel_at_cursor : true ,
105129 sixel_shared_palette : false ,
106130 jxl_supported : true ,
107131 audio_apc_supported : true ,
108132 opus_supported : true ,
109133 audio_active_channels : 0 ,
110134 lf_expand : true ,
135+ bracketed_paste : false ,
136+ synchronized_output : false ,
137+ origin_within_margins : false ,
138+ dec_left_right_margins : false ,
111139 inverse_mode : false ,
112140 ice_colors : false ,
113141 baud_emulation : BaudEmulation :: Off ,
@@ -208,6 +236,8 @@ impl TerminalInfoDialog {
208236 - Auto Wrap: {}\n \
209237 - Scroll Mode: {}\n \
210238 - Margins: {}\n \
239+ - Origin Mode: {}\n \
240+ - Left/Right Margin Mode: {}\n \
211241 - Mouse Tracking: {}\n \
212242 - Mouse Reporting: {}\n \
213243 - Mouse Encoding: {}\n \
@@ -216,6 +246,8 @@ impl TerminalInfoDialog {
216246 - Inverse Colors: {}\n \
217247 - ICE Colors: {}\n \
218248 - LF Handling: {}\n \
249+ - Bracketed Paste: {}\n \
250+ - Synchronized Output: {}\n \
219251 \n \
220252 Protocols:\n \
221253 - Kitty Flags: {}\n \
@@ -241,6 +273,8 @@ impl TerminalInfoDialog {
241273 if self . info. auto_wrap { "Yes" } else { "No" } ,
242274 scroll_mode_str,
243275 margins_str,
276+ if self . info. origin_within_margins { "Within Margins" } else { "Upper Left" } ,
277+ if self . info. dec_left_right_margins { "Enabled" } else { "Disabled" } ,
244278 self . info. mouse_mode,
245279 if self . info. mouse_reporting_enabled { "Enabled" } else { "Disabled" } ,
246280 self . info. mouse_encoding,
@@ -249,7 +283,14 @@ impl TerminalInfoDialog {
249283 if self . info. inverse_mode { "Yes" } else { "No" } ,
250284 if self . info. ice_colors { "Yes" } else { "No" } ,
251285 if self . info. lf_expand { "CR+LF" } else { "LF only" } ,
252- self . info. kitty_flags,
286+ if self . info. bracketed_paste { "On" } else { "Off" } ,
287+ if self . info. synchronized_output { "On" } else { "Off" } ,
288+ format!(
289+ "0x{:02X} {} (depth {})" ,
290+ self . info. kitty_flags,
291+ kitty_flags_names( self . info. kitty_flags) ,
292+ self . info. kitty_stack_depth
293+ ) ,
253294 if self . info. sixel_at_cursor { "Cursor" } else { "Origin" } ,
254295 if self . info. sixel_shared_palette { "Shared" } else { "Private" } ,
255296 if self . info. jxl_supported { "Yes" } else { "No" } ,
@@ -284,6 +325,26 @@ impl TerminalInfoDialog {
284325 . into ( )
285326 }
286327
328+ fn create_row_with_text_tooltip < M : Clone + ' static > ( label : String , value : String , hint : String ) -> Element < ' static , M > {
329+ row ! [
330+ text( label) . size( TEXT_SIZE_NORMAL ) . width( Length :: Fixed ( LABEL_WIDTH ) ) ,
331+ tooltip(
332+ text( value)
333+ . size( TEXT_SIZE_NORMAL )
334+ . width( Length :: Fixed ( VALUE_WIDTH ) )
335+ . style( |theme: & Theme | text:: Style {
336+ color: Some ( theme. background. on. scale_alpha( 0.7 ) ) ,
337+ } ) ,
338+ container( text( hint) . size( TEXT_SIZE_SMALL ) ) . padding( 8 ) . style( container:: rounded_box) ,
339+ tooltip:: Position :: Top ,
340+ )
341+ . gap( 5 ) ,
342+ ]
343+ . spacing ( DIALOG_SPACING )
344+ . align_y ( Alignment :: Center )
345+ . into ( )
346+ }
347+
287348 fn create_row_with_mouse_mode_tooltip < M : Clone + ' static > (
288349 label : String ,
289350 value : String ,
@@ -515,6 +576,14 @@ impl TerminalInfoDialog {
515576 Self :: create_row:: <M >( auto_wrap_label, if self . info. auto_wrap { yes_str. clone( ) } else { no_str. clone( ) } ) ,
516577 Self :: create_row:: <M >( scroll_mode_label, scroll_mode_str. to_string( ) ) ,
517578 Self :: create_row:: <M >( margins_label, margins_str) ,
579+ Self :: create_row:: <M >(
580+ "Origin / DECSLRM" . to_string( ) ,
581+ format!(
582+ "{} / {}" ,
583+ if self . info. origin_within_margins { "Margins" } else { "Corner" } ,
584+ if self . info. dec_left_right_margins { "On" } else { "Off" }
585+ )
586+ ) ,
518587 Self :: create_row_with_mouse_mode_tooltip:: <M >(
519588 mouse_tracking_label,
520589 self . info. mouse_mode. clone( ) ,
@@ -558,7 +627,16 @@ impl TerminalInfoDialog {
558627 if self . info. mouse_reporting_enabled { "Enabled" } else { "Disabled" } . to_string( )
559628 ) ,
560629 Self :: create_row:: <M >( "Mouse encoding" . to_string( ) , self . info. mouse_encoding. clone( ) ) ,
561- Self :: create_row:: <M >( "Kitty flags" . to_string( ) , self . info. kitty_flags. to_string( ) ) ,
630+ Self :: create_row:: <M >(
631+ "Focus / Alt scroll" . to_string( ) ,
632+ format!( "{} / {}" , yes_no( self . info. mouse_focus_events) , yes_no( self . info. alternate_scroll) )
633+ ) ,
634+ Self :: create_row_with_text_tooltip:: <M >(
635+ "Kitty flags" . to_string( ) ,
636+ format!( "0x{:02X} (depth {})" , self . info. kitty_flags, self . info. kitty_stack_depth) ,
637+ kitty_flags_names( self . info. kitty_flags)
638+ ) ,
639+ Self :: create_row:: <M >( "Bracketed paste" . to_string( ) , if self . info. bracketed_paste { "On" } else { "Off" } . to_string( ) ) ,
562640 Self :: create_row:: <M >( "LF handling" . to_string( ) , if self . info. lf_expand { "CR+LF" } else { "LF only" } . to_string( ) ) ,
563641 ]
564642 . spacing( SPACE_4 ) ,
@@ -579,6 +657,7 @@ impl TerminalInfoDialog {
579657 format!( "{} / {}" , yes_no( self . info. jxl_supported) , yes_no( self . info. opus_supported) )
580658 ) ,
581659 Self :: create_row:: <M >( "Audio channels" . to_string( ) , format!( "0x{:04X}" , self . info. audio_active_channels) ) ,
660+ Self :: create_row:: <M >( "Sync output" . to_string( ) , if self . info. synchronized_output { "On" } else { "Off" } . to_string( ) ) ,
582661 ]
583662 . spacing( SPACE_4 ) ,
584663 ]
0 commit comments