mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-26 15:14:13 +02:00
Added cursor hiding if not focused
This commit is contained in:
parent
2832ddebb0
commit
495e6d2dc2
@ -914,26 +914,30 @@ fn draw_search_field<B: backend::Backend>(
|
|||||||
// TODO: [SEARCH] Consider making this look prettier
|
// TODO: [SEARCH] Consider making this look prettier
|
||||||
let cursor_position = app_state.get_cursor_position();
|
let cursor_position = app_state.get_cursor_position();
|
||||||
|
|
||||||
// TODO: [SEARCH] This can be optimized...
|
// TODO: [SEARCH] This can be optimized... if the cursor is at the very end or not focused we can skip this
|
||||||
let mut query_with_cursor: Vec<Text> = shrunk_query
|
let mut query_with_cursor: Vec<Text> = shrunk_query
|
||||||
.chars()
|
.chars()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(itx, c)| {
|
.map(|(itx, c)| {
|
||||||
if itx == cursor_position {
|
if let app::ApplicationPosition::ProcessSearch = app_state.current_application_position
|
||||||
Text::styled(
|
{
|
||||||
c.to_string(),
|
if itx == cursor_position {
|
||||||
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
|
return Text::styled(
|
||||||
)
|
c.to_string(),
|
||||||
} else {
|
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
|
||||||
Text::styled(c.to_string(), Style::default().fg(TEXT_COLOUR))
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Text::styled(c.to_string(), Style::default().fg(TEXT_COLOUR))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
if cursor_position >= query.len() {
|
if let app::ApplicationPosition::ProcessSearch = app_state.current_application_position {
|
||||||
query_with_cursor.push(Text::styled(
|
if cursor_position >= query.len() {
|
||||||
" ".to_string(),
|
query_with_cursor.push(Text::styled(
|
||||||
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
|
" ".to_string(),
|
||||||
))
|
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut search_text = vec![
|
let mut search_text = vec![
|
||||||
|
Loading…
x
Reference in New Issue
Block a user