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

Function keyhandler

src/sys/console.rs:300–348  ·  view source on GitHub ↗

Key-handler

(key: char)

Source from the content-addressed store, hash-verified

298
299// Key-handler
300pub fn keyhandler(key: char)
301{
302 let mut stdin = STDIN.lock();
303
304 if key == BACKSPACE && !raw_stat()
305 {
306 if let Some(c) = stdin.pop()
307 {
308 if echo_stat()
309 {
310 let n = match c
311 {
312 END_TEXT | END_TRANS | ESC => 2,
313 _ => if (c as u32) < 0xFF
314 {
315 1
316 }
317 else
318 {
319 c.len_utf8()
320 },
321 };
322 printfmt(format_args!("{}", BACKSPACE.to_string().repeat(n)));
323 }
324 }
325 }
326 else
327 {
328 let key = if (key as u32) < 0xFF
329 {
330 (key as u8) as char
331 }
332 else
333 {
334 key
335 };
336
337 if echo_stat()
338 {
339 match key
340 {
341 END_TEXT => printfmt(format_args!("^C")),
342 END_TRANS => printfmt(format_args!("^D")),
343 ESC => printfmt(format_args!("^[")),
344 _ => printfmt(format_args!("{}", key)),
345 };
346 }
347 }
348}
349
350// Print formatting
351pub fn printfmt(args: fmt::Arguments)

Callers 2

intrhFunction · 0.85
sendkeyFunction · 0.85

Calls 4

raw_statFunction · 0.85
echo_statFunction · 0.85
lockMethod · 0.80
printfmtFunction · 0.70

Tested by

no test coverage detected