# mu-notepad

`mu-notepad` is a lightweight, feature-rich desktop text and code editor built with Vala and GTK3. It provides a clean distraction-free workspace enhanced with split-pane navigation, chapter parsing, rich text formatting, file exporting, and built-in search capabilities.

## Features

### 📁 File Management & Recent Files
* **Standard File Operations:** Open, save, and save-as support via native GTK file choosers.
* **Persistent Recent Files:** Automatically remembers and lists your recently opened files in a drop-down menu with a clear option.
* **Auto-Configuration:** Remembers your last-opened session and restores your environment seamlessly on startup.

### 📑 Sidebar & Chapter Navigation
* **Dedicated Chapter Sidebar:** Instantly parses your document for chapter tags formatted as `[[[Chapter Name]]]`.
* **Quick Jump:** Clicking any entry in the chapter list automatically scrolls the editor view to that specific section.
* **Chapter Insertion Button:** Features a dedicated button (`[[[]]]`) placed directly above the chapter sidebar to insert a new chapter tag at your current cursor position with a single click.

### 🎨 Rich Text Formatting & Syntax Handling
* **Inline Text Styling:** Easily apply or toggle **Bold** and *Italic* text formatting using toolbar buttons or standard keyboard shortcuts.
* **Color Customization:** Use the integrated color picker tool to apply custom foreground color tags to selected text snippets.
* **Serialization/Deserialization:** Automatically saves styled text using clean markup tags (`**`, `*`, `[color=...]`) so formatting is preserved seamlessly in plain text files.

### 📜 Line Numbers & View Controls
* **Dynamic Line Numbering:** Custom Cairo-rendered line number sidebar that accurately tracks scrolling and document lines.
* **Toggle Line Wrap:** Switch instantly between word wrapping (`WORD`) and continuous line mode (`NONE`) using the toolbar toggle button.
* **Smooth Scrolling:** Integrated adjustment tracking ensures fluid navigation through large text files.

### ↩️ Undo / Redo System
* **Granular State Tracking:** Full undo (`Ctrl+Z`) and redo (`Ctrl+Y` / `Ctrl+Shift+Z`) support tracking history changes safely up to 100 steps.

### 🔍 Search & Find
* **Integrated Search Bar:** Quickly search documents using `Ctrl+F` with case-insensitive matching.
* **Navigation Controls:** Convenient `Find Next` and `Find Previous` action buttons to cycle through search hits instantly.

### 📤 Export & Compatibility
* **HTML Export Preview:** Convert your structured notes and chapters into standard HTML format (`<h1>`, `<b>`, `<i>`, `<span>`, `<br>`) with a built-in copy and save dialog.
* **RTF (Rich Text Format) Support:** Generate legacy-compatible Rich Text Format code for seamless importing into Microsoft Word or WordPad.
* **PDF Document Export:** Export your formatted document directly into a paginated PDF document layout complete with A4 margins, text wrapping, and page numbering.

## Keyboard Shortcuts

| Shortcut | Action |
| :--- | :--- |
| **Ctrl + O** | Open file |
| **Ctrl + S** | Save file |
| **Ctrl + F** | Focus search bar / Find |
| **Ctrl + Z** | Undo |
| **Ctrl + Y** | Redo |
| **Ctrl + Shift + Z** | Redo (alternative) |

## Requirements

* Vala Compiler (`valac`)
* GTK+ 3.0
* Cairo / Pango
* GLib / GIO

## Building and Running

Compile the application using `valac` with the necessary package flags:
```bash
valac --pkg gtk+-3.0 --pkg gio-2.0 --pkg cairo mu-notepad.vala -o mu-notepad
./mu-notepad