mirror of
https://github.com/TaKO8Ki/gobang.git
synced 2021-09-19 22:32:56 +03:00
databases filter text overflow scroll
This commit is contained in:
@@ -61,6 +61,14 @@ impl DatabasesComponent {
|
||||
self.input.iter().collect()
|
||||
}
|
||||
|
||||
pub fn displey_input_str(&self, limit: usize) -> String {
|
||||
let mut input = self.input.clone();
|
||||
while input.iter().collect::<String>().width() > limit {
|
||||
input.remove(0);
|
||||
}
|
||||
input.iter().collect()
|
||||
}
|
||||
|
||||
pub fn update(&mut self, list: &[Database]) -> Result<()> {
|
||||
self.tree = DatabaseTree::new(list, &BTreeSet::new())?;
|
||||
self.filterd_tree = None;
|
||||
@@ -158,7 +166,7 @@ impl DatabasesComponent {
|
||||
if self.input.is_empty() && matches!(self.focus_block, FocusBlock::Tree) {
|
||||
"Filter tables".to_string()
|
||||
} else {
|
||||
self.input_str()
|
||||
self.displey_input_str(area.width.saturating_sub(3) as usize)
|
||||
},
|
||||
w = area.width as usize
|
||||
),
|
||||
@@ -187,7 +195,11 @@ impl DatabasesComponent {
|
||||
);
|
||||
self.scroll.draw(f, area);
|
||||
if let FocusBlock::Filter = self.focus_block {
|
||||
f.set_cursor(area.x + self.input_cursor_position + 1, area.y + 1)
|
||||
f.set_cursor(
|
||||
(area.x + self.input_cursor_position + 1)
|
||||
.clamp(area.x + 1, area.x + area.width.saturating_sub(2)),
|
||||
area.y + 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user