How ToCustomizing syntax highlighting colors

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:

LanguageFile Name
Klive Z80 Assemblykz80-asm.tokens.json
6510 Assembly (C64)6510-asm.tokens.json
ZX Basic Assemblyzxbasm.tokens.json
ZX Basiczxbas.tokens.json
Klive Scriptksx.tokens.json
SjASM Plussjasmp.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:

  1. Simple string (foreground color only):

    "comment": "6a9955"
  2. 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:

  1. Create a new file called kz80-asm.tokens.json in your Klive settings folder (~/Klive/ on macOS/Linux).

  2. 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"
  }
}
  1. 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 - Comments
  • keyword - CPU instructions (LD, ADD, SUB, etc.)
  • statement - Assembler directives and statements
  • pragma - Pragma directives
  • identifier - Labels and identifiers
  • register - CPU registers (A, B, C, HL, etc.)
  • condition - Condition flags (Z, NZ, C, NC, etc.)
  • function - Built-in functions
  • macroparam - Macro parameters
  • escape - Escape sequences in strings

ZX Basic

  • comment - Comments
  • statement - BASIC keywords (PRINT, LET, etc.)
  • identifier - Variable names
  • function - Built-in functions
  • escape - Escape sequences
  • asmdel - ASM block delimiters
  • directive - Preprocessor directives

Klive Script

  • comment - Comments
  • keyword - Language keywords
  • statement - Statement keywords
  • identifier - Identifiers
  • regexp - Regular expressions
  • regexp.escape - Regex escapes
  • string.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

  1. Ensure Contrast: Make sure there’s sufficient contrast between foreground and background colors
  2. Test Both Themes: Define colors for both dark and light themes
  3. Stay Consistent: Use a consistent color scheme across related token types
  4. 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.