Last active
December 3, 2017 19:33
-
-
Save Kvaz1r/d55c0a9bc6348ed0c5a28ef1a91589de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case gxui.KeyBackspace, gxui.KeyDelete: | |
var edits []input.Edit | |
selections := editor.Controller().Selections() | |
for _, s := range selections { | |
if s.Start() < 0 { | |
continue | |
} | |
edit := input.Edit{ | |
At: s.Start(), | |
Old: ctrl.TextRunes()[s.Start():s.End()], | |
} | |
if s.Start() == s.End() { | |
if ev.Key == gxui.KeyBackspace { | |
if edit.At == 0 { | |
continue | |
} | |
edit.At-- | |
} | |
edit.Old = ctrl.TextRunes()[edit.At : edit.At+1] | |
} | |
edits = append(edits, edit) | |
} | |
if len(selections) == 1 && selections[0].Start() >= 0 { | |
pos := selections[0].Start() | |
e.Apply(focused, edits...) | |
editor.Controller().SetCaret(pos) | |
editor.List.SetScrollOffset(editor.StartOffset()) | |
} else { | |
e.Apply(focused, edits...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment