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"]
path = libs/lunacolors
url = https://github.com/Rosettea/Lunacolors
url = https://github.com/Hilbis/Lunacolors
[submodule "libs/succulent"]
path = libs/succulent
url = https://github.com/Rosettea/Succulent

View File

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

View File

@ -1,7 +1,3 @@
+ `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),
`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.
+ `hilbish.vimMode` > Sent when Hilbish's Vim mode is changed (example insert to normal mode)

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

View File

@ -180,7 +180,6 @@ type Instance struct {
mutex sync.Mutex
ViModeCallback func(ViMode)
ViActionCallback func(ViAction, []string)
}
// 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.modeViMode == VimInsert {
rl.backspace()
} else if rl.pos != 0 {
} else {
rl.pos--
}
rl.renderHelpers()

View File

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

9
rl.go
View File

@ -36,14 +36,6 @@ func newLineReader(prompt string, noHist bool) *lineReader {
}
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) {
ctx := string(line)
var completions []string
@ -200,7 +192,6 @@ func (lr *lineReader) SetPrompt(p string) {
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} else {
lr.rl.Multiline = false
lr.rl.MultilinePrompt = ""
lr.rl.SetPrompt(p)
}
if initialized && !running {