diff --git a/src/bin/client.rs b/src/bin/client.rs index e3cc6eb..dcfad12 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -95,6 +95,8 @@ fn main() { .unwrap(); } + client.display_sender.send(DisplayMessage::Help).unwrap(); + let mut current_position = fetch_initial_chess_position(&client, &mut stream); loop { @@ -242,6 +244,7 @@ pub enum DisplayMessage { Message(String), Information(String), Debug(String), + Help, Input(Key), RemoveLastInput, SwitchAsciiMode, @@ -295,7 +298,7 @@ fn start_display_thread(request_recv: Receiver) { stdout, "{}{}{}{}{}", termion::cursor::Save, - termion::cursor::Goto(3, 20), + termion::cursor::Goto(3, 18), termion::clear::CurrentLine, s, termion::cursor::Restore @@ -327,11 +330,12 @@ fn start_display_thread(request_recv: Receiver) { termion::clear::AfterCursor ) .unwrap(), + DisplayMessage::Help => print_help(&mut stdout), DisplayMessage::Debug(s) => write!( stdout, "{}{}{}{}{}", termion::cursor::Save, - termion::cursor::Goto(3, 25), + termion::cursor::Goto(3, 30), termion::clear::CurrentLine, s, termion::cursor::Restore @@ -346,6 +350,19 @@ fn start_display_thread(request_recv: Receiver) { }); } +fn print_help(stdout: &mut RawTerminal) { + write!(stdout, "{}", termion::cursor::Save).unwrap(); + let help = [ + "move are parsed using SAN (Nc3) or UCI (b1c3)", + "@ to toggle ascii mode", + "Ctrl-C to quit", + ]; + for (i, h) in help.iter().enumerate() { + write!(stdout, "{}{}", termion::cursor::Goto(3, 22 + (i as u16)), h).unwrap(); + } + write!(stdout, "{}", termion::cursor::Restore).unwrap(); +} + fn start_keyboard_input_thread( display_sender: Sender, waiting_server_msg_sender: Sender,