Module colorizer.utils
Provides utility functions for color handling and file operations.
This module contains helper functions for checking byte categories, merging tables, parsing colors, managing file watchers, and handling buffer lines.
Functions
rgb_to_hex (r, g, b) | Returns HEX format from RGB values |
byte_is_alphanumeric (byte) | Checks if a byte represents an alphanumeric character. |
byte_is_hex (byte) | Checks if a byte represents a hexadecimal character. |
get_non_alphanum_keys (tbl) | Extract non-alphanumeric characters to add as a valid index in the Trie |
add_additional_color_chars (chars) | Adds additional characters to the list of valid color characters. |
byte_is_valid_color_char (byte) | Checks if a byte is valid as a color character (alphanumeric, dynamically added chars, or hardcoded characters). |
count (str, pattern) | Count the number of character in a string |
get_last_modified (path) | Get last modified time of a file |
parse_hex (byte) | Parses a hexadecimal byte. |
watch_file (path, callback, ...) | Watch a file for changes and execute callback |
bufme (bufnr) | Validates and returns a buffer number. |
visible_line_range (bufnr) | Returns range of visible lines |
hash_table (tbl) | Returns sha256 hash of lua table |
Functions
- rgb_to_hex (r, g, b)
-
Returns HEX format from RGB values
Parameters:
- r number: Red value
- g number: Green value
- b number: Blue value
- byte_is_alphanumeric (byte)
-
Checks if a byte represents an alphanumeric character.
Parameters:
- byte number The byte to check.
Returns:
-
boolean: `true` if the byte is alphanumeric, otherwise `false`.
- byte_is_hex (byte)
-
Checks if a byte represents a hexadecimal character.
Parameters:
- byte number The byte to check.
Returns:
-
boolean: `true` if the byte is hexadecimal, otherwise `false`.
- get_non_alphanum_keys (tbl)
-
Extract non-alphanumeric characters to add as a valid index in the Trie
Parameters:
- tbl table: The table to extract non-alphanumeric characters from.
Returns:
-
string: The extracted non-alphanumeric characters.
- add_additional_color_chars (chars)
-
Adds additional characters to the list of valid color characters.
Parameters:
- chars string: The additional characters to add.
Returns:
-
boolean: `true` if the characters were added, otherwise `false`.
- byte_is_valid_color_char (byte)
-
Checks if a byte is valid as a color character (alphanumeric, dynamically added chars, or hardcoded characters).
Parameters:
- byte number: The byte to check.
Returns:
-
boolean: `true` if the byte is valid, otherwise `false`.
- count (str, pattern)
-
Count the number of character in a string
Parameters:
- str string
- pattern string
Returns:
-
number
- get_last_modified (path)
-
Get last modified time of a file
Parameters:
- path string: file path
Returns:
-
number|nil: modified time
- parse_hex (byte)
-
Parses a hexadecimal byte.
Parameters:
- byte number The byte to parse.
Returns:
-
number: The parsed hexadecimal value of the byte.
- watch_file (path, callback, ...)
-
Watch a file for changes and execute callback
Parameters:
- path string: File path
- callback function: Callback to execute
- ... table: params for callback
Returns:
-
uv_fs_event_t|nil
- bufme (bufnr)
-
Validates and returns a buffer number.
If the provided buffer number is invalid, defaults to the current buffer.
Parameters:
- bufnr number|nil: The buffer number to validate.
Returns:
-
number: The validated buffer number.
- visible_line_range (bufnr)
-
Returns range of visible lines
Parameters:
- bufnr number: Buffer number
Returns:
-
number, number: Start (0-index) and end (exclusive) range of lines in viewport
- hash_table (tbl)
-
Returns sha256 hash of lua table
Parameters:
- tbl table: Table to be hashed