Skip to content

Commit

Permalink
New structure (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber authored Sep 18, 2022
1 parent 4682c4a commit a8ca6dd
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 154 deletions.
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# Highlighter
RichText highlighting Lua code with a pure Lua lexer


Usage:
```Lua
local Highlighter = require(script.Highlighter)

Highlighter(TextLabel) -- Highlights the text in the TextLabel

-- Alternatively
Highlighter.Highlight(TextLabel) -- Identical to just calling
```
Changing Colors:
```Lua
-- Any of the given entries can be left nil for default
Highlighter.UpdateColors({
background = Color3.new(...),
iden = Color3.new(...),
keyword = Color3.new(...),
builtin = Color3.new(...),
string = Color3.new(...),
number = Color3.new(...),
comment = Color3.new(...),
operator = Color3.new(...)
Highlighter.highlight({
-- The object to syntax highlight
textObject: TextLabel | TextBox,
-- The source text for highlighting- defaults to textObject.Text
src: string?,
-- Update even if there are no changes since last highlight
forceUpdate: boolean?,
-- Lexer for tokenizing src, defaults to the bundled Lua lexer
lexer: Lexer?,
})
```
Reset colors to default:

Changing the highlight colors:
```Lua
Highlighter.UpdateColors()
Highlighter.setTokenColors({
tokenName = Color3.new(...),
...
})
-- Automatically triggers Highlighter.refresh() which updates existing highlights to the new colors
```
10 changes: 10 additions & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file lists tools managed by Aftman, a cross-platform toolchain manager.
# For more information, see https://github.com/LPGhatguy/aftman

# To add a new tool, add an entry to this table.
[tools]
rojo = "rojo-rbx/[email protected]"
run-in-roblox = "rojo-rbx/[email protected]"
wally = "upliftgames/[email protected]"
selene = "Kampfkarren/[email protected]"
stylua = "JohnnyMorganz/[email protected]"
6 changes: 0 additions & 6 deletions foreman.toml

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boatbomber/highlighter",
"version": "0.4.7",
"version": "0.5.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit a8ca6dd

Please sign in to comment.