uefi
Able 2022-02-05 00:06:07 -06:00
parent 8fa33d8d1a
commit fccef8d614
Signed by untrusted user: able
GPG Key ID: D164AF5F5700BE51
2 changed files with 66 additions and 13 deletions

View File

@ -5,22 +5,17 @@ pub const VTERM_WIDTH: u32 = 100;
/// Fg and bg colors for vterm
pub type ColorCharacter = (Rgba64, Rgba64);
/// A vterm representation of a character
#[derive(Debug, Clone, Copy)]
pub struct VtermCharacter {
pub character: char,
//
pub fg: Rgba64,
pub bg: Rgba64,
pub char_color: ColorCharacter,
//
pub style: Style,
}
pub struct Vterm {
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
pub cursor_x: u32,
pub cursor_y: u32,
pub cursor_visible: bool,
}
#[derive(Debug, Clone, Copy)]
pub struct Style {
pub bold: bool,
pub underline: bool,
@ -30,10 +25,62 @@ pub struct Style {
pub strike: bool,
}
pub struct StylePacked(u8);
pub struct StylePacked(pub u8);
impl StylePacked {
pub struct Vterm {
pub characters: [[VtermCharacter; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
/// The internal representation of the vterm
style: Style,
/// The cursor position in layout x,y
cursor_position: (u32, u32),
pub cursor_visible: bool,
}
impl Vterm {
pub fn new() -> Self {
StylePacked(0)
Vterm {
characters: [[VtermCharacter {
character: ' ',
char_color: (0xff_ff_ff_ff, 0x00_00_00_00),
style: Style {
bold: false,
underline: false,
italic: false,
blink: false,
reverse: false,
strike: false,
},
}; VTERM_WIDTH as usize]; VTERM_HEIGHT as usize],
cursor_position: (0, 0),
cursor_visible: true,
style: Style {
bold: false,
underline: false,
italic: false,
blink: false,
reverse: false,
strike: false,
},
}
}
/// Set the vterm cursor to the given position
pub fn set_cursor_position(&mut self, x: u32, y: u32) {
if x > VTERM_WIDTH {
self.cursor_position.0 = VTERM_WIDTH;
} else {
self.cursor_position.0 = x;
}
if y > VTERM_HEIGHT {
self.cursor_position.1 = VTERM_HEIGHT;
} else {
self.cursor_position.1 = y;
}
}
/// Set the vterm style
pub fn set_vterm_style(&mut self, style: Style) {
self.style = style;
}
}

View File

@ -84,6 +84,9 @@ pub fn kernel_main() -> ! {
}
*/
let mut vterm0 = Vterm::new();
vterm0.set_cursor_position(123, 123);
start_facepalm();
sloop()
}
@ -138,7 +141,10 @@ use uefi::{
};
use uefi::{proto::console::gop::FrameBuffer, ResultExt};
use crate::{GraphicsReturn, ScreenBuffer};
use crate::{
vterm::{self, Vterm},
GraphicsReturn, ScreenBuffer,
};
#[entry]
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {