sudoAPWH / rano

View on GitHub
Rust terminal text-editor nano crossterm
About this project

What is rano?

rano is a from-scratch rewrite of GNU nano in Rust. Not a wrapper, not a fork — a complete reimplementation that aims to replicate the behavior and feel of GNU nano 8.7 while taking advantage of Rust's type system, memory safety, and modern tooling.

The name is a play on "Rust nano." The goal is to provide a familiar, lightweight terminal editor that nano users can switch to seamlessly, backed by a cleaner and more maintainable codebase.

The Idea

GNU nano is one of the most widely-used terminal editors, but its C codebase uses global mutable state, linked lists for text storage, and ncurses for terminal I/O — patterns that make the code difficult to extend and reason about. rano asks: what would nano look like if you rebuilt it from first principles in a modern systems language?

What Changed Under the Hood

Aspect GNU nano (C) rano (Rust)
Terminal I/O ncurses (C dependency) crossterm (pure Rust, cross-platform)
State management Global mutable variables Central Editor struct
Text storage Linked lists Indexed vectors
Configuration flags C preprocessor directives Cargo feature flags + type-safe bitflags
Memory safety Manual management Ownership system

Capabilities

✏️ Full Editing

Insert, delete, cut/copy/paste, word and line operations, auto-indent, and complete undo/redo history.

🔍 Search & Replace

Forward and backward search with case sensitivity toggle and full regex support.

🎨 Syntax Highlighting

Built-in highlighting for 40+ languages. Uses .nanorc syntax definitions for compatibility.

🖱️ Mouse Support

Click to position cursor, click-drag to select text, scroll wheel navigation.

📄 Multi-Buffer

Open and switch between multiple files in a single session, just like nano.

⚙️ .nanorc Compatible

Reads existing .nanorc configuration files, so your nano settings carry over.

Architecture

rano ├── editor.rs Central Editor struct (all mutable state) ├── terminal.rs Terminal I/O via crossterm ├── text.rs Text editing operations ├── cursor.rs Cursor movement & positioning ├── search.rs Search/replace engine ├── files.rs File I/O & line ending detection ├── syntax.rs Syntax highlighting engine └── rcfile.rs .nanorc configuration parser Key design: All state flows through a single Editor struct. No global variables. No C dependencies. Pure Rust.

The modular structure separates concerns cleanly — each file handles one domain. The central Editor struct owns all mutable state, replacing the scattered global variables in the original C implementation. This makes the control flow explicit and testable.

Back to all repositories