TyEditor is a native LCL application. The main window is a TTyForm with a
TyControls title bar, menu bar and page control. Each tab owns a TATSynEdit
instance and an EControl adapter.
| Path | Responsibility |
|---|---|
TyEditor.lpr |
Program entry point; creates TMainForm |
src/core/ |
Settings, session, encoding, macros, commands, color schemes, editor tab |
src/ui/ |
Main window, menus, dialogs, results, split view, status view |
src/syntax/ |
EControl library loading and TyEditor language definitions |
src/plugins/ |
Plugin package model, manifests, discovery, runtimes and manager |
src/platform/ |
Platform-specific single-instance and window helpers |
data/ |
Runtime icons, lexer library and bundled plugins |
languages/ |
Application and TyControls translations |
packaging/ |
Installer, desktop entry and macOS bundle assets |
scripts/ |
Build, packaging, development and test scripts |
tests/ |
Standalone FPC test projects |
Build output goes to build/; distributable packages go to dist/. Both are
ignored by Git.
TMainForm(src/ui/umain.pas) is the application controller. It owns the tab list, menu commands, settings, session timer, find dialogs, plugin host and split view.TMenuBuilder(src/ui/umenubuilder.pas) builds the static menu tree and emitsTMenuCmdtags.TMainFormdispatches those tags inMenuClick.TEditorTab(src/core/ueditortab.pas) wraps oneTTyTabSheet, oneTATSynEdit, its EControl adapter, file state and per-document settings.TAppSettings(src/core/usettings.pas) loads and saves JSON settings.TSession(src/core/usession.pas) serializes window and tab state.TLanguageManager(src/syntax/ulanguage.pas) loadsdata/lexlib/lib.lxl, registers extended lexers, applies palettes and resolves language names and extensions.TPluginManager(src/plugins/upluginmanager.pas) owns package installation, enable state andTPluginHost; the host scans manifests and dispatches to a runtime.TMainFormowns the UI and applies responses to the active tab.TToolStore(src/core/utools.pas) loads and saves user-defined external tools intools.json. The same unit expands placeholders and runs a command with stdin/stdout, timeout and cancellation;TMainFormshows the progress and output dialogs and applies the result to the active tab. External tools do not use the plugin system.
Application.CreateFormconstructsTMainForm.- Settings load from
settings.json; the backup configuration is derived. - The tab list, plugin manager/host, tools store and syntax manager are created.
- Plugin packages are loaded from bundled and user directories before the menu is built, so the Plugins menu is populated on startup.
tools.jsonis loaded before the menu is built, so the Tools menu lists enabled external tools on startup.BuildChromecreates the form surface, title bar, page control and bottom panels;BuildMenuadds menus and dynamic submenus.- Session restore is deferred to
OnShow, so crash-recovery dialogs are themed correctly andApplication.MainFormexists. - A session timer writes snapshots while the application runs.
NewUntitled creates an empty TEditorTab. Opening a file loads it into the
active tab or a new tab depending on the command. Each tab preserves:
- file name and untitled display name;
- text, encoding and EOL style;
- caret/selection and scroll position;
- language, bookmarks and folding;
- pinned state and session identity.
Closing a tab writes a backup for unsaved text, removes the page from the tab strip and frees the editor after the tab control finishes its close callback. The last tab close exits the application.
The F8 split view is a separate read-only TATSynEdit used as a document map.
It never edits the primary buffer.
The base lexers are third-party EControl definitions. src/syntax/usyntaxdefs.pas
adds language definitions using EControl’s TecSyntAnalyzer API:
- formats map to palette categories (
Keyword,Type,String,Comment,Number,Function,Constant,Operator,Attribute, and so on); - token rules use EControl regular expressions;
- comment and string styles are marked so the palette and folding code can classify them;
LexerNameandExtentionsdrive the Language menu and filename lookup.
Definitions are intentionally lexical. Add a language by extending the
SyntaxDefs array; no edits to data/lexlib/lib.lxl are required.
Plugins are installable .typlugin packages, not in-process DLLs. The package,
manifest, request/response, i18n and runtime contract are documented in
PLUGIN_PROTOCOL.md. The host:
- discovers
plugin.jsonfiles under bundled and user roots; - parses the package manifest, locales and compatibility constraints;
- applies user-over-plugin precedence and enable state from
plugins.json; - dispatches commands to a runtime implementing the same JSON boundary;
- runs process or PascalScript plugins off the UI thread with timeout and cancellation;
- returns actions that
TMainFormapplies to the active editor tab.
TPluginManager installs archives by extracting to a temporary directory,
validating the manifest, path safety and compatibility, then copying to the user
plugin directory. The manager UI exposes install, uninstall, enable/disable,
reload, open-folder and error views. Plugin options are shown before each
command.
The runtime boundary deliberately exposes no editor Pascal objects or UI
handles. A future JavaScript or native runtime should implement the same
request/response contract behind the manifest’s runtime field. Lua is not a
planned runtime.
On Linux, AppConfigDir resolves to ~/.config/TyEditor/; Windows uses
%APPDATA%\TyEditor\ and macOS uses ~/Library/Application Support/TyEditor/.
The directory contains:
settings.jsonsession.jsonandsession.json.bakrunning.markerbackups/macros/plugins/custom-scheme.jsonwhen a custom scheme is used
Writes use a temporary file and rename where the platform permits. Resource
lookup checks the executable directory, macOS Resources, parent directories,
the configuration directory and the current directory.
TyEditor intentionally has no project/workspace model, LSP, completion, terminal, debugger, Git integration or editable split view. Keep new features within the text-editor scope; do not turn the tab container into an IDE shell.
- Keep UI code in
src/ui, document/file logic insrc/core, and platform code isolated insrc/platform. - Use
Tr()for user-visible strings and updatelanguages/tyeditor.zh_CN.json; runscripts/dev/check-translations.py. - Never hardcode personal paths in scripts. Use
scripts/env.local.shor environment variables. - Treat
TyEditor.lpias the version source of truth.src/version.incis generated byscripts/dev/version.py. - Add or update an automated test when touching encoding, search, plugins or syntax registration.