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 super::{Color, ColorCode};
|
||||||
use ::context::CONTEXT;
|
use ::context::CONTEXT;
|
||||||
|
use cpuio;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
@ -34,13 +35,8 @@ pub fn print(args: fmt::Arguments) {
|
||||||
unsafe { CONTEXT.current_term().flush() };
|
unsafe { CONTEXT.current_term().flush() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern crate core;
|
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_ROWS: usize = 25;
|
||||||
const BUFFER_COLS: usize = 80 * 2;
|
const BUFFER_COLS: usize = 80 * 2;
|
||||||
|
|
||||||
|
|
@ -70,8 +66,6 @@ impl Writer {
|
||||||
match byte {
|
match byte {
|
||||||
|
|
||||||
b'\n' => {
|
b'\n' => {
|
||||||
//reset cursor
|
|
||||||
self.buffer[self.position + 1] = ColorCode::new(Color::White, Color::Black).0;
|
|
||||||
let current_line = self.position / (BUFFER_COLS);
|
let current_line = self.position / (BUFFER_COLS);
|
||||||
self.position = (current_line + 1) * BUFFER_COLS;
|
self.position = (current_line + 1) * BUFFER_COLS;
|
||||||
}
|
}
|
||||||
|
|
@ -86,10 +80,11 @@ impl Writer {
|
||||||
self.scroll();
|
self.scroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cursor
|
let cursor_position = self.position / 2;
|
||||||
self.buffer[self.position] = b' ';
|
cpuio::outb(14, 0x3D4);
|
||||||
self.buffer[self.position + 1] = ColorCode::new(Color::LightGray, Color::LightGray).0;
|
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) {
|
pub fn flush(&mut self) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue