fixes for special characters
This commit is contained in:
parent
13e0c9697c
commit
760d34c357
7 changed files with 31 additions and 17 deletions
11
liblbos/src/characters.rs
Normal file
11
liblbos/src/characters.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
pub const C_LIFEBLOOD_CAT: char = (b'~' + 1) as char;
|
||||
pub const C_SMILE: char = (b'~' + 2) as char;
|
||||
pub const C_FEARFUL: char = (b'~' + 3) as char;
|
||||
pub const C_SUNGLASSES: char = (b'~' + 4) as char;
|
||||
pub const C_COLONTHREE: char = (b'~' + 5) as char;
|
||||
pub const C_FOLDER: char = (b'~' + 6) as char;
|
||||
pub const C_FILE: char = (b'~' + 7) as char;
|
||||
pub const C_BLOOD: char = (b'~' + 8) as char;
|
||||
pub const C_WINK: char = (b'~' + 9) as char;
|
||||
pub const C_CONFUSED: char = (b'~' + 10) as char;
|
||||
pub const C_COLOND: char = (b'~' + 11) as char;
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
pub mod fs;
|
||||
pub mod ktask;
|
||||
pub mod syscalls;
|
||||
pub mod characters;
|
||||
mod arch;
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::spinlock::Spinlock;
|
|||
use crate::trafficcontrol::TrafficControl;
|
||||
|
||||
pub struct FramebufferConsole {
|
||||
pub buffer: [[char; 26]; 20], // our font is 16x16, 320x240 is the standard res, so 20x15
|
||||
pub buffer: [[u8; 26]; 20], // our font is 16x16, 320x240 is the standard res, so 20x15
|
||||
pub cursor: (usize, usize), // (x, y)
|
||||
pub need_screen_clear: bool,
|
||||
pub need_line_clear: bool,
|
||||
|
|
@ -14,7 +14,7 @@ pub static FBCONSOLE: Spinlock<FramebufferConsole> = Spinlock::new(FramebufferCo
|
|||
impl FramebufferConsole {
|
||||
pub const fn empty() -> Self {
|
||||
Self {
|
||||
buffer: [[' '; 26]; 20],
|
||||
buffer: [[b' '; 26]; 20],
|
||||
cursor: (0, 0),
|
||||
need_screen_clear: true,
|
||||
need_line_clear: false,
|
||||
|
|
@ -27,23 +27,24 @@ impl FramebufferConsole {
|
|||
let copy_from = self.buffer[line_num + 1];
|
||||
self.buffer[line_num] = copy_from;
|
||||
}
|
||||
self.buffer[self.buffer.len() - 1] = [' '; 26];
|
||||
self.buffer[self.buffer.len() - 1] = [b' '; 26];
|
||||
self.need_screen_clear = true;
|
||||
}
|
||||
|
||||
// DOES send a framebuffer update!
|
||||
pub fn clear_terminal(&mut self, tc: &mut TrafficControl) {
|
||||
self.need_screen_clear = true;
|
||||
self.buffer = [[' '; 26]; 20];
|
||||
self.buffer = [[b' '; 26]; 20];
|
||||
self.cursor = (0, 0);
|
||||
self.render(tc, true);
|
||||
}
|
||||
|
||||
// DOES send a framebuffer update!
|
||||
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &str) {
|
||||
for c in str.chars() {
|
||||
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &[u8]) {
|
||||
for c in str {
|
||||
let c = *c;
|
||||
let mut was_special_char = false;
|
||||
if c == '\n' || c == '\r' {
|
||||
if c == b'\n' || c == b'\r' {
|
||||
was_special_char = true;
|
||||
self.cursor.0 = 0;
|
||||
self.cursor.1 += 1;
|
||||
|
|
@ -53,7 +54,7 @@ impl FramebufferConsole {
|
|||
self.cursor.1 = self.buffer.len() - 1;
|
||||
self.scroll_terminal();
|
||||
}
|
||||
if c == '\x08' {
|
||||
if c == b'\x08' {
|
||||
was_special_char = true;
|
||||
// we don't clear the character, that's up to the terminal
|
||||
self.need_line_clear = true;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ impl FBColor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, chars: &[char]) {
|
||||
pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, chars: &[u8]) {
|
||||
let ogx = x;
|
||||
let ogy = y;
|
||||
const BYTES: [u8; 3] = FB_FG_COLOR.to_bytes();
|
||||
|
|
@ -46,7 +46,7 @@ pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, char
|
|||
let fbstride = FRAMEBUFFER_BPP.load(Ordering::Relaxed) * FRAMEBUFFER_WIDTH;
|
||||
for c in chars {
|
||||
let c = *c;
|
||||
if c == ' ' {
|
||||
if c == b' ' {
|
||||
x += CHAR_SIZE;
|
||||
} else if c as u8 > 32 {
|
||||
let c = c as u8 - b'!';
|
||||
|
|
|
|||
|
|
@ -186,9 +186,7 @@ pub fn handle_syscall(
|
|||
if tc.use_fb_console {
|
||||
let mut fbcons = crate::dev::framebuffer::console::FBCONSOLE.lock();
|
||||
fbcons.printstr(&mut tc, unsafe {
|
||||
core::str::from_utf8_unchecked(unsafe {
|
||||
core::slice::from_raw_parts(addr as *const u8, count)
|
||||
})
|
||||
core::slice::from_raw_parts(addr as *const u8, count)
|
||||
});
|
||||
}
|
||||
0
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ panic = "abort"
|
|||
opt-level = "z"
|
||||
debug-assertions = false
|
||||
overflow-checks = false
|
||||
strip = true
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#![no_main]
|
||||
|
||||
use core::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
|
||||
use liblbos::characters;
|
||||
use crate::terminal::{print, println};
|
||||
use liblbos::fs::{DirectoryReader, FileSystem};
|
||||
|
||||
|
|
@ -112,13 +113,16 @@ fn lsdir(env: &Environment<'_>) {
|
|||
break;
|
||||
}
|
||||
print("- ");
|
||||
let name = &record.name[..record.name.iter().position(|&x| x == 0).unwrap_or(11)];
|
||||
liblbos::syscalls::write_terminal(
|
||||
&record.name[..record.name.iter().position(|&x| x == 0).unwrap_or(11)],
|
||||
name
|
||||
);
|
||||
if record.record_type == liblbos::fs::RecordType::Directory as u8 {
|
||||
print("(dir)");
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_FOLDER as u8]);
|
||||
} else if &name[name.len() - 3..] == b"DDI" {
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_BLOOD as u8]);
|
||||
} else {
|
||||
print("(file)");
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_FILE as u8]);
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue