diff options
author | ClementTsang <clementjhtsang@gmail.com> | 2020-01-18 14:57:54 -0500 |
---|---|---|
committer | ClementTsang <clementjhtsang@gmail.com> | 2020-01-18 14:57:54 -0500 |
commit | 495e6d2dc262f9bbc9572e0dfb6456a76b87dbcc (patch) | |
tree | 7a3bc6e06785cd0285ccebf0cbad371335be5463 /src | |
parent | 2832ddebb07ee0ba63009735b47c576a670cc31e (diff) |
Added cursor hiding if not focused
Diffstat (limited to 'src')
-rw-r--r-- | src/canvas.rs | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/canvas.rs b/src/canvas.rs index dd1099d6..4d087b9e 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -914,26 +914,30 @@ fn draw_search_field<B: backend::Backend>( // TODO: [SEARCH] Consider making this look prettier 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 .chars() .enumerate() .map(|(itx, c)| { - if itx == cursor_position { - Text::styled( - c.to_string(), - Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), - ) - } else { - Text::styled(c.to_string(), Style::default().fg(TEXT_COLOUR)) + if let app::ApplicationPosition::ProcessSearch = app_state.current_application_position + { + if itx == cursor_position { + return Text::styled( + c.to_string(), + Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), + ); + } } + Text::styled(c.to_string(), Style::default().fg(TEXT_COLOUR)) }) .collect::<Vec<_>>(); - if cursor_position >= query.len() { - query_with_cursor.push(Text::styled( - " ".to_string(), - Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), - )) + if let app::ApplicationPosition::ProcessSearch = app_state.current_application_position { + if cursor_position >= query.len() { + query_with_cursor.push(Text::styled( + " ".to_string(), + Style::default().fg(TEXT_COLOUR).bg(TABLE_HEADER_COLOUR), + )) + } } let mut search_text = vec![ |