Started working on file opening support
This commit is contained in:
20
editor.c
20
editor.c
@@ -4,6 +4,7 @@
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef struct Buffer_struct Buffer;
|
||||
struct Buffer_struct {
|
||||
@@ -93,10 +94,25 @@ void sigint_handler(int dummy) {
|
||||
exit(130);
|
||||
}
|
||||
|
||||
int main() {
|
||||
int main(int argc, char** argv) {
|
||||
signal(SIGINT,sigint_handler);
|
||||
|
||||
Buffer* buffer = new_buffer(10);
|
||||
|
||||
if (argc == 2) {
|
||||
if (access(argv[1],F_OK) == 0) { /* If the file exists */
|
||||
|
||||
FILE* file = fopen(argv[1],"r");
|
||||
char c;
|
||||
while (c = fgetc(file) != EOF) {
|
||||
buffer_insert(c,buffer);
|
||||
}
|
||||
|
||||
} else {
|
||||
printf("File does not exist.\n");
|
||||
return -10;
|
||||
}
|
||||
}
|
||||
|
||||
init_curses();
|
||||
int ch;
|
||||
|
||||
|
Reference in New Issue
Block a user