diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-10 12:21:17 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-10 12:21:17 +0900 |
commit | 188c90bf2564adcade3eb283ecf72fa74b7dc6dd (patch) | |
tree | 822dcf0d44d3e4be0e107ed2743cb7c87ff08c35 /src/terminal.go | |
parent | 8b02ae650c99b3fffe9c572e96ada007cc1ccad5 (diff) |
Fix incorrect behaviors of mouse events when --multi enabled
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/terminal.go b/src/terminal.go index 7b83a475..73bf396a 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -416,14 +416,6 @@ func (t *Terminal) Loop() { t.mutex.Lock() previousInput := t.input events := []EventType{REQ_PROMPT} - toggle := func() { - item := t.merger.Get(t.listIndex(t.cy)) - if _, found := t.selected[item.text]; !found { - t.selected[item.text] = item.origText - } else { - delete(t.selected, item.text) - } - } req := func(evts ...EventType) { for _, event := range evts { events = append(events, event) @@ -432,6 +424,18 @@ func (t *Terminal) Loop() { } } } + toggle := func() { + idx := t.listIndex(t.cy) + if idx < t.merger.Length() { + item := t.merger.Get(idx) + if _, found := t.selected[item.text]; !found { + t.selected[item.text] = item.origText + } else { + delete(t.selected, item.text) + } + req(REQ_INFO) + } + } switch event.Type { case C.INVALID: t.mutex.Unlock() @@ -463,13 +467,13 @@ func (t *Terminal) Loop() { if t.multi && t.merger.Length() > 0 { toggle() t.vmove(-1) - req(REQ_LIST, REQ_INFO) + req(REQ_LIST) } case C.BTAB: if t.multi && t.merger.Length() > 0 { toggle() t.vmove(1) - req(REQ_LIST, REQ_INFO) + req(REQ_LIST) } case C.CTRL_J, C.CTRL_N: t.vmove(-1) @@ -529,11 +533,13 @@ func (t *Terminal) Loop() { } if me.S != 0 { // Scroll - if me.Mod { - toggle() + if t.merger.Length() > 0 { + if t.multi && me.Mod { + toggle() + } + t.vmove(me.S) + req(REQ_LIST) } - t.vmove(me.S) - req(REQ_LIST) } else if me.Double { // Double-click if my >= 2 { @@ -547,7 +553,7 @@ func (t *Terminal) Loop() { } else if my >= 2 { // List t.cy = t.offset + my - 2 - if me.Mod { + if t.multi && me.Mod { toggle() } req(REQ_LIST) |