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/classes/bitflags.html | 2 +- docs/examples/compat.lua.html | 2 +- docs/examples/flag_debugging.lua.html | 2 +- docs/examples/password_input.lua.html | 2 +- docs/examples/read.lua.html | 2 +- docs/examples/readline.lua.html | 10 +++++++--- docs/examples/spinner.lua.html | 2 +- docs/examples/spiral_snake.lua.html | 2 +- docs/examples/terminalsize.lua.html | 2 +- docs/index.html | 2 +- docs/modules/system.html | 31 +++++++++++++++++++++---------- docs/topics/01-introduction.md.html | 2 +- docs/topics/02-development.md.html | 2 +- docs/topics/03-terminal.md.html | 10 +++++----- docs/topics/CHANGELOG.md.html | 13 ++++++++++++- docs/topics/LICENSE.md.html | 4 ++-- 16 files changed, 58 insertions(+), 32 deletions(-) (limited to 'docs') diff --git a/docs/classes/bitflags.html b/docs/classes/bitflags.html index 4ed5aaf..dc682f2 100644 --- a/docs/classes/bitflags.html +++ b/docs/classes/bitflags.html @@ -298,7 +298,7 @@ return false if the flags are checked.
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/compat.lua.html b/docs/examples/compat.lua.html index b887c91..42928b0 100644 --- a/docs/examples/compat.lua.html +++ b/docs/examples/compat.lua.html @@ -112,7 +112,7 @@
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/flag_debugging.lua.html b/docs/examples/flag_debugging.lua.html index 8fcf0a9..862cd96 100644 --- a/docs/examples/flag_debugging.lua.html +++ b/docs/examples/flag_debugging.lua.html @@ -80,7 +80,7 @@
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/password_input.lua.html b/docs/examples/password_input.lua.html index f29e429..cf27497 100644 --- a/docs/examples/password_input.lua.html +++ b/docs/examples/password_input.lua.html @@ -132,7 +132,7 @@ useful for reading secrets from the user.
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/read.lua.html b/docs/examples/read.lua.html index 1d6bb3e..2ffcf1b 100644 --- a/docs/examples/read.lua.html +++ b/docs/examples/read.lua.html @@ -143,7 +143,7 @@ sys.setnonblock(io
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
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
diff --git a/docs/examples/spinner.lua.html b/docs/examples/spinner.lua.html index b56f1ed..ea992e3 100644 --- a/docs/examples/spinner.lua.html +++ b/docs/examples/spinner.lua.html @@ -137,7 +137,7 @@ sys.setnonblock(io
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/spiral_snake.lua.html b/docs/examples/spiral_snake.lua.html index 961f506..1f0d582 100644 --- a/docs/examples/spiral_snake.lua.html +++ b/docs/examples/spiral_snake.lua.html @@ -145,7 +145,7 @@ codes for moving the cursor around.
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/examples/terminalsize.lua.html b/docs/examples/terminalsize.lua.html index c01a3d3..a8bb42b 100644 --- a/docs/examples/terminalsize.lua.html +++ b/docs/examples/terminalsize.lua.html @@ -110,7 +110,7 @@ sys.tcsetattr(io.
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/index.html b/docs/index.html index 1ddd617..9ca0c42 100644 --- a/docs/index.html +++ b/docs/index.html @@ -142,7 +142,7 @@
generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
diff --git a/docs/modules/system.html b/docs/modules/system.html index ec077d8..093fd8b 100644 --- a/docs/modules/system.html +++ b/docs/modules/system.html @@ -152,12 +152,12 @@ Debug function for terminal flags (Posix). - readansi (timeout) + readansi (timeout[, fsleep=system.sleep]) Reads a single key, if it is the start of ansi escape sequence then it reads the full sequence. - readkey (timeout) + readkey (timeout[, fsleep=system.sleep]) Reads a single byte from the console, with a timeout. @@ -353,7 +353,8 @@ Windows, setting an empty string, will also delete the variable)
Generate random bytes. -This uses CryptGenRandom() on Windows, and /dev/urandom on other platforms. It will return the +This uses BCryptGenRandom() on Windows, getrandom() on Linux, arc4random_buf on BSD, +and /dev/urandom on other platforms. It will return the requested number of bytes, or an error, never a partial result. @@ -728,12 +729,12 @@ system.listconsoleflags(
- readansi (timeout) + readansi (timeout[, fsleep=system.sleep])
Reads a single key, if it is the start of ansi escape sequence then it reads the full sequence. The key can be a multi-byte string in case of multibyte UTF-8 character. - This function uses system.readkey, and hence system.sleep to wait until either a key is + This function uses system.readkey, and hence fsleep to wait until either a key is available or the timeout is reached. It returns immediately if a key is available or if timeout is less than or equal to 0. In case of an ANSI sequence, it will return the full sequence as a string. @@ -745,6 +746,11 @@ system.listconsoleflags( number the timeout in seconds. +
  • fsleep + function + the function to call for sleeping. + (default system.sleep) +
  • Returns:

    @@ -775,11 +781,11 @@ system.listconsoleflags(
    - readkey (timeout) + readkey (timeout[, fsleep=system.sleep])
    Reads a single byte from the console, with a timeout. - This function uses system.sleep to wait until either a byte is available or the timeout is reached. + This function uses fsleep to wait until either a byte is available or the timeout is reached. The sleep period is exponentially backing off, starting at 0.0125 seconds, with a maximum of 0.2 seconds. It returns immediately if a byte is available or if timeout is less than or equal to 0.

    @@ -793,6 +799,11 @@ system.listconsoleflags( number the timeout in seconds. +
  • fsleep + function + the function to call for sleeping. + (default system.sleep) +
  • Returns:

    @@ -1261,8 +1272,8 @@ flags for the iflags, oflags, and lflags

    Parameters:

    • utf8_char - string - the utf8 character to check, only the width of the first character will be returned + string or int + the utf8 character, or unicode codepoint, to check, only the width of the first character will be returned
    @@ -1411,7 +1422,7 @@ This function will sleep, without doing a busy-loop and wasting CPU cycles.
    generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
    diff --git a/docs/topics/01-introduction.md.html b/docs/topics/01-introduction.md.html index 5b5f07d..cf8a21f 100644 --- a/docs/topics/01-introduction.md.html +++ b/docs/topics/01-introduction.md.html @@ -84,7 +84,7 @@ independence.

    generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
    diff --git a/docs/topics/02-development.md.html b/docs/topics/02-development.md.html index b305201..b9f79fd 100644 --- a/docs/topics/02-development.md.html +++ b/docs/topics/02-development.md.html @@ -84,7 +84,7 @@ pass locally, and do not rely on CI only.

    generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
    diff --git a/docs/topics/03-terminal.md.html b/docs/topics/03-terminal.md.html index 6471a30..8c45d6e 100644 --- a/docs/topics/03-terminal.md.html +++ b/docs/topics/03-terminal.md.html @@ -202,10 +202,10 @@ sys.tcsetattr(io. sys.setnonblock(io.stdin, true) -

    Both functions require a timeout to be provided which allows for proper asynchronous -code to be written. Since the underlying sleep method used is system.sleep, just patching -that function with a coroutine based yielding one should be all that is needed to make -the result work with asynchroneous coroutine schedulers.

    +

    Both readkey and readansi require a timeout to be provided which allows for proper asynchronous +code to be written. The underlying sleep method to use can be provided, and defaults to system.sleep. +Just passing a coroutine enabled sleep method should be all that is needed to make +the result work with asynchroneous coroutine schedulers. Alternatively just patch system.sleep.

    3.3.2 Blocking input

    @@ -218,7 +218,7 @@ For an example see examples/
    generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
    diff --git a/docs/topics/CHANGELOG.md.html b/docs/topics/CHANGELOG.md.html index 8567695..fd3ba59 100644 --- a/docs/topics/CHANGELOG.md.html +++ b/docs/topics/CHANGELOG.md.html @@ -107,6 +107,17 @@

    Version history

    +

    unreleased

    + +
      +
    • Feat: when detecting character display width, also accept unicode codepoints (integers), + since the Lua utf8 library returns codepoints, not strings
    • +
    • Feat: allow passing in a sleep function to readkey and readansi
    • +
    • Fix: NetBSD fix compilation, undeclared directives
    • +
    • Refactor: random bytes; remove deprecated API usage on Windows, move to + binary api instead of /dev/urandom file on linux and bsd
    • +
    +

    version 0.4.5, released 18-Dec-2024

      @@ -183,7 +194,7 @@
      generated by LDoc 1.5.0 -Last updated 2024-12-18 02:50:03 +Last updated 2025-03-02 19:43:40
      diff --git a/docs/topics/LICENSE.md.html b/docs/topics/LICENSE.md.html index 1fe8797..bbe229e 100644 --- a/docs/topics/LICENSE.md.html +++ b/docs/topics/LICENSE.md.html @@ -69,7 +69,7 @@

      MIT License

      Copyright (c) 2016-2024, Oscar Lim

      -

      Copyright (c) 2024, the luasystem project authors.

      +

      Copyright (c) 2024-2025, the luasystem project authors.

      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -94,7 +94,7 @@ SOFTWARE.

      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