terminal_ui/ui/
ui_shared.rs

1use tui::{backend::Backend, Frame, layout::Rect};
2
3pub fn display_cursor<B>(f: &mut Frame<B>, area: Rect, cursor: usize)
4where
5    B: Backend,
6{
7    // Make the cursor visible and ask tui-rs to put it at the specified coordinates after rendering
8    f.set_cursor(
9        // Put cursor past the end of the input text
10        area.x + (cursor as u16).min(area.width.max(3) - 3) + 1,
11        // Move one line down, from the border to the input line
12        area.y + 1,
13    )
14}