Skip to content

A GUI plaintext editor written in Java Swing, optimized with a Rope data structure (based on Treap) for O(log n) text operations. Features include comprehensive file operations (open, save, auto-save), multi-tab editing, KMP-based pattern search, real-time spell checking using dynamic programming and Trie data structures.

Notifications You must be signed in to change notification settings

Abdelrhmansersawy/TextEditor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TextEditor

A feature-rich GUI plaintext editor written in Java Swing.

Table of Contents

Features

  • Create, open, and save plain text documents
  • Multi-tab support
  • Undo/redo functionality
  • Find and replace capabilities
  • Auto-save functionality

Installation & Usage

Ensure you have Java Development Kit (JDK) installed

Create output directory and compile

mkdir -p out && javac -cp "library/*:src" src/**/*.java -d out

Run the application

java -cp "out:library/*" Main

Core Features

File Operations

Create, Open, and Save Documents
  • Open files using the "Open" menu item and select through the file chooser dialog

  • Save files using the "Save" menu item with automatic overwrite protection ScreenShot ScreenShot

Multi-Tab Support

Work with multiple documents simultaneously ScreenShot

Advanced Features

Spell Checker

Creating a smart spell-checking system that suggests corrections in real-time as you type. Here’s how it works: Dictionary Management:

  • The system starts by loading a list of words from a dictionary file. If the file isn’t available, it uses a basic set of common words.

  • As you type new words, the system "learns" them and adds them to the dictionary, making it smarter over time. Suggestions:

  • If you misspell a word, the system suggests up to 7 possible corrections based on how close the word is to others in the dictionary.

You can load any dictionary file, for me I used this one 10000 English word

Here's the guide to activiate it

  1. Download google-10000-english.txt

  2. Move it to your project directory and put it into /library/

Find and Replace
  • Implements KMP string pattern search algorithm (O(n + m) complexity)
  • Supports both single and bulk replacements

Performance Comparison:

Operation Brute force KMP
search O(n * m) O(n+m)

ScreenShot ScreenShot

Auto-Save

Automatically tracks and saves changes ScreenShot

Technical Implementation

Undo/Redo System

  • Implemented using Command Pattern design pattern
  • Utilizes Stack and Rope data structures Architecture ScreenShot

Rope Data Structure

A specialized data structure for efficient string manipulation with O(log n) operations.

Note

The Rope data structure implementation is based on Treap data structure for balanced operations.

Implementation Details

  • Based on Treap (Balanced Binary Search Tree)
  • Uses randomization and Binary Heap properties

Performance Comparison:

Operation Vector/String Rope
Build O(n) O(n log n)
Insert O(n m) O(m log n)
Erase O(n) O(log n)
Concat O(m) O(log n)

How to Contribute

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Run tests if available
  5. Commit your changes (git commit -m 'Add some AmazingFeature')
  6. Push to the branch (git push origin feature/AmazingFeature)
  7. Create a Pull Request

About

A GUI plaintext editor written in Java Swing, optimized with a Rope data structure (based on Treap) for O(log n) text operations. Features include comprehensive file operations (open, save, auto-save), multi-tab editing, KMP-based pattern search, real-time spell checking using dynamic programming and Trie data structures.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages