# Lumacs

<img src="resources/logo_small.png" width="90" height="90">

A modern, highly customizable text editor engine written in C++20, deeply inspired by Emacs and featuring powerful Lua 5.4 scripting support. Lumacs emphasizes a clear separation between its core logic and UI, making it both flexible and extensible.

## Features

Lumacs aims to provide a rich, Emacs-like editing experience with a focus on configurability and modern C++ practices.

### ✅ Implemented Features

The editor currently boasts a wide array of functional features, as detailed in the [Development Plan](documentation/PLAN.md).

-   **Core Emacs Editing DNA**:
    *   **Buffer Management**: Robust handling of multiple buffers, including switching, listing, and closing.
    *   **Kill Ring**: Complete Emacs-style cut/copy/paste (kill, yank, yank-pop) operations.
    *   **Mark & Region**: Full functionality for setting marks, defining regions, and extracting text.
    *   **Registers**: Emacs-like named registers for storing and inserting text.
    *   **Rectangles**: Comprehensive operations for killing, yanking, and manipulating rectangular blocks of text.
    *   **Text Editing**: Basic insertion, deletion, and replacement, handling multi-line scenarios and buffer events.
    *   **Undo/Redo**: Functionality for reverting and re-applying changes.
    *   **Window Splits**: Dynamic horizontal and vertical window splitting, closing, and navigation.
    *   **Input System**: Functional keyboard input handling across GTK and TUI.
    *   **Cursor System**: UI-agnostic cursor position/movement logic.
    *   **Scrolling System**: Full vertical and horizontal scrolling with auto-adjustment.

-   **Advanced UI & System Integration**:
    *   **Theme System**: A robust and flexible theming engine with 6 professional themes (Dracula, Everforest, Nord, Solarized, Gruvbox, Default).
    *   **Minibuffer & Command System**: A functional interactive minibuffer with tab completion, history navigation, and command execution.
    *   **Syntax Highlighting**: Pango-based text rendering with syntax highlighting based on a face system.
    *   **GTK Frontend**: Primary GUI using GTK4 / gtkmm, supporting Pango/Cairo rendering with caching.
    *   **Ncurses TUI**: Functional terminal user interface serving as a fallback.
    *   **Modeline**: Modular and extensible status bar.
    *   **Completion**: Advanced completion with popup support.

-   **Extensibility**:
    *   **Lua Scripting**: Comprehensive Lua 5.4 API for extending and customizing the editor.
    *   **Plugin Management**: Dynamic loading and lifecycle management of Lua plugins.
    *   **Lua Debugging**: Integrated remote debugging support via MobDebug.

### 🔄 Planned Enhancements

-   **Language Modes**: Expand support for various language modes (Python, C++, JavaScript).
-   **Performance Optimization**: Further rendering optimizations for large files.
-   **Testing**: Continued expansion of test coverage.

## Tech Stack

-   **Core**: C++20
-   **UI**: GTK4 / gtkmm (GUI), Ncurses (TUI)
-   **Scripting**: Lua 5.4 with `sol2` bindings
-   **Build**: CMake 3.20+
-   **Logging**: spdlog
-   **Testing**: Google Test

## Quick Start

### Building

```bash
cmake -B build -S .
cmake --build build -j4
```

### Running

```bash
./build/lumacs [file]
```

### Key Bindings

Common Emacs-like keybindings are supported. Refer to `init.lua` for the full default keymap.

-   **Theme Switching**: `M-x set-theme` (then use Tab for completion)
-   **Window Splits**: `C-x 2` (horizontal), `C-x 3` (vertical), `C-x 0` (close window), `C-x o` (next window)
-   **Buffers**: `C-x b` (switch buffer), `C-x k` (kill buffer), `C-x C-b` (list buffers)
-   **Advanced**: `F3` (start macro), `F4` (end macro/call macro), `C-x r s` (copy to register), `C-x r i` (insert register), `C-x r k` (kill rectangle), `C-x r y` (yank rectangle)

## Documentation

-   [Architecture Overview](documentation/ARCHITECTURE.md)
-   [Lua API Reference](documentation/LUA_API.md)
-   [Development Plan](documentation/PLAN.md)

## License

MIT
