openfilestruct, and so that the values in it are used directly
instead of being periodically synced up with the globals.
Accordingly, remove the globals. Changes to pretty much
- every function. Rename global_init() window_size_init(),
- rename add_open_file() make_new_buffer(), rename load_buffer()
- open_buffer(), rename load_open_file() display_buffer(),
- rename open_prevnext_file() switch_to_prevnext_buffer(),
- rename open_prevfile_void() switch_to_prev_buffer(), rename
- open_nextfile_void() switch_to_next_buffer(), rename
- write_marked() write_marked_file(), remove load_file(), rename
- cancel_fork() cancel_command(), rename open_pipe()
- execute_command(), remove execute_command(), remove
- resize_variables(), rename get_buffer() get_key_buffer(), and
- rename get_buffer_len() get_key_buffer_len(). (DLR)
+ every function. Rename add_open_file() make_new_buffer(),
+ rename load_buffer() open_buffer(), rename load_open_file()
+ display_buffer(), rename open_prevnext_file()
+ switch_to_prevnext_buffer(), rename open_prevfile_void()
+ switch_to_prev_buffer(), rename open_nextfile_void()
+ switch_to_next_buffer(), rename write_marked()
+ write_marked_file(), remove load_file(), rename cancel_fork()
+ cancel_command(), rename open_pipe() execute_command(), remove
+ execute_command(), rename resize_variables(), rename
+ global_init() window_size_init(), rename get_buffer()
+ get_key_buffer(), and rename get_buffer_len()
+ get_key_buffer_len(). (DLR)
- Replace all mvwaddstr(hblank) calls with a new function that
does the same thing without the need for hblank. New function
blank_line(); changes to do_browser(), blank_titlebar(),
do_colorinit() (renamed color_init()), color_to_int() (renamed
color_to_short()), and parse_colors(). (DLR)
- Change color handling to save only the regex strings
- constantly, and to actually compile them on an as-needed
- basis. Changes to update_color() and
+ constantly, and to actually compile them on an as-needed
+ basis. Changes to update_color() and
thanks_for_all_the_fish(). (Brand Huntsman and DLR)
- Various other color fixes. Handle unspecified foreground
colors properly, don't automatically reinitialize the
displayed colors every time we update the current buffer's
colors (since the buffer may not be displayed immediately),
- and don't bother doing complete refreshes of the screen when
+ don't bother doing complete refreshes of the screen when
color support is enabled if there's no regex associated with
- the current file. Changes to do_colorinit() (renamed
- color_init()), update_color() (renamed color_update()),
- write_file(), do_input(), and do_output(). (DLR)
+ the current file, and rename variable exttype->val to
+ exttype->ext, for consistency. Changes to do_colorinit()
+ (renamed color_init()), update_color() (renamed
+ color_update()), write_file(), do_input(), do_output(), and
+ parse_syntax(). (DLR)
- Simplify get_totals() to only get the total number of
characters, and eliminate dependence on its old ability to get
the total number of lines by renumber()ing when necessary and
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
/* Set colorstrings if we matched the extension regex. */
- if (regexec(&e->val, openfile->filename, 0, NULL, 0) == 0)
+ if (regexec(&e->ext, openfile->filename, 0, NULL, 0) == 0)
openfile->colorstrings = tmpsyntax->color;
if (openfile->colorstrings != NULL)
#include <assert.h>
#include "proto.h"
-/* Create a new openfilestruct node. */
-openfilestruct *make_new_opennode(void)
-{
- openfilestruct *newnode =
- (openfilestruct *)nmalloc(sizeof(openfilestruct));
- newnode->filename = NULL;
-
- return newnode;
-}
-
-/* Splice a node into an existing openfilestruct. */
-void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
- openfilestruct *end)
-{
- assert(newnode != NULL && begin != NULL);
-
- newnode->next = end;
- newnode->prev = begin;
- begin->next = newnode;
- if (end != NULL)
- end->prev = newnode;
-}
-
-/* Unlink a node from the rest of the openfilestruct, and delete it. */
-void unlink_opennode(openfilestruct *fileptr)
-{
- assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL && fileptr != fileptr->prev && fileptr != fileptr->next);
-
- fileptr->prev->next = fileptr->next;
- fileptr->next->prev = fileptr->prev;
- delete_opennode(fileptr);
-}
-
-/* Delete a node from the openfilestruct. */
-void delete_opennode(openfilestruct *fileptr)
-{
- assert(fileptr != NULL && fileptr->filename != NULL && fileptr->fileage != NULL);
-
- free(fileptr->filename);
- free_filestruct(fileptr->fileage);
-#ifndef NANO_SMALL
- free(fileptr->current_stat);
-#endif
- free(fileptr);
-}
-
-#ifdef DEBUG
-/* Deallocate all memory associated with this and later files, including
- * the lines of text. */
-void free_openfilestruct(openfilestruct *src)
-{
- assert(src != NULL);
-
- while (src != src->next) {
- src = src->next;
- delete_opennode(src->prev);
- }
- delete_opennode(src);
-}
-#endif
-
/* Add an entry to the openfile openfilestruct. This should only be
* called from open_buffer(). */
void make_new_buffer(void)
/* Reinitialize the current entry of the openfile openfilestruct. */
void reinitialize_buffer(void)
{
- assert(openfile != NULL);
+ assert(openfile != NULL && openfile->filename != NULL && openfile->fileage != NULL);
free(openfile->filename);
-
free_filestruct(openfile->fileage);
-
#ifndef NANO_SMALL
- free(openfile->current_stat);
+ if (openfile->current_stat != NULL)
+ free(openfile->current_stat);
#endif
initialize_buffer();
} else
statusbar(_("Reading File"));
}
+
return 0;
}
exttype *bob = syntaxes->extensions;
syntaxes->extensions = bob->next;
- regfree(&bob->val);
+ regfree(&bob->ext);
free(bob);
}
while (syntaxes->color != NULL) {
openfile->totlines = openfile->filebot->lineno;
}
+/* Create a new openfilestruct node. */
+openfilestruct *make_new_opennode(void)
+{
+ openfilestruct *newnode =
+ (openfilestruct *)nmalloc(sizeof(openfilestruct));
+
+ newnode->filename = NULL;
+ newnode->fileage = NULL;
+ newnode->filebot = NULL;
+ newnode->edittop = NULL;
+ newnode->current = NULL;
+
+ return newnode;
+}
+
+/* Splice a node into an existing openfilestruct. */
+void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
+ openfilestruct *end)
+{
+ assert(newnode != NULL && begin != NULL);
+
+ newnode->next = end;
+ newnode->prev = begin;
+ begin->next = newnode;
+
+ if (end != NULL)
+ end->prev = newnode;
+}
+
+/* Unlink a node from the rest of the openfilestruct, and delete it. */
+void unlink_opennode(openfilestruct *fileptr)
+{
+ assert(fileptr != NULL && fileptr->prev != NULL && fileptr->next != NULL && fileptr != fileptr->prev && fileptr != fileptr->next);
+
+ fileptr->prev->next = fileptr->next;
+ fileptr->next->prev = fileptr->prev;
+
+ delete_opennode(fileptr);
+}
+
+/* Delete a node from the openfilestruct. */
+void delete_opennode(openfilestruct *fileptr)
+{
+ assert(fileptr != NULL && fileptr->filename != NULL && fileptr->fileage != NULL);
+
+ free(fileptr->filename);
+ free_filestruct(fileptr->fileage);
+#ifndef NANO_SMALL
+ if (fileptr->current_stat != NULL)
+ free(fileptr->current_stat);
+#endif
+
+ free(fileptr);
+}
+
+#ifdef DEBUG
+/* Deallocate all memory associated with this and later files, including
+ * the lines of text. */
+void free_openfilestruct(openfilestruct *src)
+{
+ assert(src != NULL);
+
+ while (src != src->next) {
+ src = src->next;
+ delete_opennode(src->prev);
+ }
+
+ delete_opennode(src);
+}
+#endif
+
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
ssize_t lineno; /* The line number. */
} filestruct;
+typedef struct partition {
+ filestruct *fileage;
+ filestruct *top_prev;
+ char *top_data;
+ filestruct *filebot;
+ filestruct *bot_next;
+ char *bot_data;
+} partition;
+
#ifdef ENABLE_COLOR
typedef struct colortype {
short fg; /* Foreground color. */
} colortype;
typedef struct exttype {
- regex_t val; /* The extensions that match this
+ regex_t ext; /* The extensions that match this
* syntax. */
struct exttype *next;
} exttype;
/* Previous node. */
} openfilestruct;
-typedef struct partition {
- filestruct *fileage;
- filestruct *top_prev;
- char *top_data;
- filestruct *filebot;
- filestruct *bot_next;
- char *bot_data;
-} partition;
-
typedef struct shortcut {
/* Key values that aren't used should be set to NANO_NO_KEY. */
int ctrlval; /* Special sentinel key or control key we want
void do_uncut_text(void);
/* Public functions in files.c. */
-openfilestruct *make_new_opennode(void);
-void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
- openfilestruct *end);
-void unlink_opennode(openfilestruct *fileptr);
-void delete_opennode(openfilestruct *fileptr);
-#ifdef DEBUG
-void free_openfilestruct(openfilestruct *src);
-#endif
void make_new_buffer(void);
void initialize_buffer(void);
#ifndef DISABLE_SPELLER
void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
filestruct *top, size_t top_x, filestruct *bot, size_t bot_x);
void copy_from_filestruct(filestruct *file_top, filestruct *file_bot);
+openfilestruct *make_new_opennode(void);
+void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
+ openfilestruct *end);
+void unlink_opennode(openfilestruct *fileptr);
+void delete_opennode(openfilestruct *fileptr);
+#ifdef DEBUG
+void free_openfilestruct(openfilestruct *src);
+#endif
void print_view_warning(void);
void finish(void);
void die(const char *msg, ...);
break;
newext = (exttype *)nmalloc(sizeof(exttype));
- if (nregcomp(&newext->val, fileregptr, REG_NOSUB)) {
+ if (nregcomp(&newext->ext, fileregptr, REG_NOSUB)) {
if (endext == NULL)
endsyntax->extensions = newext;
else