mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-27 00:00:03 +03:00
Compare commits
2 commits
ea52c99560
...
75a38fa38b
Author | SHA1 | Date | |
---|---|---|---|
75a38fa38b | |||
ac62a3713c |
|
@ -331,7 +331,7 @@ impl AppState {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Official exercises: Dump the solution file form the binary and return its path.
|
/// Official exercises: Dump the solution file from the binary and return its path.
|
||||||
/// Third-party exercises: Check if a solution file exists and return its path in that case.
|
/// Third-party exercises: Check if a solution file exists and return its path in that case.
|
||||||
pub fn current_solution_path(&self) -> Result<Option<String>> {
|
pub fn current_solution_path(&self) -> Result<Option<String>> {
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
|
|
|
@ -44,7 +44,6 @@ pub struct ListState<'a> {
|
||||||
term_width: u16,
|
term_width: u16,
|
||||||
term_height: u16,
|
term_height: u16,
|
||||||
separator_line: Vec<u8>,
|
separator_line: Vec<u8>,
|
||||||
narrow_term: bool,
|
|
||||||
show_footer: bool,
|
show_footer: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +77,6 @@ impl<'a> ListState<'a> {
|
||||||
term_width: 0,
|
term_width: 0,
|
||||||
term_height: 0,
|
term_height: 0,
|
||||||
separator_line: Vec::new(),
|
separator_line: Vec::new(),
|
||||||
narrow_term: false,
|
|
||||||
show_footer: true,
|
show_footer: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,13 +94,9 @@ impl<'a> ListState<'a> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let wide_help_footer_width = 95;
|
|
||||||
// The help footer is shorter when nothing is selected.
|
|
||||||
self.narrow_term = width < wide_help_footer_width && self.scroll_state.selected().is_some();
|
|
||||||
|
|
||||||
let header_height = 1;
|
let header_height = 1;
|
||||||
// 2 separator, 1 progress bar, 1-2 footer message.
|
// 2 separators, 1 progress bar, 2 footer message lines.
|
||||||
let footer_height = 4 + u16::from(self.narrow_term);
|
let footer_height = 5;
|
||||||
self.show_footer = height > header_height + footer_height;
|
self.show_footer = height > header_height + footer_height;
|
||||||
|
|
||||||
if self.show_footer {
|
if self.show_footer {
|
||||||
|
@ -227,14 +221,10 @@ impl<'a> ListState<'a> {
|
||||||
// Help footer message
|
// Help footer message
|
||||||
if self.scroll_state.selected().is_some() {
|
if self.scroll_state.selected().is_some() {
|
||||||
writer.write_str("↓/j ↑/k home/g end/G | <c>ontinue at | <r>eset exercise")?;
|
writer.write_str("↓/j ↑/k home/g end/G | <c>ontinue at | <r>eset exercise")?;
|
||||||
if self.narrow_term {
|
|
||||||
next_ln(stdout)?;
|
next_ln(stdout)?;
|
||||||
writer = MaxLenWriter::new(stdout, self.term_width as usize);
|
writer = MaxLenWriter::new(stdout, self.term_width as usize);
|
||||||
|
|
||||||
writer.write_ascii(b"filter ")?;
|
writer.write_ascii(b"<s>earch | filter ")?;
|
||||||
} else {
|
|
||||||
writer.write_ascii(b" | filter ")?;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Nothing selected (and nothing shown), so only display filter and quit.
|
// Nothing selected (and nothing shown), so only display filter and quit.
|
||||||
writer.write_ascii(b"filter ")?;
|
writer.write_ascii(b"filter ")?;
|
||||||
|
@ -263,18 +253,15 @@ impl<'a> ListState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write_ascii(b" | <q>uit list")?;
|
writer.write_ascii(b" | <q>uit list")?;
|
||||||
next_ln(stdout)?;
|
|
||||||
} else {
|
} else {
|
||||||
writer.stdout.queue(SetForegroundColor(Color::Magenta))?;
|
writer.stdout.queue(SetForegroundColor(Color::Magenta))?;
|
||||||
writer.write_str(&self.message)?;
|
writer.write_str(&self.message)?;
|
||||||
stdout.queue(ResetColor)?;
|
stdout.queue(ResetColor)?;
|
||||||
next_ln(stdout)?;
|
next_ln(stdout)?;
|
||||||
|
}
|
||||||
|
|
||||||
if self.narrow_term {
|
|
||||||
next_ln(stdout)?;
|
next_ln(stdout)?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stdout.queue(EndSynchronizedUpdate)?.flush()
|
stdout.queue(EndSynchronizedUpdate)?.flush()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue