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

Unexpected blank area #291

Open
GavinGuan24 opened this issue Jul 17, 2019 · 7 comments
Open

Unexpected blank area #291

GavinGuan24 opened this issue Jul 17, 2019 · 7 comments
Labels

Comments

@GavinGuan24
Copy link

GavinGuan24 commented Jul 17, 2019

call stty -a, show like that 23 rows; 97 columns;

Step 1: I call

screen.SetContent(0, 95, '中', nil, tcell.defaultStyle)
screen.Show()

that's working.

Step 2: I call

screen.SetContent(0, 95, 't', nil, tcell.defaultStyle)
screen.SetContent(0, 96, 'k', nil, tcell.defaultStyle)
screen.Show()

that's working with a bug. the t disappeared !!!
I think you have a bug with handling Double wide character.
It happens on the right edge of the screen.

for avoiding this, I have to call screen.Clear();screen.Show().
This will cause the screen to flicker.
I can't accept this thing.

@gdamore
Copy link
Owner

gdamore commented Aug 5, 2019

It looks like the problem is that the final column isn't handled properly when there are an odd number of columns and using wide characters. Does this problem occur when using a terminal width of 96 or 98 instead of 97?

@gdamore
Copy link
Owner

gdamore commented Aug 5, 2019

I'm actually thinking that I may have made a bogus assumption that wide characters will only occur in an even numbered cell.

@gdamore
Copy link
Owner

gdamore commented Sep 22, 2019

What terminal are you using?

@gdamore
Copy link
Owner

gdamore commented Sep 22, 2019

I've tried to reproduce this unsuccessfully. This was using go in a Windows terminal on both Windows and on WSL (Linux, but still using the Windows terminal).

Here's the code I used:

@gdamore
Copy link
Owner

gdamore commented Sep 22, 2019

package main

import (
	"time"

	"github.com/gdamore/tcell"
)

func main() {

	s, e := tcell.NewScreen()
	if e != nil {
		panic(e.Error())
	}

	if e = s.Init(); e != nil {
		panic(e.Error())
	}

	s.SetStyle(tcell.StyleDefault.
		Foreground(tcell.ColorBlack).
		Background(tcell.ColorWhite))
	s.Clear()

	s.SetContent(0, 0, 'A', nil, tcell.StyleDefault)
	s.SetContent(95, 0, '中', nil, tcell.StyleDefault)
	s.Show()

	time.Sleep(time.Second * 2)
	s.SetContent(95, 0, 't', nil, tcell.StyleDefault)
	s.SetContent(96, 0, 'k', nil, tcell.StyleDefault)
	s.Show()
	time.Sleep(time.Second * 2)

	s.Fini()
}

@gdamore
Copy link
Owner

gdamore commented Sep 22, 2019

You'll note that you had several other bugs in your original post (X and Y mismatched, style settings incorrect, etc.)

I will also note that I tested in both conemu and Windows Terminal. One thing that is a little weird if you put a sleep between the emit of 't' and the emit of 'k' (and a Show() in there too), then conemu attempts to move the Chinese character one space to the right.

The Windows terminal does not properly display the chinese character at all, but instead places a Unicode place holder character there. But it does display the English characters fine, without any problems.

I suspect we're in a problematic area for handling wide characters in the terminals themselves, but without more information there's not much I can do to validate.

@GavinGuan24
Copy link
Author

GavinGuan24 commented Sep 28, 2019

Thanks for your reply. I am so sorry to reply you now.
I'm a Chinese, not good at using English.
And I was coding a TUI frame on my Macbook Pro (early 2015) three months ago.
The product was running on Iterm 2, you can google Item2.

https://github.com/GavinGuan24/gofer
I have forced fix it on [bugfix 20190717], but this is not what I wanna see.

https://github.com/GavinGuan24/gofer/blob/master/gofer/rootView.go (line: 72 ~ 78)

There is enough space on the screen to display those content.
I also follow the logic of Tcell to set the content of each point.
I am not sure if it is Tcell's problem. But the BUG did happen.
I am sure that my code logic here is ok.
Because I checked my code for this bug many several times.

I will describe the process again. Let's say '0' is a pixel, '中' is two pixel.
screen size (1 row × 4 col )
Move '中' to right edge.

step 1
0000

step 2
a中b

step 3
0a中

step 4
00a>

on step 4, '00a>' is what I want to display.
Because you can't use one pixel to show two pixel width characters ('中').
But, in fact, what appears on the screen is '00_>'. ('_' is ASCII code 0x20. yeah, it's SPACE.)
it's a BUG. It happens at the right edge of the screen.
so, I have to check if the original content of the second to last pixel of each line is a double wide character.
And invoke Screen.Clear() and Screen.Show().
'sw' is the width of screen.

        for row := 0; row < sh; row++ {
            _, _, _, width := v.Screen.GetContent(sw-2, row)
            if width > 1 {
                v.Screen.Clear()
                v.Screen.Show()
            }
        }

I hope that my description is clear enough. 😅

You can reproduce this.

step 1
git clone Latest version code of github.com/GavinGuan24/gofer

And comment out these lines.
https://github.com/GavinGuan24/gofer/blob/master/gofer/rootView.go (line: 72 ~ 78)

step 2
edit line 9, Empty = ' ' to Empty = '-'
https://github.com/GavinGuan24/gofer/blob/master/gofer/rune.go

step 3
go run https://github.com/GavinGuan24/gofer/blob/master/demo/view_relationship_test/test.go
type d, move view1 to right edge of screen. you will see that bug.

by the way, Ctrl+q to quit.
'wsad' to move view1
'↑↓←→' to move view2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants