diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | startmode.c | 13 | ||||
-rw-r--r-- | test/Makefile | 8 |
3 files changed, 21 insertions, 8 deletions
@@ -3,10 +3,12 @@ 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) + @echo "$(TARGET) is done. Run 'make install' as root to install it" clean: rm -f $(TARGET) @@ -14,4 +16,8 @@ clean: tests: $(CC) $(CFLAGS_TESTBIN) 7ed.c functions.c startmode.c editmode.c -o test/$(TESTTARGET) - + +install: + cp $(TARGET) $(INSTALL_DIRECTORY) + @echo "$(TARGET) was installed to $(INSTALL_DIRECTORY)" + diff --git a/startmode.c b/startmode.c index 9a760b1..d90f785 100644 --- a/startmode.c +++ b/startmode.c @@ -26,7 +26,7 @@ int ncat(char filename[]) { } int startmode(char filename[]) { - + // The entry to the program. Count lines and display the count. Also show which file is being edited. uint64_t Flines; int returnval = count_lines_in_file(filename, &Flines); if (returnval == 1) { @@ -34,9 +34,8 @@ int startmode(char filename[]) { } fprintf(stdout,"%s %lu lines\n", filename, Flines); - uint64_t focus = 1; - // This stuff before the while loop is to display the amount of lines upon starting the editor and also setting focus - while(1) { + uint64_t focus = 1; // The focus variable. Which is the actual line number we have "selected" + while(1) { // The main loop to get the "UI" started firstwhile: int ret = count_lines_in_file(filename, &Flines); @@ -53,9 +52,9 @@ int startmode(char filename[]) { } while ('\n' != getchar()); - switch (command) { + switch (command) { case 'L': - case 'l': + case 'l': // L is how we change out "focus" uint64_t Lfocus = 0; char buf[1024]; int success; @@ -67,7 +66,7 @@ int startmode(char filename[]) { break; } if (buf[0] == '\n') { - goto firstwhile; // start the first while loop aka startmode + goto firstwhile; // If the user presses enter then we just goto start of the main loop } char *endptr; diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..75145a3 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,8 @@ +all: 7ed-TESTING +7ed-TESTING: + cd .. && make tests + @echo "Done." + +clean: + cd .. && make clean + @echo "Cleaned." |