can now save to file
parent
bd0198b407
commit
64be24496e
|
@ -0,0 +1,17 @@
|
||||||
|
void
|
||||||
|
c_save(char *file) {
|
||||||
|
FILE *f = fopen(file + 2, "w");
|
||||||
|
if(f == NULL) { puts("couldnt open file."); return; }
|
||||||
|
Row *row = buffer;
|
||||||
|
while (1) {
|
||||||
|
for(int i = 0; i < ROW_SIZE; i++) {
|
||||||
|
if (row->text[i] == '\0' || row->text[i] == '\n')
|
||||||
|
break;
|
||||||
|
fwrite(&row->text[i], 1, 1, f);
|
||||||
|
}
|
||||||
|
fwrite("\n", 1, 1, f);
|
||||||
|
if (row->n == NULL) break;
|
||||||
|
row = row->n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,3 +6,4 @@ NULL,
|
||||||
['w'] = c_writeline,
|
['w'] = c_writeline,
|
||||||
['q'] = NULL,
|
['q'] = NULL,
|
||||||
['Q'] = c_quit,
|
['Q'] = c_quit,
|
||||||
|
['S'] = c_save,
|
||||||
|
|
1
efn.c
1
efn.c
|
@ -20,3 +20,4 @@
|
||||||
#include "c_writeline.c"
|
#include "c_writeline.c"
|
||||||
#include "b_getline.c"
|
#include "b_getline.c"
|
||||||
|
|
||||||
|
#include "c_save.c"
|
||||||
|
|
Loading…
Reference in New Issue