statusbar(_("Read %d lines"), lines);
return 1;
}
+
if (current != NULL) {
fileptr->next = current;
current->prev = fileptr;
placewewant = 0;
} else if (fileptr->next == NULL) {
filebot = fileptr;
+ new_magicline();
+
+ /* Update the edit buffer */
load_file();
}
statusbar(_("Read %d lines"), lines);
dump_buffer(fileage);
while (fileptr != NULL && fileptr->next != NULL) {
+ /* Next line is so we discount the "magic line" */
+ if(filebot == fileptr && fileptr->data[0] == '\0') break;
+
size = write(fd, fileptr->data, strlen(fileptr->data));
if (size == -1) {
statusbar(_("Could not open file for writing: %s"),
/* The user typed a printable character; add it to the edit buffer */
void do_char(char ch)
{
+ /* magic-line: when a character is inserted on the current magic line,
+ * it means we need a new one! */
+ if(filebot == current && current->data[0] == '\0') {
+ new_magicline();
+ if(current == editbot)
+ fix_editbot();
+ }
+
/* More dangerousness fun =) */
current->data = nrealloc(current->data, strlen(current->data) + 2);
memmove(¤t->data[current_x + 1],
void *nrealloc(void *ptr, size_t howmuch);
void die(char *msg, ...);
void new_file(void);
-
+void new_magicline(void);
int do_writeout_void(void), do_exit(void), do_gotoline_void(void);
int do_insertfile(void), do_search(void), page_up(void), page_down(void);
filestruct *copy_node(filestruct * src);
filestruct *copy_filestruct(filestruct * src);
filestruct *make_new_node(filestruct * prevnode);
-
-
return r;
}
+
+/* Append a new magic-line to filebot */
+void new_magicline(void) {
+ filebot->next = nmalloc(sizeof(filestruct));
+ filebot->next->data = nmalloc(1);
+ filebot->next->data[0] = '\0';
+ filebot->next->prev = filebot;
+ filebot->next->next = NULL;
+ filebot->next->lineno = filebot->lineno + 1;
+ filebot = filebot->next;
+ totlines++;
+}