cursor is now the real VGA buffer cursor
This commit is contained in:
parent
bd86aae536
commit
6598cbe3eb
1 changed files with 6 additions and 11 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
use super::{Color, ColorCode};
|
||||
use ::context::CONTEXT;
|
||||
use cpuio;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[repr(C)]
|
||||
|
|
@ -34,13 +35,8 @@ pub fn print(args: fmt::Arguments) {
|
|||
unsafe { CONTEXT.current_term().flush() };
|
||||
}
|
||||
|
||||
|
||||
extern crate core;
|
||||
|
||||
// pub const unsafe fn vga_slice() -> &'static [u8] {
|
||||
// unsafe { core::slice::from_raw_parts_mut(0xb8000 as *mut u8, 4000) }
|
||||
// }
|
||||
|
||||
const BUFFER_ROWS: usize = 25;
|
||||
const BUFFER_COLS: usize = 80 * 2;
|
||||
|
||||
|
|
@ -70,8 +66,6 @@ impl Writer {
|
|||
match byte {
|
||||
|
||||
b'\n' => {
|
||||
//reset cursor
|
||||
self.buffer[self.position + 1] = ColorCode::new(Color::White, Color::Black).0;
|
||||
let current_line = self.position / (BUFFER_COLS);
|
||||
self.position = (current_line + 1) * BUFFER_COLS;
|
||||
}
|
||||
|
|
@ -86,10 +80,11 @@ impl Writer {
|
|||
self.scroll();
|
||||
}
|
||||
|
||||
// cursor
|
||||
self.buffer[self.position] = b' ';
|
||||
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
||||
|
||||
let cursor_position = self.position / 2;
|
||||
cpuio::outb(14, 0x3D4);
|
||||
cpuio::outb((cursor_position >> 8) as u8, 0x3D5);
|
||||
cpuio::outb(15, 0x3D4);
|
||||
cpuio::outb((cursor_position >> 0) as u8 & 0x00ff, 0x3D5);
|
||||
}
|
||||
|
||||
pub fn flush(&mut self) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue