Skip to content

Conversation

@junkdog
Copy link
Collaborator

@junkdog junkdog commented Jun 28, 2025

Updates to beamterm 0.5.0 0.7.0, which brings a simplified and extended API + some perf improvements.

new in 0.7.0: doubled glyph count to 1024 glyphs per font style. the default font now contains the full braille set/

The updates removes the internal cell buffer, as we can retrieve and manage any cell data from beamterm directly, without relying on our own cell buffer for internal bookkeeping. With the buffer gone, resize() etc was also removed + simplified cursor position handling.

The performance impact from updating to 0.5.0 0.6.0 0.7.0 and removing the buffer is in the ballpark of 1/3 to 1/4 less time spent by the backend each frame.

There's also a slight change in cursor shape behavior: the cursor shape style modifier now toggles instead of setting its associated style attribute. this is done so that at least something is shown if the cell is already underlined or reversed (though i think the reverse case was probably working fine before, i.e., applying REVERSE twice).

new options

  • WebGl2BackendOptions::fallback_glyph: when a symbol is missing during rendering
  • WebGl2BackendOptions::font_atlas: for custom font atlases (glyph set, font, weights etc)
  • WebGl2BackendOptions::canvas_padding_color: any space not covered by the terminal grid
  • WebGl2BackendOptions::enable_console_debug_api: wires a simple browser console-based debug API under window.__beamterm_debug
  • WebGl2BackendOptions::enable_mouse_selection: beamterm's default mouse selection handler
  • WebGl2BackendOptions::cursor_shape: moved from WebGl2Backend
  • WebGl2BackendOptions::enable_hyperlinks: registers a default link HyperLink widget handler
  • WebGl2BackendOptions::on_hyperlink_click: sets a custom hyperlink callback handler

Example options:

let options  = WebGl2BackendOptions::new()
    .measure_performance(true)
    .enable_hyperlinks()       // clickable hyperlinks
    .enable_mouse_selection(); // copy to clipboard on selection
    

image

hyperlinks change the mouse cursor shape on hover

Browser Console Debugging API

As mentioned above, enabled with enable_console_debug_api(). it's pretty bare-bones, but supplants previously present console logging.

image

todo

  • release beamterm-0.5.0
  • release beamterm-0.6.0

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good!
Gave this a quick read... will look into it in detail later
I wonder how the hyperlink/mouse stuff works so it'd be nice to update one of the examples to showcase it

| (m << 5) & (1 << 13) // strikethrough
}

impl std::fmt::Debug for WebGl2Backend {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why manual Debug implementations for WebGl2Backend and WebGl2BackendOptions? (i.e. which member of the struct is not Debug?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take your pick inside Option<Rc<RefCell<dyn FnMut(&str)>>>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could put it in a wrapper w debug?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's now wrapped inside HyperlinkCallback, so we're back to deriving Debug

@junkdog
Copy link
Collaborator Author

junkdog commented Jun 30, 2025

I wonder how the hyperlink/mouse stuff works so it'd be nice to update one of the examples to showcase it

it'll be once #109 is merged, as it allows updating the existing examples with per-backend options (that's how i tested it locally).

@junkdog
Copy link
Collaborator Author

junkdog commented Jul 21, 2025

todo: update examples with appropriate configs (as #109 is merged)

@junkdog
Copy link
Collaborator Author

junkdog commented Jul 24, 2025

bugs:

  • active mouse selection must trigger redraw
  • mouse-relate intermittent panic
website-41e08a225213f301.js:401 panicked at /home/junkdog/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/beamterm-renderer-0.5.0/src/mouse.rs:439:9:
assertion failed: matches!(self, SelectionState::Idle)

Stack:

Error
    at imports.wbg.__wbg_new_8a6f238a6ece86ea (http://localhost:8080/website-41e08a225213f301.js:572:21)
    at website-9d2528066d59e0ac.wasm.__wbg_new_8a6f238a6ece86ea externref shim (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[7222]:0x1dabcc)
    at website-9d2528066d59e0ac.wasm.console_error_panic_hook::Error::new::hcfb1159b478f61ab (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[4586]:0x1b4a89)
    at website-9d2528066d59e0ac.wasm.console_error_panic_hook::hook_impl::h8179f11935818c63 (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[1105]:0x111a94)
    at website-9d2528066d59e0ac.wasm.console_error_panic_hook::hook::h8fa472b839e50b60 (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[6182]:0x1cfddc)
    at website-9d2528066d59e0ac.wasm.core::ops::function::Fn::call::hab788c02fab1c1da (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[5454]:0x1c5331)
    at website-9d2528066d59e0ac.wasm.std::panicking::rust_panic_with_hook::hc276d0501ad5b954 (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[2278]:0x165a07)
    at website-9d2528066d59e0ac.wasm.std::panicking::begin_panic_handler::{{closure}}::h23ff416a921468b4 (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[3096]:0x18ab29)
    at website-9d2528066d59e0ac.wasm.std::sys::backtrace::__rust_end_short_backtrace::h16ab72765b32282d (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[7398]:0x1db5ec)
    at website-9d2528066d59e0ac.wasm.__rustc[4794b31dd7191200]::rust_begin_unwind (http://localhost:8080/website-41e08a225213f301_bg.wasm:wasm-function[6769]:0x1d72a0)

@junkdog junkdog marked this pull request as draft July 24, 2025 20:15
@junkdog
Copy link
Collaborator Author

junkdog commented Jul 26, 2025

  • active mouse selection must trigger redraw

copied from demo2:

▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄███▄▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▄███████▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▄█████████▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀████████████▄▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀███████████▀▀▀▀▄▄██████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀███▀▄█▀▀████████▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄▄▄▀▄████████████▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀████████████████▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀███▀██████████▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▄▀▀▄▀▀▀█████████▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▄▀ ▄  ▀▄▀█████████▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▄▀  ▀▀    ▀▄▀███████▄▄▄▀▀▀▀
▀▀▀▀▀▄▀      ▄▄    ▀▄▀█████████▀▀▀
▀▀▀▄▀         ▀▀     ▀▄▀██▀▀▀███▀▀
▀▀█                    ▀▄▀▀▀▄██▀▀▀
▀▀▀▀▄                    ▀▄▀█▀▀▀▀▀

@junkdog
Copy link
Collaborator Author

junkdog commented Jul 26, 2025

i need to push a new beamterm version before removing the draft status

@orhun
Copy link
Owner

orhun commented Aug 2, 2025

How is this looking?

@junkdog
Copy link
Collaborator Author

junkdog commented Aug 3, 2025

How is this looking?

the above mentioned bugs/panics are fixed on dev, but i haven't released yet because i noticed the font selection for non-normal font variants is off. (you can see it in exabind by toggling the modifier keys: 1, 2, 3, 4).

i'll release it once font generation is working as expected; which is sometime during the coming week (guesstimate).

@junkdog
Copy link
Collaborator Author

junkdog commented Aug 14, 2025

i released beamterm 0.6.0, so no more panics in non-release modes + fixed some font rendering issues, so no more blockers

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good!

junkdog and others added 2 commits September 24, 2025 22:13
Co-authored-by: Orhun Parmaksız <[email protected]>
Co-authored-by: Orhun Parmaksız <[email protected]>
@orhun
Copy link
Owner

orhun commented Sep 25, 2025

ship it :)

@junkdog junkdog changed the title WebGl2Backend: update beamterm feat(backend): update WebGl2Backend integration Sep 25, 2025
@junkdog junkdog merged commit d72116d into orhun:main Sep 25, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants