Add word selection with double click

This commit is contained in:
Zachary Yedidia
2016-03-28 08:43:08 -04:00
parent 4d9e45bfca
commit a6764a04bc
5 changed files with 127 additions and 26 deletions

View File

@@ -456,14 +456,19 @@ func (v *View) HandleEvent(event tcell.Event) {
if v.doubleClick {
// Triple click
v.lastClickTime = time.Now()
v.tripleClick = true
v.doubleClick = false
v.cursor.SelectLine()
} else {
// Double click
v.lastClickTime = time.Now()
v.doubleClick = true
v.tripleClick = false
v.lastClickTime = time.Now()
v.cursor.SelectWord()
}
} else {
v.doubleClick = false
@@ -478,7 +483,7 @@ func (v *View) HandleEvent(event tcell.Event) {
if v.tripleClick {
v.cursor.AddLineToSelection()
} else if v.doubleClick {
v.cursor.AddWordToSelection()
} else {
v.cursor.curSelection[1] = v.cursor.Loc()
}