MCPcopy Index your code
hub / github.com/endbasic/endbasic / refresh

Method refresh

repl/src/editor.rs:189–213  ·  view source on GitHub ↗

Refreshes the contents of the whole `console`, using the previously queried `console_size`. It is the responsibility of the caller to move the cursor back to the appropriate location after calling this function, and the caller should also hide the cursor before calling this function.

(&self, console: &mut dyn Console, console_size: CharsXY)

Source from the content-addressed store, hash-verified

187 /// after calling this function, and the caller should also hide the cursor before calling this
188 /// function.
189 fn refresh(&self, console: &mut dyn Console, console_size: CharsXY) -> io::Result<()> {
190 console.set_color(TEXT_COLOR.0, TEXT_COLOR.1)?;
191 console.clear(ClearType::All)?;
192 self.refresh_status(console, console_size)?;
193 console.set_color(TEXT_COLOR.0, TEXT_COLOR.1)?;
194 console.locate(CharsXY::default())?;
195
196 let mut row = self.viewport_pos.line;
197 let mut printed_rows = 0;
198 while row < self.content.len() && printed_rows < console_size.y - 1 {
199 let line = &self.content[row];
200 let line_len = line.len();
201 if line_len > self.viewport_pos.col {
202 console.print(&line.range(
203 self.viewport_pos.col,
204 self.viewport_pos.col + usize::from(console_size.x),
205 ))?;
206 } else {
207 console.print("")?;
208 }
209 row += 1;
210 printed_rows += 1;
211 }
212 Ok(())
213 }
214
215 /// Refreshes only the line under the cursor, using the previously queried `console_size`.
216 fn refresh_current_line(

Calls 9

yxFunction · 0.85
refresh_statusMethod · 0.80
rangeMethod · 0.80
pushMethod · 0.80
set_colorMethod · 0.45
clearMethod · 0.45
locateMethod · 0.45
lenMethod · 0.45
printMethod · 0.45