Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some emojis move entire line upwards when rendered at bottom of terminal #679

Closed
ghost opened this issue Jan 30, 2024 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Jan 30, 2024

I noticed an issue when rendering certain emojis using SetContent. It works fine, unless the Emoji is on the bottom row of the terminal, in which case it moves the whole line upwards.

Tested in Alacritty, Kitty and xfce-terminal and it happens in all of them so I don't think it's terminal specific.

Running the code below, you would expect the bottom line to contain an emoji, then the letter T, but they will be 1 line up instead.

package main

import (
    "github.com/gdamore/tcell/v2"
    //"time"
)

func main() {
    s, err := tcell.NewScreen()
    if err != nil {
        panic(err)
    }
    s.Init()
    defStyle := tcell.StyleDefault.Background(tcell.ColorReset).Foreground(tcell.ColorReset)
    s.SetStyle(defStyle)
    
    termWidth, termHeight := s.Size()
    _, _ = termWidth, termHeight
    
    s.SetContent(4, termHeight-1, 'T', nil, defStyle)
    s.SetContent(1, termHeight-1, '🥹', []rune{' '}, defStyle)
    
    
    for {
        s.Show()
        // Poll event
        ev := s.PollEvent()
        // Process event
        switch ev := ev.(type) {
        case *tcell.EventResize:
            s.Sync()
        case *tcell.EventKey:
            if ev.Key() == tcell.KeyEscape || ev.Key() == tcell.KeyCtrlC {
                s.Fini()
                return
            }
        }
        
    }
}

This is what it looks like:
wrong

@gdamore
Copy link
Owner

gdamore commented Feb 16, 2024

I think this is caused by a defect in our hack for the automargin bug. We try to insert the last character in a way that won't cause the automatic margin to scroll. Unfortunately this hack doesn't seem to have properly accounted for the extra space/offset used by full width characters.

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

No branches or pull requests

1 participant