From 03f53f231f0708b9f9f74302554a5d7d982aaa21 Mon Sep 17 00:00:00 2001 From: Oskar Date: Sat, 23 Dec 2023 19:22:23 +0100 Subject: New delete line feature. Lost of fixes too --- 7ed.h | 2 -- README | 11 ----------- editmode.c | 1 - startmode.c | 3 +-- 4 files changed, 1 insertion(+), 16 deletions(-) diff --git a/7ed.h b/7ed.h index f0be605..ece0aab 100644 --- a/7ed.h +++ b/7ed.h @@ -8,8 +8,6 @@ #define BUF_SZ_4 4096 #define BUF_SZ_8 8192 - - int count_lines_in_file(char filename[], uint64_t *lines); int count_lines_in_file_posix(char filename[], size_t *lines); diff --git a/README b/README index 366fb1d..f5d2f01 100644 --- a/README +++ b/README @@ -2,14 +2,3 @@ This is my take on a so called "Line editor" Its a crude and simple line editor. WARNING: Do not use this program on any files that you dont want to risk damaging, deleting or overwriting. I can not gaurantee that this program will function as expected. - -TODO: -- Create a function to retrieve a line from file (DONE) It's called: GET_LINE(char filename[], long focus, char **line) -- Create edit mode to actually make edits to the file (DONE) -- Find and fix bugs. Fixed one bug in write_line() function. (btw this was written with 7ed!!!) -- Create functionality to actually add new lines. You cant actually add a line on the end of the file. You also cant just add a line and move everything under it one line down. I will get to fixing that though. - - - - - diff --git a/editmode.c b/editmode.c index a5d7641..2fb40b2 100644 --- a/editmode.c +++ b/editmode.c @@ -14,7 +14,6 @@ int delete_specified_newline(char filename[], long focus) { // special version o if (ret == 1) { return EXIT_FAILURE; } - // TODO: Some code that checks if its the first line in the file. Because such a situation might cause a problem. Im not entirely sure yet. start = start-1; // decrement by 1 to place start position at the newline diff --git a/startmode.c b/startmode.c index 5df9032..7bd5049 100644 --- a/startmode.c +++ b/startmode.c @@ -109,7 +109,6 @@ int startmode(char filename[]) { return EXIT_FAILURE; } fprintf(stdout, "%s", line); - //printf("%ld", start); free(line); break; @@ -189,7 +188,7 @@ int startmode(char filename[]) { return 1; } int increment = 0; - if (focus == 1) { // if we are at line 1 then increment becomes 1 + if (focus == 1) { // checks if its line 1. This is so that we can remove the newline properly. increment++; } int rlc = remove_line_contents(filename, focus); -- cgit v1.2.3