Skip to content

Commit c19314c

Browse files
authored
Merge pull request #55 from Neotron-Compute/add-ansi-parser
Add ansi parser
2 parents ecba53d + c50c4a9 commit c19314c

File tree

14 files changed

+1645
-253
lines changed

14 files changed

+1645
-253
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
- name: Check Syntax
1515
run: |
1616
cargo check
17+
- name: Test
18+
run: |
19+
cargo test --lib
1720
- name: Install Targets and Tools
1821
run: |
1922
rustup target add thumbv7em-none-eabi
@@ -22,7 +25,8 @@ jobs:
2225
rustup component add llvm-tools-preview
2326
cargo install cargo-binutils
2427
- name: Build
25-
run: ./build.sh --verbose
28+
run: |
29+
./build.sh --verbose
2630
- name: Upload files to Release
2731
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
2832
uses: softprops/action-gh-release@v1

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ required-features = ["native-log"]
3434
lto = true
3535
debug = true
3636
codegen-units = 1
37-
opt-level = "s"
37+
opt-level = "z"
3838
panic = "abort"
3939

4040
[profile.dev]
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/commands/block.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Block Device related commands for Neotron OS
22
3-
use crate::{bios, print, println, Ctx, API};
3+
use crate::{bios, osprint, osprintln, Ctx, API};
44

55
pub static LSBLK_ITEM: menu::Item<Ctx> = menu::Item {
66
item_type: menu::ItemType::Callback {
@@ -34,7 +34,7 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
3434
let api = API.get();
3535
let mut found = false;
3636

37-
println!("Block Devices:");
37+
osprintln!("Block Devices:");
3838
for dev_idx in 0..=255u8 {
3939
if let bios::FfiOption::Some(device_info) = (api.block_dev_get_info)(dev_idx) {
4040
let (bsize, bunits, dsize, dunits) =
@@ -48,12 +48,12 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
4848
(10 * x / (1024 * 1024 * 1024), "GiB", x / 100_000_000, "GB")
4949
}
5050
};
51-
println!("Device {}:", dev_idx);
52-
println!(" Name: {}", device_info.name);
53-
println!(" Type: {:?}", device_info.device_type);
54-
println!(" Block size: {}", device_info.block_size);
55-
println!(" Num Blocks: {}", device_info.num_blocks);
56-
println!(
51+
osprintln!("Device {}:", dev_idx);
52+
osprintln!(" Name: {}", device_info.name);
53+
osprintln!(" Type: {:?}", device_info.device_type);
54+
osprintln!(" Block size: {}", device_info.block_size);
55+
osprintln!(" Num Blocks: {}", device_info.num_blocks);
56+
osprintln!(
5757
" Card Size: {}.{} {} ({}.{} {})",
5858
bsize / 10,
5959
bsize % 10,
@@ -62,30 +62,30 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
6262
dsize % 10,
6363
dunits
6464
);
65-
println!(" Ejectable: {}", device_info.ejectable);
66-
println!(" Removable: {}", device_info.removable);
67-
println!(" Media Present: {}", device_info.media_present);
68-
println!(" Read Only: {}", device_info.read_only);
65+
osprintln!(" Ejectable: {}", device_info.ejectable);
66+
osprintln!(" Removable: {}", device_info.removable);
67+
osprintln!(" Media Present: {}", device_info.media_present);
68+
osprintln!(" Read Only: {}", device_info.read_only);
6969
found = true;
7070
}
7171
}
7272
if !found {
73-
println!(" None");
73+
osprintln!(" None");
7474
}
7575
}
7676

7777
/// Called when the "read_block" command is executed.
7878
fn read_block(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], _ctx: &mut Ctx) {
7979
let api = API.get();
8080
let Ok(dev_idx) = args[0].parse::<u8>() else {
81-
println!("Couldn't parse {:?}", args[0]);
81+
osprintln!("Couldn't parse {:?}", args[0]);
8282
return;
8383
};
8484
let Ok(block_idx) = args[1].parse::<u64>() else {
85-
println!("Couldn't parse {:?}", args[1]);
85+
osprintln!("Couldn't parse {:?}", args[1]);
8686
return;
8787
};
88-
println!("Reading block {}:", block_idx);
88+
osprintln!("Reading block {}:", block_idx);
8989
let mut buffer = [0u8; 512];
9090
match (api.block_read)(
9191
dev_idx,
@@ -97,16 +97,16 @@ fn read_block(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], _
9797
// Carry on
9898
let mut count = 0;
9999
for chunk in buffer.chunks(32) {
100-
print!("{:03x}: ", count);
100+
osprint!("{:03x}: ", count);
101101
for b in chunk {
102-
print!("{:02x}", *b);
102+
osprint!("{:02x}", *b);
103103
}
104104
count += chunk.len();
105-
println!();
105+
osprintln!();
106106
}
107107
}
108108
bios::ApiResult::Err(e) => {
109-
println!("Failed to read: {:?}", e);
109+
osprintln!("Failed to read: {:?}", e);
110110
}
111111
}
112112
}

0 commit comments

Comments
 (0)