mirror of
https://github.com/Hilbis/Hilbish
synced 2025-05-13 15:53:23 +00:00
Compare commits
1 Commits
51a8258e47
...
f6b3ed6407
Author | SHA1 | Date | |
---|---|---|---|
f6b3ed6407 |
@ -1,13 +1,5 @@
|
|||||||
# 🎀 Changelog
|
# 🎀 Changelog
|
||||||
|
|
||||||
## [2.2.3] - 2024-04-27
|
|
||||||
### Fixed
|
|
||||||
- Highligher and hinter work now, since it was regressed from the previous minor release.
|
|
||||||
- `cat` command no longer prints extra newline at end of each file
|
|
||||||
|
|
||||||
### Added
|
|
||||||
- `cat` command now reads files in chunks, allowing for reading large files
|
|
||||||
|
|
||||||
## [2.2.2] - 2024-04-16
|
## [2.2.2] - 2024-04-16
|
||||||
### Fixed
|
### Fixed
|
||||||
- Line refresh fixes (less flicker)
|
- Line refresh fixes (less flicker)
|
||||||
|
11
api.go
11
api.go
@ -712,14 +712,5 @@ func hlhinter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
|||||||
// #example
|
// #example
|
||||||
// #param line string
|
// #param line string
|
||||||
func hlhighlighter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
func hlhighlighter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
|
||||||
if err := c.Check1Arg(); err != nil {
|
return c.Next(), nil
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
line, err := c.StringArg(0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.PushingNext1(t.Runtime, rt.StringValue(line)), nil
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,6 @@ commander.register('cat', function(args, sinks)
|
|||||||
usage: cat [file]...]]
|
usage: cat [file]...]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local chunkSize = 2^13 -- 8K buffer size
|
|
||||||
|
|
||||||
for _, fName in ipairs(args) do
|
for _, fName in ipairs(args) do
|
||||||
local f = io.open(fName)
|
local f = io.open(fName)
|
||||||
if f == nil then
|
if f == nil then
|
||||||
@ -19,11 +17,7 @@ usage: cat [file]...]]
|
|||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
sinks.out:writeln(f:read '*a')
|
||||||
local block = f:read(chunkSize)
|
|
||||||
if not block then break end
|
|
||||||
sinks.out:write(block)
|
|
||||||
end
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
io.flush()
|
io.flush()
|
||||||
|
@ -271,15 +271,6 @@ end
|
|||||||
function Greenhouse:input(char)
|
function Greenhouse:input(char)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function read()
|
|
||||||
terminal.saveState()
|
|
||||||
terminal.setRaw()
|
|
||||||
local c = hilbish.editor.readChar()
|
|
||||||
|
|
||||||
terminal.restoreState()
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
|
|
||||||
function Greenhouse:initUi()
|
function Greenhouse:initUi()
|
||||||
local ansikit = require 'ansikit'
|
local ansikit = require 'ansikit'
|
||||||
local bait = require 'bait'
|
local bait = require 'bait'
|
||||||
@ -289,17 +280,14 @@ function Greenhouse:initUi()
|
|||||||
local Page = require 'nature.greenhouse.page'
|
local Page = require 'nature.greenhouse.page'
|
||||||
local done = false
|
local done = false
|
||||||
|
|
||||||
local function sigint()
|
bait.catch('signal.sigint', function()
|
||||||
ansikit.clear()
|
ansikit.clear()
|
||||||
done = true
|
done = true
|
||||||
end
|
end)
|
||||||
|
|
||||||
local function resize()
|
bait.catch('signal.resize', function()
|
||||||
self:update()
|
self:update()
|
||||||
end
|
end)
|
||||||
bait.catch('signal.sigint', sigint)
|
|
||||||
|
|
||||||
bait.catch('signal.resize', resize)
|
|
||||||
|
|
||||||
ansikit.screenAlt()
|
ansikit.screenAlt()
|
||||||
ansikit.clear(true)
|
ansikit.clear(true)
|
||||||
@ -323,10 +311,15 @@ function Greenhouse:initUi()
|
|||||||
|
|
||||||
ansikit.showCursor()
|
ansikit.showCursor()
|
||||||
ansikit.screenMain()
|
ansikit.screenMain()
|
||||||
|
end
|
||||||
|
|
||||||
self = nil
|
function read()
|
||||||
bait.release('signal.sigint', sigint)
|
terminal.saveState()
|
||||||
bait.release('signal.resize', resize)
|
terminal.setRaw()
|
||||||
|
local c = hilbish.editor.readChar()
|
||||||
|
|
||||||
|
terminal.restoreState()
|
||||||
|
return c
|
||||||
end
|
end
|
||||||
|
|
||||||
return Greenhouse
|
return Greenhouse
|
||||||
|
13
rl.go
13
rl.go
@ -70,8 +70,11 @@ func newLineReader(prompt string, noHist bool) *lineReader {
|
|||||||
hooks.Emit("hilbish.vimAction", actionStr, args)
|
hooks.Emit("hilbish.vimAction", actionStr, args)
|
||||||
}
|
}
|
||||||
rl.HintText = func(line []rune, pos int) []rune {
|
rl.HintText = func(line []rune, pos int) []rune {
|
||||||
hinter := hshMod.Get(rt.StringValue("hinter"))
|
if hinter == nil {
|
||||||
retVal, err := rt.Call1(l.MainThread(), hinter,
|
return []rune{}
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal, err := rt.Call1(l.MainThread(), rt.FunctionValue(hinter),
|
||||||
rt.StringValue(string(line)), rt.IntValue(int64(pos)))
|
rt.StringValue(string(line)), rt.IntValue(int64(pos)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@ -86,8 +89,10 @@ func newLineReader(prompt string, noHist bool) *lineReader {
|
|||||||
return []rune(hintText)
|
return []rune(hintText)
|
||||||
}
|
}
|
||||||
rl.SyntaxHighlighter = func(line []rune) string {
|
rl.SyntaxHighlighter = func(line []rune) string {
|
||||||
highlighter := hshMod.Get(rt.StringValue("highlighter"))
|
if highlighter == nil {
|
||||||
retVal, err := rt.Call1(l.MainThread(), highlighter,
|
return string(line)
|
||||||
|
}
|
||||||
|
retVal, err := rt.Call1(l.MainThread(), rt.FunctionValue(highlighter),
|
||||||
rt.StringValue(string(line)))
|
rt.StringValue(string(line)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user