gui

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PaletteSize = 32

PaletteSize is the number of colors in the rotating palette.

Variables

View Source
var Palette = [PaletteSize]TagColor{

	{Hex: "#FF453A"},
	{Hex: "#FF9F0A"},
	{Hex: "#FFD60A"},
	{Hex: "#30D158"},
	{Hex: "#40C8E0"},
	{Hex: "#0A84FF"},
	{Hex: "#BF5AF2"},
	{Hex: "#FF375F"},

	{Hex: "#FF6B6B"},
	{Hex: "#E07C24"},
	{Hex: "#A8D830"},
	{Hex: "#2EB086"},
	{Hex: "#00A3CC"},
	{Hex: "#5856D6"},
	{Hex: "#E040A0"},
	{Hex: "#FF8FA0"},
	{Hex: "#C44040"},
	{Hex: "#CC8800"},
	{Hex: "#88B830"},
	{Hex: "#10A060"},
	{Hex: "#3090B0"},
	{Hex: "#4060E0"},
	{Hex: "#9040C0"},
	{Hex: "#D05080"},
	{Hex: "#E08060"},
	{Hex: "#B09030"},
	{Hex: "#60A830"},
	{Hex: "#20C0A0"},
	{Hex: "#50A0D0"},
	{Hex: "#7070E0"},
	{Hex: "#A060D0"},
	{Hex: "#D06090"},
}

Palette contains 32 visually distinct colors for window tags. First 8 are Apple HIG system colors; the rest extend across hue bands.

Functions

func Run

func Run(cfgPath string) error

Run is the GUI process entry point. It reads the config from the temp file, starts an HTTP server, optionally starts file watchers, creates a frameless webview window, and runs the event loop until the window is closed.

func RunHost

func RunHost(cfgPath string) error

RunHost is the host process entry point. It reads the initial config, sets up the dock icon, starts IPC, creates the first window, and runs the NSApp event loop.

func WriteConfig

func WriteConfig(cfg Config) (string, error)

WriteConfig serializes cfg to a temp JSON file and returns the path.

Types

type Config

type Config struct {
	Port       int           `json:"port"`
	Theme      string        `json:"theme"`
	Content    string        `json:"content"`
	Filename   string        `json:"filename"`
	IsMarkdown bool          `json:"is_markdown"`
	WatchFiles []string      `json:"watch_files,omitempty"`
	Poll       time.Duration `json:"poll,omitempty"`
	NoWatch    bool          `json:"no_watch"`
	Verbose    bool          `json:"verbose"`
	FilePath   string        `json:"file_path,omitempty"` // normalized absolute path for dedup
}

Config holds configuration passed from CLI mode to GUI mode via a temp JSON file.

func ReadConfig

func ReadConfig(path string) (Config, error)

ReadConfig reads the config from the given path and deletes the file.

type Host

type Host struct {
	// contains filtered or unexported fields
}

Host is the single process that manages all preview windows.

func (*Host) ActivateWindow

func (h *Host) ActivateWindow(id string)

ActivateWindow brings a window to the front.

func (*Host) CloseWindow

func (h *Host) CloseWindow(id string)

CloseWindow closes a single window and its resources.

func (*Host) OpenFile

func (h *Host) OpenFile(path string)

OpenFile reads a mermaid or markdown file and opens a new window.

func (*Host) WindowList

func (h *Host) WindowList() []WindowEntry

WindowList returns a snapshot of all window entries.

type TagColor

type TagColor struct {
	Hex string
}

TagColor holds a palette entry with a hex color string for CSS/HTML.

type WindowEntry

type WindowEntry struct {
	ID         string
	Filename   string
	Label      string // display name: filename or "Diagram N"
	ColorIndex int    // 0-7 palette index
	FilePath   string // normalized absolute path for dedup (empty for stdin)
	Webview    webview.WebView
	Server     *server.Server
	Cancel     context.CancelFunc
}

WindowEntry tracks a single preview window and its resources.

Jump to

Keyboard shortcuts

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