This commit is contained in:
Junegunn Choi 2015-08-02 13:06:15 +09:00
parent dea60b11bc
commit 634670e3ea
7 changed files with 14 additions and 12 deletions

View File

@ -8,7 +8,7 @@ import (
const ( const (
// Current version // Current version
Version = "0.10.1" version = "0.10.1"
// Core // Core
coordinatorDelayMax time.Duration = 100 * time.Millisecond coordinatorDelayMax time.Duration = 100 * time.Millisecond

View File

@ -55,7 +55,7 @@ func Run(opts *Options) {
rankTiebreak = opts.Tiebreak rankTiebreak = opts.Tiebreak
if opts.Version { if opts.Version {
fmt.Println(Version) fmt.Println(version)
os.Exit(0) os.Exit(0)
} }

View File

@ -7,6 +7,7 @@ import (
"strings" "strings"
) )
// History struct represents input history
type History struct { type History struct {
path string path string
lines []string lines []string
@ -15,6 +16,7 @@ type History struct {
cursor int cursor int
} }
// NewHistory returns the pointer to a new History struct
func NewHistory(path string, maxSize int) (*History, error) { func NewHistory(path string, maxSize int) (*History, error) {
fmtError := func(e error) error { fmtError := func(e error) error {
if os.IsPermission(e) { if os.IsPermission(e) {

View File

@ -96,7 +96,7 @@ func (m *Matcher) Loop() {
} }
if !cancelled { if !cancelled {
if merger.Cacheable() { if merger.cacheable() {
m.mergerCache[patternString] = merger m.mergerCache[patternString] = merger
} }
merger.final = request.final merger.final = request.final

View File

@ -82,7 +82,7 @@ func (mg *Merger) Get(idx int) *Item {
panic(fmt.Sprintf("Index out of bounds (unsorted, %d/%d)", idx, mg.count)) panic(fmt.Sprintf("Index out of bounds (unsorted, %d/%d)", idx, mg.count))
} }
func (mg *Merger) Cacheable() bool { func (mg *Merger) cacheable() bool {
return mg.count < mergerCacheMax return mg.count < mergerCacheMax
} }

View File

@ -513,7 +513,7 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
case "delete-char": case "delete-char":
keymap[key] = actDeleteChar keymap[key] = actDeleteChar
case "delete-char/eof": case "delete-char/eof":
keymap[key] = actDeleteCharEof keymap[key] = actDeleteCharEOF
case "end-of-line": case "end-of-line":
keymap[key] = actEndOfLine keymap[key] = actEndOfLine
case "cancel": case "cancel":

View File

@ -106,7 +106,7 @@ const (
actCancel actCancel
actClearScreen actClearScreen
actDeleteChar actDeleteChar
actDeleteCharEof actDeleteCharEOF
actEndOfLine actEndOfLine
actForwardChar actForwardChar
actForwardWord actForwardWord
@ -141,7 +141,7 @@ func defaultKeymap() map[int]actionType {
keymap[C.CtrlG] = actAbort keymap[C.CtrlG] = actAbort
keymap[C.CtrlQ] = actAbort keymap[C.CtrlQ] = actAbort
keymap[C.ESC] = actAbort keymap[C.ESC] = actAbort
keymap[C.CtrlD] = actDeleteCharEof keymap[C.CtrlD] = actDeleteCharEOF
keymap[C.CtrlE] = actEndOfLine keymap[C.CtrlE] = actEndOfLine
keymap[C.CtrlF] = actForwardChar keymap[C.CtrlF] = actForwardChar
keymap[C.CtrlH] = actBackwardDeleteChar keymap[C.CtrlH] = actBackwardDeleteChar
@ -436,7 +436,7 @@ func (t *Terminal) printHeader() {
} }
line := idx + 2 line := idx + 2
if t.inlineInfo { if t.inlineInfo {
line -= 1 line--
} }
if line >= max { if line >= max {
continue continue
@ -462,7 +462,7 @@ func (t *Terminal) printList() {
for i := 0; i < maxy; i++ { for i := 0; i < maxy; i++ {
line := i + 2 + len(t.header) line := i + 2 + len(t.header)
if t.inlineInfo { if t.inlineInfo {
line -= 1 line--
} }
t.move(line, 0, true) t.move(line, 0, true)
if i < count { if i < count {
@ -862,7 +862,7 @@ func (t *Terminal) Loop() {
req(reqQuit) req(reqQuit)
case actDeleteChar: case actDeleteChar:
t.delChar() t.delChar()
case actDeleteCharEof: case actDeleteCharEOF:
if !t.delChar() && t.cx == 0 { if !t.delChar() && t.cx == 0 {
req(reqQuit) req(reqQuit)
} }
@ -1013,7 +1013,7 @@ func (t *Terminal) Loop() {
} }
min := 2 + len(t.header) min := 2 + len(t.header)
if t.inlineInfo { if t.inlineInfo {
min -= 1 min--
} }
if me.Double { if me.Double {
// Double-click // Double-click
@ -1099,7 +1099,7 @@ func (t *Terminal) vset(o int) bool {
func (t *Terminal) maxItems() int { func (t *Terminal) maxItems() int {
max := t.maxHeight() - 2 - len(t.header) max := t.maxHeight() - 2 - len(t.header)
if t.inlineInfo { if t.inlineInfo {
max += 1 max++
} }
return util.Max(max, 0) return util.Max(max, 0)
} }