fn draw_input_panel(
    frame: &mut Frame<CrosstermBackend<Stdout>>,
    state: &mut InputState,
    chunk: Rect,
) {
    let history: String = state
        .history
        .iter()
        .map(|h| {
            format!(
                "{}{}\n",
                WASH_PROMPT,
                format_input_for_display(h.to_vec(), state.input_width)
            )
        })
        .collect();
    let prompt: String = WASH_PROMPT.to_string();

    let display = format!(
        "{}{}{}",
        history,
        prompt,
        format_input_for_display(state.input.clone(), state.input_width)
    );

    // 5 is the offset from the bottom of the chunk (3) plus 2 lines for buffer
    let scroll_offset = if state.history.len() as u16 + state.multiline_history >= chunk.height - 3
    {
        state.multiline_history + state.history.len() as u16 + 5 - chunk.height
    } else {
        0
    };
    // 3 is chunk size minus borders minus buffer space
    state.input_width = chunk.width as usize - 3;

    // Draw REPL panel
    let input_panel = Paragraph::new(display)
        .block(Block::default().borders(Borders::ALL).title(Span::styled(
            " REPL ",
            Style::default().add_modifier(Modifier::BOLD),
        )))
        .style(Style::default().fg(Color::White))
        .alignment(Alignment::Left)
        .scroll((scroll_offset, 0));
    frame.render_widget(input_panel, chunk);

    let input_cursor = state.cursor_location();

    // Draw cursor on screen
    frame.set_cursor(
        chunk.x + 1 + input_cursor.0,
        chunk.y + 1 + input_cursor.1 - scroll_offset,
    )
}
/// Display the wash REPL in the provided panel, automatically scroll with overflow
Display the wash REPL in the provided panel, automatically scroll with overflow
Display the wash REPL in the provided panel automatically scroll with overflow
fn draw_input_panel(
    frame: &mut Frame<CrosstermBackend<Stdout>>,
    state: &mut InputState,
    chunk: Rect,
) {
    let history: String = state
        .history
        .iter()
        .map(|h| {
            format!(
                "{}{}\n",
                WASH_PROMPT,
                format_input_for_display(h.to_vec(), state.input_width)
            )
        })
        .collect();
    let prompt: String = WASH_PROMPT.to_string();
    let display = format!(
        "{}{}{}",
        history,
        prompt,
        format_input_for_display(state.input.clone(), state.input_width)
    );
    // 5 is the offset from the bottom of the chunk (3) plus 2 lines for buffer
    let scroll_offset = if state.history.len() as u16 + state.multiline_history >= chunk.height - 3
    {
        state.multiline_history + state.history.len() as u16 + 5 - chunk.height
    } else {
        0
    };
    // 3 is chunk size minus borders minus buffer space
    state.input_width = chunk.width as usize - 3;
    // Draw REPL panel
    let input_panel = Paragraph::new(display)
        .block(Block::default().borders(Borders::ALL).title(Span::styled(
            " REPL ",
            Style::default().add_modifier(Modifier::BOLD),
        )))
        .style(Style::default().fg(Color::White))
        .alignment(Alignment::Left)
        .scroll((scroll_offset, 0));
    frame.render_widget(input_panel, chunk);
    let input_cursor = state.cursor_location();
    // Draw cursor on screen
    frame.set_cursor(
        chunk.x + 1 + input_cursor.0,
        chunk.y + 1 + input_cursor.1 - scroll_offset,
    )
}
fn draw_input_panel ( frame : & mut Frame < CrosstermBackend < Stdout > > , state : & mut InputState , chunk : Rect , ) { let history : String = state . history . iter ( ) . map ( | h | { format ! ( " \n " WASH_PROMPT format_input_for_display ( h to_vec ( ) state input_width ) ) } ) . collect ( ) ; let prompt : String = WASH_PROMPT . to_string ( ) ; let display = format ! ( " " history prompt format_input_for_display ( state input clone ( ) state input_width ) ) ; // 5 is the offset from the bottom of the chunk (3) plus 2 lines for buffer let scroll_offset = if state . history . len ( ) as u16 + state . multiline_history >= chunk . height - 3 { state . multiline_history + state . history . len ( ) as u16 + 5 - chunk . height } else { 0 } ; // 3 is chunk size minus borders minus buffer space state . input_width = chunk . width as usize - 3 ; // Draw REPL panel let input_panel = Paragraph :: new ( display ) . block ( Block :: default ( ) . borders ( Borders :: ALL ) . title ( Span :: styled ( " " , Style :: default ( ) . add_modifier ( Modifier :: BOLD ) , ) ) ) . style ( Style :: default ( ) . fg ( Color :: White ) ) . alignment ( Alignment :: Left ) . scroll ( ( scroll_offset , 0 ) ) ; frame . render_widget ( input_panel , chunk ) ; let input_cursor = state . cursor_location ( ) ; // Draw cursor on screen frame . set_cursor ( chunk . x + 1 + input_cursor . 0 , chunk . y + 1 + input_cursor . 1 - scroll_offset , ) }
Display the wash REPL in the provided panel, automatically scroll with overflow
Display the wash REPL in the provided panel automatically scroll with overflow
frame
&mut Frame<CrosstermBackend<Stdout>>
state
&mut InputState
chunk
Rect
frame
&mut Frame<CrosstermBackend<Stdout>>
state
&mut InputState
chunk
Rect