Added cursor hiding if not focused

This commit is contained in:
ClementTsang 2020-01-18 14:57:54 -05:00
parent 2832ddebb0
commit 495e6d2dc2

View File

@ -914,27 +914,31 @@ 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 let app::ApplicationPosition::ProcessSearch = app_state.current_application_position
{
if itx == cursor_position { if itx == cursor_position {
Text::styled( return Text::styled(
c.to_string(), c.to_string(),
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
) );
} else {
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 let app::ApplicationPosition::ProcessSearch = app_state.current_application_position {
if cursor_position >= query.len() { if cursor_position >= query.len() {
query_with_cursor.push(Text::styled( query_with_cursor.push(Text::styled(
" ".to_string(), " ".to_string(),
Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR),
)) ))
} }
}
let mut search_text = vec![ let mut search_text = vec![
if app_state.is_searching_with_pid() { if app_state.is_searching_with_pid() {