MousePress is the event that should happen when a normal click happens This is almost always bound to left click
(e *tcell.EventMouse)
| 57 | // MousePress is the event that should happen when a normal click happens |
| 58 | // This is almost always bound to left click |
| 59 | func (h *BufPane) MousePress(e *tcell.EventMouse) bool { |
| 60 | b := h.Buf |
| 61 | mx, my := e.Position() |
| 62 | // ignore click on the status line |
| 63 | if my >= h.BufView().Y+h.BufView().Height { |
| 64 | return false |
| 65 | } |
| 66 | mouseLoc := h.LocFromVisual(buffer.Loc{mx, my}) |
| 67 | h.Cursor.Loc = mouseLoc |
| 68 | |
| 69 | if b.NumCursors() > 1 { |
| 70 | b.ClearCursors() |
| 71 | h.Relocate() |
| 72 | h.Cursor = h.Buf.GetActiveCursor() |
| 73 | h.Cursor.Loc = mouseLoc |
| 74 | } |
| 75 | if time.Since(h.lastClickTime)/time.Millisecond < config.DoubleClickThreshold && (mouseLoc.X == h.lastLoc.X && mouseLoc.Y == h.lastLoc.Y) { |
| 76 | if h.DoubleClick { |
| 77 | // Triple click |
| 78 | h.lastClickTime = time.Now() |
| 79 | |
| 80 | h.TripleClick = true |
| 81 | h.DoubleClick = false |
| 82 | |
| 83 | h.Cursor.SelectLine() |
| 84 | h.Cursor.CopySelection(clipboard.PrimaryReg) |
| 85 | } else { |
| 86 | // Double click |
| 87 | h.lastClickTime = time.Now() |
| 88 | |
| 89 | h.DoubleClick = true |
| 90 | h.TripleClick = false |
| 91 | |
| 92 | h.Cursor.SelectWord() |
| 93 | h.Cursor.CopySelection(clipboard.PrimaryReg) |
| 94 | } |
| 95 | } else { |
| 96 | h.DoubleClick = false |
| 97 | h.TripleClick = false |
| 98 | h.lastClickTime = time.Now() |
| 99 | |
| 100 | h.Cursor.OrigSelection[0] = h.Cursor.Loc |
| 101 | h.Cursor.CurSelection[0] = h.Cursor.Loc |
| 102 | h.Cursor.CurSelection[1] = h.Cursor.Loc |
| 103 | } |
| 104 | |
| 105 | h.Cursor.StoreVisualX() |
| 106 | h.lastLoc = mouseLoc |
| 107 | h.Relocate() |
| 108 | return true |
| 109 | } |
| 110 | |
| 111 | func (h *BufPane) MouseDrag(e *tcell.EventMouse) bool { |
| 112 | mx, my := e.Position() |
nothing calls this directly
no test coverage detected