1use std::collections::HashMap;
4
5use chrono::{DateTime, Local};
6use ratatui::{
7 Frame,
8 layout::{Alignment, Rect},
9 style::{Color, Style},
10 text::{Line, Span},
11 widgets::{Block, Borders, Padding, Paragraph},
12};
13
14use crate::tui::themes::theme as app_theme;
15use crate::tui::markdown::{render_markdown_with_prefix, wrap_with_prefix};
16
17pub mod defaults {
19 pub const USER_PREFIX: &str = "> ";
21 pub const SYSTEM_PREFIX: &str = "* ";
23 pub const TIMESTAMP_PREFIX: &str = " - ";
25 pub const CONTINUATION: &str = " ";
27 pub const SPINNER_CHARS: &[char] = &['\u{280B}', '\u{2819}', '\u{2839}', '\u{2838}', '\u{283C}', '\u{2834}', '\u{2826}', '\u{2827}', '\u{2807}', '\u{280F}'];
29 pub const DEFAULT_TITLE: &str = "Chat";
31 pub const DEFAULT_EMPTY_MESSAGE: &str = " Type a message to start chatting...";
33 pub const TOOL_ICON: &str = "\u{2692}";
35 pub const TOOL_EXECUTING_ARROW: &str = "\u{2192}";
37 pub const TOOL_COMPLETED_CHECKMARK: &str = "\u{2713}";
39 pub const TOOL_FAILED_ICON: &str = "\u{26A0}";
41}
42
43#[derive(Clone)]
55pub struct ChatViewConfig {
56 pub user_prefix: String,
58 pub system_prefix: String,
60 pub timestamp_prefix: String,
62 pub continuation: String,
64 pub spinner_chars: Vec<char>,
66 pub default_title: String,
68 pub empty_message: String,
70 pub tool_icon: String,
72 pub tool_executing_arrow: String,
74 pub tool_completed_checkmark: String,
76 pub tool_failed_icon: String,
78}
79
80impl Default for ChatViewConfig {
81 fn default() -> Self {
82 Self::new()
83 }
84}
85
86impl ChatViewConfig {
87 pub fn new() -> Self {
89 Self {
90 user_prefix: defaults::USER_PREFIX.to_string(),
91 system_prefix: defaults::SYSTEM_PREFIX.to_string(),
92 timestamp_prefix: defaults::TIMESTAMP_PREFIX.to_string(),
93 continuation: defaults::CONTINUATION.to_string(),
94 spinner_chars: defaults::SPINNER_CHARS.to_vec(),
95 default_title: defaults::DEFAULT_TITLE.to_string(),
96 empty_message: defaults::DEFAULT_EMPTY_MESSAGE.to_string(),
97 tool_icon: defaults::TOOL_ICON.to_string(),
98 tool_executing_arrow: defaults::TOOL_EXECUTING_ARROW.to_string(),
99 tool_completed_checkmark: defaults::TOOL_COMPLETED_CHECKMARK.to_string(),
100 tool_failed_icon: defaults::TOOL_FAILED_ICON.to_string(),
101 }
102 }
103
104 pub fn with_user_prefix(mut self, prefix: impl Into<String>) -> Self {
106 self.user_prefix = prefix.into();
107 self
108 }
109
110 pub fn with_system_prefix(mut self, prefix: impl Into<String>) -> Self {
112 self.system_prefix = prefix.into();
113 self
114 }
115
116 pub fn with_timestamp_prefix(mut self, prefix: impl Into<String>) -> Self {
118 self.timestamp_prefix = prefix.into();
119 self
120 }
121
122 pub fn with_continuation(mut self, continuation: impl Into<String>) -> Self {
124 self.continuation = continuation.into();
125 self
126 }
127
128 pub fn with_spinner_chars(mut self, chars: &[char]) -> Self {
130 self.spinner_chars = chars.to_vec();
131 self
132 }
133
134 pub fn with_default_title(mut self, title: impl Into<String>) -> Self {
136 self.default_title = title.into();
137 self
138 }
139
140 pub fn with_empty_message(mut self, message: impl Into<String>) -> Self {
142 self.empty_message = message.into();
143 self
144 }
145
146 pub fn with_tool_icon(mut self, icon: impl Into<String>) -> Self {
148 self.tool_icon = icon.into();
149 self
150 }
151
152 pub fn with_tool_status_icons(
154 mut self,
155 executing_arrow: impl Into<String>,
156 completed_checkmark: impl Into<String>,
157 failed_icon: impl Into<String>,
158 ) -> Self {
159 self.tool_executing_arrow = executing_arrow.into();
160 self.tool_completed_checkmark = completed_checkmark.into();
161 self.tool_failed_icon = failed_icon.into();
162 self
163 }
164}
165
166#[derive(Debug, Clone, Copy, PartialEq)]
168pub enum MessageRole {
169 User,
170 Assistant,
171 System,
172 Tool,
173}
174
175#[derive(Debug, Clone, PartialEq)]
177pub enum ToolStatus {
178 Executing,
179 WaitingForUser,
180 Completed,
181 Failed(String),
182}
183
184#[derive(Debug, Clone)]
187pub struct ToolMessageData {
188 #[allow(dead_code)] pub tool_use_id: String,
191 pub display_name: String,
193 pub display_title: String,
195 pub status: ToolStatus,
197}
198
199struct Message {
200 role: MessageRole,
201 content: String,
202 timestamp: DateTime<Local>,
203 cached_lines: Option<Vec<Line<'static>>>,
205 cached_width: usize,
207 tool_data: Option<ToolMessageData>,
209}
210
211impl Message {
212 fn new(role: MessageRole, content: String) -> Self {
213 Self {
214 role,
215 content,
216 timestamp: Local::now(),
217 cached_lines: None,
218 cached_width: 0,
219 tool_data: None,
220 }
221 }
222
223 fn new_tool(tool_data: ToolMessageData) -> Self {
224 Self {
225 role: MessageRole::Tool,
226 content: String::new(),
227 timestamp: Local::now(),
228 cached_lines: None,
229 cached_width: 0,
230 tool_data: Some(tool_data),
231 }
232 }
233
234 fn get_rendered_lines(&mut self, available_width: usize, config: &ChatViewConfig) -> &[Line<'static>] {
236 if self.cached_width != available_width {
238 self.cached_lines = None;
239 }
240
241 if self.cached_lines.is_none() {
243 let lines = self.render_lines(available_width, config);
244 self.cached_lines = Some(lines);
245 self.cached_width = available_width;
246 }
247
248 self.cached_lines.as_ref().unwrap()
249 }
250
251 fn render_lines(&self, available_width: usize, config: &ChatViewConfig) -> Vec<Line<'static>> {
253 let mut lines = Vec::new();
254 let t = app_theme();
255
256 match self.role {
257 MessageRole::User => {
258 let rendered = wrap_with_prefix(
259 &self.content,
260 &config.user_prefix,
261 t.user_prefix,
262 &config.continuation,
263 available_width,
264 &t,
265 );
266 lines.extend(rendered);
267 }
268 MessageRole::System => {
269 let rendered = wrap_with_prefix(
270 &self.content,
271 &config.system_prefix,
272 t.system_prefix,
273 &config.continuation,
274 available_width,
275 &t,
276 );
277 lines.extend(rendered);
278 }
279 MessageRole::Assistant => {
280 let rendered = render_markdown_with_prefix(&self.content, available_width, &t);
281 lines.extend(rendered);
282 }
283 MessageRole::Tool => {
284 if let Some(ref data) = self.tool_data {
285 lines.extend(render_tool_message(data, config, available_width));
286 }
287 }
288 }
289
290 if self.role != MessageRole::Assistant && self.role != MessageRole::Tool {
293 let time_str = self.timestamp.format("%I:%M:%S %p").to_string();
294 let timestamp_text = format!("{}{}", config.timestamp_prefix, time_str);
295 lines.push(Line::from(vec![Span::styled(
296 timestamp_text,
297 app_theme().timestamp,
298 )]));
299 }
300
301 lines.push(Line::from(""));
303
304 lines
305 }
306}
307
308pub use super::chat_helpers::RenderFn;
310
311use crate::tui::themes::Theme;
312
313pub type TitleRenderFn = Box<dyn Fn(&str, &Theme) -> (Line<'static>, Line<'static>) + Send + Sync>;
316
317pub struct ChatView {
319 messages: Vec<Message>,
320 scroll_offset: u16,
321 streaming_buffer: Option<String>,
323 streaming_cache: Option<Vec<Line<'static>>>,
325 streaming_cache_len: usize,
327 streaming_cache_width: usize,
329 last_max_scroll: u16,
331 auto_scroll_enabled: bool,
333 tool_index: HashMap<String, usize>,
335 spinner_index: usize,
337 title: String,
339 render_initial_content: Option<RenderFn>,
341 render_title: Option<TitleRenderFn>,
343 config: ChatViewConfig,
345}
346
347impl ChatView {
348 pub fn new() -> Self {
350 Self::with_config(ChatViewConfig::new())
351 }
352
353 pub fn with_config(config: ChatViewConfig) -> Self {
355 let title = config.default_title.clone();
356 Self {
357 messages: Vec::new(),
358 scroll_offset: 0,
359 streaming_buffer: None,
360 streaming_cache: None,
361 streaming_cache_len: 0,
362 streaming_cache_width: 0,
363 last_max_scroll: 0,
364 auto_scroll_enabled: true,
365 tool_index: HashMap::new(),
366 spinner_index: 0,
367 title,
368 render_initial_content: None,
369 render_title: None,
370 config,
371 }
372 }
373
374 pub fn config(&self) -> &ChatViewConfig {
376 &self.config
377 }
378
379 pub fn set_config(&mut self, config: ChatViewConfig) {
381 self.config = config;
382 for msg in &mut self.messages {
384 msg.cached_lines = None;
385 }
386 }
387
388 pub fn with_title(mut self, title: impl Into<String>) -> Self {
390 self.title = title.into();
391 self
392 }
393
394 pub fn with_initial_content(mut self, render: RenderFn) -> Self {
399 self.render_initial_content = Some(render);
400 self
401 }
402
403 pub fn with_title_renderer<F>(mut self, render: F) -> Self
408 where
409 F: Fn(&str, &Theme) -> (Line<'static>, Line<'static>) + Send + Sync + 'static,
410 {
411 self.render_title = Some(Box::new(render));
412 self
413 }
414
415 pub fn set_title(&mut self, title: impl Into<String>) {
417 self.title = title.into();
418 }
419
420 pub fn title(&self) -> &str {
422 &self.title
423 }
424
425 pub fn step_spinner(&mut self) {
427 let len = self.config.spinner_chars.len().max(1);
428 self.spinner_index = (self.spinner_index + 1) % len;
429 }
430
431 pub fn add_user_message(&mut self, content: String) {
433 if !content.trim().is_empty() {
434 self.messages.push(Message::new(MessageRole::User, content));
435 if self.auto_scroll_enabled {
437 self.scroll_offset = u16::MAX;
438 }
439 }
440 }
441
442 pub fn add_assistant_message(&mut self, content: String) {
444 if !content.trim().is_empty() {
445 self.messages
446 .push(Message::new(MessageRole::Assistant, content));
447 if self.auto_scroll_enabled {
449 self.scroll_offset = u16::MAX;
450 }
451 }
452 }
453
454 pub fn add_system_message(&mut self, content: String) {
456 if content.trim().is_empty() {
457 return;
458 }
459 self.messages
460 .push(Message::new(MessageRole::System, content));
461 if self.auto_scroll_enabled {
463 self.scroll_offset = u16::MAX;
464 }
465 }
466
467 pub fn add_tool_message(
469 &mut self,
470 tool_use_id: &str,
471 display_name: &str,
472 display_title: &str,
473 ) {
474 let index = self.messages.len();
475
476 let tool_data = ToolMessageData {
477 tool_use_id: tool_use_id.to_string(),
478 display_name: display_name.to_string(),
479 display_title: display_title.to_string(),
480 status: ToolStatus::Executing,
481 };
482
483 self.messages.push(Message::new_tool(tool_data));
484 self.tool_index.insert(tool_use_id.to_string(), index);
485
486 if self.auto_scroll_enabled {
488 self.scroll_offset = u16::MAX;
489 }
490 }
491
492 pub fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus) {
494 if let Some(&index) = self.tool_index.get(tool_use_id) {
495 if let Some(msg) = self.messages.get_mut(index) {
496 if let Some(ref mut data) = msg.tool_data {
497 data.status = status;
498 msg.cached_lines = None; }
500 }
501 }
502 }
503
504 pub fn enable_auto_scroll(&mut self) {
506 self.auto_scroll_enabled = true;
507 self.scroll_offset = u16::MAX;
508 }
509
510 pub fn append_streaming(&mut self, text: &str) {
512 match &mut self.streaming_buffer {
513 Some(buffer) => buffer.push_str(text),
514 None => self.streaming_buffer = Some(text.to_string()),
515 }
516 self.streaming_cache = None;
518 self.streaming_cache_len = 0;
519 self.streaming_cache_width = 0;
520 if self.auto_scroll_enabled {
522 self.scroll_offset = u16::MAX;
523 }
524 }
525
526 pub fn complete_streaming(&mut self) {
528 if let Some(content) = self.streaming_buffer.take() {
529 if !content.trim().is_empty() {
530 self.messages
531 .push(Message::new(MessageRole::Assistant, content));
532 }
533 }
534 self.streaming_cache = None;
536 self.streaming_cache_len = 0;
537 self.streaming_cache_width = 0;
538 }
539
540 pub fn discard_streaming(&mut self) {
542 self.streaming_buffer = None;
543 self.streaming_cache = None;
545 self.streaming_cache_len = 0;
546 self.streaming_cache_width = 0;
547 }
548
549 pub fn is_streaming(&self) -> bool {
551 self.streaming_buffer.is_some()
552 }
553
554 pub fn scroll_up(&mut self) {
555 if self.scroll_offset == u16::MAX {
557 self.scroll_offset = self.last_max_scroll;
558 }
559 self.scroll_offset = self.scroll_offset.saturating_sub(3);
560 self.auto_scroll_enabled = false;
562 }
563
564 pub fn scroll_down(&mut self) {
565 if self.scroll_offset == u16::MAX {
567 return;
568 }
569 self.scroll_offset = self.scroll_offset.saturating_add(3);
570 if self.scroll_offset >= self.last_max_scroll {
572 self.scroll_offset = u16::MAX;
573 self.auto_scroll_enabled = true; }
575 }
576
577 pub fn render_chat(&mut self, frame: &mut Frame, area: Rect, pending_status: Option<&str>) {
578 let theme = app_theme();
579
580 let content_block = if let Some(ref render_fn) = self.render_title {
582 let (left_title, right_title) = render_fn(&self.title, &theme);
583 Block::default()
584 .title(left_title)
585 .title_alignment(Alignment::Left)
586 .title(right_title.alignment(Alignment::Right))
587 .borders(Borders::TOP)
588 .border_style(theme.border)
589 .padding(Padding::new(1, 0, 1, 0))
590 } else {
591 Block::default()
592 .borders(Borders::TOP)
593 .border_style(theme.border)
594 .padding(Padding::new(1, 0, 1, 0))
595 };
596
597 let is_initial_state = self.messages.is_empty() && self.streaming_buffer.is_none() && pending_status.is_none();
599
600 if is_initial_state {
602 if let Some(ref render_fn) = self.render_initial_content {
603 let inner = content_block.inner(area);
604 frame.render_widget(content_block, area);
605 render_fn(frame, inner, &theme);
606 return;
607 }
608 }
609
610 let available_width = area.width.saturating_sub(2) as usize; let mut message_lines: Vec<Line> = Vec::new();
615
616 if is_initial_state {
618 message_lines.push(Line::from(""));
619 message_lines.push(Line::from(Span::styled(
620 self.config.empty_message.clone(),
621 Style::default().fg(Color::DarkGray),
622 )));
623 }
624
625 for msg in &mut self.messages {
626 let cached = msg.get_rendered_lines(available_width, &self.config);
628 message_lines.extend(cached.iter().cloned());
629 }
630
631 if let Some(ref buffer) = self.streaming_buffer {
633 let buffer_len = buffer.len();
634
635 let cache_valid = self.streaming_cache.is_some()
637 && self.streaming_cache_len == buffer_len
638 && self.streaming_cache_width == available_width;
639
640 if !cache_valid {
641 let rendered = render_markdown_with_prefix(buffer, available_width, &theme);
643 self.streaming_cache = Some(rendered);
644 self.streaming_cache_len = buffer_len;
645 self.streaming_cache_width = available_width;
646 }
647
648 if let Some(ref cached) = self.streaming_cache {
650 message_lines.extend(cached.iter().cloned());
651 }
652
653 if let Some(last) = message_lines.last_mut() {
655 last.spans
656 .push(Span::styled("\u{2588}", theme.cursor));
657 }
658 } else if let Some(status) = pending_status {
659 let spinner_char = self.config.spinner_chars.get(self.spinner_index).copied().unwrap_or(' ');
661 message_lines.push(Line::from(vec![
662 Span::styled(format!("{} ", spinner_char), theme.throbber_spinner),
663 Span::styled(status, theme.throbber_label),
664 ]));
665 }
666
667 let available_height = area.height.saturating_sub(2) as usize; let total_lines = message_lines.len();
670 let max_scroll = total_lines.saturating_sub(available_height) as u16;
671 self.last_max_scroll = max_scroll;
672
673 let scroll_offset = if self.scroll_offset == u16::MAX {
681 max_scroll
682 } else {
683 let clamped = self.scroll_offset.min(max_scroll);
684 if clamped != self.scroll_offset {
685 self.scroll_offset = clamped;
686 }
687 clamped
688 };
689
690 let messages_widget = Paragraph::new(message_lines)
691 .block(content_block)
692 .style(theme.background.patch(theme.text))
693 .scroll((scroll_offset, 0));
694 frame.render_widget(messages_widget, area);
695 }
696}
697
698fn render_tool_message(
700 data: &ToolMessageData,
701 config: &ChatViewConfig,
702 available_width: usize,
703) -> Vec<Line<'static>> {
704 let mut lines = Vec::new();
705 let theme = app_theme();
706
707 let header = if data.display_title.is_empty() {
709 format!("{} {}", config.tool_icon, data.display_name)
710 } else {
711 format!("{} {}({})", config.tool_icon, data.display_name, data.display_title)
712 };
713 lines.push(Line::from(Span::styled(header, theme.tool_header)));
714
715 match &data.status {
717 ToolStatus::Executing => {
718 lines.push(Line::from(Span::styled(
719 format!(" {} executing...", config.tool_executing_arrow),
720 theme.tool_executing,
721 )));
722 }
723 ToolStatus::WaitingForUser => {
724 lines.push(Line::from(Span::styled(
725 format!(" {} waiting for user...", config.tool_executing_arrow),
726 theme.tool_executing,
727 )));
728 }
729 ToolStatus::Completed => {
730 lines.push(Line::from(Span::styled(
731 format!(" {} Completed", config.tool_completed_checkmark),
732 theme.tool_completed,
733 )));
734 }
735 ToolStatus::Failed(err) => {
736 let prefix = format!(" {} ", config.tool_failed_icon);
738 let cont_prefix = " "; let wrapped = wrap_with_prefix(
740 err,
741 &prefix,
742 theme.tool_failed,
743 cont_prefix,
744 available_width,
745 &theme,
746 );
747 lines.extend(wrapped);
748 }
749 }
750
751 lines
752}
753
754impl Default for ChatView {
755 fn default() -> Self {
756 Self::new()
757 }
758}
759
760use super::ConversationView;
763
764#[derive(Clone)]
766struct ChatViewState {
767 messages: Vec<MessageSnapshot>,
768 scroll_offset: u16,
769 streaming_buffer: Option<String>,
770 last_max_scroll: u16,
771 auto_scroll_enabled: bool,
772 tool_index: HashMap<String, usize>,
773 spinner_index: usize,
774}
775
776#[derive(Clone)]
778struct MessageSnapshot {
779 role: MessageRole,
780 content: String,
781 timestamp: DateTime<Local>,
782 tool_data: Option<ToolMessageData>,
783}
784
785impl From<&Message> for MessageSnapshot {
786 fn from(msg: &Message) -> Self {
787 Self {
788 role: msg.role,
789 content: msg.content.clone(),
790 timestamp: msg.timestamp,
791 tool_data: msg.tool_data.clone(),
792 }
793 }
794}
795
796impl From<MessageSnapshot> for Message {
797 fn from(snapshot: MessageSnapshot) -> Self {
798 Self {
799 role: snapshot.role,
800 content: snapshot.content,
801 timestamp: snapshot.timestamp,
802 cached_lines: None,
803 cached_width: 0,
804 tool_data: snapshot.tool_data,
805 }
806 }
807}
808
809impl ConversationView for ChatView {
810 fn add_user_message(&mut self, content: String) {
811 ChatView::add_user_message(self, content);
812 }
813
814 fn add_assistant_message(&mut self, content: String) {
815 ChatView::add_assistant_message(self, content);
816 }
817
818 fn add_system_message(&mut self, content: String) {
819 ChatView::add_system_message(self, content);
820 }
821
822 fn append_streaming(&mut self, text: &str) {
823 ChatView::append_streaming(self, text);
824 }
825
826 fn complete_streaming(&mut self) {
827 ChatView::complete_streaming(self);
828 }
829
830 fn discard_streaming(&mut self) {
831 ChatView::discard_streaming(self);
832 }
833
834 fn is_streaming(&self) -> bool {
835 ChatView::is_streaming(self)
836 }
837
838 fn add_tool_message(&mut self, tool_use_id: &str, display_name: &str, display_title: &str) {
839 ChatView::add_tool_message(self, tool_use_id, display_name, display_title);
840 }
841
842 fn update_tool_status(&mut self, tool_use_id: &str, status: ToolStatus) {
843 ChatView::update_tool_status(self, tool_use_id, status);
844 }
845
846 fn scroll_up(&mut self) {
847 ChatView::scroll_up(self);
848 }
849
850 fn scroll_down(&mut self) {
851 ChatView::scroll_down(self);
852 }
853
854 fn enable_auto_scroll(&mut self) {
855 ChatView::enable_auto_scroll(self);
856 }
857
858 fn render(&mut self, frame: &mut Frame, area: Rect, _theme: &Theme, pending_status: Option<&str>) {
859 self.render_chat(frame, area, pending_status);
860 }
861
862 fn step_spinner(&mut self) {
863 ChatView::step_spinner(self);
864 }
865
866 fn save_state(&self) -> Box<dyn Any + Send> {
867 let state = ChatViewState {
868 messages: self.messages.iter().map(MessageSnapshot::from).collect(),
869 scroll_offset: self.scroll_offset,
870 streaming_buffer: self.streaming_buffer.clone(),
871 last_max_scroll: self.last_max_scroll,
872 auto_scroll_enabled: self.auto_scroll_enabled,
873 tool_index: self.tool_index.clone(),
874 spinner_index: self.spinner_index,
875 };
876 Box::new(state)
877 }
878
879 fn restore_state(&mut self, state: Box<dyn Any + Send>) {
880 if let Ok(chat_state) = state.downcast::<ChatViewState>() {
881 self.messages = chat_state.messages.into_iter().map(Message::from).collect();
882 self.scroll_offset = chat_state.scroll_offset;
883 self.streaming_buffer = chat_state.streaming_buffer;
884 self.streaming_cache = None;
886 self.streaming_cache_len = 0;
887 self.streaming_cache_width = 0;
888 self.last_max_scroll = chat_state.last_max_scroll;
889 self.auto_scroll_enabled = chat_state.auto_scroll_enabled;
890 self.tool_index = chat_state.tool_index;
891 self.spinner_index = chat_state.spinner_index;
892 }
893 }
894
895 fn clear(&mut self) {
896 self.messages.clear();
897 self.streaming_buffer = None;
898 self.streaming_cache = None;
899 self.streaming_cache_len = 0;
900 self.streaming_cache_width = 0;
901 self.tool_index.clear();
902 self.scroll_offset = 0;
903 self.last_max_scroll = 0;
904 self.auto_scroll_enabled = true;
905 self.spinner_index = 0;
906 }
908}
909
910use std::any::Any;
913use crossterm::event::KeyEvent;
914use super::{widget_ids, Widget, WidgetKeyContext, WidgetKeyResult};
915
916impl Widget for ChatView {
917 fn id(&self) -> &'static str {
918 widget_ids::CHAT_VIEW
919 }
920
921 fn priority(&self) -> u8 {
922 50 }
924
925 fn is_active(&self) -> bool {
926 true }
928
929 fn handle_key(&mut self, _key: KeyEvent, _ctx: &WidgetKeyContext) -> WidgetKeyResult {
930 WidgetKeyResult::NotHandled
933 }
934
935 fn render(&mut self, frame: &mut Frame, area: Rect, _theme: &Theme) {
936 self.render_chat(frame, area, None);
939 }
940
941 fn required_height(&self, _available: u16) -> u16 {
942 0 }
944
945 fn blocks_input(&self) -> bool {
946 false
947 }
948
949 fn is_overlay(&self) -> bool {
950 false
951 }
952
953 fn as_any(&self) -> &dyn Any {
954 self
955 }
956
957 fn as_any_mut(&mut self) -> &mut dyn Any {
958 self
959 }
960
961 fn into_any(self: Box<Self>) -> Box<dyn Any> {
962 self
963 }
964}
965