@@ -59,21 +59,21 @@ impl Page {
59
59
. into_iter ( )
60
60
}
61
61
62
- pub fn get_label ( & self , key : & Key ) -> String {
62
+ pub fn get_label ( & self , key : & Key ) -> Vec < String > {
63
63
match self {
64
64
Page :: Layer1 | Page :: Layer2 | Page :: Layer3 | Page :: Layer4 => {
65
65
let ( scancode, scancode_name) = key. get_scancode ( self . layer ( ) . unwrap ( ) ) . unwrap ( ) ;
66
66
match scancode_name {
67
67
Some ( keycode) => {
68
- keycode_label ( & keycode) . unwrap_or_else ( || format ! ( "{:?}" , keycode) )
68
+ keycode_label ( & keycode) . unwrap_or_else ( || vec ! [ format!( "{:?}" , keycode) ] )
69
69
}
70
- None => format ! ( "{}" , scancode) ,
70
+ None => vec ! [ format!( "{}" , scancode) ] ,
71
71
}
72
72
}
73
- Page :: Keycaps => key. physical_name . clone ( ) ,
74
- Page :: Logical => key. logical_name . clone ( ) ,
75
- Page :: Electrical => key. electrical_name . clone ( ) ,
76
- Page :: Leds => key. led_name . clone ( ) ,
73
+ Page :: Keycaps => vec ! [ key. physical_name. clone( ) ] ,
74
+ Page :: Logical => vec ! [ key. logical_name. clone( ) ] ,
75
+ Page :: Electrical => vec ! [ key. electrical_name. clone( ) ] ,
76
+ Page :: Leds => vec ! [ key. led_name. clone( ) ] ,
77
77
}
78
78
}
79
79
}
@@ -85,11 +85,11 @@ impl Default for Page {
85
85
}
86
86
87
87
// TODO: represent mod-tap/layer-tap by rendering button with a seperator?
88
- fn keycode_label ( keycode : & Keycode ) -> Option < String > {
88
+ fn keycode_label ( keycode : & Keycode ) -> Option < Vec < String > > {
89
89
match keycode {
90
90
Keycode :: Basic ( mods, keycode) => {
91
91
if mods. is_empty ( ) {
92
- SCANCODE_LABELS . get ( keycode) . cloned ( )
92
+ Some ( vec ! [ SCANCODE_LABELS . get( keycode) ? . clone ( ) ] )
93
93
} else {
94
94
let mut label = String :: new ( ) ;
95
95
for name in mods. mod_names ( ) {
@@ -104,28 +104,26 @@ fn keycode_label(keycode: &Keycode) -> Option<String> {
104
104
label. push_str ( " + " ) ;
105
105
label. push_str ( keycode_label) ;
106
106
}
107
- Some ( label)
107
+ Some ( vec ! [ label] )
108
108
}
109
109
}
110
110
Keycode :: MT ( mods, keycode) => {
111
- let mut label = String :: new ( ) ;
111
+ let mut mods_label = String :: new ( ) ;
112
112
for name in mods. mod_names ( ) {
113
113
let mod_label = SCANCODE_LABELS . get ( name) ?;
114
- if !label . is_empty ( ) {
115
- label . push_str ( " + " ) ;
114
+ if !mods_label . is_empty ( ) {
115
+ mods_label . push_str ( " + " ) ;
116
116
}
117
- label . push_str ( mod_label) ;
117
+ mods_label . push_str ( mod_label) ;
118
118
}
119
- let keycode_label = SCANCODE_LABELS . get ( keycode) ?;
120
- label. push ( '\n' ) ;
121
- label. push_str ( keycode_label) ;
122
- Some ( label)
119
+ let keycode_label = SCANCODE_LABELS . get ( keycode) ?. clone ( ) ;
120
+ Some ( vec ! [ mods_label, keycode_label] )
123
121
}
124
122
Keycode :: LT ( layer, keycode) => {
125
123
let layer_id = * LAYERS . get ( usize:: from ( * layer) ) ?;
126
- let layer_label = SCANCODE_LABELS . get ( layer_id) ?;
127
- let keycode_label = SCANCODE_LABELS . get ( keycode) ?;
128
- Some ( format ! ( "{} \n {}" , layer_label, keycode_label) )
124
+ let layer_label = SCANCODE_LABELS . get ( layer_id) ?. clone ( ) ;
125
+ let keycode_label = SCANCODE_LABELS . get ( keycode) ?. clone ( ) ;
126
+ Some ( vec ! [ layer_label, keycode_label] )
129
127
}
130
128
}
131
129
}
0 commit comments