summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-02-11 16:42:31 +0100
committerOskar <[email protected]>2024-02-11 16:42:31 +0100
commit30fc82f1b352b806c3716bf551f372cefc84c1d7 (patch)
tree7a91bb442018963d63eec101317b194d420b9a87
parentcbaeb6f6a24532b5ecbc4fea4dcb329961ad4e37 (diff)
More changes to the makefile to make it easier for testing
-rw-r--r--Makefile8
-rw-r--r--startmode.c13
-rw-r--r--test/Makefile8
3 files changed, 21 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 60578f9..b2e88de 100644
--- a/Makefile
+++ b/Makefile
@@ -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."