Yureka LogoDocs

Code Editor

The Code Editor is a full-featured code editing environment with multi-language syntax highlighting, code folding, and a VFS-backed file tree sidebar.

Core Features

  • Syntax Highlighting: Supports C++, JavaScript, TypeScript, and Python with automatic language detection.
  • Code Folding: Collapse and expand code blocks with fold chevrons in the gutter.
  • Multi-Tab Editing: Open multiple files simultaneously with a tab bar.
  • File Tree Sidebar: VFS-backed SCodeFileTreeView with lazy directory expansion (root: /home).
  • Line Numbers & Indent Guides: Visual aids for code navigation.
  • VFS Integration: Open, save, and save-as through the virtual filesystem.
  • File Dialogs: Integrated open/save file dialogs via AppLauncher::RequestFileDialog.

Technical Details

  • Controller Class: UCodeEditorApp (Inherits from UAppBase)
  • Widget Class: UCodeEditorWidget (Slate host, implements IAppContentWidget)
  • Window Specs:
    • Initial Size: 980x680
    • Resizable: true
    • Maximizable: true
  • Category: "Development"

Data Structures

  • FCodeEditorDocument: FilePath="Untitled.cpp", Content, bIsDirty.

Key Controller Methods

  • NewDocument() / OpenDocument(Path) / SaveDocument() / SaveDocumentAs(Path)
  • GetCurrentContent() / SetCurrentContent()
  • AddTab() / CloseTab(Index) / SwitchTab(Index)

Delegates

  • OnDocumentChanged / OnTabsChanged / OnActiveTabChanged (dynamic/BP).

Syntax Highlighting System

The editor uses a hand-rolled tokenizer defined in the CodeSyntaxRules namespace:

Supported Languages (ECodeSyntaxLanguage)

  • Auto (detected from file extension)
  • Cpp, JavaScript, TypeScript, Python

Token Types (ECodeTokenType)

11 token types with VS Code Dark+ color palette:

  • Normal, Keyword, TypeName, String, Number, Comment, Preprocessor, Operator, FunctionName, Builtin, Decorator.

Editor Architecture

The code editor uses SAdvancedCodeEditor, a fully custom-painted SLeafWidget. It renders the gutter, indent guides, selection highlights, syntax tokens, line numbers, fold chevrons, and caret entirely through custom OnPaint() overrides — no SMultiLineEditableText dependency.

Key APIs: GetDocument / SetPlainText / GetPlainText / SetLanguage. Supports Ctrl+A/C/X/V.

File Associations

The Code Editor handles these file extensions by default: json, py, md, bat, cpp, h, hpp, c, cs, js, ts, html, css, xml, sh.