fix backspace

This commit is contained in:
able 2022-08-03 02:09:34 -05:00
parent 1ca1594f66
commit ce765f2488
10 changed files with 34 additions and 115 deletions

View file

@ -1,6 +1,6 @@
use core::panic::PanicInfo; use core::panic::PanicInfo;
use crate::{arch::gdt, println, rhai_shell::KEYBUFF}; use crate::{arch::gdt, print, println, rhai_shell::KEYBUFF};
use cpuio::outb; use cpuio::outb;
use pic8259::ChainedPics; use pic8259::ChainedPics;
use qrcode::QrCode; use qrcode::QrCode;
@ -141,6 +141,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
// TODO: Fix this and apply to new term // TODO: Fix this and apply to new term
KEYBUFF.lock().push(8.into()); KEYBUFF.lock().push(8.into());
// trace!("8");
// print!("\u{8}"); // print!("\u{8}");
} }
// '^' => KERNEL_STATE.lock().shutdown(), // '^' => KERNEL_STATE.lock().shutdown(),

View file

@ -1,40 +0,0 @@
use alloc::collections::VecDeque;
#[derive(Debug)]
pub struct ChannelPermission {
pub owner: bool,
pub producer: bool,
pub consumer: bool,
/// Whether or not the process can be destructive about reading
pub distructive_consumer: bool,
}
#[derive(Debug)]
pub struct Channel {
inner: VecDeque<u8>,
}
impl Channel {
pub fn new() -> Self {
let deq = VecDeque::from([]);
Self { inner: deq }
}
pub fn read(&mut self) -> Result<u8, ChannelError> {
if let Some(abc) = self.inner.pop_front() {
return Ok(abc);
}
return Err(ChannelError::EmptyBuffer);
}
pub fn send(&mut self, data: u8) {
self.inner.push_back(data);
}
}
pub enum ChannelError {
EmptyBuffer,
InvalidPermissions,
}

View file

@ -68,14 +68,13 @@ pub mod wasm_jumploader;
pub mod allocator; pub mod allocator;
// pub use allocator as aalloc; // pub use allocator as aalloc;
pub mod channels;
pub mod handle; pub mod handle;
pub mod hardware; pub mod hardware;
pub mod ipc; pub mod ipc;
pub mod panic; pub mod panic;
mod unicode_utils; mod unicode_utils;
pub mod vga_e; pub mod vga_e;
pub mod vgai; // pub mod vgai;
pub mod vterm; pub mod vterm;
#[prelude_import] #[prelude_import]

View file

