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 fs;
|
||||||
pub mod ktask;
|
pub mod ktask;
|
||||||
pub mod syscalls;
|
pub mod syscalls;
|
||||||
|
pub mod characters;
|
||||||
mod arch;
|
mod arch;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::spinlock::Spinlock;
|
||||||
use crate::trafficcontrol::TrafficControl;
|
use crate::trafficcontrol::TrafficControl;
|
||||||
|
|
||||||
pub struct FramebufferConsole {
|
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 cursor: (usize, usize), // (x, y)
|
||||||
pub need_screen_clear: bool,
|
pub need_screen_clear: bool,
|
||||||
pub need_line_clear: bool,
|
pub need_line_clear: bool,
|
||||||
|
|
@ -14,7 +14,7 @@ pub static FBCONSOLE: Spinlock<FramebufferConsole> = Spinlock::new(FramebufferCo
|
||||||
impl FramebufferConsole {
|
impl FramebufferConsole {
|
||||||
pub const fn empty() -> Self {
|
pub const fn empty() -> Self {
|
||||||
Self {
|
Self {
|
||||||
buffer: [[' '; 26]; 20],
|
buffer: [[b' '; 26]; 20],
|
||||||
cursor: (0, 0),
|
cursor: (0, 0),
|
||||||
need_screen_clear: true,
|
need_screen_clear: true,
|
||||||
need_line_clear: false,
|
need_line_clear: false,
|
||||||
|
|
@ -27,23 +27,24 @@ impl FramebufferConsole {
|
||||||
let copy_from = self.buffer[line_num + 1];
|
let copy_from = self.buffer[line_num + 1];
|
||||||
self.buffer[line_num] = copy_from;
|
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;
|
self.need_screen_clear = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOES send a framebuffer update!
|
// DOES send a framebuffer update!
|
||||||
pub fn clear_terminal(&mut self, tc: &mut TrafficControl) {
|
pub fn clear_terminal(&mut self, tc: &mut TrafficControl) {
|
||||||
self.need_screen_clear = true;
|
self.need_screen_clear = true;
|
||||||
self.buffer = [[' '; 26]; 20];
|
self.buffer = [[b' '; 26]; 20];
|
||||||
self.cursor = (0, 0);
|
self.cursor = (0, 0);
|
||||||
self.render(tc, true);
|
self.render(tc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOES send a framebuffer update!
|
// DOES send a framebuffer update!
|
||||||
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &str) {
|
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &[u8]) {
|
||||||
for c in str.chars() {
|
for c in str {
|
||||||
|
let c = *c;
|
||||||
let mut was_special_char = false;
|
let mut was_special_char = false;
|
||||||
if c == '\n' || c == '\r' {
|
if c == b'\n' || c == b'\r' {
|
||||||
was_special_char = true;
|
was_special_char = true;
|
||||||
self.cursor.0 = 0;
|
self.cursor.0 = 0;
|
||||||
self.cursor.1 += 1;
|
self.cursor.1 += 1;
|
||||||
|
|
@ -53,7 +54,7 @@ impl FramebufferConsole {
|
||||||
self.cursor.1 = self.buffer.len() - 1;
|
self.cursor.1 = self.buffer.len() - 1;
|
||||||
self.scroll_terminal();
|
self.scroll_terminal();
|
||||||
}
|
}
|
||||||
if c == '\x08' {
|
if c == b'\x08' {
|
||||||
was_special_char = true;
|
was_special_char = true;
|
||||||
// we don't clear the character, that's up to the terminal
|
// we don't clear the character, that's up to the terminal
|
||||||
self.need_line_clear = true;
|
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 ogx = x;
|
||||||
let ogy = y;
|
let ogy = y;
|
||||||
const BYTES: [u8; 3] = FB_FG_COLOR.to_bytes();
|
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;
|
let fbstride = FRAMEBUFFER_BPP.load(Ordering::Relaxed) * FRAMEBUFFER_WIDTH;
|
||||||
for c in chars {
|
for c in chars {
|
||||||
let c = *c;
|
let c = *c;
|
||||||
if c == ' ' {
|
if c == b' ' {
|
||||||
x += CHAR_SIZE;
|
x += CHAR_SIZE;
|
||||||
} else if c as u8 > 32 {
|
} else if c as u8 > 32 {
|
||||||
let c = c as u8 - b'!';
|
let c = c as u8 - b'!';
|
||||||
|
|
|
||||||
|
|
@ -186,9 +186,7 @@ pub fn handle_syscall(
|
||||||
if tc.use_fb_console {
|
if tc.use_fb_console {
|
||||||
let mut fbcons = crate::dev::framebuffer::console::FBCONSOLE.lock();
|
let mut fbcons = crate::dev::framebuffer::console::FBCONSOLE.lock();
|
||||||
fbcons.printstr(&mut tc, unsafe {
|
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
|
0
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ panic = "abort"
|
||||||
opt-level = "z"
|
opt-level = "z"
|
||||||
debug-assertions = false
|
debug-assertions = false
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
strip = true
|
|
||||||
lto = true
|
lto = true
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
|
use core::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
|
||||||
|
use liblbos::characters;
|
||||||
use crate::terminal::{print, println};
|
use crate::terminal::{print, println};
|
||||||
use liblbos::fs::{DirectoryReader, FileSystem};
|
use liblbos::fs::{DirectoryReader, FileSystem};
|
||||||
|
|
||||||
|
|
@ -112,13 +113,16 @@ fn lsdir(env: &Environment<'_>) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
print("- ");
|
print("- ");
|
||||||
|
let name = &record.name[..record.name.iter().position(|&x| x == 0).unwrap_or(11)];
|
||||||
liblbos::syscalls::write_terminal(
|
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 {
|
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 {
|
} else {
|
||||||
print("(file)");
|
liblbos::syscalls::write_terminal(&[b' ', characters::C_FILE as u8]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue