summaryrefslogtreecommitdiff
path: root/src/terminal.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal.go')
-rw-r--r--src/terminal.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/terminal.go b/src/terminal.go
index f3f5298b..7e179bea 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -291,6 +291,8 @@ type Terminal struct {
gapLineLen int
wordRubout string
wordNext string
+ subWordRubout string
+ subWordNext string
cx int
cy int
offset int
@@ -512,6 +514,7 @@ const (
actBackwardDeleteChar
actBackwardDeleteCharEof
actBackwardWord
+ actBackwardSubWord
actCancel
actChangeBorderLabel
@@ -541,12 +544,15 @@ const (
actFatal
actForwardChar
actForwardWord
+ actForwardSubWord
actKillLine
actKillWord
+ actKillSubWord
actUnixLineDiscard
actUnixWordRubout
actYank
actBackwardKillWord
+ actBackwardKillSubWord
actSelectAll
actDeselectAll
actToggle
@@ -937,6 +943,8 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
}
wordRubout := "[^\\pL\\pN][\\pL\\pN]"
wordNext := "[\\pL\\pN][^\\pL\\pN]|(.$)"
+ subWordRubout := "[a-z][A-Z]|[^\\pL\\pN][\\pL\\pN]"
+ subWordNext := "[a-z][A-Z]|[\\pL\\pN][^\\pL\\pN]|(.$)"
if opts.FileWord {
sep := regexp.QuoteMeta(string(os.PathSeparator))
wordRubout = fmt.Sprintf("%s[^%s]", sep, sep)
@@ -970,6 +978,8 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
markerMultiLine: *opts.MarkerMulti,
wordRubout: wordRubout,
wordNext: wordNext,
+ subWordRubout: subWordRubout,
+ subWordNext: subWordNext,
cx: len(input),
cy: 0,
offset: 0,
@@ -6021,6 +6031,11 @@ func (t *Terminal) Loop() error {
if t.cx > 0 {
t.rubout(t.wordRubout)
}
+ case actBackwardKillSubWord:
+ beof = len(t.input) == 0
+ if t.cx > 0 {
+ t.rubout(t.subWordRubout)
+ }
case actYank:
suffix := copySlice(t.input[t.cx:])
t.input = append(append(t.input[:t.cx], t.yanked...), suffix...)
@@ -6132,6 +6147,10 @@ func (t *Terminal) Loop() error {
t.cx = findLastMatch(t.wordRubout, string(t.input[:t.cx])) + 1
case actForwardWord:
t.cx += findFirstMatch(t.wordNext, string(t.input[t.cx:])) + 1
+ case actBackwardSubWord:
+ t.cx = findLastMatch(t.subWordRubout, string(t.input[:t.cx])) + 1
+ case actForwardSubWord:
+ t.cx += findFirstMatch(t.subWordNext, string(t.input[t.cx:])) + 1
case actKillWord:
ncx := t.cx +
findFirstMatch(t.wordNext, string(t.input[t.cx:])) + 1
@@ -6139,6 +6158,13 @@ func (t *Terminal) Loop() error {
t.yanked = copySlice(t.input[t.cx:ncx])
t.input = append(t.input[:t.cx], t.input[ncx:]...)
}
+ case actKillSubWord:
+ ncx := t.cx +
+ findFirstMatch(t.subWordNext, string(t.input[t.cx:])) + 1
+ if ncx > t.cx {
+ t.yanked = copySlice(t.input[t.cx:ncx])
+ t.input = append(t.input[:t.cx], t.input[ncx:]...)
+ }
case actKillLine:
if t.cx < len(t.input) {
t.yanked = copySlice(t.input[t.cx:])