MCPcopy Index your code
hub / github.com/algoscienceacademy/RustUI / run

Method run

src/dev_server.rs:126–176  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

124 }
125
126 pub fn run(&mut self) -> Result<(), Box<dyn std::error::Error>> {
127 use crossterm::{
128 event::{self, Event, KeyCode},
129 terminal::{disable_raw_mode, enable_raw_mode},
130 };
131
132 enable_raw_mode()?;
133
134 // Show welcome screen first
135 self.render_welcome_screen()?;
136
137 loop {
138 self.render_ui()?;
139
140 if let Ok(Event::Key(key_event)) = event::read() {
141 match key_event.code {
142 KeyCode::Char('q') => break,
143 KeyCode::Char('1') => {
144 self.set_platform(Platform::Desktop);
145 self.show_platform_setup("Desktop")?;
146 },
147 KeyCode::Char('2') => {
148 self.set_platform(Platform::IOS);
149 self.show_platform_setup("iOS")?;
150 },
151 KeyCode::Char('3') => {
152 self.set_platform(Platform::Android);
153 self.show_platform_setup("Android")?;
154 },
155 KeyCode::Char('4') => {
156 self.set_platform(Platform::Web);
157 self.show_platform_setup("Web")?;
158 },
159 KeyCode::Char('r') => {
160 if self.is_platform_selected() {
161 self.rebuild();
162 }
163 },
164 KeyCode::Char('s') => {
165 if self.is_platform_selected() {
166 self.restart()?;
167 }
168 },
169 _ => {}
170 }
171 }
172 }
173
174 disable_raw_mode()?;
175 Ok(())
176 }
177
178 fn is_platform_selected(&self) -> bool {
179 !matches!(self.get_status().message, None)

Callers

nothing calls this directly

Calls 7

render_welcome_screenMethod · 0.80
render_uiMethod · 0.80
set_platformMethod · 0.80
show_platform_setupMethod · 0.80
is_platform_selectedMethod · 0.80
rebuildMethod · 0.80
restartMethod · 0.80

Tested by

no test coverage detected