-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix bug in utf8 editing & set cursor #103
Conversation
module github.com/awesome-gocui/gocui | ||
module github.com/aynakeya/gocui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you restore this change?
@@ -183,7 +205,7 @@ func (v *View) moveCursor(dx, dy int) { | |||
if newX > len(line) { | |||
if dy == 0 && newY+1 < len(v.lines) { | |||
newY++ | |||
// line = v.lines[newY] // Uncomment if adding code that uses line | |||
//line = v.lines[newY] // Uncomment if adding code that uses line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you restore this change?
newX, newY := v.cx+dx, v.cy+dy | ||
// If newY is more than all lines set it to the last line | ||
if newY >= len(v.lines) { | ||
newY = len(v.lines) - 1 | ||
} | ||
if newY < 0 { | ||
newY = 0 | ||
} | ||
if dx != 0 { | ||
line := v.lines[newY] | ||
col := 0 | ||
for index, _ := range line { | ||
col += runewidth.RuneWidth(line[index].chr) | ||
if newX <= col && dx >= 0 { | ||
dx = runewidth.RuneWidth(line[index].chr) | ||
break | ||
} | ||
if newX < col && dx < 0 { | ||
dx = -runewidth.RuneWidth(line[index].chr) | ||
break | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to what this is doing?
for i := 1; i < w; i++ { | ||
v.lines[y][x+i] = cell{ | ||
fgColor: v.FgColor, | ||
bgColor: v.BgColor, | ||
chr: '\x00', | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to what this is doing?
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/gdamore/tcell/v2 v2.0.0 | ||
github.com/mattn/go-runewidth v0.0.9 | ||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this change
@@ -6,7 +6,6 @@ package gocui | |||
|
|||
import ( | |||
"errors" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you restore this change
v.moveCursor(dx, dy) | ||
v.gui.userEvents <- userEvent{func(g *Gui) error { return nil }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this line?
sry i forget to create a new branch. gonna create a new pull request again. |
Fix problem with delete, insert, cursor move when editing utf8 runes.
Related: jroimartin#74 jesseduffield#10