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