v.Cursor.Right()
} else {
for key, action := range bindings {
- if e.Key() == key {
- relocate = action(v)
- for _, pl := range loadedPlugins {
- funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
- err := Call(pl + "_on" + funcName[len(funcName)-1])
- if err != nil {
- TermMessage(err)
+ if e.Key() == key.keyCode {
+ if e.Modifiers() == key.modifiers {
+ relocate = action(v)
+ for _, pl := range loadedPlugins {
+ funcName := strings.Split(runtime.FuncForPC(reflect.ValueOf(action).Pointer()).Name(), ".")
+ err := Call(pl + "_on" + funcName[len(funcName)-1])
+ if err != nil {
+ TermMessage(err)
+ }
}
}
}
x, y := e.Position()
x -= v.lineNumOffset - v.leftCol
y += v.Topline
+ // Don't relocate for mouse events
+ relocate = false
button := e.Buttons()
switch button {
case tcell.Button1:
// Left click
- if v.mouseReleased && !e.HasMotion() {
+ if v.mouseReleased {
v.MoveToMouseClick(x, y)
if time.Since(v.lastClickTime)/time.Millisecond < doubleClickThreshold {
if v.doubleClick {
}
v.mouseReleased = true
}
- // We don't want to relocate because otherwise the view will be relocated
- // every time the user moves the cursor
- relocate = false
case tcell.WheelUp:
// Scroll up
scrollSpeed := int(settings["scrollSpeed"].(float64))
v.ScrollUp(scrollSpeed)
- // We don't want to relocate if the user is scrolling
- relocate = false
case tcell.WheelDown:
// Scroll down
scrollSpeed := int(settings["scrollSpeed"].(float64))
v.ScrollDown(scrollSpeed)
- // We don't want to relocate if the user is scrolling
- relocate = false
}
}
if style, ok := colorscheme["indent-char"]; ok {
lineIndentStyle = style
}
+ if v.Cursor.HasSelection() &&
+ (charNum >= v.Cursor.curSelection[0] && charNum < v.Cursor.curSelection[1] ||
+ charNum < v.Cursor.curSelection[0] && charNum >= v.Cursor.curSelection[1]) {
+
+ lineIndentStyle = tcell.StyleDefault.Reverse(true)
+
+ if style, ok := colorscheme["selection"]; ok {
+ lineIndentStyle = style
+ }
+ }
indentChar := []rune(settings["indentchar"].(string))
- screen.SetContent(x+tabchars, lineN, indentChar[0], nil, lineIndentStyle)
+ screen.SetContent(x-v.leftCol+tabchars, lineN, indentChar[0], nil, lineIndentStyle)
tabSize := int(settings["tabsize"].(float64))
for i := 0; i < tabSize-1; i++ {
tabchars++