Skip to content

Commit 470a13d

Browse files
committed
Rewrite the web terminal and drop xterm.js
This change updates the web terminal implementation to use a custom-built console based on the SDL code and drops the use of xterm.js. This is to permit rendering graphics. Note that this change duplicates a lot of the logic that currently exists in the sdl crate. This is unfortunate, but generalizing the console code to separate general logic from rendering is quite a bit of work, and it can be done later once we have complete implementations and can see what is and what isn't common.
1 parent ef954ec commit 470a13d

16 files changed

Lines changed: 753 additions & 235 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"crossterm",
6767
"endbasic",
6868
"eval",
69+
"framebuffer",
6970
"jmmv",
7071
"monospaced",
7172
"MSRV",

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ for the time being.**
6868
of the `endbasic-web` crate on the `endbasic` CLI crate, which required
6969
optional features to work.
7070

71+
* Rewrote the web frontend to support graphics rendering. This implies that
72+
we do not use `xterm.js` any more and instead we use a custom-built
73+
console implementation.
74+
7175
## Changes in version 0.7.0
7276

7377
**Released on 2021-07-03.**

sdl/src/console.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,9 @@ impl Console for SdlConsole {
730730
self.cursor_pos.y = 0;
731731
self.cursor_pos.x = 0;
732732

733-
// We intentionally do not draw the cursor here and wait until the first time we write text
734-
// to the console. This allows the user to clear the screen and render graphics if they
735-
// want to without interference.
733+
// We intentionally do not draw the cursor here and wait until the first time we
734+
// write text to the console. This allows the user to clear the screen and render
735+
// graphics if they want to without interference.
736736
self.cursor_backup.clear();
737737
}
738738
ClearType::CurrentLine => {

std/src/console/colors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
//! Color palette for terminals with precise color support.
1717
18+
/// Represents an RGB color in `[0,255]` quantities.
1819
#[allow(clippy::upper_case_acronyms)]
19-
type RGB = (u8, u8, u8);
20+
pub type RGB = (u8, u8, u8);
2021

2122
static COLORS: &[RGB] = &[
2223
(0, 0, 0), // Black.

std/src/console/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use std::str;
2828
mod cmds;
2929
pub(crate) use cmds::add_all;
3030
mod colors;
31-
pub use colors::ansi_color_to_rgb;
31+
pub use colors::{ansi_color_to_rgb, RGB};
3232
mod format;
3333
pub(crate) use format::refill_and_print;
3434
mod readline;

web/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ serde_json = "1.0"
2929
time = { version = "0.2", features = ["serde", "std"] }
3030
wasm-bindgen = "^0.2.78"
3131
wasm-bindgen-futures = "0.4"
32-
xterm-js-rs = "0.1.1"
3332

3433
[dependencies.endbasic-core]
3534
version = "0.7.0" # ENDBASIC-VERSION
@@ -46,7 +45,13 @@ path = "../std"
4645
[dependencies.web-sys]
4746
version = "0.3"
4847
features = [
48+
"CanvasRenderingContext2d",
49+
"EventTarget",
50+
"HtmlCanvasElement",
51+
"ImageData",
52+
"KeyboardEvent",
4953
"Storage",
54+
"TextMetrics",
5055
"Window",
5156
]
5257

web/package-lock.json

Lines changed: 1 addition & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
},
2626
"homepage": "https://www.endbasic.dev/",
2727
"dependencies": {
28-
"jquery": "3.6.0",
29-
"xterm": "4.14.1",
30-
"xterm-addon-fit": "0.5.0"
28+
"jquery": "3.6.0"
3129
},
3230
"devDependencies": {
3331
"@wasm-tool/wasm-pack-plugin": "^1.6.0",

0 commit comments

Comments
 (0)