mirror of https://github.com/Hilbis/Hilbish
Compare commits
10 Commits
e5c8e5eaff
...
117a4580b4
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 117a4580b4 | |
TorchedSammy | 0db7f96fd7 | |
TorchedSammy | 300248de54 | |
TorchedSammy | 3ee2b03330 | |
TorchedSammy | 3bec2c91a8 | |
TorchedSammy | b4ca5bfda3 | |
TorchedSammy | 308e257872 | |
TorchedSammy | 7db2a2c826 | |
TorchedSammy | 22f6ea8a3e | |
TorchedSammy | 91596fa81c |
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
**NOTE:** Hilbish now uses [Task] insead of Make for builds.
|
**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/#/
|
[Task]: https://taskfile.dev/#/
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ and aims to be infinitely configurable. If something isn't, open an issue!
|
||||||
- [AUR](#AUR)
|
- [AUR](#AUR)
|
||||||
- [Nixpkgs](#Nixpkgs)
|
- [Nixpkgs](#Nixpkgs)
|
||||||
- [Manual Build](#Manual-Build)
|
- [Manual Build](#Manual-Build)
|
||||||
- [Getting Started](#Getting-Started)
|
|
||||||
- [Contributing](#Contributing)
|
- [Contributing](#Contributing)
|
||||||
|
|
||||||
# Screenshots
|
# Screenshots
|
||||||
|
@ -42,6 +41,10 @@ and aims to be infinitely configurable. If something isn't, open an issue!
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
# Installation
|
# 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
|
## Prebuilt binaries
|
||||||
Go [here](https://nightly.link/Rosettea/Hilbish/workflows/build/master) for
|
Go [here](https://nightly.link/Rosettea/Hilbish/workflows/build/master) for
|
||||||
builds on the master branch.
|
builds on the master branch.
|
||||||
|
|
|
@ -13,13 +13,13 @@ vars:
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
default:
|
||||||
cmds:
|
cmds:
|
||||||
- go build {{.GOFLAGS}}
|
- CGO_ENABLED=0 go build {{.GOFLAGS}}
|
||||||
vars:
|
vars:
|
||||||
GOFLAGS: '-ldflags "-s -w -X main.gitCommit=$(git rev-parse --short HEAD) -X main.gitBranch=$(git rev-parse --abbrev-ref HEAD)"'
|
GOFLAGS: '-ldflags "-s -w -X main.gitCommit=$(git rev-parse --short HEAD) -X main.gitBranch=$(git rev-parse --abbrev-ref HEAD)"'
|
||||||
|
|
||||||
build:
|
build:
|
||||||
cmds:
|
cmds:
|
||||||
- go build {{.GOFLAGS}}
|
- CGO_ENABLED=0 go build {{.GOFLAGS}}
|
||||||
|
|
||||||
install:
|
install:
|
||||||
cmds:
|
cmds:
|
||||||
|
|
22
api.go
22
api.go
|
@ -250,21 +250,27 @@ 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.
|
// Read input from the user, using Hilbish's line editor/input reader.
|
||||||
// This is a separate instance from the one Hilbish actually uses.
|
// 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)
|
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||||
// --- @param prompt string
|
// --- @param prompt string
|
||||||
func hlread(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
func hlread(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
if err := c.Check1Arg(); err != nil {
|
luaprompt := c.Arg(0)
|
||||||
return nil, err
|
if typ := luaprompt.Type(); typ != rt.StringType && typ != rt.NilType {
|
||||||
|
return nil, errors.New("expected #1 to be a string")
|
||||||
}
|
}
|
||||||
luaprompt, err := c.StringArg(0)
|
prompt, ok := luaprompt.TryString()
|
||||||
if err != nil {
|
if !ok {
|
||||||
return nil, err
|
// if we are here and `luaprompt` is not a string, it's nil
|
||||||
|
// substitute with an empty string
|
||||||
|
prompt = ""
|
||||||
}
|
}
|
||||||
lualr := newLineReader("", true)
|
|
||||||
lualr.SetPrompt(luaprompt)
|
lualr := &lineReader{
|
||||||
|
rl: readline.NewInstance(),
|
||||||
|
}
|
||||||
|
lualr.SetPrompt(prompt)
|
||||||
|
|
||||||
input, err := lualr.Read()
|
input, err := lualr.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -41,7 +41,7 @@ These will be formatted and replaced with the appropriate values.
|
||||||
`%u` - Name of current user
|
`%u` - Name of current user
|
||||||
`%h` - Hostname of device
|
`%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.
|
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)
|
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
local bait = require 'bait'
|
local bait = require 'bait'
|
||||||
|
|
||||||
bait.catch('command.exit', function(_, cmd, priv)
|
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
|
if not priv and hilbish.opts.history then hilbish.history.add(cmd) end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package readline
|
package readline
|
||||||
|
|
||||||
import "golang.org/x/text/width"
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/text/width"
|
||||||
|
)
|
||||||
|
|
||||||
// updateHelpers is a key part of the whole refresh process:
|
// updateHelpers is a key part of the whole refresh process:
|
||||||
// it should coordinate reprinting the input line, any Infos and completions
|
// it should coordinate reprinting the input line, any Infos and completions
|
||||||
|
@ -52,19 +56,19 @@ func (rl *Instance) updateReferences() {
|
||||||
rl.posY = 0
|
rl.posY = 0
|
||||||
rl.fullY = 0
|
rl.fullY = 0
|
||||||
|
|
||||||
var fullLine, cPosLine int
|
var curLine []rune
|
||||||
if len(rl.currentComp) > 0 {
|
if len(rl.currentComp) > 0 {
|
||||||
fullLine = getWidth(rl.lineComp)
|
curLine = rl.lineComp
|
||||||
cPosLine = getWidth(rl.lineComp[:rl.pos])
|
|
||||||
} else {
|
} else {
|
||||||
fullLine = getWidth(rl.line)
|
curLine = 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
|
// We need the X offset of the whole line
|
||||||
toEndLine := rl.promptLen + fullLine
|
toEndLine := rl.promptLen + fullLine
|
||||||
fullOffset := toEndLine / GetTermWidth()
|
fullOffset := toEndLine / GetTermWidth()
|
||||||
rl.fullY = fullOffset
|
rl.fullY = fullOffset + strings.Count(string(curLine), "\n")
|
||||||
fullRest := toEndLine % GetTermWidth()
|
fullRest := toEndLine % GetTermWidth()
|
||||||
rl.fullX = fullRest
|
rl.fullX = fullRest
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ func (rl *Instance) vi(r rune) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep the previous cursor position
|
// Keep the previous cursor position
|
||||||
prev := rl.pos
|
//prev := rl.pos
|
||||||
|
|
||||||
new, err := rl.StartEditorWithBuffer(multiline, "")
|
new, err := rl.StartEditorWithBuffer(multiline, "")
|
||||||
if err != nil || len(new) == 0 || string(new) == string(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.
|
// Clean the shell and put the new buffer, with adjusted pos if needed.
|
||||||
rl.clearLine()
|
rl.clearLine()
|
||||||
rl.line = new
|
rl.line = new
|
||||||
if prev > len(rl.line) {
|
rl.pos = len(rl.line)
|
||||||
rl.pos = len(rl.line) - 1
|
/*if prev > len(rl.line) {
|
||||||
} else {
|
} else {
|
||||||
rl.pos = prev
|
rl.pos = prev
|
||||||
}
|
}*/
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
// If we were not yanking
|
// If we were not yanking
|
||||||
|
|
Loading…
Reference in New Issue