@ -41,8 +41,10 @@ impl core::fmt::Write for Stdout {
// trace!("printing"); // trace!("printing");
// x86_64::instructions::interrupts::without_interrupts(|| { // x86_64::instructions::interrupts::without_interrupts(|| {
let mut term = TERM.lock(); let mut term = TERM.lock();
term.set_dirty(true); term.set_dirty(true);
term.print(s); term.print(s);
drop(term); drop(term);
// }); // });
// trace!("Finished printing"); // trace!("Finished printing");

View file

@ -9,6 +9,9 @@ pub fn bruh() {
let xyz_old = decode(&xyz_new); let xyz_old = decode(&xyz_new);
println!("{}", xyz_new.len());
println!("{}", xyz_old.len());
let screen_lock = VGAE.lock(); let screen_lock = VGAE.lock();
screen_lock.set_mode(); screen_lock.set_mode();
for y in 0..8 { for y in 0..8 {

View file

@ -1,5 +1,6 @@
use crate::arch::drivers::sysinfo::master; use crate::arch::drivers::sysinfo::master;
use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2}; use crate::arch::interrupts::{reset_pit_for_cpu, set_pit_2};
use crate::image::mono_bitmap::bruh;
use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE}; use crate::systeminfo::{KERNEL_VERSION, RELEASE_TYPE};
use crate::time::fetch_time; use crate::time::fetch_time;
use crate::{ use crate::{
@ -65,6 +66,8 @@ pub fn scratchpad() {
println!("\0RED\0OHNO\0RESET\0"); println!("\0RED\0OHNO\0RESET\0");
// bruh();
disable(); disable();
let tick_time = fetch_time(); let tick_time = fetch_time();
@ -133,7 +136,7 @@ pub fn real_shell() {
let mut buf = String::new(); let mut buf = String::new();
print!("{}", prompt); print!("{}", prompt);
// panic!(":<");
loop { loop {
match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) { match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) {
Some('\n') => { Some('\n') => {
@ -151,9 +154,9 @@ pub fn real_shell() {
buf.clear(); buf.clear();
print!("{}", prompt); print!("{}", prompt);
} }
Some('\u{0008}') => { Some('\u{8}') => {
print!("\u{08}"); print!("\u{8}");
trace!("");
buf.pop(); buf.pop();
} }

View file

@ -1,62 +0,0 @@
pub enum Color {
/// Represents the color `Black (0x0)`.
Black = 0x0,
/// Represents the color `Blue (0x1)`.
Blue = 0x1,
/// Represents the color `Green (0x2)`.
Green = 0x2,
/// Represents the color `Cyan (0x3)`.
Cyan = 0x3,
/// Represents the color `Red (0x4)`.
Red = 0x4,
/// Represents the color `Magenta (0x5)`.
Magenta = 0x5,
/// Represents the color `Brown (0x6)`.
Brown = 0x6,
/// Represents the color `LightGrey (0x7)`.
LightGrey = 0x7,
/// Represents the color `DarkGrey (0x8)`.
DarkGrey = 0x8,
/// Represents the color `LightBlue (0x9)`.
LightBlue = 0x9,
/// Represents the color `LightGreen (0xA)`.
LightGreen = 0xA,
/// Represents the color `LightCyan (0xB)`.
LightCyan = 0xB,
/// Represents the color `LightRed (0xC)`.
LightRed = 0xC,
/// Represents the color `Pink (0xD)`.
Pink = 0xD,
/// Represents the color `Yellow (0xE)`.
Yellow = 0xE,
/// Represents the color `White (0xF)`.
White = 0xF,
}
const VGA_BUFFER_SIZE: usize = 480;
pub struct ScreenBuffer {}
impl ScreenBuffer {
pub fn initialise() {}
pub fn flip_buffer() {
/*
before doing anything past here we need to tell the VGA about some things
*/
let setup = false;
if setup {
use Color::*;
let dualpixel: u8 = Red as u8;
let buff: [u8; VGA_BUFFER_SIZE] = [dualpixel; VGA_BUFFER_SIZE];
let buff_ptr = buff.as_ptr();
let vga_buffer = 0xb8000 as *mut u8;
use core::ptr;
unsafe {
ptr::copy(buff_ptr, vga_buffer, VGA_BUFFER_SIZE);
}
}
}
}

View file

@ -10,17 +10,20 @@ pub struct Term {
dirty: bool, dirty: bool,
color: Color16, color: Color16,
term: [(char, Color16); 80 * 60], term: [(char, Color16); 80 * 60],
back_buffer: [u8; 640 * 480],
x: u8, x: u8,
} }
impl Term { impl Term {
pub fn new() -> Self { pub fn new() -> Self {
let mode = VGAE.lock(); let mode = VGAE.lock();
mode.set_mode(); mode.set_mode();
// let fb = mode.get_frame_buffer();
drop(mode); drop(mode);
Self { Self {
dirty: false, dirty: false,
x: 0, x: 0,
back_buffer: [0; 640 * 480],
term: [('\0', Color16::LightGrey); 80 * 60], term: [('\0', Color16::LightGrey); 80 * 60],
color: Color16::White, color: Color16::White,
} }
@ -67,11 +70,11 @@ impl Term {
if self.x == 80 { if self.x == 80 {
self.move_up(); self.move_up();
} }
// trace!("C");
match c { match c {
'\u{08}' => { '\u{08}' => {
if self.x == 0 { if self.x == 0 {
// trace!("IMPOSSIBLE BACKSPACE"); trace!("IMPOSSIBLE BACKSPACE");
return; return;
} }
trace!("BACKSPACE"); trace!("BACKSPACE");
@ -111,7 +114,7 @@ impl Term {
pub fn draw_term(&mut self) { pub fn draw_term(&mut self) {
if self.is_dirty() { if self.is_dirty() {
trace!("Redrawing"); // trace!("Redrawing");
use Color16::*; use Color16::*;
let mode = VGAE.lock(); let mode = VGAE.lock();
mode.clear_screen(DarkGrey); mode.clear_screen(DarkGrey);
@ -153,7 +156,7 @@ impl Term {
} }
self.set_dirty(false); self.set_dirty(false);
trace!("Finished drawing"); // trace!("Finished drawing");
} }
} }
} }
@ -203,7 +206,7 @@ pub enum Token {
#[token(" ")] #[token(" ")]
Space, Space,
#[regex("[\t\n!-~]+", text_lex, priority = 0)] #[regex("[\t\n\u{8}!-~]+", text_lex, priority = 0)]
Text(String), Text(String),
} }

View file

@ -1,4 +1,4 @@
use crate::{arch::generate_process_pass, rhai_shell::KEYBUFF}; use crate::{arch::generate_process_pass, ipc::channel::ChannelMessage, rhai_shell::KEYBUFF};
use wasmi::{ use wasmi::{
Error, Externals, FuncInstance, FuncRef, ModuleImportResolver, RuntimeArgs, RuntimeValue, Error, Externals, FuncInstance, FuncRef, ModuleImportResolver, RuntimeArgs, RuntimeValue,
Signature, Trap, ValueType, Signature, Trap, ValueType,
@ -165,4 +165,14 @@ host_externals! {
print!("{}", char::from(chr)); print!("{}", char::from(chr));
Ok(None) Ok(None)
} }
// TODO: Send a message to a channel
6: send_channel_message(){
Ok(None)
}
} }

Binary file not shown.