|
|
@ -99,19 +99,28 @@ int main(int argc, char** argv) {
|
|
|
|
Buffer* buffer = new_buffer(10);
|
|
|
|
Buffer* buffer = new_buffer(10);
|
|
|
|
|
|
|
|
|
|
|
|
if (argc == 2) {
|
|
|
|
if (argc == 2) {
|
|
|
|
|
|
|
|
int num_of_chars = 0;
|
|
|
|
if (access(argv[1],F_OK) == 0) { /* If the file exists */
|
|
|
|
if (access(argv[1],F_OK) == 0) { /* If the file exists */
|
|
|
|
FILE* file = fopen(argv[1],"r");
|
|
|
|
FILE* file = fopen(argv[1],"r");
|
|
|
|
char c;
|
|
|
|
char c;
|
|
|
|
while ((c = fgetc(file)) != EOF) {
|
|
|
|
while ((c = fgetc(file)) != EOF) {
|
|
|
|
buffer_insert(c,buffer);
|
|
|
|
buffer_insert(c,buffer);
|
|
|
|
|
|
|
|
num_of_chars++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
printf("File does not exist.\n");
|
|
|
|
printf("File does not exist.\n");
|
|
|
|
return -10;
|
|
|
|
return -10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (num_of_chars > 1) {
|
|
|
|
|
|
|
|
buffer_left(buffer);
|
|
|
|
|
|
|
|
num_of_chars--;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_curses();
|
|
|
|
init_curses();
|
|
|
|
int ch;
|
|
|
|
int ch;
|
|
|
|
|
|
|
|
|
|
|
@ -120,8 +129,8 @@ int main(int argc, char** argv) {
|
|
|
|
clear();
|
|
|
|
clear();
|
|
|
|
|
|
|
|
|
|
|
|
int i=0;
|
|
|
|
int i=0;
|
|
|
|
if (buffer->start != buffer->text) { /* We don't want to print the string, if the
|
|
|
|
if ((buffer->start != buffer->text) || (buffer->gap_size != buffer->size)) { /* We don't want to print the string, if the
|
|
|
|
gap starts at the first index of the string */
|
|
|
|
gap starts at the first index of the string, and continues till the end */
|
|
|
|
|
|
|
|
|
|
|
|
while (i < buffer->size) {
|
|
|
|
while (i < buffer->size) {
|
|
|
|
addch(*(buffer->text + i));
|
|
|
|
addch(*(buffer->text + i));
|
|
|
@ -131,6 +140,7 @@ int main(int argc, char** argv) {
|
|
|
|
getyx(stdscr,y,x);
|
|
|
|
getyx(stdscr,y,x);
|
|
|
|
i += buffer->gap_size;
|
|
|
|
i += buffer->gap_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
move(y,x);
|
|
|
|
move(y,x);
|
|
|
|