summaryrefslogtreecommitdiffstats
path: root/src/client/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/ui.rs')
-rw-r--r--src/client/ui.rs13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/client/ui.rs b/src/client/ui.rs
index 0fe78ae..4ab0759 100644
--- a/src/client/ui.rs
+++ b/src/client/ui.rs
@@ -94,10 +94,7 @@ pub fn command_names() -> Vec<&'static str> {
94pub fn help_lines() -> Vec<String> { 94pub fn help_lines() -> Vec<String> {
95 let mut lines = vec!["Available commands:".to_string()]; 95 let mut lines = vec!["Available commands:".to_string()];
96 for command in COMMANDS { 96 for command in COMMANDS {
97 lines.push(format!( 97 lines.push(format!(" {:<28} - {}", command.usage, command.description));
98 " {:<28} - {}",
99 command.usage, command.description
100 ));
101 } 98 }
102 lines 99 lines
103} 100}
@@ -291,16 +288,12 @@ pub fn host_lines(hosts: &[(String, Option<String>)]) -> Vec<String> {
291/// on the current line. `render()` has no trailing newline, so a 7-line board 288/// on the current line. `render()` has no trailing newline, so a 7-line board
292/// needs `MoveUp(6)`. 289/// needs `MoveUp(6)`.
293pub fn lines_to_move_up(previous_lines: usize) -> u16 { 290pub fn lines_to_move_up(previous_lines: usize) -> u16 {
294 previous_lines 291 previous_lines.saturating_sub(1).min(u16::MAX as usize) as u16
295 .saturating_sub(1)
296 .min(u16::MAX as usize) as u16
297} 292}
298 293
299/// Column (0-based) to move to after the given prompt and input text. 294/// Column (0-based) to move to after the given prompt and input text.
300pub fn input_cursor_column(prompt_len: usize, input_len: usize) -> u16 { 295pub fn input_cursor_column(prompt_len: usize, input_len: usize) -> u16 {
301 prompt_len 296 prompt_len.saturating_add(input_len).min(u16::MAX as usize) as u16
302 .saturating_add(input_len)
303 .min(u16::MAX as usize) as u16
304} 297}
305 298
306/// Number of terminal rows a block of logical lines occupies after wrapping. 299/// Number of terminal rows a block of logical lines occupies after wrapping.