Display 20 lines from the current line on the screen


The program starts by printing your name with an end sign ">".
2. Then, you can type in a string. If the string is not "vi xxx", you print "I don't know this command." You keep getting a string until you get a string starting with "vi". For example, "vi myp.c". Your program will then open "myp.c" for reading. If the file does not exist, then there is nothing to read.
3. Read the file into a fixed array of "mytext[1000][ 81]". Presumably, the "myp.c" text file is not too large with each line 80 characters or fewer. If there are more characters than 80 in a line, you can just ignore the characters beyond 80.
4. Close your file.
5. Change all your texts to upper case, and display the first 20 lines on your screen.
6. Then, your program will wait for a command from the keyboard.
7. If you type ":w", your program will open the same file for writing, and write your array of text into that file.
8. If you type ":q!", your program will quite.
9. If your type ":w myp1.c", your program will open "myp1.c" and write into that file. You should always close your file after finish.
10. Display one special character as the cursor using ascii code "@" at the position of mytext[0][0]. 
11. Replace Step 5. "Change all your texts to upper case" with "Display 20 lines from the current line on the screen". The current line is where you start displaying lines of texts. It's original value is zero, but it can be modified by the cursor moving out of the 20-line frame.
12. You can use "j" to move the cursor down one line, "k" up one line, "h" left one character, and "l" right one character. Of course, if there is no place to move left, right, up, or down, the cursor just stays. Because you moved the cursor, you need to clear the screen and then display again with the new cursor position. system("clear"); will be able to clear the screen.

Extending on the previous homework, let's have more functions in our editor: 

1. You can use "x" to delete a single character at the special character, which we call the "cursor"; 
2. You can use "dd" to delete a single line, so that all lines behind the deleted line move up accordingly; 
3. You can use "i" to start inserting a string at the cursor. Also, when you type "enter" while you are inserting, the rest of the string behind the current cursor will go to the next line, and all the lines behind will move down as well, and your insertion will continue at the beginning of next line. You can use "esc", the escape key, to stop insertion, so that your system comes back into where before you started insertion. You may want to stop insertion if the current line is full of characters. 

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Display 20 lines from the current line on the screen
Reference No:- TGS093660

Expected delivery within 24 Hours