Overview
Utility modules provide core functionality for config parsing, color operations, and keybind validation.settings.ts
Location:src/lib/data/settings.ts
Settings schema and metadata for the Ghostty Config editor.
Exports
Settings Structure
The default export is an array of Panel objects, each containing Groups, which contain individual Settings:Setting Types
switch— Boolean togglenumber— Numeric input with optional rangedropdown— Select from optionstext— Text inputcolor— Color pickerpalette— 256-color arraykeybinds— Keybinding arraytheme— Theme selector (special dropdown)
fetchColorScheme()
Fetches color schemes from the iTerm2-Color-Schemes repository.- Loads themes from GitHub API
- Parses iTerm2 XML format
- Converts to Ghostty color format
- Used by the Theme component
parse.ts
Location:src/lib/utils/parse.ts
Parses Ghostty config file format into JavaScript objects.
Default Export
Return Type
Parsing Rules
Line format:key = value
Special Handling
Palette Colors
Palette Colors
Format: Example:
palette = N=colorKeybinds
Keybinds
Accumulated into an array.Example:
Color Values
Color Values
Auto-prefixes Example:
# for 6-character hex values.Usage Example
colors.ts
Location:src/lib/utils/colors.ts
Color conversion and manipulation utilities.
Types
Functions
luminosity()
luminosity()
Calculates relative luminance of a color.Formula: ITU-R BT.709 weighted RGBReturns: Value from 0 (black) to 255 (white)
Usage
isDark()
isDark()
hsvToRgb()
hsvToRgb()
rgbToHsv()
rgbToHsv()
hexToRgb()
hexToRgb()
keybinds.ts
Location:src/lib/utils/keybinds.ts
Keybind parsing, validation, and formatting.
Constants
KEY_NAMES
KEY_NAMES
Array of 177 valid key names.
VALID_MODIFIERS
VALID_MODIFIERS
control→ctrlcmd,command→superopt,option→alt
VALID_PREFIXES
VALID_PREFIXES
ACTION_DEFINITIONS
ACTION_DEFINITIONS
Array of 80+ action definitions.
Types
Functions
parseKeybind()
parseKeybind()
parseTrigger()
parseTrigger()
formatTrigger()
formatTrigger()
Formats a ParsedTrigger back to string.Normalizations:
- Removes duplicate prefixes
- Sorts modifiers alphabetically
- Lowercases keys
Example
getDiagnostics()
getDiagnostics()
canonicalTrigger()
canonicalTrigger()
Normalizes trigger to canonical form for comparison.Normalizations:
- Sorts modifiers alphabetically
- Lowercases everything
- Removes whitespace
Example
Action Type Validation
none: No arguments allowedfree: Any argument or none (ifallowEmpty)text: Requires Zig string literalnumber: Must be numericinteger: Must be whole numberenum: Must be in options listresize: Formatdirection,offsetwhere direction ∈