Customizing Syntax Highlighting Colors
Klive IDE allows you to customize the syntax highlighting colors for each programming language. You can modify token colors by creating simple JSON configuration files in your Klive settings folder.
Token Color Files Location
Create your custom token files in the Klive settings folder:
- macOS/Linux:
~/Klive/ - Windows:
C:\Users\<YourUsername>\Klive\
The Klive settings folder is created automatically when you first run Klive. It’s the same folder where application settings are stored.
Supported Languages
You can customize token colors for these languages:
| Language | File Name |
|---|---|
| Klive Z80 Assembly | kz80-asm.tokens.json |
| 6510 Assembly (C64) | 6510-asm.tokens.json |
| ZX Basic Assembly | zxbasm.tokens.json |
| ZX Basic | zxbas.tokens.json |
| Klive Script | ksx.tokens.json |
| SjASM Plus | sjasmp.tokens.json |
Token File Format
Each token file uses a simple JSON structure with two main sections:
{
"darkTheme": {
"comment": "6a9955",
"keyword": {
"foreground": "569cd6",
"fontStyle": "bold"
},
"identifier": "dcdcaa"
},
"lightTheme": {
"comment": "237122",
"keyword": {
"foreground": "0070c0",
"fontStyle": "bold"
},
"identifier": "795e26"
}
}Token Values
You can specify each token in two ways:
-
Simple string (foreground color only):
"comment": "6a9955" -
Object (with font style):
"keyword": { "foreground": "569cd6", "fontStyle": "bold" }
Color Format
Colors are specified as 6-digit hexadecimal values without the # prefix:
"6a9955"- greenish gray"569cd6"- blue"af00db"- purple
Font Styles
Available font styles:
"bold""italic""underline"- Or combinations:
"bold italic"
Example: Customizing Z80 Assembly Colors
Let’s customize the syntax highlighting for Klive Z80 Assembly:
-
Create a new file called
kz80-asm.tokens.jsonin your Klive settings folder (~/Klive/on macOS/Linux). -
Add the following content:
{
"darkTheme": {
"comment": "6a9955",
"keyword": {
"foreground": "569cd6",
"fontStyle": "bold"
},
"identifier": "dcdcaa",
"register": "9cdcfe"
},
"lightTheme": {
"comment": "237122",
"keyword": {
"foreground": "0070c0",
"fontStyle": "bold"
},
"identifier": "795e26",
"register": "0089ba"
}
}- Save the file and restart Klive IDE.
You must restart Klive IDE for token color changes to take effect.
Common Token Names
Assembly Languages (Z80, 6510, ZXB Assembly, SjASM)
comment- Commentskeyword- CPU instructions (LD, ADD, SUB, etc.)statement- Assembler directives and statementspragma- Pragma directivesidentifier- Labels and identifiersregister- CPU registers (A, B, C, HL, etc.)condition- Condition flags (Z, NZ, C, NC, etc.)function- Built-in functionsmacroparam- Macro parametersescape- Escape sequences in strings
ZX Basic
comment- Commentsstatement- BASIC keywords (PRINT, LET, etc.)identifier- Variable namesfunction- Built-in functionsescape- Escape sequencesasmdel- ASM block delimitersdirective- Preprocessor directives
Klive Script
comment- Commentskeyword- Language keywordsstatement- Statement keywordsidentifier- Identifiersregexp- Regular expressionsregexp.escape- Regex escapesstring.escape- String escapes
Partial Customization
You don’t need to specify all tokens. You can override only the tokens you want to customize:
{
"lightTheme": {
"comment": "008000",
"keyword": "0000ff"
}
}Unspecified tokens will use their default colors.
Tips for Choosing Colors
- Ensure Contrast: Make sure there’s sufficient contrast between foreground and background colors
- Test Both Themes: Define colors for both dark and light themes
- Stay Consistent: Use a consistent color scheme across related token types
- Start Simple: Begin by customizing just a few key tokens (comments, keywords, identifiers)
Troubleshooting
Colors Not Applied
- Verify the file is in the correct folder with the correct name
- Check that the JSON syntax is valid (no missing commas, brackets, etc.)
- Ensure you’ve restarted Klive IDE
Invalid JSON
Use a JSON validator or editor with JSON support to check for syntax errors.
Wrong Colors Displayed
- Verify you’re using 6-digit hex values without the
#prefix - Check that you’re editing the right theme section (dark vs light)
- Ensure file permissions allow Klive to read the file
If a token file cannot be read or parsed, Klive will silently skip it and use default colors. Check your JSON syntax if your customizations don’t appear.