summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <>2024-03-26 20:13:15 +0100
committerOskar <>2024-03-26 20:13:15 +0100
commit289756c87adbbab92a85699e250e4ef3ac97f269 (patch)
tree5e4f25ba009f9b07db59701eec4bdb489974e76d
parent939dd3053fbc6a64eeb8be398fe4c6785933988f (diff)
added display_name_linecount, kinda out of scope but it was on my mind
-rwxr-xr-x7edbin0 -> 647824 bytes
-rw-r--r--startmode.c23
-rw-r--r--test/testgrounds/file.txt5
3 files changed, 20 insertions, 8 deletions
diff --git a/7ed b/7ed
new file mode 100755
index 0000000..5e1dcce
--- /dev/null
+++ b/7ed
Binary files differ
diff --git a/startmode.c b/startmode.c
index 43def3b..e9064f4 100644
--- a/startmode.c
+++ b/startmode.c
@@ -25,15 +25,24 @@ int ncat(char filename[]) {
return 0;
}
-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 display_name_linecount(char *filename, uint64_t Flines) {
+
int returnval = count_lines_in_file(filename, &Flines);
if (returnval == 1) {
return 1;
}
fprintf(stdout,"%s %lu lines\n", filename, Flines);
+ return 0;
+}
+
+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 dnl = display_name_linecount(filename, Flines);
+ if (dnl == 1) {
+ return EXIT_FAILURE;
+ }
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
@@ -130,13 +139,11 @@ int startmode(char filename[]) {
case 'C':
case 'c':
- uint64_t CFlines;
- int returnval = count_lines_in_file(filename, &CFlines);
- if (returnval == 1) {
+ int dnl = display_name_linecount(filename, Flines);
+ if (dnl == 1) {
return EXIT_FAILURE;
}
- fprintf(stdout,"%s %zu lines\n", filename, CFlines);
-
+
break;
case 'Q':
case 'q':
diff --git a/test/testgrounds/file.txt b/test/testgrounds/file.txt
index 6f741aa..42bd85b 100644
--- a/test/testgrounds/file.txt
+++ b/test/testgrounds/file.txt
@@ -1,3 +1,7 @@
+what!
+
+
+
lksdjflsdjfls209432+093+20943????01+230+2,.,-.,-,-.,-.,.,..,.,.,¨.¨,¨.,¨.´.´,´.,´.,´.´,.´,.´.´,´.????`?`?`?`?`?`?`?`?`???????!!!!!!!!
@@ -23,4 +27,5 @@ LINE 22!!!!!!!
ast line!!!
+what what whaat wwhhhhaaaaaaaat