config

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package config manages editor configuration. Loads ~/.easyedit.toml or %APPDATA%/easyedit/config.toml, providing key bindings, color themes, indent width, line numbers, backup toggle, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigPath

func ConfigPath() string

ConfigPath returns the config file path, cross-platform.

Types

type Config

type Config struct {
	Theme       Theme       `toml:"theme"`
	Keys        KeyBindings `toml:"keys"`
	TabWidth    int         `toml:"tab_width"`     // Indent width, default 4
	ShowLineNum bool        `toml:"show_line_num"` // Show line numbers, default true
	Backup      bool        `toml:"backup"`        // Create .bak backup, default true
	SoftWrap    bool        `toml:"soft_wrap"`     // Enable soft wrap, default true
	AutoIndent  bool        `toml:"auto_indent"`   // Enable auto-indent, default true
	UndoLimit   int         `toml:"undo_limit"`    // Undo step limit, default 100
	TabToSpaces bool        `toml:"tab_to_spaces"` // Convert tab to spaces, default true
}

Config is the editor configuration struct.

func LoadConfig

func LoadConfig() Config

LoadConfig loads the config file; returns default config if file does not exist.

type KeyBindings

type KeyBindings struct {
	Save        string `toml:"save"`         // Save file, default Ctrl+S
	Quit        string `toml:"quit"`         // Quit, default Ctrl+Q
	Find        string `toml:"find"`         // Search, default Ctrl+F
	Replace     string `toml:"replace"`      // Replace, default Ctrl+H
	SelectAll   string `toml:"select_all"`   // Select all, default Ctrl+A
	Undo        string `toml:"undo"`         // Undo, default Ctrl+Z
	Redo        string `toml:"redo"`         // Redo, default Ctrl+Y
	Cut         string `toml:"cut"`          // Cut, default Ctrl+X
	Copy        string `toml:"copy"`         // Copy, default Ctrl+C
	Paste       string `toml:"paste"`        // Paste, default Ctrl+V
	ToggleWrap  string `toml:"toggle_wrap"`  // Toggle soft wrap, default Alt+W
	CommandMode string `toml:"command_mode"` // Command mode, default :
	SaveAs      string `toml:"save_as"`      // Save as, default Ctrl+Shift+S
}

KeyBindings defines user-customizable key mappings.

type Theme

type Theme struct {
	DefaultFg     string `toml:"default_fg"`      // Default foreground color
	DefaultBg     string `toml:"default_bg"`      // Default background color
	LineNumFg     string `toml:"linenum_fg"`      // Line number foreground
	LineNumBg     string `toml:"linenum_bg"`      // Line number background
	StatusBarFg   string `toml:"statusbar_fg"`    // Status bar foreground
	StatusBarBg   string `toml:"statusbar_bg"`    // Status bar background
	SearchMatchBg string `toml:"search_match_bg"` // Search match highlight background
	BracketMatch  string `toml:"bracket_match"`   // Bracket match highlight foreground
	SelectionBg   string `toml:"selection_bg"`    // Selection background
}

Theme defines color theme palette. Each field uses tcell color names (e.g., "aqua", "green", "#ff00ff") or "default".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL