Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need it in a .c and .h data Texteditor For the following exercises make sure to make enough comments to explain the important steps

i need it in a .c and .h data
image text in transcribed
image text in transcribed
image text in transcribed
Texteditor For the following exercises make sure to make enough comments to explain the important steps of the program that you will programm. Exercise 1 Reading in the user commands Our simple editor is to be controlled via standard input commands. (An example of such an editor is the Unix editor vi). To do this, write a function that reads and checks the next input command and returns the command data as a result The following commands are intended for our editor and must be readin and recognized d Delete rowcrow> i/ Add a rowcrow> with the Text in por pcrow Print the whole text or the row crow> on the screen 9 Exit editor (quit) Reset data (reset) Implement a function void sett command (char* commisd_char, int "line_ne, char texD): that reads in a command row using ets and returns the command letter, the row specification and the text via the parameters. If there is no row specification or text in a command, zero or an empty string is returned. You can assume that only correct inputs have been made, that means you do not have to check whether the command structure is correct. Examples of commands: The commands should look like this (order is not important for the examples here): d34 11/Hallo Welt! p1 r Aufgabe 2 Functionality of the text editor Create and initialize the global data structure A global two-dimensional array of characters is to be created (catfield). The number of rows LINE_COUNT and characters per line LINE LENGTI are to be defined as preprocessor constants with value 1000 and 256 respectively. Furthermore, you need a variable max_line_ho, that stores the number of written lines; this initially has the value 0. The use of masline, n allows us, for output on the screen (Kommando p) to output the text only up to the last described row. Auxiliary functions for strings Implement the following auxiliary functions for inserting, deleting and copying rows: void copy_line (int to, int from Copies the text of the row from into the line o. void add_line (int line_no): Adds an empty row. To do this, all lines from line to to the end of the text Gut_line_) must first be copied down one row at a time. void delete_line (int line_no): To do this, the row line, nor up to the end of the text (nuclinen) must each be copied one row upwards. In addition, an empty row must be inserted at the end of the text. Hints: For the last two functions, the global variables_for_ meest also be updated Input and output Implement the following two output functions: void printit (void) Outputs the entire text on the screen. void print_line int line.no). Outputs the row line_no on the screen. In the output, the row number should always be written in front of each row (row number with: positions) Example: 1 aaa 2 bbb 3 CCC Editor functions Now implement the following functions of the editor: void insert Cintline_do. churc): Inserts the text in the row To do this, use the above-mentioned auxiliary functions from the previous task void dolce Cintline) Deletes the powinno To do this, use the above-mentioned auxiliary functions from the sub functions module. Global.control Write the main function which first initialises text_field and then carries out the user intention. In essence, the main function consists of an endless loop that reads in a command van and calls the corresponding editor function from the functie module depending on the command letter returned. The programme is terminated with the commande The varinbles in field and male, declared globally in main.h are to be defined and initialised in the module main Hints: You can implement the task as an extension of task 1. Document your programme in detail, ie the purpose of each global variable and each function must be explained! . You may use the string library string for the implementation . Please upload all files for this task (only cand.h files)! Example of an interaction sequence : 11/Hello i2/World! 13/Programming 14/in i5/C 16/is 17/great! i7/really d7 P 9 Output: 1 Hello 2 World! 3 Programming 4 in 5 C 6 is 7 great! 1 Hello 2 World! 3 Programming 5 C 7 really 8 great! 1 Hello 2 World! 3 Programming 4 in 5 C 7 great! Texteditor For the following exercises make sure to make enough comments to explain the important steps of the program that you will programm. Exercise 1 Reading in the user commands Our simple editor is to be controlled via standard input commands. (An example of such an editor is the Unix editor vi). To do this, write a function that reads and checks the next input command and returns the command data as a result The following commands are intended for our editor and must be readin and recognized d Delete rowcrow> i/ Add a rowcrow> with the Text in por pcrow Print the whole text or the row crow> on the screen 9 Exit editor (quit) Reset data (reset) Implement a function void sett command (char* commisd_char, int "line_ne, char texD): that reads in a command row using ets and returns the command letter, the row specification and the text via the parameters. If there is no row specification or text in a command, zero or an empty string is returned. You can assume that only correct inputs have been made, that means you do not have to check whether the command structure is correct. Examples of commands: The commands should look like this (order is not important for the examples here): d34 11/Hallo Welt! p1 r Aufgabe 2 Functionality of the text editor Create and initialize the global data structure A global two-dimensional array of characters is to be created (catfield). The number of rows LINE_COUNT and characters per line LINE LENGTI are to be defined as preprocessor constants with value 1000 and 256 respectively. Furthermore, you need a variable max_line_ho, that stores the number of written lines; this initially has the value 0. The use of masline, n allows us, for output on the screen (Kommando p) to output the text only up to the last described row. Auxiliary functions for strings Implement the following auxiliary functions for inserting, deleting and copying rows: void copy_line (int to, int from Copies the text of the row from into the line o. void add_line (int line_no): Adds an empty row. To do this, all lines from line to to the end of the text Gut_line_) must first be copied down one row at a time. void delete_line (int line_no): To do this, the row line, nor up to the end of the text (nuclinen) must each be copied one row upwards. In addition, an empty row must be inserted at the end of the text. Hints: For the last two functions, the global variables_for_ meest also be updated Input and output Implement the following two output functions: void printit (void) Outputs the entire text on the screen. void print_line int line.no). Outputs the row line_no on the screen. In the output, the row number should always be written in front of each row (row number with: positions) Example: 1 aaa 2 bbb 3 CCC Editor functions Now implement the following functions of the editor: void insert Cintline_do. churc): Inserts the text in the row To do this, use the above-mentioned auxiliary functions from the previous task void dolce Cintline) Deletes the powinno To do this, use the above-mentioned auxiliary functions from the sub functions module. Global.control Write the main function which first initialises text_field and then carries out the user intention. In essence, the main function consists of an endless loop that reads in a command van and calls the corresponding editor function from the functie module depending on the command letter returned. The programme is terminated with the commande The varinbles in field and male, declared globally in main.h are to be defined and initialised in the module main Hints: You can implement the task as an extension of task 1. Document your programme in detail, ie the purpose of each global variable and each function must be explained! . You may use the string library string for the implementation . Please upload all files for this task (only cand.h files)! Example of an interaction sequence : 11/Hello i2/World! 13/Programming 14/in i5/C 16/is 17/great! i7/really d7 P 9 Output: 1 Hello 2 World! 3 Programming 4 in 5 C 6 is 7 great! 1 Hello 2 World! 3 Programming 5 C 7 really 8 great! 1 Hello 2 World! 3 Programming 4 in 5 C 7 great

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

| What are the values that are most important to me?

Answered: 1 week ago

Question

Discuss the history of human resource management (HRM).

Answered: 1 week ago