rename 'hist' to 'history'

This commit is contained in:
Gokcehan 2018-05-16 00:16:49 +03:00
parent 04f1d68d1e
commit d9761d2dc8
5 changed files with 28 additions and 28 deletions

4
app.go
View File

@ -23,8 +23,8 @@ type app struct {
cmd *exec.Cmd cmd *exec.Cmd
cmdIn io.WriteCloser cmdIn io.WriteCloser
cmdOutBuf []byte cmdOutBuf []byte
cmdHist []cmdItem cmdHistory []cmdItem
cmdHistInd int cmdHistoryInd int
} }
func newApp() *app { func newApp() *app {

4
doc.go
View File

@ -57,8 +57,8 @@ keybindings:
cmd-escape (default '<esc>') cmd-escape (default '<esc>')
cmd-complete (default '<tab>') cmd-complete (default '<tab>')
cmd-enter (default '<c-j>' and '<enter>') cmd-enter (default '<c-j>' and '<enter>')
cmd-hist-next (default '<c-n>') cmd-history-next (default '<c-n>')
cmd-hist-prev (default '<c-p>') cmd-history-prev (default '<c-p>')
cmd-delete (default '<c-d>' and '<delete>') cmd-delete (default '<c-d>' and '<delete>')
cmd-delete-back (default '<bs>' and '<bs2>') cmd-delete-back (default '<bs>' and '<bs2>')
cmd-left (default '<c-b>' and '<left>') cmd-left (default '<c-b>' and '<left>')

View File

@ -61,8 +61,8 @@ keybindings:
cmd-escape (default '<esc>') cmd-escape (default '<esc>')
cmd-complete (default '<tab>') cmd-complete (default '<tab>')
cmd-enter (default '<c-j>' and '<enter>') cmd-enter (default '<c-j>' and '<enter>')
cmd-hist-next (default '<c-n>') cmd-history-next (default '<c-n>')
cmd-hist-prev (default '<c-p>') cmd-history-prev (default '<c-p>')
cmd-delete (default '<c-d>' and '<delete>') cmd-delete (default '<c-d>' and '<delete>')
cmd-delete-back (default '<bs>' and '<bs2>') cmd-delete-back (default '<bs>' and '<bs2>')
cmd-left (default '<c-b>' and '<left>') cmd-left (default '<c-b>' and '<left>')

24
eval.go
View File

@ -492,7 +492,7 @@ func (e *callExpr) eval(app *app, args []string) {
case "%": case "%":
log.Printf("shell-pipe: %s", s) log.Printf("shell-pipe: %s", s)
app.runShell(s, nil, app.ui.cmdPrefix) app.runShell(s, nil, app.ui.cmdPrefix)
app.cmdHist = append(app.cmdHist, cmdItem{"%", s}) app.cmdHistory = append(app.cmdHistory, cmdItem{"%", s})
return return
case ">": case ">":
io.WriteString(app.cmdIn, s+"\n") io.WriteString(app.cmdIn, s+"\n")
@ -525,36 +525,36 @@ func (e *callExpr) eval(app *app, args []string) {
default: default:
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix) log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
} }
app.cmdHist = append(app.cmdHist, cmdItem{app.ui.cmdPrefix, s}) app.cmdHistory = append(app.cmdHistory, cmdItem{app.ui.cmdPrefix, s})
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
case "cmd-hist-next": case "cmd-history-next":
if app.ui.cmdPrefix == "" { if app.ui.cmdPrefix == "" {
return return
} }
if app.cmdHistInd > 0 { if app.cmdHistoryInd > 0 {
app.cmdHistInd-- app.cmdHistoryInd--
} }
if app.cmdHistInd == 0 { if app.cmdHistoryInd == 0 {
app.ui.menuBuf = nil app.ui.menuBuf = nil
app.ui.cmdAccLeft = nil app.ui.cmdAccLeft = nil
app.ui.cmdAccRight = nil app.ui.cmdAccRight = nil
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
return return
} }
cmd := app.cmdHist[len(app.cmdHist)-app.cmdHistInd] cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
app.ui.cmdPrefix = cmd.prefix app.ui.cmdPrefix = cmd.prefix
app.ui.cmdAccLeft = []rune(cmd.value) app.ui.cmdAccLeft = []rune(cmd.value)
app.ui.cmdAccRight = nil app.ui.cmdAccRight = nil
app.ui.menuBuf = nil app.ui.menuBuf = nil
case "cmd-hist-prev": case "cmd-history-prev":
if app.ui.cmdPrefix == "" { if app.ui.cmdPrefix == "" {
app.cmdHistInd = 0 app.cmdHistoryInd = 0
} }
if app.cmdHistInd == len(app.cmdHist) { if app.cmdHistoryInd == len(app.cmdHistory) {
return return
} }
app.cmdHistInd++ app.cmdHistoryInd++
cmd := app.cmdHist[len(app.cmdHist)-app.cmdHistInd] cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
app.ui.cmdPrefix = cmd.prefix app.ui.cmdPrefix = cmd.prefix
app.ui.cmdAccLeft = []rune(cmd.value) app.ui.cmdAccLeft = []rune(cmd.value)
app.ui.cmdAccRight = nil app.ui.cmdAccRight = nil

View File

@ -101,8 +101,8 @@ func init() {
gOpts.keys["?"] = &callExpr{"search-back", nil, 1} gOpts.keys["?"] = &callExpr{"search-back", nil, 1}
gOpts.keys["n"] = &callExpr{"search-next", nil, 1} gOpts.keys["n"] = &callExpr{"search-next", nil, 1}
gOpts.keys["N"] = &callExpr{"search-prev", nil, 1} gOpts.keys["N"] = &callExpr{"search-prev", nil, 1}
gOpts.keys["<c-n>"] = &callExpr{"cmd-hist-next", nil, 1} gOpts.keys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1}
gOpts.keys["<c-p>"] = &callExpr{"cmd-hist-prev", nil, 1} gOpts.keys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
gOpts.keys["zh"] = &setExpr{"hidden!", ""} gOpts.keys["zh"] = &setExpr{"hidden!", ""}
gOpts.keys["zr"] = &setExpr{"reverse!", ""} gOpts.keys["zr"] = &setExpr{"reverse!", ""}
@ -122,8 +122,8 @@ func init() {
gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-complete", nil, 1} gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-complete", nil, 1}
gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil, 1}
gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil, 1}
gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-hist-next", nil, 1} gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1}
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-hist-prev", nil, 1} gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1}
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
gOpts.cmdkeys["<bs>"] = &callExpr{"cmd-delete-back", nil, 1} gOpts.cmdkeys["<bs>"] = &callExpr{"cmd-delete-back", nil, 1}