@@ -237,40 +237,66 @@ impl<'a> ListState<'a> {
237237 if self . message . is_empty ( ) {
238238 // Help footer message
239239 if self . scroll_state . selected ( ) . is_some ( ) {
240- writer
241- . write_str ( "↓/j ↑/k home/g end/G | ↩️/<c>ontinue at | <r>eset exercise" ) ?;
240+ writer. write_str ( "↓/" ) ?;
241+ hotkey ( & mut writer, b"j" ) ?;
242+ writer. write_str ( " ↑/" ) ?;
243+ hotkey ( & mut writer, b"k" ) ?;
244+ writer. write_ascii ( b" home/" ) ?;
245+ hotkey ( & mut writer, b"g" ) ?;
246+ writer. write_ascii ( b" end/" ) ?;
247+ hotkey ( & mut writer, b"G" ) ?;
248+ writer. write_str ( " | ↩️/" ) ?;
249+ hotkey ( & mut writer, b"c" ) ?;
250+ writer. write_ascii ( b"ontinue at | " ) ?;
251+ hotkey ( & mut writer, b"r" ) ?;
252+ writer. write_ascii ( b"eset exercise" ) ?;
242253 next_ln ( stdout) ?;
243254 writer = MaxLenWriter :: new ( stdout, self . term_width as usize ) ;
244255
245- writer. write_ascii ( b"<s>earch | filter " ) ?;
256+ hotkey ( & mut writer, b"s" ) ?;
257+ writer. write_ascii ( b"earch | filter " ) ?;
246258 } else {
247259 // Nothing selected (and nothing shown), so only display filter and quit.
248260 writer. write_ascii ( b"filter " ) ?;
249261 }
250262
251263 match self . filter {
252264 Filter :: Done => {
265+ writer. stdout . queue ( SetAttribute ( Attribute :: Underlined ) ) ?;
266+ hotkey ( & mut writer, b"d" ) ?;
253267 writer
254268 . stdout
255269 . queue ( SetForegroundColor ( Color :: Magenta ) ) ?
256270 . queue ( SetAttribute ( Attribute :: Underlined ) ) ?;
257- writer. write_ascii ( b"<d> one") ?;
271+ writer. write_str ( " one") ?;
258272 writer. stdout . queue ( ResetColor ) ?;
259- writer. write_ascii ( b"/<p>ending" ) ?;
273+ writer. write_ascii ( b"/" ) ?;
274+ hotkey ( & mut writer, b"p" ) ?;
275+ writer. write_ascii ( b"ending" ) ?;
260276 }
261277 Filter :: Pending => {
262- writer. write_ascii ( b"<d>one/" ) ?;
278+ hotkey ( & mut writer, b"d" ) ?;
279+ writer. write_ascii ( b"one/" ) ?;
280+ writer. stdout . queue ( SetAttribute ( Attribute :: Underlined ) ) ?;
281+ hotkey ( & mut writer, b"p" ) ?;
263282 writer
264283 . stdout
265284 . queue ( SetForegroundColor ( Color :: Magenta ) ) ?
266285 . queue ( SetAttribute ( Attribute :: Underlined ) ) ?;
267- writer. write_ascii ( b"<p> ending" ) ?;
286+ writer. write_ascii ( b"ending" ) ?;
268287 writer. stdout . queue ( ResetColor ) ?;
269288 }
270- Filter :: None => writer. write_ascii ( b"<d>one/<p>ending" ) ?,
289+ Filter :: None => {
290+ hotkey ( & mut writer, b"d" ) ?;
291+ writer. write_ascii ( b"one/" ) ?;
292+ hotkey ( & mut writer, b"p" ) ?;
293+ writer. write_ascii ( b"ending" ) ?;
294+ }
271295 }
272296
273- writer. write_ascii ( b" | <q>uit list" ) ?;
297+ writer. write_ascii ( b" | " ) ?;
298+ hotkey ( & mut writer, b"q" ) ?;
299+ writer. write_ascii ( b"uit list" ) ?;
274300 } else {
275301 writer. stdout . queue ( SetForegroundColor ( Color :: Magenta ) ) ?;
276302 writer. write_str ( & self . message ) ?;
@@ -410,3 +436,14 @@ impl<'a> ListState<'a> {
410436 Ok ( true )
411437 }
412438}
439+
440+ /// Draw an emphasized hotkey in the list footer.
441+ fn hotkey ( writer : & mut MaxLenWriter , hotkey : & [ u8 ] ) -> io:: Result < ( ) > {
442+ writer
443+ . stdout
444+ . queue ( SetForegroundColor ( Color :: Yellow ) ) ?
445+ . queue ( SetAttribute ( Attribute :: Bold ) ) ?;
446+ writer. write_ascii ( hotkey) ?;
447+ writer. stdout . queue ( ResetColor ) ?;
448+ Ok ( ( ) )
449+ }
0 commit comments