JEditor — Terminal-Based Text Editor
A Java terminal text editor with document editing, cursor navigation, viewport management, search, dialogs, command-line options and terminal rendering.
Project overview
JEditor is a terminal-based text editor written in Java. Its Maven configuration targets Java 22 and includes JLine for terminal interaction and JUnit 5 for tests. The repository separates application startup, command-line parsing, document state, editor behaviour, layout calculation, viewport navigation and search. Its changelog records file open/save workflows, cursor navigation, status and message bars, incremental and exact search, case-sensitive search, match navigation, Go To Line, horizontal and vertical scrolling, and word/character statistics.
Capabilities and scope
Architecture at a glance
The following sequence summarises the principal components and boundaries described in the project material.
- 1App and EditorLauncher coordinate startup and command-line options
- 2CommandLineParser converts CLI arguments into EditorOptions
- 3EditorApplication coordinates the terminal interaction loop
- 4Document owns editable document content and file-related state
- 5Editor and Cursor handle editing commands and cursor movement
- 6EditorLayout and EditorLayoutCalculator map document state to terminal layout
- 7ViewportController keeps the visible region aligned with the cursor
- 8SearchEngine, SearchController and SearchState manage search behaviour
- 9JLine provides terminal interaction; Maven packages the Java application
1. Project purpose: bring document editing into a terminal
JEditor is a terminal-based text editor inspired by the classic edit-style workflow. A terminal editor must do more than read a line from standard input: it needs to interpret keyboard input, maintain document state, position the cursor, render only the visible viewport, and coordinate commands such as open, save, search and navigation. The project is useful for studying how a user-facing terminal application can be decomposed into focused subsystems.
2. Technology choices and build configuration
The Maven project targets Java 22 and uses JLine for terminal interaction. The POM configures compiler, test and executable-jar/shaded-jar packaging. JUnit 5 dependencies support automated tests. JLine provides lower-level terminal capabilities so the application can manage terminal input and output without treating the editor as a simple line-oriented console program.
3. Application startup and command-line options
The repository separates App, EditorLauncher, HelpPrinter, Version and ExitCode from the editor's core behaviour. CommandLineParser turns command-line arguments into EditorOptions, keeping CLI parsing out of the editing engine. This makes the application entry point responsible for launching the editor with a configuration rather than mixing command syntax with document manipulation.
4. Document model and editing operations
The Document class represents the content being edited and the state associated with file operations. The Editor and EditorApplication coordinate editing behaviour, while Cursor represents the current logical location. Keeping document content separate from terminal coordinates matters because a character's position in the file is not always the same as its position on the visible screen. A long line can extend beyond the terminal width, and a document can contain more lines than fit on the screen.
5. Layout and viewport are separate concerns
The repository contains EditorLayout, EditorLayoutCalculator, DocumentPosition, ScreenPosition, ViewPort and ViewportController. This separation is important in terminal software. DocumentPosition describes where the cursor or content belongs in the document, while ScreenPosition describes where it appears in the terminal. The viewport maps a window of the larger document onto the available terminal area. Horizontal and vertical scrolling update that mapping without changing the underlying document content.
6. Search is a subsystem, not just a string operation
The search package contains SearchEngine, SearchController, SearchState, SearchOptions, SearchResult, SearchBounds, SearchFocus and layout/mouse controller classes. The changelog records incremental search, exact matching, case-sensitive search, navigation between matches and a result counter. Separating the search engine from its state and UI controller keeps matching logic distinct from how the editor displays and navigates results. Boundary handling is particularly important when the document changes while a search is active.
7. File lifecycle, dialogs and user feedback
The changelog records open, save and Save As support, a dialog framework, an About dialog, confirmation dialogs and unsaved-change protection. It also records file information in the status bar and a message-bar timeout. These features introduce important state transitions: a document can be modified, saved, redirected to another path or closed only after a confirmation decision. Keeping these transitions explicit prevents accidental data loss and makes the editor easier to reason about.
8. Testing and incremental development
The changelog records tests for search, search navigation, viewport scrolling, Go To Line and line merging, along with an expanded editor test suite. This is a useful example of testing behaviour at subsystem boundaries. Search tests should verify match ranges and boundary handling; viewport tests should verify how cursor movement changes the visible region; file tests should cover missing paths and save behaviour. Small tests make terminal interaction code safer to evolve.
9. Architectural lessons
JEditor demonstrates why even a relatively small terminal tool benefits from boundaries between CLI parsing, document state, editing commands, layout, viewport navigation, search and terminal I/O. This is not a claim that the project is an operating-system editor or a complete replacement for a graphical IDE. It is a focused terminal application whose internal responsibilities can be studied and extended independently.
What this project teaches
- ✓Design a terminal application's command-line and startup flow.
- ✓Separate logical document positions from terminal screen positions.
- ✓Understand viewport calculation and scrolling for long documents.
- ✓Decompose search into engine, state, controller and display concerns.
- ✓Test stateful editing behaviour and boundary conditions with JUnit.