MCPcopy Create free account
hub / github.com/Autoparallel/learner / run

Method run

crates/learnerd/src/tui/mod.rs:75–103  ·  view source on GitHub ↗

Runs the TUI main loop

(&mut self)

Source from the content-addressed store, hash-verified

73
74 /// Runs the TUI main loop
75 pub async fn run(&mut self) -> Result<()> {
76 loop {
77 if let Some(cmd) = self.state.pending_command.take() {
78 if let Err(e) = self.execute_command(cmd).await {
79 self.state.set_status_message(format!("Error: {}", e));
80 }
81 }
82 // Draw UI if needed
83 if self.state.needs_redraw {
84 self.terminal.draw(|f| UIDrawer::new(f, &mut self.state).draw())?;
85 }
86
87 // Handle events
88 if event::poll(std::time::Duration::from_millis(1))? {
89 match event::read()? {
90 Event::Key(key) =>
91 if self.state.handle_input(key.code, key.modifiers) {
92 break;
93 },
94 Event::Resize(..) => self.state.needs_redraw = true,
95 _ => {},
96 }
97 }
98 }
99
100 // Cleanup and restore terminal
101 self.cleanup()?;
102 Ok(())
103 }
104
105 /// Cleans up the terminal state
106 fn cleanup(&mut self) -> Result<()> {

Callers 1

runFunction · 0.45

Calls 5

execute_commandMethod · 0.80
set_status_messageMethod · 0.80
drawMethod · 0.80
handle_inputMethod · 0.80
cleanupMethod · 0.80

Tested by

no test coverage detected