Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mehul237/text-editor
Built a text editor application using Stack, Object - Oriented Programming principles and File Handling
https://github.com/mehul237/text-editor
data-structure filehandling object-oriented-programming stack
Last synced: 8 days ago
JSON representation
Built a text editor application using Stack, Object - Oriented Programming principles and File Handling
- Host: GitHub
- URL: https://github.com/mehul237/text-editor
- Owner: Mehul237
- Created: 2024-06-22T16:35:44.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-11T17:02:11.000Z (2 months ago)
- Last Synced: 2024-09-12T02:30:29.351Z (2 months ago)
- Topics: data-structure, filehandling, object-oriented-programming, stack
- Language: C++
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stack based Text-Editor
Built a text editor application using Stack, Object - Oriented Programming principles and File Handling in C++## Problem Statement
- A text editor is a program that allows the user to open, view and edit plain text files (files containing only text).
- Text editors deal with manipulating text and provide features to enhance the experience. As mentioned before, The major functionalities of text editors are: inserting, deleting and viewing text. Additional features that are practically required to even compete with other text editors are: find and replace, copy/cut and paste, text formatting, sentence highlighting and etc.## Algorithm
### Three Stack Model
- This approach is most likely only found in programming assignments rather than actual implementation, but it is good practice using stacks. The idea is to use two stacks to maintain the current cursor position. Left stack would contain the contents to the left of the cursor and the right stack would contain the contents to the right cursor. You would just push or pop the elements to get to where you need and either insert or delete text.- We used the cursor position as ‘divider’ and maintained two stacks to hold characters on either side. All characters to the left of the cursor are pushed on the ‘left’ stack All characters to its right are pushed on the ‘right’ stack.
Use 2 stacks to depict the text editor| TASK | OPERATION |
| ---------------------------------- | --------------------------------------------------------------- |
| Insert a character/word | push it on the left Stack |
| Delete a character using DEL | perform pop operation on the right stack |
| Delete a character using Backspace | perform pop operation on the left stack |
| Move cursor to the left | copy the required characters from left stack to right stack |
| Move cursor to the right | copy the required characters from right stack to left stack |
| To replace | Use a combination of move cursor with DEL and insert operations |##
![ezgif com-gif-maker](https://user-images.githubusercontent.com/77978729/146603312-3b970521-de58-4d2f-8a38-bcf2fbd01619.gif)
# Demo output