Skip to content

Night-Traders-Dev/embedText

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

embedText

A lightweight, fast terminal text editor written in C with syntax highlighting, undo/redo, find & replace, and line numbers.

Features

  • Syntax Highlighting - Support for C, Python, JavaScript, and plain text
  • Undo/Redo - Full command history with Ctrl-Z and Ctrl-Y
  • Find & Replace - Search with Ctrl-F and navigate with Ctrl-N
  • Line Numbers - Toggle with Ctrl-L
  • Multiple Themes - Dark, Light, Solarized, and Dracula themes (Ctrl-T to cycle)
  • Efficient Rendering - Fast screen updates with minimal I/O
  • Terminal Native - Works in any terminal, no external dependencies

Building

Requirements

  • GCC or Clang
  • POSIX-compliant system (Linux, macOS, BSD)
  • Standard C library

Compile

bash build.sh release

Or for debug build:

bash build.sh debug

Run

./bin/embedText [filename]

Keyboard Shortcuts

Shortcut Action
Ctrl-S Save file
Ctrl-Q Quit (with unsaved check)
Ctrl-F Find text
Ctrl-N Find next occurrence
Ctrl-Z Undo
Ctrl-Y Redo
Ctrl-T Cycle themes
Ctrl-L Toggle line numbers
Ctrl-H Backspace
Arrow keys Move cursor
Page Up/Down Scroll page
Home/End Start/end of line
Delete Delete character at cursor

Project Structure

embedText/
├── include/          # Header files
│   ├── editor.h     # Main editor state
│   ├── doc.h        # Document management
│   ├── term.h       # Terminal control
│   ├── syntax.h     # Syntax highlighting
│   ├── theme.h      # Color themes
│   ├── abuf.h       # Output buffer
│   ├── history.h    # Undo/redo history
│   └── search.h     # Find functionality
├── src/              # Implementation files
│   ├── main.c       # Entry point
│   ├── editor.c     # Core editor loop
│   ├── doc.c        # Document operations
│   ├── term.c       # Terminal I/O
│   ├── syntax.c     # Language tokenization
│   ├── theme.c      # Theme definitions
│   ├── abuf.c       # Buffer implementation
│   ├── history.c    # Command history
│   └── search.c     # Search algorithm
├── bin/              # Compiled binaries
├── build.sh         # Build script
├── .gitignore       # Git ignore rules
└── README.md        # This file

Architecture

Document Model

  • Rows are dynamically allocated and stored in a Doc struct
  • Each row holds a character array and metadata
  • Efficient insertions/deletions with minimal copying

Rendering Pipeline

  1. Tokenization - Break lines into syntax tokens
  2. Coloring - Apply theme colors based on token type
  3. Scrolling - Calculate visible viewport based on cursor
  4. Buffering - Accumulate escape sequences in memory
  5. Flushing - Write entire screen in one syscall

Command History

  • Fixed-size circular buffer (100 commands by default)
  • Each command stores position, type, and affected content
  • Undo/redo traverses history pointer bidirectionally

Performance

  • O(1) rendering - Constant time screen updates
  • O(n) search - Linear search with early termination
  • O(1) history - Constant time undo/redo
  • Minimal allocations - Most data in fixed-size buffers

Limitations

  • Single-file editing (one file per session)
  • Basic syntax highlighting (no regex-based rules)
  • Find/replace is find-only (no replace operation yet)
  • No multi-byte Unicode support (ASCII/Latin-1 only)
  • No plugins or configuration file support

Future Enhancements

  • Multiple file tabs
  • Search and replace with regex
  • Configuration file support
  • Macro recording
  • Code folding
  • Clipboard integration
  • Window splitting

License

MIT License - See LICENSE file for details

Author

Created as a modern C programming exercise combining systems programming, data structures, and terminal UI techniques.

About

A light-weight text editor for the terminal

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published