From 9318a7dc9f7def35a2e9d85ccffe63c06950be09 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sun, 2 Mar 2025 19:45:04 +0100 Subject: Release v0.5.0 --- docs/examples/readline.lua.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'docs/examples/readline.lua.html') diff --git a/docs/examples/readline.lua.html b/docs/examples/readline.lua.html index a78f5b3..ba453ad 100644 --- a/docs/examples/readline.lua.html +++ b/docs/examples/readline.lua.html @@ -213,10 +213,12 @@ readline.__index = readline -- @tparam[opt=""] string opts.value the default value -- @tparam[opt=#value] number opts.position of the cursor in the input -- @tparam[opt={"\10"/"\13"}] table opts.exit_keys an array of keys that will cause the readline to exit +-- @tparam[opt=system.sleep] function opts.fsleep the sleep function to use (see system.readansi) -- @treturn readline the new readline object function readline.new(opts) local value = utf8parse(opts.value or "") local prompt = utf8parse(opts.prompt or "") + local fsleep = opts.fsleep or sys.sleep local pos = math.floor(opts.position or (#value + 1)) pos = math.max(math.min(pos, (#value + 1)), 1) local len = math.floor(opts.max_length or 80) @@ -244,6 +246,7 @@ readline.__index = readline position = pos, -- the current position in the input drawn_before = false, -- if the prompt has been drawn exit_keys = exit_keys, -- the keys that will cause the readline to exit + fsleep = fsleep, -- the sleep function to use } setmetatable(self, readline) @@ -482,7 +485,7 @@ readline.__index = readline local timeout_end = sys.gettime() + timeout while true do - local key, keytype = sys.readansi(timeout_end - sys.gettime()) + local key, keytype = sys.readansi(timeout_end - sys.gettime(), self.fsleep) if not key then -- error or timeout return nil, keytype @@ -527,7 +530,8 @@ sys.setconsoleflags(io"Hello, 你-好 World 🚀!", -- position = 2, exit_keys = {key_sequences.enter, "\27", "\t", "\27[Z"}, -- enter, escape, tab, shift-tab -} + fsleep = sys.sleep, +} local result, key = rl() @@ -545,7 +549,7 @@ sys.setconsoleflags(io
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
-- cgit v1.2.3-55-g6feb