Compare commits

..

No commits in common. "91222f9d747c7dea2bd43a550db530a01ad0c5c7" and "0113a4e0b45675106b5c9028c1a0512963173671" have entirely different histories.

8 changed files with 8 additions and 31 deletions

2
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "libs/lunacolors"] [submodule "libs/lunacolors"]
path = libs/lunacolors path = libs/lunacolors
url = https://github.com/Rosettea/Lunacolors url = https://github.com/Hilbis/Lunacolors
[submodule "libs/succulent"] [submodule "libs/succulent"]
path = libs/succulent path = libs/succulent
url = https://github.com/Rosettea/Succulent url = https://github.com/Rosettea/Succulent

View File

@ -3,7 +3,7 @@ local lunacolors = require 'lunacolors'
local bait = require 'bait' local bait = require 'bait'
local ansikit = require 'ansikit' local ansikit = require 'ansikit'
local function doPrompt(fail) local function doPrompt(fail, mode)
hilbish.prompt(lunacolors.format( hilbish.prompt(lunacolors.format(
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '' '{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. ''
)) ))
@ -23,4 +23,6 @@ bait.catch('hilbish.vimMode', function(mode)
else else
ansikit.cursorStyle(ansikit.lineCursor) ansikit.cursorStyle(ansikit.lineCursor)
end end
doPrompt(false, mode)
end) end)

View File

@ -1,7 +1,3 @@
+ `hilbish.exit` > Sent when Hilbish is about to exit. + `hilbish.exit` > Sent when Hilbish is about to exit.
+ `hilbish.vimMode` -> modeName > Sent when Hilbish's Vim mode is changed (example insert to normal mode), + `hilbish.vimMode` > Sent when Hilbish's Vim mode is changed (example insert to normal mode)
`modeName` is the name of the mode changed to (can be `insert`, `normal`, `delete` or `replace`).
+ `hilbish.vimAction` -> actionName, args > Sent when the user does a "vim action," being something
like yanking or pasting text. See `doc vimMode actions` for more info.

@ -1 +1 @@
Subproject commit 5a59d0f4543eb982593750c52f7393e2fd2d15f9 Subproject commit d200fca13df1c47e133b269420223d7e257dbc41

View File

@ -180,7 +180,6 @@ type Instance struct {
mutex sync.Mutex mutex sync.Mutex
ViModeCallback func(ViMode) ViModeCallback func(ViMode)
ViActionCallback func(ViAction, []string)
} }
// NewInstance is used to create a readline instance and initialise it with sane defaults. // NewInstance is used to create a readline instance and initialise it with sane defaults.

View File

@ -214,7 +214,7 @@ func (rl *Instance) Readline() (string, error) {
if rl.InputMode == Vim { if rl.InputMode == Vim {
if rl.modeViMode == VimInsert { if rl.modeViMode == VimInsert {
rl.backspace() rl.backspace()
} else if rl.pos != 0 { } else {
rl.pos-- rl.pos--
} }
rl.renderHelpers() rl.renderHelpers()

View File

@ -33,12 +33,6 @@ var (
VimKeysStr = "[N]" VimKeysStr = "[N]"
) )
type ViAction int
const (
VimActionYank = iota
VimActionPaste
)
var ( var (
// registerFreeKeys - Some Vim keys don't act on/ aren't affected by registers, // registerFreeKeys - Some Vim keys don't act on/ aren't affected by registers,
// and using these keys will automatically cancel any active register. // and using these keys will automatically cancel any active register.
@ -53,7 +47,6 @@ var (
// have been moved away, and only the rl.pos is adjusted: when echoing the input line, the shell // have been moved away, and only the rl.pos is adjusted: when echoing the input line, the shell
// will compute the new cursor pos accordingly. // will compute the new cursor pos accordingly.
func (rl *Instance) vi(r rune) { func (rl *Instance) vi(r rune) {
activeRegister := string(rl.registers.currentRegister)
// Check if we are in register mode. If yes, and for some characters, // Check if we are in register mode. If yes, and for some characters,
// we select the register and exit this func immediately. // we select the register and exit this func immediately.
@ -201,11 +194,10 @@ func (rl *Instance) vi(r rune) {
case 'p': case 'p':
// paste after the cursor position // paste after the cursor position
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
rl.pos++ rl.pos += 2
buffer := rl.pasteFromRegister() buffer := rl.pasteFromRegister()
vii := rl.getViIterations() vii := rl.getViIterations()
rl.ViActionCallback(VimActionPaste, []string{activeRegister, string(buffer)})
for i := 1; i <= vii; i++ { for i := 1; i <= vii; i++ {
rl.insert(buffer) rl.insert(buffer)
} }
@ -216,7 +208,6 @@ func (rl *Instance) vi(r rune) {
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
buffer := rl.pasteFromRegister() buffer := rl.pasteFromRegister()
vii := rl.getViIterations() vii := rl.getViIterations()
rl.ViActionCallback(VimActionPaste, []string{activeRegister, string(buffer)})
for i := 1; i <= vii; i++ { for i := 1; i <= vii; i++ {
rl.insert(buffer) rl.insert(buffer)
} }
@ -320,7 +311,6 @@ func (rl *Instance) vi(r rune) {
case 'y': case 'y':
if rl.viIsYanking { if rl.viIsYanking {
rl.ViActionCallback(VimActionYank, []string{activeRegister, string(rl.line)})
rl.saveBufToRegister(rl.line) rl.saveBufToRegister(rl.line)
rl.viIsYanking = false rl.viIsYanking = false
} }
@ -328,7 +318,6 @@ func (rl *Instance) vi(r rune) {
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true
case 'Y': case 'Y':
rl.ViActionCallback(VimActionYank, []string{activeRegister, string(rl.line)})
rl.saveBufToRegister(rl.line) rl.saveBufToRegister(rl.line)
rl.viUndoSkipAppend = true rl.viUndoSkipAppend = true

9
rl.go
View File

@ -36,14 +36,6 @@ func newLineReader(prompt string, noHist bool) *lineReader {
} }
setVimMode(modeStr) setVimMode(modeStr)
} }
rl.ViActionCallback = func(action readline.ViAction, args []string) {
actionStr := ""
switch action {
case readline.VimActionPaste: actionStr = "paste"
case readline.VimActionYank: actionStr = "yank"
}
hooks.Em.Emit("hilbish.vimAction", actionStr, args)
}
rl.TabCompleter = func(line []rune, pos int, _ readline.DelayedTabContext) (string, []*readline.CompletionGroup) { rl.TabCompleter = func(line []rune, pos int, _ readline.DelayedTabContext) (string, []*readline.CompletionGroup) {
ctx := string(line) ctx := string(line)
var completions []string var completions []string
@ -200,7 +192,6 @@ func (lr *lineReader) SetPrompt(p string) {
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0] lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} else { } else {
lr.rl.Multiline = false lr.rl.Multiline = false
lr.rl.MultilinePrompt = ""
lr.rl.SetPrompt(p) lr.rl.SetPrompt(p)
} }
if initialized && !running { if initialized && !running {