MCPcopy Create free account
hub / github.com/GCWing/BitFun / render

Method render

src/apps/cli/src/ui/session_selector.rs:234–359  ·  view source on GitHub ↗

Render the session selector popup as an overlay

(&mut self, frame: &mut Frame, area: Rect, theme: &Theme)

Source from the content-addressed store, hash-verified

232
233 /// Render the session selector popup as an overlay
234 pub fn render(&mut self, frame: &mut Frame, area: Rect, theme: &Theme) {
235 if !self.visible || self.items.is_empty() {
236 self.last_area = None;
237 return;
238 }
239
240 // +2 for border, +2 for hint line at bottom
241 let popup_width = area.width.saturating_sub(4).min(70);
242 let popup_height = (self.items.len() as u16 + 2 + 2).min(area.height.saturating_sub(2));
243 if popup_height < 5 || popup_width < 20 {
244 self.last_area = None;
245 return;
246 }
247
248 let popup_x = area.x + (area.width.saturating_sub(popup_width)) / 2;
249 let popup_y = area.y + (area.height.saturating_sub(popup_height)) / 2;
250
251 let popup_area = Rect {
252 x: popup_x,
253 y: popup_y,
254 width: popup_width,
255 height: popup_height,
256 };
257 self.last_area = Some(popup_area);
258
259 let selected_idx = self.list_state.selected();
260
261 let list_items: Vec<ListItem> = self
262 .items
263 .iter()
264 .enumerate()
265 .map(|(i, session)| {
266 let is_current = self
267 .current_session_id
268 .as_ref()
269 .map_or(false, |id| id == &session.session_id);
270
271 let marker = if is_current { "● " } else { " " };
272 let marker_style = if is_current {
273 theme.style(StyleKind::Success)
274 } else {
275 theme.style(StyleKind::Muted)
276 };
277
278 // If this row is being renamed, show the edit buffer
279 if self.rename_editing && selected_idx == Some(i) {
280 let edit_style = Style::default()
281 .fg(Color::Yellow)
282 .add_modifier(Modifier::BOLD);
283 let line = Line::from(vec![
284 Span::styled(marker, marker_style),
285 Span::styled(&self.rename_buffer, edit_style),
286 Span::styled("_", Style::default().fg(Color::Yellow)),
287 ]);
288 return ListItem::new(line);
289 }
290
291 let name_style = theme.style(StyleKind::Primary).add_modifier(Modifier::BOLD);

Callers

nothing calls this directly

Calls 9

collectMethod · 0.80
iterMethod · 0.80
styleMethod · 0.80
titleMethod · 0.80
selection_foregroundMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected