/edU-command-line-text-editor-w-multiple-Un-Redo

Time (ms) and space (RAM usage) optimized command line text editor with multiple undo/redo feature

Primary LanguageC

🔃edU GitHub commit activity GitHub last commit GitHub code size GitHub repo size GitHub file count GitHub follow GitHub fork GitHub watchers GitHub star

EdU (editor with Undo) is an highly efficient text editor (in time (ms) and space (RAM usage)), with a multiple undo/redo feature. The program utilizes the command line interface and works with textual input commands. This project was made as an assignment for Algorithms and Data Structures (2019-2020).

Author

Demo

GIF demo

Installation

Download the repository and extract everything into a folder. The code has already been compiled as "runnable.exe", which can be run directly by double clicking it on any machine with a Windows OS. Otherwise, to compile and run the "code.c" file, type the following commands into a terminal or command prompt opened in the folder where you extracted the zip's content:

  gcc code.c -o runnable
  ./runnable

You can now use the text editor ⌨️.

How to use

The program accepts the following inputs:

  • (ind1, ind2)c: changes the text present on the lines between ind1 and ind2 (extremes included). The text following the command must be a number of lines equal to ind2-ind1 + 1. ind1 must actually be either an address present in the text, or the first address after the last line present in the text (or 1 if the text is still empty).
  • (ind1, ind2)d: deletes the lines between ind1 and ind2 (extremes included), by moving upwards the lines following that of address ind2 (if there are any). Deleting a line that does not exist in the text has no effect.
  • (ind1, ind2)p: prints the lines between ind1 and ind2 (or between ind1 and the end of the text if ind2 does not match any address in the text). For each non-existing row between ind1 and ind2 (included) the editor prints a line containing only the dot character.
  • (number)u: undo a number of commands (c or d) equal to the one specified in parentheses (an integer strictly greater than zero). A sequence of consecutive undo commands cancels a number of steps equal to the sum of the steps specified in each of them. If the number of commands to be canceled is higher than that of the commands executed, all steps are canceled. The execution of a text modification command (c, d) after an undo cancels the effects of the permanently canceled commands. Note that in the number of commands to cancel the no-effects commands (for example deleting a block of lines that do not exist) are also counted.
  • (number) r: cancels the effect of undo for a number of commands equal to the starting number from the current version. The number must be an integer strictly greater than zero. We therefore have that a sequence of commands like 10u 5r is equivalent to the 5u command only. Similarly, the sequence 12u 3r 2u 7r is equivalent to the 4u command. If the number of commands to be redo is greater than those currently canceled, it is performed the maximum number of redos possible.
  • q: finishes the execution of the editor.

Example

carbon (1)

🛠 Skills

Basics of C ad standard libraries. Optimization of RAM usage and execution time with highly efficient data structures.

🔗 Links

portfolio linkedin