1
1

add miscellaneous color and openfilestruct cleanups, and move the

openfilestruct functions to nano.c, since they're no longer specific to
file operations


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2903 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2005-07-20 21:08:38 +00:00
родитель ca62f9fa2b
Коммит e99494f21a
8 изменённых файлов: 116 добавлений и 103 удалений

Просмотреть файл

@ -13,17 +13,18 @@ CVS code -
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(),
@ -49,18 +50,20 @@ CVS code -
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

Просмотреть файл

@ -124,7 +124,7 @@ void color_update(void)
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)

Просмотреть файл

@ -37,67 +37,6 @@
#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)
@ -159,14 +98,13 @@ void initialize_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();
@ -619,6 +557,7 @@ int open_file(const char *filename, bool newfie, FILE **f)
} else
statusbar(_("Reading File"));
}
return 0;
}

Просмотреть файл

@ -1218,7 +1218,7 @@ void thanks_for_all_the_fish(void)
exttype *bob = syntaxes->extensions;
syntaxes->extensions = bob->next;
regfree(&bob->val);
regfree(&bob->ext);
free(bob);
}
while (syntaxes->color != NULL) {

Просмотреть файл

@ -469,6 +469,77 @@ void copy_from_filestruct(filestruct *file_top, filestruct *file_bot)
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"));

Просмотреть файл

@ -160,6 +160,15 @@ typedef struct filestruct {
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. */
@ -180,7 +189,7 @@ typedef struct colortype {
} 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;
@ -228,15 +237,6 @@ typedef struct openfilestruct {
/* 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

Просмотреть файл

@ -228,14 +228,6 @@ void do_cut_till_end(void);
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
@ -362,6 +354,14 @@ void unpartition_filestruct(partition **p);
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, ...);

Просмотреть файл

@ -329,7 +329,7 @@ void parse_syntax(char *ptr)
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