summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorOskar <[email protected]>2023-11-07 23:12:31 +0100
committerOskar <[email protected]>2023-11-07 23:12:31 +0100
commite2965f7ea63a5426e018c4e8c7f557fcce4c69c0 (patch)
treec6c351a729b64a8a0112de6f1e3849746f629695 /functions.c
parentc09957c3026aa7f25d7bc7a0379d961990bc9e34 (diff)
Added edit mode and function to write the changes to file. Write function is not completely done yet because the temp file created by it is not removed when it is done. But other than that the editor actually works now. There are still some quirks that i need to sort out, especially the fact that you cant actually create a new line beyond the amount in the file you are editing
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/functions.c b/functions.c
index 34e0dd7..ac3f789 100644
--- a/functions.c
+++ b/functions.c
@@ -123,15 +123,6 @@ void shuffle(char arr[], int n) {
int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Making this function was hell. Hardest thing ive coded in a while.
- size_t lines;
- int ret = COUNT_LINES_IN_FILE(filename, &lines);
- if (ret == 1) {
- return EXIT_FAILURE;
- }
-
- if ((long)lines < focus) { // check if focus is bigger than the amount of
- return EXIT_FAILURE; // lines in the actual file and returns exit failure
- }
FILE *file;
file = fopen(filename,"r"); // Open file
@@ -141,6 +132,17 @@ int GET_LINE(char filename[], long focus, char **line, size_t *start) { // Makin
return 1;
}
+ /*
+ size_t lines;
+ int ret = COUNT_LINES_IN_FILE(filename, &lines);
+ if (ret == 1) {
+ return EXIT_FAILURE;
+ }
+
+ if ((long)lines < focus) { // check if focus is bigger than the amount of
+ return EXIT_FAILURE; // lines in the actual file and returns exit failure
+ }
+ */
if (focus == 1) {
int c1_count = 0;
while (1) {