The project consists in implementing (in C language) a simple text editor. The editor considers a document as a sequence of lines, of arbitrary size, numbered starting from one. The document...

The project specifications are attached. I would like to know if it is doable and for how much. Thank you


The project consists in implementing (in C language) a simple text editor. The editor considers a document as a sequence of lines, of arbitrary size, numbered starting from one. The document representation also includes an integer index, which represents the current line number, hereinafter referred to as the current address. The editor interface is made up of text commands, terminated by a "newline" character. The commands can be followed by a portion of text, consisting of one or more lines, terminated by a character. (period) which appears as the only character on the next line. The commands consist of a single letter, optionally preceded by one or two whole numbers. The editor interface is freely inspired by that of the traditional editor ed. In some commands, the integers that appear in them represent address specifiers. More precisely, an address specifier is a number n, expressed in decimal, which indicates the address of the n-th line; the first line of the text has address 1. The supported commands are the following, with the convention that ind1, ind2 indicate two address specifiers such that ind1 ≤ ind2 and round brackets are introduced for ease of reading this text, but not included in the command: · (ind1,ind2)c Changes the text present on the lines between ind1 and ind2 (extremes included). The text following the command must be made up of a number of lines equal to ind2-ind1 + 1. ind1 must be either an address actually present in the text, or the first address after the last line in the text (or 1 if the text is still empty). · (ind1,ind2)d Deletes the lines between ind1 and ind2 (extremes included), moving up 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-existent line included in the region between ind1 and ind2 (included) the editor prints a line containing only the dot character. · (number)u It performs the cancellation (undo) of a number of commands (c or d) equal to that specified in round brackets (where number is 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 the number of executed commands, all steps are canceled. The execution of a text modification command (c, d) after an undo cancels the effects of the commands definitively canceled. Note that the commands that have no effect are also counted in the number of commands to be canceled (for example, the cancellation of a block of lines that do not exist). · (number)r Cancels the effect of undo for a number of commands equal to the number starting from the current version (redo function). Note that number must be an integer strictly greater than zero. For example if it is given a sequence of commands like 10u 5r it is equivalent to the 5u command only. Similarly, the sequence 12u 3r 2u 7r is equivalent to command 4u. In the event that the number of commands to be redoed is greater than those currently canceled, the maximum number of possible redos is performed. · q Finishes the execution of the editor Other specifications: · Inputs are provided by standard input (stdin). · The length of the strings does not exceed 1024 characters · Do not consider bifurcations, if after an undo I find a command that modifies the text, the history of the changes is reset. · You can only use the standard C library libc (no external libraries). · No threads or parallelization techniques are allowed. · Assume that only correct commands are given to the editor (it is therefore not necessary to verify their correctness). For example, a command c is never given where ind1> ind2, or ind1 <1, or ind1 is not the address of a line in the text, nor is the address of the first line after the text . similarly for the other commands. note, however, that, in some cases, the command is allowed, but simply has no effect; for example, it is possible to give a command d in which ind1 is not the address of a line of text, but in this case the command has no effect on the text. · undos applied in a greater number than the changes made restore the document to its initial state, i.e. empty (excess undo has no effect) · redos applied in a higher number than the cancellations made bring the document back to the last modification (redo in excess have no effect) the program has to go through an online tester provided by my school that checks the correctness of the program and the performances. note that the program has to be optimized for time and memory performances or it won’t pass the tests. unfortunately the tests are private and i can’t see the input that it is given. those tests stress a lot the program with thousands of lines of commands. we do however have some public tests to check if the program works. input example: 1,2c first line second line . 2,3c new second line third line . 1,3p 1,1c new first line . 1,2p 2,2d 4,5p 1,3p 4,5d 1,4p 3u 1,6p 1r 1,3p q output: first line new second line third line new first line new second line . . new first line third line . new first line third line . . first line new second line third line . or="" ind1="" is="" not="" the="" address="" of="" a="" line="" in="" the="" text,="" nor="" is="" the="" address="" of="" the="" first="" line="" after="" the="" text="" .="" similarly="" for="" the="" other="" commands.="" note,="" however,="" that,="" in="" some="" cases,="" the="" command="" is="" allowed,="" but="" simply="" has="" no="" effect;="" for="" example,="" it="" is="" possible="" to="" give="" a="" command="" d="" in="" which="" ind1="" is="" not="" the="" address="" of="" a="" line="" of="" text,="" but="" in="" this="" case="" the="" command="" has="" no="" effect="" on="" the="" text.="" ·="" undos="" applied="" in="" a="" greater="" number="" than="" the="" changes="" made="" restore="" the="" document="" to="" its="" initial="" state,="" i.e.="" empty="" (excess="" undo="" has="" no="" effect)="" ·="" redos="" applied="" in="" a="" higher="" number="" than="" the="" cancellations="" made="" bring="" the="" document="" back="" to="" the="" last="" modification="" (redo="" in="" excess="" have="" no="" effect)="" the="" program="" has="" to="" go="" through="" an="" online="" tester="" provided="" by="" my="" school="" that="" checks="" the="" correctness="" of="" the="" program="" and="" the="" performances.="" note="" that="" the="" program="" has="" to="" be="" optimized="" for="" time="" and="" memory="" performances="" or="" it="" won’t="" pass="" the="" tests.="" unfortunately="" the="" tests="" are="" private="" and="" i="" can’t="" see="" the="" input="" that="" it="" is="" given.="" those="" tests="" stress="" a="" lot="" the="" program="" with="" thousands="" of="" lines="" of="" commands.="" we="" do="" however="" have="" some="" public="" tests="" to="" check="" if="" the="" program="" works.="" input="" example:="" 1,2c="" first="" line="" second="" line="" .="" 2,3c="" new="" second="" line="" third="" line="" .="" 1,3p="" 1,1c="" new="" first="" line="" .="" 1,2p="" 2,2d="" 4,5p="" 1,3p="" 4,5d="" 1,4p="" 3u="" 1,6p="" 1r="" 1,3p="" q="" output:="" first="" line="" new="" second="" line="" third="" line="" new="" first="" line="" new="" second="" line="" .="" .="" new="" first="" line="" third="" line="" .="" new="" first="" line="" third="" line="" .="" .="" first="" line="" new="" second="" line="" third="" line="">
Aug 31, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here