How kde/ghostwriter works
Main components in the system
• GUI / Frontend Layer:
– MainWindow (src/mainwindow.cpp/h) assembling the visual components.
– Editor component (src/editor/) that handles the text editing, syntax highlighting, and state management.
– Preview pane (src/preview/) which renders the live HTML preview using either Qt’s web components (e.g., QWebEngineView) or a sandboxed webpage.
– Sidebar and auxiliary UI widgets (src/sidebar.cpp, src/timelabel.cpp).
– Menu actions and command components (src/appactions and UI dialogs under src/settings).
• Business & Application Layer:
– Document Manager (src/documentmanager) managing open documents and files.
– Markdown processor integration (src/markdown/) that integrates cmark-gfm (and optionally Pandoc or MultiMarkdown, auto-detected at runtime).
– Export functionality (src/export/) that interacts with the Markdown processor to produce files in different formats.
– Spell Checking module (src/spelling/) to handle real-time spell checking.
– Statistics and Logging modules (src/statistics/ and src/logging.*) for performance metrics and error logging.
• Integration & Dependencies:
– Third-Party Libraries: 3rdparty directory includes dependencies like MathJax for math rendering, cmark-gfm for Markdown processing, and React (perhaps for specialized parsing or dynamic content modules).
– Build and CI tools: CMake configuration (CMakeLists.txt in various directories, build system integration in .github and .gitlab-ci.yml), testing folders (autotest/), and packaging files (such as snapcraft.yaml).
Relationships and interactions
• User actions (typing/editing, invoking preview/export) occur in the GUI layer.
• The Document Manager receives these UI events, updates the internal document model, and forward the content to the Markdown Processing module.
• The Markdown processor (using cmark-gfm and possibly other Markdown processors auto-detected at startup) converts the text to HTML.
• The Preview module receives the processed HTML and renders it within a sandboxed webpage.
• The Exporter module can also invoke the Markdown processing to produce output in different formats.
• Settings and Theme modules supply configuration to the GUI and core modules at startup, and changing them propagates new appearance settings to the Editor and Preview.
• Spellchecking services monitor the text input and interact (via decorators) with the editing widget layers.
• Logging and statistics monitor user activity, errors, and provide diagnostics that may be shown on-screen or saved.
• CI/build modules trigger automated tests and build pipelines as defined in the repository’s various config files.
Architectural Patterns
• Layered Architecture: The overall structure is layered (UI -> Business Logic -> Integration/Third-Party Dependencies) which allows for clear separation of concerns.
• Modular design: Each major functionality (editor, export, markdown processing, settings, theming) is contained within its own module directory that may communicate via defined interfaces.
• Extensibility: The use of external Markdown processors and the auto-detection of optional tools (Pandoc, MultiMarkdown, cmark) show that the design allows integration with external libraries.
Relevant technologies, frameworks, and libraries
• Qt (likely Qt 6 even though there is mention of potential issues on Windows, with backward compatibility to Qt 5).
• C++ and CMake for core application development and building.
• Third-party libraries such as cmark-gfm (Markdown processor), MathJax (for math rendering), and some React components (possibly for interactive preview or help sections).
• CI and version control integrations: Git, GitHub/GitLab workflows, and build automation scripts.
• Clear labels for each identified module (e.g., “Editor Component”, “Markdown Processor”, “Document Manager”, “Preview Pane”, “Export Module”, “Spellchecker”, “Theme Manager”, “Settings”, “Third-Party Libraries”).
– Core application modules.
– UI components.
– External dependencies.
– Build/CI components.
• Ancillary components such as logging/statistics to show diagnostics and monitoring across the system.