A terminal-based text editor built using the ncurses library in C. u0date provides fundamental text editing capabilities, including a robust undo and redo system implemented using the Command design pattern.
u0date currently supports the following features:
- File Reading: Load content from a specified file upon startup.
- File Writing: Save the current buffer content back to the file.
- Text Insertion: Add new characters at the cursor position and insert new lines (via the Enter key).
- Text Deletion: Remove characters (via Backspace) and join lines.
- Cursor Navigation: Move the cursor through the text using arrow keys (Up, Down, Left, Right).
- Editing Modes: Switch between Normal (for navigation and commands) and Insert Mode (for typing and text entry).
- Undo Functionality: Reverse the last performed change (
u). - Redo Functionality: Re-apply the last undone change (
Ctrl + R). - Basic Status Display: A status line at the bottom shows the current editing mode (on the left) and messages like "Saved!", "Undo!", "Redo!" (on the right).
- Bounds Checking: Prevents the cursor from moving or operations from writing outside the valid text boundaries within the buffer structure.
To build and run u0date, you need:
- A C compiler (like GCC or Clang).
- The ncurses library and its development headers.
You can typically install ncurses development headers using your system's package manager:
- Debian/Ubuntu:
sudo apt-get install libncurses-dev - Fedora/RHEL:
sudo dnf install ncurses-devel - macOS (using Homebrew):
brew install ncurses
First, clone the repository to your local machine:
git clone https://github.com/3akare/u0date.gitNavigate into the cloned repository directory:
cd u0dateNow, build the project using make:
makeThis will compile the source files and create the executable u0date inside the build/ directory.
You can run u0date in a couple of ways after building:
-
Directly using the compiled executable:
./build/u0date <name_of_the_file>
Replace
<name_of_the_file>with the path to the file you want to edit. This command requires a filename argument. If the file does not exist, it will be created upon saving. -
Using the build script:
./build.sh <name_of_the_file> [<-flag>]
Replace
<name_of_the_file>with the path to the file you want to edit. The optional[<-flag>]can be any additional argument (the specific content of the flag doesn't matter; its presence simply indicates a behavior flag to the script), which according to the script's logic, means the file should be deleted upon application exit. Consult thebuild.shscript for its exact implementation details. If<name_of_the_file>is not specified when running./build.sh, the script will typically create a default file (likefile.txt) for editing.
- Normal Mode:
h,j,k,lor Arrow Keys: Move cursor Left, Down, Up, Right.i: Enter Insert Mode.Ctrl + S: Save the file.u: Undo the last action.Ctrl + R: Redo the last undone action.q: Quit the editor.
- Insert Mode:
- Typing any character: Inserts the character at the cursor position.
- Enter: Splits the current line at the cursor position, creating a new line below.
- Backspace: Deletes the character before the cursor. If at the beginning of a line (and not the first line), joins the current line with the previous one.
Esc: Exit Insert Mode and return to Normal Mode.
This project is licensed under the MIT License - see the LICENSE.md file for details.