diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2021-03-03 16:42:43 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2021-03-03 16:42:43 +0100 |
commit | e7a4c61b637612aced4f0176ee5120986a22f9cc (patch) | |
tree | 1ff0d1c467c5af9c213c9e03300edfe61459683d /ui/tcell/view.go | |
parent | eddb1c60371d2b2e10bd1952d68a6dec00545e39 (diff) | |
download | poe-e7a4c61b637612aced4f0176ee5120986a22f9cc.tar.gz poe-e7a4c61b637612aced4f0176ee5120986a22f9cc.tar.bz2 poe-e7a4c61b637612aced4f0176ee5120986a22f9cc.zip |
Fix middle click selection.
Diffstat (limited to 'ui/tcell/view.go')
-rw-r--r-- | ui/tcell/view.go | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ui/tcell/view.go b/ui/tcell/view.go index ecd5aa4..73f1453 100644 --- a/ui/tcell/view.go +++ b/ui/tcell/view.go @@ -558,10 +558,10 @@ func RuneWidth(r rune) int { func ButtonSecondary(v *View, mx, my int) { pos := v.XYToOffset(mx, my) - // if we clicked inside a current selection, open that one + // if we clicked outside a current selection, open that one q0, q1 := v.text.Dot() if pos < q0 || pos > q1 || q0 == q1 { - // otherwise, select everything inside surround spaces and open that + // select everything inside surround spaces and open that p := pos - v.text.PrevSpace(pos) n := pos + v.text.NextSpace(pos) v.text.SetDot(p, n) @@ -596,19 +596,21 @@ func ButtonSecondary(v *View, mx, my int) { func ButtonMiddle(v *View, mx, my int) { pos := v.XYToOffset(mx, my) - // if we clicked inside a current selection, run that one + // if we clicked outside a current selection, run that one q0, q1 := v.text.Dot() - if pos >= q0 && pos <= q1 && q0 != q1 { - Cmd(v.text.ReadDot()) - return + if pos < q0 || pos > q1 || q0 == q1 { + // select everything inside surround spaces and run that + p := pos - v.text.PrevSpace(pos) + n := pos + v.text.NextSpace(pos) + v.text.SetDot(p, n) } - // otherwise, select non-space chars under mouse and run that - p := pos - v.text.PrevSpace(pos) - n := pos + v.text.NextSpace(pos) - v.text.SetDot(p, n) - fn := strings.Trim(v.text.ReadDot(), "\n\t ") + str := strings.Trim(v.text.ReadDot(), "\n\t ") v.text.SetDot(q0, q1) - Cmd(fn) + + output := Cmd(str) + if output != "" { + printMsg(output) + } return } |