MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / readchar

Function readchar

src/sys/console.rs:381–415  ·  view source on GitHub ↗

Read character

()

Source from the content-addressed store, hash-verified

379
380// Read character
381pub fn readchar() -> char
382{
383 // Disable echo
384 echo_off();
385
386 // Enable raw
387 raw_on();
388
389 loop
390 {
391 crate::time::halt();
392 let res = interrupts::without_interrupts(||
393 {
394 let mut stdin = STDIN.lock();
395 if !stdin.is_empty()
396 {
397 Some(stdin.remove(0))
398 }
399 else
400 {
401 None
402 }
403 });
404
405 if let Some(c) = res
406 {
407 // Enable echo
408 crate::sys::console::echo_on();
409
410 // Disable raw
411 crate::sys::console::raw_off();
412 return c;
413 }
414 }
415}
416
417
418// Read line

Callers 1

readMethod · 0.85

Calls 6

echo_offFunction · 0.85
raw_onFunction · 0.85
haltFunction · 0.85
echo_onFunction · 0.85
raw_offFunction · 0.85
lockMethod · 0.80

Tested by

no test coverage detected