Skip to content

Commit 630004c

Browse files
committed
Add ANSI parser, and cursor support.
1 parent 9d450df commit 630004c

File tree

4 files changed

+486
-78
lines changed

4 files changed

+486
-78
lines changed

Cargo.lock

Lines changed: 33 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ panic = "abort"
4141
panic = "abort"
4242

4343
[dependencies]
44-
neotron-common-bios = "0.9"
44+
neotron-common-bios = "0.10"
4545
pc-keyboard = "0.7"
4646
r0 = "1.0"
4747
postcard = "1.0"
@@ -51,6 +51,7 @@ chrono = { version = "0.4", default-features = false }
5151
embedded-sdmmc = { version = "0.5", default-features = false }
5252
neotron-api = "0.1"
5353
neotron-loader = "0.1"
54+
vte = { git = "https://github.com/neotron-compute/vte", branch="limit-osc-raw-size" }
5455

5556
[features]
5657
lib-mode = []

src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use config::Config as OsConfig;
2525
// ===========================================================================
2626

2727
/// The OS version string
28-
const OS_VERSION: &str = concat!("Neotron OS, version ", env!("OS_VERSION"));
28+
const OS_VERSION: &str = concat!("Neotron OS, v", env!("OS_VERSION"));
2929

3030
/// Used to convert between POSIX epoch (for `chrono`) and Neotron epoch (for BIOS APIs).
3131
const SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH: i64 = 946684800;
@@ -136,7 +136,7 @@ struct SerialConsole(u8);
136136
impl SerialConsole {
137137
fn write_bstr(&mut self, data: &[u8]) -> core::fmt::Result {
138138
let api = API.get();
139-
let is_panic = IS_PANIC.load(Ordering::SeqCst);
139+
let is_panic = IS_PANIC.load(Ordering::Relaxed);
140140
let res = (api.serial_write)(
141141
// Which port
142142
self.0,
@@ -155,7 +155,7 @@ impl SerialConsole {
155155
impl core::fmt::Write for SerialConsole {
156156
fn write_str(&mut self, data: &str) -> core::fmt::Result {
157157
let api = API.get();
158-
let is_panic = IS_PANIC.load(Ordering::SeqCst);
158+
let is_panic = IS_PANIC.load(Ordering::Relaxed);
159159
let res = (api.serial_write)(
160160
// Which port
161161
self.0,
@@ -252,7 +252,7 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
252252
unsafe {
253253
VGA_CONSOLE = Some(vga);
254254
}
255-
println!("Configured VGA console {}x{}", width, height);
255+
println!("\u{001b}[0mConfigured VGA console {}x{}", width, height);
256256
}
257257
}
258258

@@ -263,8 +263,8 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
263263
}
264264

265265
// Now we can call println!
266-
println!("Welcome to {}!", OS_VERSION);
267-
println!("Copyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2022");
266+
println!("\u{001b}[44;33;1m{}\u{001b}[0m", OS_VERSION);
267+
println!("\u{001b}[41;37;1mCopyright © Jonathan 'theJPster' Pallant and the Neotron Developers, 2022\u{001b}[0m");
268268

269269
let (tpa_start, tpa_size) = match (api.memory_get_region)(0) {
270270
bios::FfiOption::None => {
@@ -295,11 +295,14 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
295295
};
296296

297297
println!(
298-
"TPA: {} bytes @ {:p}",
298+
"\u{001b}[7mTPA: {} bytes @ {:p}\u{001b}[0m",
299299
ctx.tpa.as_slice_u8().len(),
300300
ctx.tpa.as_slice_u8().as_ptr()
301301
);
302302

303+
// Show the cursor
304+
print!("\u{001b}[?25h");
305+
303306
let mut buffer = [0u8; 256];
304307
let mut menu = menu::Runner::new(&commands::OS_MENU, &mut buffer, ctx);
305308

@@ -376,7 +379,7 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
376379
#[panic_handler]
377380
#[cfg(not(feature = "lib-mode"))]
378381
fn panic(info: &core::panic::PanicInfo) -> ! {
379-
IS_PANIC.store(true, Ordering::SeqCst);
382+
IS_PANIC.store(true, Ordering::Relaxed);
380383
println!("PANIC!\n{:#?}", info);
381384
let api = API.get();
382385
loop {

0 commit comments

Comments
 (0)