B-textEditor is a lightweight, modular, terminal-based text editor written in C, inspired by the Kilo editor. It showcases low-level terminal handling, dynamic memory management, and efficient screen rendering using POSIX APIs.
├── include
│ ├── common.h
│ ├── data.h
│ └── prototypes.h
├── src
│ ├── data.c
│ ├── editor.c
│ ├── file_io.c
│ ├── find.c
│ ├── input.c
│ ├── main.c
│ ├── output.c
│ ├── row.c
│ └── terminal.c
├── Makefile
└── README.md
The project uses a Makefile to automate compilation and manage object files.
Run the following command from the project root:
make
This will:
- Compile all source files
- Create an obj/ directory for object files
- Generate the B-textEditor executable
Remove compiled files and reset the build state:
make clean
To open the editor with a file:
./B-textEditor filename.txt
If the file does not exist, it will be created when saved.
- Arrow Keys — Move the cursor
- Page Up / Page Down — Scroll by one screen
- Home / End — Jump to the start or end of the current line
- Enter — Insert a new line
- Backspace — Delete characters and merge lines
- Ctrl + Q — Quit the editor immediately
The editor disables standard terminal features such as:
- Canonical input mode (ICANON)
- Character echoing (ECHO)
This allows input to be processed byte-by-byte for real-time interaction.
- Uses an internal append buffer (abuf)
- All screen updates are batched into a single write() call
- Minimizes flickering and improves rendering performance
- Text is stored as a dynamic array of erow structures
- Memory is resized using realloc() as lines are inserted, deleted, or modified
- Tabs are expanded virtually using a render index (rx)
- Ensures correct alignment on an 8-column grid
This project is heavily inspired by the Kilo text editor, adapted into a modular, multi-file C codebase for better scalability and learning purposes.