From 32e27cbd2d5c151e7f4805dd862c5ec18ca62b9d Mon Sep 17 00:00:00 2001 From: Oskar Date: Sun, 11 Feb 2024 17:51:01 +0100 Subject: README update --- 7ed | Bin 766048 -> 0 bytes Makefile | 5 +++-- README | 4 ++++ functions.c | 16 +--------------- startmode.c | 10 +++++----- 5 files changed, 13 insertions(+), 22 deletions(-) delete mode 100755 7ed diff --git a/7ed b/7ed deleted file mode 100755 index 5e05ffc..0000000 Binary files a/7ed and /dev/null differ diff --git a/Makefile b/Makefile index d4371ce..83d8401 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ -CC=gcc #gcc works best here, mostly because i experienced errors in clang that i dont care to deal with quite yet. +CC=cc CFLAGS=-Wfatal-errors -Wall -Werror -Wextra -g -O2 -static CFLAGS_TESTBIN=-Wfatal-errors -Wall -Werror -Wextra -g -fsanitize=address TARGET=7ed TESTTARGET=7ed-TESTING INSTALL_DIRECTORY=/usr/local/bin + all: 7ed 7ed: $(CC) $(CFLAGS) 7ed.c functions.c startmode.c editmode.c -o $(TARGET) @@ -18,6 +19,6 @@ tests: $(CC) $(CFLAGS_TESTBIN) 7ed.c functions.c startmode.c editmode.c -o test/$(TESTTARGET) install: - cp $(TARGET) $(INSTALL_DIRECTORY) + @cp $(TARGET) $(INSTALL_DIRECTORY) @echo "$(TARGET) was installed to $(INSTALL_DIRECTORY)" diff --git a/README b/README index f5d2f01..ded9675 100644 --- a/README +++ b/README @@ -2,3 +2,7 @@ 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: +-Add some sort of feature to do L+ or L- to increment or decrement without having to do too many inputs +-Change "N" to make it a bit less annoying to use diff --git a/functions.c b/functions.c index b308622..e0f6ba9 100644 --- a/functions.c +++ b/functions.c @@ -6,20 +6,6 @@ #include #include -void confirm() { - struct termios old,new; - - tcgetattr(fileno(stdin),&old); - tcgetattr(fileno(stdin),&new); - cfmakeraw(&new); - tcsetattr(fileno(stdin),TCSANOW,&new); - fputs("Press any key to continue...",stdout); - fflush(NULL); - fgetc(stdin); - tcsetattr(fileno(stdin),TCSANOW,&old); - puts(""); -} - int choice() { char choice; @@ -56,7 +42,7 @@ int count_lines_in_file (char filename[], uint64_t *lines) { file = fopen(filename,"rb"); // Open file if (file == NULL) { // Check if you can open file - fprintf(stderr, "Cannot open file. COUNT_LINES_IN_FILE\n"); + fprintf(stderr, "count_lines_in_file(): Cannot open file.\n"); return 1; } fseek(file, -1, SEEK_END); diff --git a/startmode.c b/startmode.c index bf948ce..9e0daf1 100644 --- a/startmode.c +++ b/startmode.c @@ -41,10 +41,8 @@ int startmode(char filename[]) { int ret = count_lines_in_file(filename, &Flines); if (ret == 1) { return EXIT_FAILURE; - } // I do not know WHY i can not have this return to a variable?? - // For some reason whenever i do int x = count_lines_in_file(.....) it will NOT compile - // I can not for the life of me figure out what the compiler is trying to say about the"expected expression" error - // I HAVE DONE THE SAME THING EVERYWHERE ELSE WHY WOULD IT INEXPLICABLY NOT WORK SPECIFICALLY HERE? + } + fprintf(stdout, "(%lu): ", focus); char command = getchar(); if (command == '\n') { @@ -217,11 +215,13 @@ int startmode(char filename[]) { break; } default: fprintf(stdout, "?\n"); + } - + } + return EXIT_SUCCESS; } -- cgit v1.2.3