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

Unicode: Fix wide runes in various szenarios #3516

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions internal/display/bufwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,9 @@ func (w *BufWindow) displayBuffer() {
for _, r := range word {
draw(r.r, r.combc, r.style, true, true)

// Draw any extra characters either spaces for tabs or @ for incomplete wide runes
// Draw space for incomplete wide runes
if r.width > 1 {
char := ' '
if r.r != '\t' {
char = '@'
}

for i := 1; i < r.width; i++ {
draw(char, nil, r.style, true, false)
}
Expand Down
13 changes: 2 additions & 11 deletions internal/display/infowindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,7 @@ func (i *InfoWindow) displayBuffer() {

}

rw := runewidth.RuneWidth(r)
for j := 0; j < rw; j++ {
c := r
if j > 0 {
c = ' '
combc = nil
}
screen.SetContent(vlocX, i.Y, c, combc, style)
}
screen.SetContent(vlocX, i.Y, r, combc, style)
vlocX++
}
nColsBeforeStart--
Expand All @@ -153,13 +145,12 @@ func (i *InfoWindow) displayBuffer() {
width = ts
default:
width = runewidth.RuneWidth(r)
char = '@'
}

blocX++
line = line[size:]

// Draw any extra characters either spaces for tabs or @ for incomplete wide runes
// Draw space for incomplete wide runes
if width > 1 {
for j := 1; j < width; j++ {
draw(char, nil, i.defStyle())
Expand Down
16 changes: 8 additions & 8 deletions internal/display/tabwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package display

import (
runewidth "github.com/mattn/go-runewidth"
"github.com/zyedidia/tcell/v2"
"github.com/zyedidia/micro/v2/internal/buffer"
"github.com/zyedidia/micro/v2/internal/config"
"github.com/zyedidia/micro/v2/internal/screen"
"github.com/zyedidia/micro/v2/internal/util"
"github.com/zyedidia/tcell/v2"
)

type TabWindow struct {
Expand Down Expand Up @@ -112,10 +112,10 @@ func (w *TabWindow) Display() {
}
return tabBarStyle, tabBarActiveStyle
}

draw := func(r rune, n int, active bool, reversed bool) {
tabBarStyle, tabBarActiveStyle := reverseStyles(reversed)

style := tabBarStyle
if active {
style = tabBarActiveStyle
Expand All @@ -124,7 +124,7 @@ func (w *TabWindow) Display() {
rw := runewidth.RuneWidth(r)
for j := 0; j < rw; j++ {
c := r
if j > 0 {
if x+rw-j >= w.Width {
c = ' '
}
if x == w.Width-1 && !done {
Expand All @@ -147,23 +147,23 @@ func (w *TabWindow) Display() {
} else {
draw(' ', 1, false, tabCharHighlight)
}

for _, c := range n {
draw(c, 1, i == w.active, tabCharHighlight)
}

if i == len(w.Names)-1 {
done = true
}

if i == w.active {
draw(']', 1, true, tabCharHighlight)
draw(' ', 2, true, globalTabReverse)
} else {
draw(' ', 1, false, tabCharHighlight)
draw(' ', 2, false, globalTabReverse)
}

if x >= w.Width {
break
}
Expand Down