fn draw_footer_frame()

in codex-rs/tui/src/bottom_pane/footer.rs [1310:1479]


    fn draw_footer_frame<B: Backend>(
        terminal: &mut Terminal<B>,
        height: u16,
        props: &FooterProps,
        collaboration_mode_indicator: Option<CollaborationModeIndicator>,
        ide_context_active: bool,
        context_line: Line<'static>,
    ) {
        terminal
            .draw(|f| {
                let area = Rect::new(0, 0, f.area().width, height);
                let show_cycle_hint = !props.is_task_running;
                let show_shortcuts_hint = match props.mode {
                    FooterMode::ComposerEmpty => true,
                    FooterMode::ComposerHasDraft => false,
                    FooterMode::HistorySearch
                    | FooterMode::QuitShortcutReminder
                    | FooterMode::ShortcutOverlay
                    | FooterMode::EscHint => false,
                };
                let show_queue_hint = match props.mode {
                    FooterMode::ComposerHasDraft => props.is_task_running,
                    FooterMode::HistorySearch
                    | FooterMode::QuitShortcutReminder
                    | FooterMode::ComposerEmpty
                    | FooterMode::ShortcutOverlay
                    | FooterMode::EscHint => false,
                };
                let status_line_active = uses_passive_footer_status_layout(props);
                let passive_status_line = if status_line_active {
                    passive_footer_status_line(props)
                } else {
                    None
                };
                let left_mode_indicator = if status_line_active {
                    None
                } else {
                    collaboration_mode_indicator
                };
                let available_width = area.width.saturating_sub(FOOTER_INDENT_COLS as u16) as usize;
                let mut truncated_status_line = if status_line_active
                    && matches!(
                        props.mode,
                        FooterMode::ComposerEmpty | FooterMode::ComposerHasDraft
                    ) {
                    passive_status_line.as_ref().map(|line| {
                        truncate_line_with_ellipsis_if_overflow(line.clone(), available_width)
                    })
                } else {
                    None
                };
                let mut left_width = if status_line_active {
                    truncated_status_line
                        .as_ref()
                        .map(|line| line.width() as u16)
                        .unwrap_or(0)
                } else {
                    footer_line_width(
                        props,
                        left_mode_indicator,
                        show_cycle_hint,
                        show_shortcuts_hint,
                        show_queue_hint,
                    )
                };
                let right_line = if status_line_active {
                    let full = status_line_right_indicator_line(
                        collaboration_mode_indicator,
                        /*goal_status_indicator*/ None,
                        ide_context_active,
                        show_cycle_hint,
                    );
                    let compact = status_line_right_indicator_line(
                        collaboration_mode_indicator,
                        /*goal_status_indicator*/ None,
                        ide_context_active,
                        /*show_cycle_hint*/ false,
                    );
                    let full_width = full.as_ref().map(|line| line.width() as u16).unwrap_or(0);
                    if can_show_left_with_context(area, left_width, full_width) {
                        full
                    } else {
                        compact
                    }
                } else {
                    Some(context_line.clone())
                };
                let right_width = right_line
                    .as_ref()
                    .map(|line| line.width() as u16)
                    .unwrap_or(0);
                if status_line_active
                    && let Some(max_left) = max_left_width_for_right(area, right_width)
                    && left_width > max_left
                    && let Some(line) = passive_status_line.as_ref().map(|line| {
                        truncate_line_with_ellipsis_if_overflow(line.clone(), max_left as usize)
                    })
                {
                    left_width = line.width() as u16;
                    truncated_status_line = Some(line);
                }
                let can_show_left_and_context =
                    can_show_left_with_context(area, left_width, right_width);
                if matches!(
                    props.mode,
                    FooterMode::ComposerEmpty | FooterMode::ComposerHasDraft
                ) {
                    if status_line_active {
                        if let Some(line) = truncated_status_line.clone() {
                            render_footer_line(area, f.buffer_mut(), line);
                        }
                        if can_show_left_and_context && let Some(line) = &right_line {
                            render_context_right(area, f.buffer_mut(), line);
                        }
                    } else {
                        let (summary_left, show_context) = single_line_footer_layout(
                            area,
                            right_width,
                            left_mode_indicator,
                            show_cycle_hint,
                            show_shortcuts_hint,
                            show_queue_hint,
                            props.key_hints,
                        );
                        match summary_left {
                            SummaryLeft::Default => {
                                render_footer_from_props(
                                    area,
                                    f.buffer_mut(),
                                    props,
                                    left_mode_indicator,
                                    show_cycle_hint,
                                    show_shortcuts_hint,
                                    show_queue_hint,
                                );
                            }
                            SummaryLeft::Custom(line) => {
                                render_footer_line(area, f.buffer_mut(), line);
                            }
                            SummaryLeft::None => {}
                        }
                        if show_context && let Some(line) = &right_line {
                            render_context_right(area, f.buffer_mut(), line);
                        }
                    }
                } else {
                    render_footer_from_props(
                        area,
                        f.buffer_mut(),
                        props,
                        left_mode_indicator,
                        show_cycle_hint,
                        show_shortcuts_hint,
                        show_queue_hint,
                    );
                    let show_context = can_show_left_and_context
                        && !matches!(
                            props.mode,
                            FooterMode::EscHint
                                | FooterMode::HistorySearch
                                | FooterMode::QuitShortcutReminder
                                | FooterMode::ShortcutOverlay
                        );
                    if show_context && let Some(line) = &right_line {
                        render_context_right(area, f.buffer_mut(), line);
                    }
                }
            })
            .unwrap();
    }