Compare commits

..

6 Commits

Author SHA1 Message Date
TorchedSammy e367eeb19d
chore: merge from master branch 2022-10-10 18:20:08 -04:00
TorchedSammy b4ca5bfda3
fix(readline): put cursor at end of text when exiting editor 2022-10-10 18:19:24 -04:00
TorchedSammy 308e257872
fix(readline): take into account newlines when calculating amount of lines taken up by input
this does not really fix the issue of multiline input
being broken completely, but prevents the prompt
being reprinted on input
2022-10-10 18:17:58 -04:00
TorchedSammy 7db2a2c826
fix: check if there is cmd input before attempting to add to history (closes #206) 2022-10-10 18:11:09 -04:00
TorchedSammy 22f6ea8a3e
docs: remove getting started from readme toc 2022-10-10 17:34:08 -04:00
TorchedSammy 91596fa81c
docs: document drop in windows support 2022-10-10 17:33:36 -04:00
5 changed files with 22 additions and 12 deletions

View File

@ -2,6 +2,8 @@
## 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,7 +31,6 @@ 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
@ -42,6 +41,10 @@ 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

@ -1,5 +1,6 @@
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,6 +1,10 @@
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:
// it should coordinate reprinting the input line, any Infos and completions
@ -52,19 +56,19 @@ func (rl *Instance) updateReferences() {
rl.posY = 0
rl.fullY = 0
var fullLine, cPosLine int
var curLine []rune
if len(rl.currentComp) > 0 {
fullLine = getWidth(rl.lineComp)
cPosLine = getWidth(rl.lineComp[:rl.pos])
curLine = rl.lineComp
} else {
fullLine = getWidth(rl.line)
cPosLine = getWidth(rl.line[:rl.pos])
curLine = rl.line
}
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
rl.fullY = fullOffset + strings.Count(string(curLine), "\n")
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
if prev > len(rl.line) {
rl.pos = len(rl.line) - 1
rl.pos = len(rl.line)
/*if prev > len(rl.line) {
} else {
rl.pos = prev
}
}*/
case 'w':
// If we were not yanking