Compare commits

..

No commits in common. "117a4580b46615c62eb7319e0dfbdf37fbc695ec" and "e5c8e5eaffae28099c8b83db4fef501a899d23a4" have entirely different histories.

8 changed files with 23 additions and 39 deletions

View File

@ -2,8 +2,6 @@
## Unreleased
**NOTE:** Hilbish now uses [Task] insead of Make for builds.
Windows support is also now at a lower tier; The only thing guaranteed is
Hilbish *compiling* on Windows.
[Task]: https://taskfile.dev/#/

View File

@ -31,6 +31,7 @@ and aims to be infinitely configurable. If something isn't, open an issue!
- [AUR](#AUR)
- [Nixpkgs](#Nixpkgs)
- [Manual Build](#Manual-Build)
- [Getting Started](#Getting-Started)
- [Contributing](#Contributing)
# Screenshots
@ -41,10 +42,6 @@ and aims to be infinitely configurable. If something isn't, open an issue!
</div>
# Installation
**NOTE:** Hilbish is not guaranteed to work properly on Windows, starting
from the 2.0 version. It will still be able to compile, but functionality
may be lacking.
## Prebuilt binaries
Go [here](https://nightly.link/Rosettea/Hilbish/workflows/build/master) for
builds on the master branch.

View File

@ -13,13 +13,13 @@ vars:
tasks:
default:
cmds:
- CGO_ENABLED=0 go build {{.GOFLAGS}}
- go build {{.GOFLAGS}}
vars:
GOFLAGS: '-ldflags "-s -w -X main.gitCommit=$(git rev-parse --short HEAD) -X main.gitBranch=$(git rev-parse --abbrev-ref HEAD)"'
build:
cmds:
- CGO_ENABLED=0 go build {{.GOFLAGS}}
- go build {{.GOFLAGS}}
install:
cmds:

22
api.go
View File

@ -250,27 +250,21 @@ func hlcwd(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
}
// read(prompt?) -> input?
// read(prompt) -> input?
// Read input from the user, using Hilbish's line editor/input reader.
// This is a separate instance from the one Hilbish actually uses.
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
// --- @param prompt string
func hlread(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
luaprompt := c.Arg(0)
if typ := luaprompt.Type(); typ != rt.StringType && typ != rt.NilType {
return nil, errors.New("expected #1 to be a string")
if err := c.Check1Arg(); err != nil {
return nil, err
}
prompt, ok := luaprompt.TryString()
if !ok {
// if we are here and `luaprompt` is not a string, it's nil
// substitute with an empty string
prompt = ""
luaprompt, err := c.StringArg(0)
if err != nil {
return nil, err
}
lualr := &lineReader{
rl: readline.NewInstance(),
}
lualr.SetPrompt(prompt)
lualr := newLineReader("", true)
lualr.SetPrompt(luaprompt)
input, err := lualr.Read()
if err != nil {

View File

@ -41,7 +41,7 @@ These will be formatted and replaced with the appropriate values.
`%u` - Name of current user
`%h` - Hostname of device
read(prompt?) -> input? > Read input from the user, using Hilbish's line editor/input reader.
read(prompt) -> input? > Read input from the user, using Hilbish's line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)

View File

@ -1,6 +1,5 @@
local bait = require 'bait'
bait.catch('command.exit', function(_, cmd, priv)
if not cmd then return end
if not priv and hilbish.opts.history then hilbish.history.add(cmd) end
end)

View File

@ -1,10 +1,6 @@
package readline
import (
"strings"
"golang.org/x/text/width"
)
import "golang.org/x/text/width"
// updateHelpers is a key part of the whole refresh process:
// it should coordinate reprinting the input line, any Infos and completions
@ -56,19 +52,19 @@ func (rl *Instance) updateReferences() {
rl.posY = 0
rl.fullY = 0
var curLine []rune
var fullLine, cPosLine int
if len(rl.currentComp) > 0 {
curLine = rl.lineComp
fullLine = getWidth(rl.lineComp)
cPosLine = getWidth(rl.lineComp[:rl.pos])
} else {
curLine = rl.line
fullLine = getWidth(rl.line)
cPosLine = getWidth(rl.line[:rl.pos])
}
fullLine := getWidth(curLine)
cPosLine := getWidth(curLine[:rl.pos])
// We need the X offset of the whole line
toEndLine := rl.promptLen + fullLine
fullOffset := toEndLine / GetTermWidth()
rl.fullY = fullOffset + strings.Count(string(curLine), "\n")
rl.fullY = fullOffset
fullRest := toEndLine % GetTermWidth()
rl.fullX = fullRest

View File

@ -245,7 +245,7 @@ func (rl *Instance) vi(r rune) {
}
// Keep the previous cursor position
//prev := rl.pos
prev := rl.pos
new, err := rl.StartEditorWithBuffer(multiline, "")
if err != nil || len(new) == 0 || string(new) == string(multiline) {
@ -257,11 +257,11 @@ func (rl *Instance) vi(r rune) {
// Clean the shell and put the new buffer, with adjusted pos if needed.
rl.clearLine()
rl.line = new
rl.pos = len(rl.line)
/*if prev > len(rl.line) {
if prev > len(rl.line) {
rl.pos = len(rl.line) - 1
} else {
rl.pos = prev
}*/
}
case 'w':
// If we were not yanking