@@ -7,7 +7,7 @@ use ratatui::{
77 Frame ,
88 layout:: { Alignment , Constraint , Direction , Flex , Layout } ,
99 style:: { Color , Style , Stylize } ,
10- text:: { Line , Text } ,
10+ text:: { Line , Span } ,
1111 widgets:: { Block , BorderType , Borders , Cell , Clear , List , Padding , Row , Table , TableState } ,
1212} ;
1313use tokio:: sync:: mpsc:: UnboundedSender ;
@@ -434,26 +434,43 @@ impl Adapter {
434434 }
435435
436436 let help_message = match focused_block {
437- FocusedBlock :: Device => {
438- format ! (
439- "β: Nav | {}: Show information | {}: Toggle power" ,
440- self . config. device. infos, self . config. device. toggle_power
441- )
442- }
443- FocusedBlock :: AdapterInfos | FocusedBlock :: AccessPointInput => {
444- "β: Nav | σ±· : Discard" . to_string ( )
445- }
446- FocusedBlock :: AccessPoint => {
447- format ! (
448- "β: Nav | {}: New AP | {}: Stop AP" ,
449- self . config. ap. start, self . config. ap. stop
450- )
451- }
452- _ => "" . to_string ( ) ,
437+ FocusedBlock :: Device => Line :: from ( vec ! [
438+ Span :: from( self . config. device. infos. to_string( ) ) . bold( ) ,
439+ Span :: from( " Infos" ) ,
440+ Span :: from( " | " ) ,
441+ Span :: from( self . config. device. toggle_power. to_string( ) ) . bold( ) ,
442+ Span :: from( " Toggle Power" ) ,
443+ Span :: from( " | " ) ,
444+ Span :: from( "ctrl+r" ) . bold( ) ,
445+ Span :: from( " Switch Mode" ) ,
446+ Span :: from( " | " ) ,
447+ Span :: from( "β" ) . bold( ) ,
448+ Span :: from( " Nav" ) ,
449+ ] ) ,
450+ FocusedBlock :: AdapterInfos | FocusedBlock :: AccessPointInput => Line :: from ( vec ! [
451+ Span :: from( "σ±· " ) . bold( ) ,
452+ Span :: from( " Discard" ) ,
453+ Span :: from( " | " ) ,
454+ Span :: from( "β" ) . bold( ) ,
455+ Span :: from( " Nav" ) ,
456+ ] ) ,
457+ FocusedBlock :: AccessPoint => Line :: from ( vec ! [
458+ Span :: from( self . config. ap. start. to_string( ) ) . bold( ) ,
459+ Span :: from( " New AP" ) ,
460+ Span :: from( " | " ) ,
461+ Span :: from( self . config. ap. stop. to_string( ) ) . bold( ) ,
462+ Span :: from( " Stop AP" ) ,
463+ Span :: from( " | " ) ,
464+ Span :: from( "ctrl+r" ) . bold( ) ,
465+ Span :: from( " Switch Mode" ) ,
466+ Span :: from( " | " ) ,
467+ Span :: from( "β" ) . bold( ) ,
468+ Span :: from( " Nav" ) ,
469+ ] ) ,
470+ _ => Line :: from ( "" ) ,
453471 } ;
454472
455- let help_message = Text :: from ( help_message) . centered ( ) . bold ( ) . blue ( ) ;
456-
473+ let help_message = help_message. centered ( ) . blue ( ) ;
457474 frame. render_widget ( help_message, help_block) ;
458475 }
459476
@@ -1019,34 +1036,95 @@ impl Adapter {
10191036 ) ;
10201037
10211038 let help_message = match focused_block {
1022- FocusedBlock :: Device => {
1023- format ! (
1024- "β: Nav | {}: Scan | {}: Show information | {}: Toggle power" ,
1025- self . config. station. start_scanning,
1026- self . config. device. infos,
1027- self . config. device. toggle_power
1039+ FocusedBlock :: Device => Line :: from ( vec ! [
1040+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1041+ Span :: from( " Scan" ) ,
1042+ Span :: from( " | " ) ,
1043+ Span :: from( self . config. device. infos. to_string( ) ) . bold( ) ,
1044+ Span :: from( " Infos" ) ,
1045+ Span :: from( " | " ) ,
1046+ Span :: from( self . config. device. toggle_power. to_string( ) ) . bold( ) ,
1047+ Span :: from( " Toggle Power" ) ,
1048+ Span :: from( " | " ) ,
1049+ Span :: from( "ctrl+r" ) . bold( ) ,
1050+ Span :: from( " Switch Mode" ) ,
1051+ Span :: from( " | " ) ,
1052+ Span :: from( "β" ) . bold( ) ,
1053+ Span :: from( " Nav" ) ,
1054+ ] ) ,
1055+ FocusedBlock :: Station => Line :: from ( vec ! [
1056+ Span :: from( self . config. station. start_scanning. to_string( ) ) . bold( ) ,
1057+ Span :: from( " Scan" ) ,
1058+ Span :: from( " | " ) ,
1059+ Span :: from( "ctrl+r" ) . bold( ) ,
1060+ Span :: from( " Switch Mode" ) ,
1061+ Span :: from( " | " ) ,
1062+ Span :: from( "β" ) . bold( ) ,
1063+ Span :: from( " Nav" ) ,
1064+ ] ) ,
1065+ FocusedBlock :: KnownNetworks => Line :: from ( vec ! [
1066+ Span :: from( "k,ο’" ) . bold( ) ,
1067+ Span :: from( " Up" ) ,
1068+ Span :: from( " | " ) ,
1069+ Span :: from( "j,ο£" ) . bold( ) ,
1070+ Span :: from( " Down" ) ,
1071+ Span :: from( " | " ) ,
1072+ Span :: from( if self . config. station. toggle_connect == ' ' {
1073+ "σ± " . to_string( )
1074+ } else {
1075+ self . config. station. toggle_connect. to_string( )
1076+ } )
1077+ . bold( ) ,
1078+ Span :: from( " Connect/Disconnect" ) ,
1079+ Span :: from( " | " ) ,
1080+ Span :: from( self . config. station. known_network. remove. to_string( ) ) . bold( ) ,
1081+ Span :: from( " Remove" ) ,
1082+ Span :: from( " | " ) ,
1083+ Span :: from(
1084+ self . config
1085+ . station
1086+ . known_network
1087+ . toggle_autoconnect
1088+ . to_string( ) ,
10281089 )
1090+ . bold( ) ,
1091+ Span :: from( " Toggle Autoconnect" ) ,
1092+ Span :: from( " | " ) ,
1093+ Span :: from( "σ±· " ) . bold( ) ,
1094+ Span :: from( " Discard" ) ,
1095+ Span :: from( " | " ) ,
1096+ Span :: from( "ctrl+r" ) . bold( ) ,
1097+ Span :: from( " Switch Mode" ) ,
1098+ Span :: from( " | " ) ,
1099+ Span :: from( "β" ) . bold( ) ,
1100+ Span :: from( " Nav" ) ,
1101+ ] ) ,
1102+ FocusedBlock :: NewNetworks => Line :: from ( vec ! [
1103+ Span :: from( "k,ο’" ) . bold( ) ,
1104+ Span :: from( " Up" ) ,
1105+ Span :: from( " | " ) ,
1106+ Span :: from( "j,ο£" ) . bold( ) ,
1107+ Span :: from( " Down" ) ,
1108+ Span :: from( " | " ) ,
1109+ Span :: from( "σ± " ) . bold( ) ,
1110+ Span :: from( " Connect" ) ,
1111+ Span :: from( " | " ) ,
1112+ Span :: from( "σ±· " ) . bold( ) ,
1113+ Span :: from( " Discard" ) ,
1114+ Span :: from( " | " ) ,
1115+ Span :: from( "ctrl+r" ) . bold( ) ,
1116+ Span :: from( " Switch Mode" ) ,
1117+ Span :: from( " | " ) ,
1118+ Span :: from( "β" ) . bold( ) ,
1119+ Span :: from( " Nav" ) ,
1120+ ] ) ,
1121+ FocusedBlock :: AdapterInfos | FocusedBlock :: AuthKey => {
1122+ Line :: from ( vec ! [ Span :: from( "σ±· " ) . bold( ) , Span :: from( " Discard" ) ] )
10291123 }
1030- FocusedBlock :: Station => format ! (
1031- "β: Nav | {}: Start Scanning" ,
1032- self . config. station. start_scanning
1033- ) ,
1034- FocusedBlock :: KnownNetworks => format ! (
1035- "k,β: Up | j,β: Down | β: Nav | {}: Connect/Disconnect | {}: Remove | {}: Toggle autoconnect" ,
1036- if self . config. station. toggle_connect == ' ' {
1037- "σ± "
1038- } else {
1039- & self . config. station. toggle_connect. to_string( )
1040- } ,
1041- self . config. station. known_network. remove,
1042- self . config. station. known_network. toggle_autoconnect
1043- ) ,
1044- FocusedBlock :: NewNetworks => "k,β: Up | j,β: Down | β: Nav | σ± : Connect" . to_string ( ) ,
1045- FocusedBlock :: AdapterInfos | FocusedBlock :: AuthKey => "σ±· : Discard" . to_string ( ) ,
1046- _ => "" . to_string ( ) ,
1124+ _ => Line :: from ( "" ) ,
10471125 } ;
10481126
1049- let help_message = Text :: from ( help_message) . centered ( ) . bold ( ) . blue ( ) ;
1127+ let help_message = help_message. centered ( ) . blue ( ) ;
10501128
10511129 frame. render_widget ( help_message, help_block) ;
10521130 }
0 commit comments