Tachikoma does not compute the correct textwidth for characters with zero width #28

Closed
opened 2026-03-26 12:49:16 -07:00 by ronisbr · 3 comments
ronisbr commented 2026-03-26 12:49:16 -07:00 (Migrated from github.com)

Hi!

If I try to render this string:

        --- n = 2 ---
        --- ṅ = 2 ---
        --- n̈ = 2 ---

I get the following in Tachikoma.jl:

Image

Notice that the equal signs are note aligned. This is caused because Tachikoma.jl is considering the dot and double dot as additional characters (see the empty space after n).

The MWE is:

using Tachikoma
@tachikoma_app

Base.@kwdef mutable struct Dummy <: Model
    quit::Bool = false
end

should_quit(m::Dummy) = m.quit

function update!(m::Dummy, evt::KeyEvent)
    if evt.key == :char
        if evt.char == 'q'
            m.quit = true
        end
    end

    return nothing
end

function view(m::Dummy, f::Frame)
    buf = f.buffer
    area = f.area

    blk = Block(title = "Dummy")
    inner = render(blk, area, buf)

    p = Paragraph("""
        --- n = 2 ---
        --- ṅ = 2 ---
        --- n̈ = 2 ---"""
    )

    render(p, inner, buf)

    return nothing
end

app(Dummy())
Hi! If I try to render this string: ``` --- n = 2 --- --- ṅ = 2 --- --- n̈ = 2 --- ``` I get the following in Tachikoma.jl: <img width="853" height="592" alt="Image" src="https://github.com/user-attachments/assets/902fd37a-5090-4195-9e9f-efad86e9043d" /> Notice that the equal signs are note aligned. This is caused because Tachikoma.jl is considering the dot and double dot as additional characters (see the empty space after `n`). The MWE is: ```julia using Tachikoma @tachikoma_app Base.@kwdef mutable struct Dummy <: Model quit::Bool = false end should_quit(m::Dummy) = m.quit function update!(m::Dummy, evt::KeyEvent) if evt.key == :char if evt.char == 'q' m.quit = true end end return nothing end function view(m::Dummy, f::Frame) buf = f.buffer area = f.area blk = Block(title = "Dummy") inner = render(blk, area, buf) p = Paragraph(""" --- n = 2 --- --- ṅ = 2 --- --- n̈ = 2 ---""" ) render(p, inner, buf) return nothing end app(Dummy()) ```
ronisbr commented 2026-03-26 12:55:37 -07:00 (Migrated from github.com)

The problem is because Tachikoma.jl cell system consider that each cell is a character:

struct Cell
    char::Char
    style::Style
end

and the buffer is a vector of characters:

mutable struct Buffer
    area::Rect
    content::Vector{Cell}
end

Hence, for those characters with zero width, it will advance the display by one row. I have no idea what is the best way to fix this.

The problem is because Tachikoma.jl cell system consider that each cell is a character: ```julia struct Cell char::Char style::Style end ``` and the buffer is a vector of characters: ```julia mutable struct Buffer area::Rect content::Vector{Cell} end ``` Hence, for those characters with zero width, it will advance the display by one row. I have no idea what is the best way to fix this.
kahliburke commented 2026-03-27 04:38:21 -07:00 (Migrated from github.com)

@ronisbr Thank you for the detailed writeup on this, I will address it soon.

@ronisbr Thank you for the detailed writeup on this, I will address it soon.
ronisbr commented 2026-03-27 05:21:32 -07:00 (Migrated from github.com)

I might have a working implementation where we add a String to each cell to store the suffix. I just testing if anything breaks and if we have a huge slowdown. If not, I will submit a PR soon.

I might have a working implementation where we add a `String` to each cell to store the suffix. I just testing if anything breaks and if we have a huge slowdown. If not, I will submit a PR soon.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kahliburke/Tachikoma.jl#28
No description provided.