Question: ---------------I ONLY NEED DELETE FUNCTION------------- Please just implement the deleting funciton In this project, you will implement a simple graphics editor named gfedit. Write your


---------------I ONLY NEED DELETE FUNCTION-------------
Please just implement the deleting funciton
In this project, you will implement a simple graphics editor named gfedit. Write your graphics editor in C using gfx graphics tool. Use gcc compiler on Linux. The editor will be designed to draw lines. It must perform the following functions: - E (edit): opens the specified file and a window on the screen. If the file exists, its contents are drawn on the window. - L (insert): Draws a line on the window. -D (delete): Deletes the specified line from the window. -S (save): Saves the file The editor must keep the lines in a memory buffer using the following data structure: struct line { int lineno; int xl; // the line will be drawn from (x1, yl) to (x2, y2) int yl; int x2; int y2; char color; // line color int next; // link to the next node in the linked list } struct line memorybuffer[25]; // max. 25 lines Memory buffer must be managed using two linked lists: in-use list and free list. int free head; int inuse_head; // head node that points to the first free line in memorybuffer[] // head node that points to the first used line in memorybuffer[] memorybuffer[].next, is the index of the next array element in the linked list. free_head and inuse_head are also array indices. Use -1 to mark the end of the linked list. memorybuffer[25], free_head and inuse_head are global. Write the following editing functions: edit (char *filename) Opens the specified file (with .gfe extension), reads its contents, stores them in the memorybuffer[], and sets the in-use and free list links. If the file does not exist, all nodes in the memorybuffer[] must be in the free list. Then, it must open a window (size 200x300) on the screen, draw the background color and display the lines in memorybuffer[]. Filename must be given by the user in the argument list when he/she runs gfedit. insert(int lineno, int xl, int yl, int x2, int y2, char color) Stores the line parameters in the memorybuffer[] and updates the in-use list and free list links and draws the line on the screen. The new line must be inserted in the memorybuffer[] by taking a node from the beginning of the free list. You must set the line color before drawing the line. Line colors are: R-red gfx_color (255,0,0) G-green gfx_color(0,255,0) B-blue gfx_color(0,0,255) Y-yellow gfx_color (255,255, 0) W-white gfx_color (255, 255, 255) delete(int lineno) Updates the in-use list and free list links, so that the deleted node is deleted from the in-use list and added to the beginning of the free list. Then, refreshes the window on the screen by drawing the background color and then following the in-use list links, draws all lines in the memorybuffer[]. save (char *filename) Follows the links, starting from the inuse_head, writes the contents of memorybuffer[] to the .gfe file and closes the file. Implement the following algorithm: call edit() read input from keyboard and parse it while (input is not x) { if input is L then call insert() if input is D then call delete() if input is s then call save() read input from keyboard and parse it } exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
