diff options
author | Oskar <[email protected]> | 2024-03-31 22:28:31 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-03-31 22:28:31 +0200 |
commit | c5b58534dc41ec36e041717918de5727e0200b28 (patch) | |
tree | fd0ef1f829792fc8b70bf7869d25b67e13cb11f1 | |
parent | a632711155260c9d7bd679736987857041afbddb (diff) |
Singles done
-rw-r--r-- | 7ed.h | 2 | ||||
-rw-r--r-- | editmode.c | 2 | ||||
-rw-r--r-- | input.c | 3 | ||||
-rw-r--r-- | input.h | 1 | ||||
-rw-r--r-- | process_multiples.c | 10 | ||||
-rw-r--r-- | startmode.c | 31 |
6 files changed, 43 insertions, 6 deletions
@@ -26,7 +26,7 @@ int startmode(char filename[]); int get_line(char filename[], long focus, char **line, size_t *start); -int editmode(char filename[], long focus); +int editmode(char filename[], uint64_t focus); int new_line(char filename[], long new_line_pos_temp); @@ -226,7 +226,7 @@ int remove_line_contents(char filename[], long focus) { // removes contents of a } -int editmode(char filename[], long focus) { // the editing interface +int editmode(char filename[], uint64_t focus) { // the editing interface char *line; size_t start; @@ -106,6 +106,9 @@ int smode_input(char *single, char **multiple, uint64_t focus) { // This functio *single = smode_buf[0]; return _SINGLE; break; + case '\n': + return _RETURN; + break; } @@ -9,6 +9,7 @@ #define SMODE_MAX_SIZE 33 #define SMODE_MAX_INPUT_SIZE 32 +#define _RETURN 3 #define _ONE 1 #define _SINGLE 1 #define _MULTIPLE 2 diff --git a/process_multiples.c b/process_multiples.c new file mode 100644 index 0000000..839573a --- /dev/null +++ b/process_multiples.c @@ -0,0 +1,10 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include "7ed.h" +#include "input.h" +#include "i_validation.h" +#include <stdint.h> + diff --git a/startmode.c b/startmode.c index a52e4d2..3b4179b 100644 --- a/startmode.c +++ b/startmode.c @@ -39,30 +39,52 @@ int display_name_linecount(char *filename) { return 0; } -int call_singles(char single) { +int call_singles(char single, uint64_t focus, char *filename) { switch(single) { case 'p': case 'P': - + + char *line; + size_t start; + int ret = get_line(filename, focus, &line, &start); + if (ret == 1) { + return EXIT_FAILURE; + } + fprintf(stdout, "%s", line); + free(line); + break; case 'e': case 'E': + editmode(filename, focus); + break; case 'c': case 'C': + int dnl = display_name_linecount(filename); + if (dnl == 1) { + return EXIT_FAILURE; + } + break; case 'q': case 'Q': + exit(EXIT_SUCCESS); + break; case 'a': case 'A': + ncat(filename); + break; } + + return 0; } int startmode(char filename[]) { @@ -81,8 +103,7 @@ int startmode(char filename[]) { switch (smode_input_ret) { case _SINGLE: - fprintf(stdout, "single\n"); - fprintf(stdout, "%c\n", single); + call_singles(single, focus, filename); break; case _MULTIPLE: fprintf(stdout, "multiple\n"); @@ -92,6 +113,8 @@ int startmode(char filename[]) { case _FAIL: fprintf(stdout, "?\n"); break; + case _RETURN: // if user just preses 'return' button + break; } |