summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-04-16 14:44:41 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-04-16 14:46:10 +0900
commitd1d59272a2e148e936daff9cefb23cfcaf408848 (patch)
treea6e8a8a2cce03137ecfc3cfee61c9cafc3a41115
parentd08542ce5d4a81c13404311c3d1605654978bd1b (diff)
Add visual indication of --toggle-sort
Close #194
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/core.go5
-rw-r--r--src/terminal.go12
3 files changed, 15 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c3399fd0..e3c58dd9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ CHANGELOG
- Added `--tiebreak` option (#191)
- Added `--no-hscroll` option (#193)
+- Visual indication of `--toggle-sort` (#194)
0.9.8
-----
diff --git a/src/core.go b/src/core.go
index 4a834240..b56fbf64 100644
--- a/src/core.go
+++ b/src/core.go
@@ -195,8 +195,9 @@ func Run(options *Options) {
matcher.Reset(snapshot, terminal.Input(), false, !reading, sort)
case EvtSearchNew:
- if value.(bool) {
- sort = !sort
+ switch val := value.(type) {
+ case bool:
+ sort = val
}
snapshot, _ := chunkList.Snapshot()
matcher.Reset(snapshot, terminal.Input(), true, !reading, sort)
diff --git a/src/terminal.go b/src/terminal.go
index b16daeca..790ccc1b 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -29,6 +29,7 @@ type Terminal struct {
yanked []rune
input []rune
multi bool
+ sort bool
toggleSort int
expect []int
pressed int
@@ -96,6 +97,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
yanked: []rune{},
input: input,
multi: opts.Multi,
+ sort: opts.Sort > 0,
toggleSort: opts.ToggleSort,
expect: opts.Expect,
pressed: 0,
@@ -241,6 +243,13 @@ func (t *Terminal) printInfo() {
t.move(1, 2, false)
output := fmt.Sprintf("%d/%d", t.merger.Length(), t.count)
+ if t.toggleSort > 0 {
+ if t.sort {
+ output += "/S"
+ } else {
+ output += " "
+ }
+ }
if t.multi && len(t.selected) > 0 {
output += fmt.Sprintf(" (%d)", len(t.selected))
}
@@ -579,7 +588,8 @@ func (t *Terminal) Loop() {
}
if t.toggleSort > 0 {
if keyMatch(t.toggleSort, event) {
- t.eventBox.Set(EvtSearchNew, true)
+ t.sort = !t.sort
+ t.eventBox.Set(EvtSearchNew, t.sort)
t.mutex.Unlock()
continue
}