implemented stdin methods for reading a string (async) and reading keystrokes (sync + async). added a very basic shell on top of it for debugging
This commit is contained in:
@@ -29,9 +29,6 @@ pub struct Writer {
|
||||
|
||||
fg_color: Colour,
|
||||
bg_color: Colour,
|
||||
|
||||
offset1: usize,
|
||||
offset2: usize,
|
||||
}
|
||||
|
||||
impl Default for Writer {
|
||||
@@ -54,8 +51,6 @@ impl Writer {
|
||||
text_col: 0,
|
||||
fg_color: Colour::White,
|
||||
bg_color: Colour::Black,
|
||||
offset1: 16,
|
||||
offset2: 0,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -65,10 +60,10 @@ impl Writer {
|
||||
}
|
||||
|
||||
/// This is sent when the user types a backspace.
|
||||
const BACKSPACE: u16 = 8;
|
||||
const BACKSPACE: u8 = 8;
|
||||
|
||||
pub fn write_glyph(&mut self, c: u16) {
|
||||
if c == b'\n' as u16 {
|
||||
pub fn write_glyph(&mut self, c: u8) {
|
||||
if c == b'\n' {
|
||||
self.newline();
|
||||
return;
|
||||
} else if c == Self::BACKSPACE {
|
||||
@@ -104,11 +99,6 @@ impl Writer {
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn set_offset(&mut self, offset1: usize, offset2: usize) {
|
||||
self.offset1 = offset1;
|
||||
self.offset2 = offset2;
|
||||
}
|
||||
|
||||
pub const fn dimensions(&self) -> (u32, u32) {
|
||||
(self.screen_width, self.screen_height)
|
||||
}
|
||||
@@ -133,14 +123,14 @@ impl Writer {
|
||||
if self.text_col > 0 {
|
||||
self.text_col -= 1;
|
||||
// Blank out the previous char.
|
||||
self.write_glyph(' ' as u16);
|
||||
self.write_glyph(b' ');
|
||||
self.text_col -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_string(&mut self, s: &str) {
|
||||
for c in s.chars() {
|
||||
self.write_glyph(c as u16);
|
||||
self.write_glyph(c as u8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,6 +193,14 @@ pub fn clear_screen() {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn reset_cursor() {
|
||||
interrupts::without_interrupts(|| {
|
||||
let mut writer = WRITER.lock();
|
||||
writer.text_line = 0;
|
||||
writer.text_col = 0;
|
||||
});
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! println_log {
|
||||
() => ($crate::print_log!("\n"));
|
||||
|
||||
Reference in New Issue
Block a user