summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-02-09 21:49:03 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-04-06 19:34:32 +1000
commit6472bda29e52de51bd66d3cbf45e9bef72689649 (patch)
tree4d9e8775839d1d9d70c44b649ff038a38d4c719c /vendor
parentc0cad91cb6825ad7e8e2299f44888a7d9f7863a3 (diff)
bump gocui
Diffstat (limited to 'vendor')
-rw-r--r--vendor/github.com/jesseduffield/gocui/edit.go19
-rw-r--r--vendor/github.com/jesseduffield/gocui/keybinding.go5
-rw-r--r--vendor/github.com/jesseduffield/gocui/tcell_driver.go35
3 files changed, 49 insertions, 10 deletions
diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/vendor/github.com/jesseduffield/gocui/edit.go
index f548ebd76..a47f45c9d 100644
--- a/vendor/github.com/jesseduffield/gocui/edit.go
+++ b/vendor/github.com/jesseduffield/gocui/edit.go
@@ -356,17 +356,18 @@ func (v *View) writeRune(x, y int, ch rune) error {
}
olen := len(v.lines[y])
+ w := runewidth.RuneWidth(ch)
var s []cell
if x >= len(v.lines[y]) {
- s = make([]cell, x-len(v.lines[y])+1)
+ s = make([]cell, x-len(v.lines[y])+w)
} else if !v.Overwrite {
- s = make([]cell, 1)
+ s = make([]cell, w)
}
v.lines[y] = append(v.lines[y], s...)
- if !v.Overwrite || (v.Overwrite && x >= olen-1) {
- copy(v.lines[y][x+1:], v.lines[y][x:])
+ if !v.Overwrite || (v.Overwrite && x >= olen-w) {
+ copy(v.lines[y][x+w:], v.lines[y][x:])
}
v.lines[y][x] = cell{
fgColor: v.FgColor,
@@ -374,6 +375,14 @@ func (v *View) writeRune(x, y int, ch rune) error {
chr: ch,
}
+ for i := 1; i < w; i++ {
+ v.lines[y][x+i] = cell{
+ fgColor: v.FgColor,
+ bgColor: v.BgColor,
+ chr: '\x00',
+ }
+ }
+
return nil
}
@@ -400,7 +409,7 @@ func (v *View) deleteRune(x, y int) (int, error) {
w := runewidth.RuneWidth(v.lines[y][i].chr)
tw += w
if tw > x {
- v.lines[y] = append(v.lines[y][:i], v.lines[y][i+1:]...)
+ v.lines[y] = append(v.lines[y][:i], v.lines[y][i+w:]...)
return w, nil
}
diff --git a/vendor/github.com/jesseduffield/gocui/keybinding.go b/vendor/github.com/jesseduffield/gocui/keybinding.go
index 00bdcd0bf..f9df6993b 100644
--- a/vendor/github.com/jesseduffield/gocui/keybinding.go
+++ b/vendor/github.com/jesseduffield/gocui/keybinding.go
@@ -317,8 +317,9 @@ const (
// Modifiers.
const (
- ModNone Modifier = Modifier(0)
- ModAlt = Modifier(tcell.ModAlt)
+ ModNone Modifier = Modifier(0)
+ ModAlt = Modifier(tcell.ModAlt)
+ ModMotion = Modifier(2) // just picking an arbitrary number here that doesn't clash with tcell.ModAlt
// ModCtrl doesn't work with keyboard keys. Use CtrlKey in Key and ModNone. This is was for mouse clicks only (tcell.v1)
// ModCtrl = Modifier(tcell.ModCtrl)
)
diff --git a/vendor/github.com/jesseduffield/gocui/tcell_driver.go b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
index 2ede319a3..c7e313716 100644
--- a/vendor/github.com/jesseduffield/gocui/tcell_driver.go
+++ b/vendor/github.com/jesseduffield/gocui/tcell_driver.go
@@ -104,9 +104,18 @@ const (
eventRaw
)
+const (
+ NOT_DRAGGING int = iota
+ MAYBE_DRAGGING
+ DRAGGING
+)
+
var (
lastMouseKey tcell.ButtonMask = tcell.ButtonNone
lastMouseMod tcell.ModMask = tcell.ModNone
+ dragState int = NOT_DRAGGING
+ lastX int = 0
+ lastY int = 0
)
// pollEvent get tcell.Event and transform it into gocuiEvent
@@ -172,6 +181,17 @@ func pollEvent() GocuiEvent {
if button != tcell.ButtonNone && lastMouseKey == tcell.ButtonNone {
lastMouseKey = button
lastMouseMod = tev.Modifiers()
+ switch button {
+ case tcell.ButtonPrimary:
+ mouseKey = MouseLeft
+ dragState = MAYBE_DRAGGING
+ lastX = x
+ lastY = y
+ case tcell.ButtonSecondary:
+ mouseKey = MouseRight
+ case tcell.ButtonMiddle:
+ mouseKey = MouseMiddle
+ }
}
switch tev.Buttons() {
@@ -179,11 +199,9 @@ func pollEvent() GocuiEvent {
if lastMouseKey != tcell.ButtonNone {
switch lastMouseKey {
case tcell.ButtonPrimary:
- mouseKey = MouseLeft
+ dragState = NOT_DRAGGING
case tcell.ButtonSecondary:
- mouseKey = MouseRight
case tcell.ButtonMiddle:
- mouseKey = MouseMiddle
}
mouseMod = Modifier(lastMouseMod)
lastMouseMod = tcell.ModNone
@@ -191,6 +209,17 @@ func pollEvent() GocuiEvent {
}
}
+ switch dragState {
+ // if we haven't released the left mouse button and we've moved the cursor then we're dragging
+ case MAYBE_DRAGGING:
+ if x != lastX || y != lastY {
+ dragState = DRAGGING
+ }
+ case DRAGGING:
+ mouseMod = ModMotion
+ mouseKey = MouseLeft
+ }
+
return GocuiEvent{
Type: eventMouse,
MouseX: x,