Merge branch 'uefi' of ssh://git.ablecorp.us:20/able/ableos into uefi

This commit is contained in:
Able 2022-02-05 00:26:36 -06:00
commit 7785de8fd9

View file

@ -1,3 +1,5 @@
use core::ops::Not;
use shadeable::pixel_format::Rgba64;
pub const VTERM_HEIGHT: u32 = 40;
@ -8,79 +10,157 @@ pub type ColorCharacter = (Rgba64, Rgba64);
/// A vterm representation of a character
#[derive(Debug, Clone, Copy)]
pub struct VtermCharacter {
pub character: char,
//
pub char_color: ColorCharacter,
//
pub style: Style,
pub character: char,
//
pub style: Style,
//
pub char_color: ColorCharacter,
}
#[derive(Debug, Clone, Copy)]
pub struct Style {
pub bold: bool,
pub underline: bool,
pub italic: bool,
pub blink: bool,
pub reverse: bool,
pub strike: bool,
pub bold: bool,
pub underline: bool,
pub italic: bool,
pub blink: bool,
pub reverse: bool,
pub strike: bool,
}
#[derive(Default)]
pub struct StylePacked(pub u8);
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),
impl StylePacked {
pub fn bold(&self) -> bool {
(self.0 & 0x01) > 0
}
pub fn underlined(&self) -> bool {
(self.0 & 0x02) > 0
}
pub fn italic(&self) -> bool {
(self.0 & 0x04) > 0
}
pub fn blinking(&self) -> bool {
(self.0 & 0x08) > 0
}
pub fn reversed(&self) -> bool {
(self.0 & 0x10) > 0
}
pub fn struck(&self) -> bool {
(self.0 & 0x20) > 0
}
#[must_use]
pub fn set_bold(mut self, v: bool) -> Self {
if v {
self.0 |= 0x01;
} else {
self.0 &= 0x01u8.not();
}
self
}
#[must_use]
pub fn set_underlined(mut self, v: bool) -> Self {
if v {
self.0 |= 0x02;
} else {
self.0 &= 0x02u8.not();
}
self
}
#[must_use]
pub fn set_italic(mut self, v: bool) -> Self {
if v {
self.0 |= 0x04;
} else {
self.0 &= 0x04u8.not();
}
self
}
#[must_use]
pub fn set_blinking(mut self, v: bool) -> Self {
if v {
self.0 |= 0x08;
} else {
self.0 &= 0x08u8.not();
}
self
}
#[must_use]
pub fn set_reversed(mut self, v: bool) -> Self {
if v {
self.0 |= 0x10;
} else {
self.0 &= 0x10u8.not();
}
self
}
#[must_use]
pub fn set_struck(mut self, v: bool) -> Self {
if v {
self.0 |= 0x20;
} else {
self.0 &= 0x20u8.not();
}
self
}
}
pub cursor_visible: bool,
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 Default for Vterm {
fn default() -> Self {
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,
},
}
}
}
impl Vterm {
pub fn new() -> Self {
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 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;
}
/// Set the vterm style
pub fn set_vterm_style(&mut self, style: Style) {
self.style = style;
}
}