mirror of https://github.com/Hilbis/Hilbish
Compare commits
7 Commits
0113a4e0b4
...
91222f9d74
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 91222f9d74 | |
TorchedSammy | feb2ea18fb | |
TorchedSammy | 726d265cca | |
TorchedSammy | 7d9c7ddf18 | |
TorchedSammy | 5e505d0a8d | |
TorchedSammy | e5b6a2586b | |
TorchedSammy | c5dd05bb1e |
|
@ -1,6 +1,6 @@
|
|||
[submodule "libs/lunacolors"]
|
||||
path = libs/lunacolors
|
||||
url = https://github.com/Hilbis/Lunacolors
|
||||
url = https://github.com/Rosettea/Lunacolors
|
||||
[submodule "libs/succulent"]
|
||||
path = libs/succulent
|
||||
url = https://github.com/Rosettea/Succulent
|
||||
|
|
|
@ -3,7 +3,7 @@ local lunacolors = require 'lunacolors'
|
|||
local bait = require 'bait'
|
||||
local ansikit = require 'ansikit'
|
||||
|
||||
local function doPrompt(fail, mode)
|
||||
local function doPrompt(fail)
|
||||
hilbish.prompt(lunacolors.format(
|
||||
'{blue}%u {cyan}%d ' .. (fail and '{red}' or '{green}') .. '∆ '
|
||||
))
|
||||
|
@ -23,6 +23,4 @@ bait.catch('hilbish.vimMode', function(mode)
|
|||
else
|
||||
ansikit.cursorStyle(ansikit.lineCursor)
|
||||
end
|
||||
|
||||
doPrompt(false, mode)
|
||||
end)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
+ `hilbish.exit` > Sent when Hilbish is about to exit.
|
||||
|
||||
+ `hilbish.vimMode` > Sent when Hilbish's Vim mode is changed (example insert to normal mode)
|
||||
+ `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.
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d200fca13df1c47e133b269420223d7e257dbc41
|
||||
Subproject commit 5a59d0f4543eb982593750c52f7393e2fd2d15f9
|
|
@ -180,6 +180,7 @@ 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.
|
||||
|
|
|
@ -214,7 +214,7 @@ func (rl *Instance) Readline() (string, error) {
|
|||
if rl.InputMode == Vim {
|
||||
if rl.modeViMode == VimInsert {
|
||||
rl.backspace()
|
||||
} else {
|
||||
} else if rl.pos != 0 {
|
||||
rl.pos--
|
||||
}
|
||||
rl.renderHelpers()
|
||||
|
|
|
@ -33,6 +33,12 @@ 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.
|
||||
|
@ -47,6 +53,7 @@ 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.
|
||||
|
@ -194,10 +201,11 @@ func (rl *Instance) vi(r rune) {
|
|||
case 'p':
|
||||
// paste after the cursor position
|
||||
rl.viUndoSkipAppend = true
|
||||
rl.pos += 2
|
||||
rl.pos++
|
||||
|
||||
buffer := rl.pasteFromRegister()
|
||||
vii := rl.getViIterations()
|
||||
rl.ViActionCallback(VimActionPaste, []string{activeRegister, string(buffer)})
|
||||
for i := 1; i <= vii; i++ {
|
||||
rl.insert(buffer)
|
||||
}
|
||||
|
@ -208,6 +216,7 @@ 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)
|
||||
}
|
||||
|
@ -311,6 +320,7 @@ 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
|
||||
}
|
||||
|
@ -318,6 +328,7 @@ 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
9
rl.go
|
@ -36,6 +36,14 @@ 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
|
||||
|
@ -192,6 +200,7 @@ 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 {
|
||||
|
|
Loading…
Reference in New Issue