add descriptive comments to pretty much all functions and major

variables that don't have them, plus a few miscellaneous minor fixes


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3237 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
David Lawrence Ramsey 2005-12-08 07:09:08 +00:00
parent 034b994eb5
commit 6d6a36c647
14 changed files with 672 additions and 350 deletions

View File

@ -1,5 +1,7 @@
CVS code -
- General:
- Miscellaneous comment fixes. (DLR)
- More int -> bool conversions. (DLR)
- Add the ability to scroll up or down single lines without
scrolling the cursor, via Meta-- and Meta-+. Note that this
is disabled when NANO_SMALL is defined. New functions
@ -170,6 +172,9 @@ CVS code -
(DLR)
- nano.h:
- Readd MIN_EDITOR_COLS #define, set to 4. (DLR)
- proto.h:
- Remove now-unused externs for currslen, shortcut_list,
fileinfo, syntaxfile_regexp, and synfilematches. (DLR)
- prompt.c:
do_statusbar_input()
- Fix misplaced break when handling NANO_VERBATIM_KEY. (DLR)
@ -183,12 +188,17 @@ CVS code -
do_rcfile()
- Remove unneeded assert. (DLR)
- search.c:
search_abort()
- Rename to search_replace_abort(). (DLR)
findnextstr()
- Remove parameter can_display_wrap, as it's always set to TRUE
now, and rename parameter wholeword to whole_word, for
consistency. (DLR)
- Only include the whole_word parameter when DISABLE_SPELLER
isn't defined, as it's only used then. (DLR)
replace_abort()
- Replace with search_replace_abort(), since it does the same
things that this function does. (DLR)
do_replace_loop()
- Change order of parameters to more closely match those of
findnextstr(), and rename parameter wholewords to whole_word,
@ -244,6 +254,8 @@ CVS code -
- Fix test so that we scroll through the line in 8-character
chunks when COLS is greater than 8, not when COLS is greater
than 9. (DLR)
remove_magicline()
- Add assert. (DLR)
- winio.c:
nanoget_repaint()
- Rename parameter inputbuf to buf, for consistency. (DLR)

View File

@ -31,6 +31,8 @@ static bool keep_cutbuffer = FALSE;
static filestruct *cutbottom = NULL;
/* Pointer to the end of the cutbuffer. */
/* Indicate that we should no longer keep the contents of the
* cutbuffer. */
void cutbuffer_reset(void)
{
keep_cutbuffer = FALSE;

View File

@ -336,6 +336,8 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
return fileptr;
}
/* Read an open file into the current buffer. f should be set to the
* open file, and filename should be set to the name of the file. */
void read_file(FILE *f, const char *filename)
{
size_t num_lines = 0;
@ -665,6 +667,9 @@ char *get_next_filename(const char *name, const char *suffix)
return buf;
}
/* Insert a file into a new buffer if the MULTIBUFFER flag is set, or
* into the current buffer if it isn't. If execute is TRUE, insert the
* output of an executed command instead of a file. */
void do_insertfile(
#ifndef NANO_TINY
bool execute
@ -871,6 +876,9 @@ void do_insertfile(
free(ans);
}
/* Insert a file into a new buffer or the current buffer, depending on
* whether the MULTIBUFFER flag is set. If we're in view mode, only
* allow inserting a file into a new buffer. */
void do_insertfile_void(void)
{
#ifdef ENABLE_MULTIBUFFER
@ -1687,6 +1695,10 @@ int write_marked_file(const char *name, FILE *f_open, bool tmp,
}
#endif /* !NANO_TINY */
/* Write the current file to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the file to disk
* regardless of whether the mark is on, and without prompting if the
* TEMP_FILE flag is set. */
int do_writeout(bool exiting)
{
int i, retval = 0;
@ -1854,6 +1866,8 @@ int do_writeout(bool exiting)
return retval;
}
/* Write the current file to disk. If the mark is on, write the current
* marked selection to disk. */
void do_writeout_void(void)
{
do_writeout(FALSE);
@ -2353,6 +2367,9 @@ void load_history(void)
}
}
/* Write the lines of a history list, starting with the line at h, to
* the open file at hist. Return TRUE if the write succeeded, and FALSE
* otherwise. */
bool writehist(FILE *hist, filestruct *h)
{
filestruct *p;

View File

@ -25,132 +25,180 @@
/* Global variables */
#ifndef DISABLE_WRAPJUSTIFY
ssize_t fill = 0; /* The column where we will wrap
* lines. */
ssize_t fill = 0;
/* The column where we will wrap lines. */
ssize_t wrap_at = -CHARS_FROM_EOL;
/* The position where we will wrap
* lines. fill is equal to this if it's
* greater than zero, and equal to
* (COLS + this) if it isn't. */
/* The position where we will wrap lines. fill is equal to this
* if it's greater than zero, and equal to (COLS + this) if it
* isn't. */
#endif
char *last_search = NULL; /* Last string we searched for */
char *last_replace = NULL; /* Last replacement string */
char *last_search = NULL;
/* The last string we searched for. */
char *last_replace = NULL;
/* The last replacement string we searched for. */
long flags = 0; /* Our flag containing many options */
WINDOW *topwin; /* Top subwindow */
WINDOW *edit; /* The file portion of the editor */
WINDOW *bottomwin; /* Bottom subwindow */
long flags = 0;
/* Our flag containing the states of all global options. */
WINDOW *topwin;
/* The top portion of the window, where we display the version
* number of nano, the name of the current file, and whether the
* current file has been modified. */
WINDOW *edit;
/* The middle portion of the window, i.e, the edit window, where
* we display the current file we're editing. */
WINDOW *bottomwin;
/* The bottom portion of the window, where we display statusbar
* messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
/* How many rows does the edit window take up? */
int editwinrows = 0; /* How many rows long is the edit
window? */
filestruct *cutbuffer = NULL; /* A place to store cut text */
filestruct *cutbuffer = NULL;
/* The buffer where we store cut text. */
#ifndef DISABLE_JUSTIFY
filestruct *jusbuffer = NULL; /* A place to store unjustified text */
filestruct *jusbuffer = NULL;
/* The buffer where we store unjustified text. */
#endif
partition *filepart = NULL; /* A place to store a portion of the
file struct */
partition *filepart = NULL;
/* The partition where we store a portion of the current
* file. */
openfilestruct *openfile = NULL;
/* The list of open file buffers */
/* The list of all open file buffers. */
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
char *whitespace = NULL; /* Characters used when displaying
the first characters of tabs and
spaces. */
int whitespace_len[2]; /* The length of the characters. */
char *whitespace = NULL;
/* The characters used when displaying the first characters of
* tabs and spaces. */
int whitespace_len[2];
/* The length of these characters. */
#endif
#ifndef DISABLE_JUSTIFY
char *punct = NULL; /* Closing punctuation that can end
sentences. */
char *brackets = NULL; /* Closing brackets that can follow
closing punctuation and can end
sentences. */
char *quotestr = NULL; /* Quote string. The default value is
set in main(). */
char *punct = NULL;
/* The closing punctuation that can end sentences. */
char *brackets = NULL;
/* The closing brackets that can follow closing punctuation and
* can end sentences. */
char *quotestr = NULL;
/* The quoting string. The default value is set in main(). */
#ifdef HAVE_REGEX_H
regex_t quotereg; /* Compiled quotestr regular expression. */
int quoterc; /* Did it compile? */
char *quoteerr = NULL; /* The error message. */
regex_t quotereg;
/* The compiled regular expression from the quoting string. */
int quoterc;
/* Whether it actually compiled. */
char *quoteerr = NULL;
/* The error message, if it didn't. */
#else
size_t quotelen; /* strlen(quotestr) */
size_t quotelen;
/* The length of the quoting string in bytes. */
#endif
#endif
char *answer = NULL;
/* The answer string used in the statusbar prompt. */
ssize_t tabsize = -1;
/* The width of a tab in spaces. The default value is set in
* main(). */
#ifndef NANO_TINY
char *backup_dir = NULL; /* Backup directory. */
char *backup_dir = NULL;
/* The directory where we store backup files. */
#endif
char *answer = NULL; /* The answer string for statusbar
* questions. */
ssize_t tabsize = -1; /* Our internal tabsize variable. The
default value is set in main(). */
#ifndef DISABLE_OPERATINGDIR
char *operating_dir = NULL; /* Operating directory, which we can't */
char *full_operating_dir = NULL;/* go higher than */
char *operating_dir = NULL;
/* The relative path to the operating directory, which we can't
* move outside of. */
char *full_operating_dir = NULL;
/* The full path to it. */
#endif
#ifndef DISABLE_SPELLER
char *alt_speller = NULL; /* Alternative spell command */
char *alt_speller = NULL;
/* The command to use for the alternate spell checker. */
#endif
shortcut *main_list = NULL;
/* The main shortcut list. */
shortcut *whereis_list = NULL;
/* The "Search" shortcut list. */
shortcut *replace_list = NULL;
shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
/* The "Search (to replace)" shortcut list. */
shortcut *replace_list_2 = NULL;
/* The "Replace with" shortcut list. */
shortcut *gotoline_list = NULL;
/* The "Enter line number, column number" shortcut list. */
shortcut *writefile_list = NULL;
/* The "File Name to Write" shortcut list. */
shortcut *insertfile_list = NULL;
/* The "File to insert" shortcut list. */
#ifndef NANO_TINY
shortcut *extcmd_list = NULL;
/* The "Command to execute" shortcut list. */
#endif
#ifndef DISABLE_HELP
shortcut *help_list = NULL;
/* The help text shortcut list. */
#endif
#ifndef DISABLE_SPELLER
shortcut *spell_list = NULL;
#endif
#ifndef NANO_TINY
shortcut *extcmd_list = NULL;
/* The internal spell checker shortcut list. */
#endif
#ifndef DISABLE_BROWSER
shortcut *browser_list = NULL;
/* The file browser shortcut list. */
shortcut *gotodir_list = NULL;
/* The "Go To Directory" shortcut list. */
#endif
#ifdef ENABLE_COLOR
syntaxtype *syntaxes = NULL;
/* The global list of color syntaxes. */
char *syntaxstr = NULL;
/* The color syntax name specified on the command line. */
#endif
const shortcut *currshortcut; /* Current shortcut list we're using */
const shortcut *currshortcut;
/* The current shortcut list we're using. */
#ifndef NANO_TINY
toggle *toggles = NULL;
/* The global toggle list. */
#endif
#ifndef NANO_TINY
filestruct *search_history = NULL;
/* The search string history list. */
filestruct *searchage = NULL;
/* The top of the search string history list. */
filestruct *searchbot = NULL;
/* The bottom of the search string history list. */
filestruct *replace_history = NULL;
/* The replace string history list. */
filestruct *replaceage = NULL;
/* The top of the replace string history list. */
filestruct *replacebot = NULL;
/* The bottom of the replace string history list. */
#endif
/* Regular expressions */
#ifdef HAVE_REGEX_H
regex_t search_regexp; /* Global to store compiled search regexp */
regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
regex_t search_regexp;
/* The compiled regular expression to use in searches. */
regmatch_t regmatches[10];
/* The match positions for parenthetical subexpressions, 10
* maximum, used in regular expression searches. */
#endif
bool curses_ended = FALSE; /* Indicates to statusbar() to simply
* write to stderr, since endwin() has
* ended curses mode. */
bool curses_ended = FALSE;
/* Whether endwin() has ended curses mode and statusbar()
* should hence write to stderr instead of displaying on the
* statusbar. */
char *homedir = NULL; /* $HOME or from /etc/passwd. */
char *homedir = NULL;
/* The user's home directory, from $HOME or
* /etc/passwd. */
/* Return the number of entries in the shortcut list s. */
size_t length_of_list(const shortcut *s)
{
size_t i = 0;
@ -194,6 +242,8 @@ void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
s->next = NULL;
}
/* Initialize all shortcut lists. If unjustify is TRUE, replace the
* Uncut shortcut in the main shortcut list with UnJustify. */
void shortcut_init(bool unjustify)
{
const char *get_help_msg = N_("Get Help");
@ -365,7 +415,7 @@ void shortcut_init(bool unjustify)
free_shortcutage(&main_list);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
@ -376,7 +426,7 @@ void shortcut_init(bool unjustify)
#endif
);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
openfile != NULL && openfile != openfile->next ?
@ -385,12 +435,12 @@ void shortcut_init(bool unjustify)
exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
NANO_NO_KEY, VIEW, do_exit);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_WRITEOUT_KEY, N_("WriteOut"),
IFHELP(nano_writeout_msg, NANO_NO_KEY), NANO_WRITEOUT_FKEY,
NANO_NO_KEY, NOVIEW, do_writeout_void);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
IFHELP(nano_justify_msg, NANO_NO_KEY),
NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
@ -402,11 +452,12 @@ void shortcut_init(bool unjustify)
);
/* We allow inserting files in view mode if multibuffers are
* available, so that we can view multiple files. */
/* If we're using restricted mode, inserting files is disabled since
* it allows reading from or writing to files not specified on the
* command line. */
/* Translators: try to keep this string under 10 characters long */
* available, so that we can view multiple files. If we're using
* restricted mode, inserting files is disabled, since it allows
* reading from or writing to files not specified on the command
* line. */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_INSERTFILE_KEY, N_("Read File"),
IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
NANO_NO_KEY,
@ -418,38 +469,38 @@ void shortcut_init(bool unjustify)
, !ISSET(RESTRICTED) ? do_insertfile_void :
nano_disabled_msg);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_WHEREIS_KEY, N_("Where Is"),
IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_WHEREIS_FKEY,
NANO_NO_KEY, VIEW, do_search);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_PREVPAGE_KEY, prev_page_msg,
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
NANO_NO_KEY, VIEW, do_page_up);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_NEXTPAGE_KEY, next_page_msg,
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
NANO_NO_KEY, VIEW, do_page_down);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
NANO_NO_KEY, NOVIEW, do_cut_text);
if (unjustify)
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_UNJUSTIFY_KEY, N_("UnJustify"),
IFHELP(NULL, NANO_NO_KEY), NANO_UNJUSTIFY_FKEY,
NANO_NO_KEY, NOVIEW, NULL);
else
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_UNCUT_KEY, N_("UnCut Txt"),
IFHELP(nano_uncut_msg, NANO_NO_KEY), NANO_UNCUT_FKEY,
NANO_NO_KEY, NOVIEW, do_uncut_text);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_CURSORPOS_KEY, N_("Cur Pos"),
IFHELP(nano_cursorpos_msg, NANO_NO_KEY), NANO_CURSORPOS_FKEY,
NANO_NO_KEY, VIEW, do_cursorpos_void);
@ -457,7 +508,7 @@ void shortcut_init(bool unjustify)
/* If we're using restricted mode, spell checking is disabled
* because it allows reading from or writing to files not specified
* on the command line. */
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
NANO_NO_KEY, NOVIEW,
@ -552,12 +603,12 @@ void shortcut_init(bool unjustify)
#endif
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_NO_KEY, beg_of_par_msg,
IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_NO_KEY, end_of_par_msg,
IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
@ -578,14 +629,14 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, NOVIEW, do_verbatim_input);
#ifndef NANO_TINY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_NO_KEY, cut_till_end_msg,
IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
#endif
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_NO_KEY, fulljstify_msg,
IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
@ -609,76 +660,76 @@ void shortcut_init(bool unjustify)
#endif
);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
NANO_NO_KEY, VIEW, do_first_line);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_LASTLINE_KEY, last_line_msg,
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
NANO_NO_KEY, VIEW, do_last_line);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_TOOTHERSEARCH_KEY, replace_msg,
IFHELP(nano_replace_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_TOGOTOLINE_KEY, go_to_line_msg,
IFHELP(nano_gotoline_msg, NANO_NO_KEY), NANO_GOTOLINE_FKEY,
NANO_NO_KEY, VIEW, NULL);
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_PARABEGIN_KEY, beg_of_par_msg,
IFHELP(nano_parabegin_msg, NANO_PARABEGIN_ALTKEY1), NANO_NO_KEY,
NANO_PARABEGIN_ALTKEY2, VIEW, do_para_begin_void);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_PARAEND_KEY, end_of_par_msg,
IFHELP(nano_paraend_msg, NANO_PARAEND_ALTKEY1), NANO_NO_KEY,
NANO_PARAEND_ALTKEY2, VIEW, do_para_end_void);
#endif
#ifndef NANO_TINY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_NO_KEY, case_sens_msg,
IFHELP(nano_case_msg, TOGGLE_CASE_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_NO_KEY, backwards_msg,
IFHELP(nano_reverse_msg, TOGGLE_BACKWARDS_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
#ifdef HAVE_REGEX_H
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_NO_KEY, regexp_msg,
IFHELP(nano_regexp_msg, NANO_REGEXP_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
#ifndef NANO_TINY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
IFHELP(nano_cut_till_end_msg, NANO_CUTTILLEND_ALTKEY),
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_cut_till_end);
#endif
#ifndef DISABLE_JUSTIFY
/* Translators: try to keep this string under 10 characters long */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_FULLJUSTIFY_KEY, fulljstify_msg,
IFHELP(nano_fulljustify_msg, NANO_FULLJUSTIFY_ALTKEY),
NANO_NO_KEY, NANO_NO_KEY, NOVIEW, do_full_justify);
@ -708,7 +759,7 @@ void shortcut_init(bool unjustify)
IFHELP(nano_lastline_msg, NANO_NO_KEY), NANO_LASTLINE_FKEY,
NANO_NO_KEY, VIEW, do_last_line);
/* Translators: try to keep this string under 12 characters long */
/* Translators: try to keep this string under 12 characters long. */
sc_init_one(&replace_list, NANO_TOOTHERSEARCH_KEY, N_("No Replace"),
IFHELP(nano_whereis_msg, NANO_NO_KEY), NANO_REPLACE_FKEY,
NANO_NO_KEY, VIEW, NULL);
@ -797,34 +848,6 @@ void shortcut_init(bool unjustify)
N_("Go To Text"), IFHELP(nano_whereis_msg, NANO_NO_KEY),
NANO_NO_KEY, NANO_NO_KEY, VIEW, NULL);
#ifndef DISABLE_HELP
free_shortcutage(&help_list);
sc_init_one(&help_list, NANO_REFRESH_KEY, refresh_msg,
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
free_shortcutage(&writefile_list);
sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
@ -844,7 +867,8 @@ void shortcut_init(bool unjustify)
#ifndef DISABLE_BROWSER
/* If we're using restricted mode, the file browser is disabled.
* It's useless since inserting files is disabled. */
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_TOFILES_KEY, to_files_msg,
IFHELP(nano_tofiles_msg, NANO_NO_KEY), NANO_NO_KEY,
@ -858,33 +882,34 @@ void shortcut_init(bool unjustify)
* and fourth are disabled because they allow writing to files not
* specified on the command line, and the fifth is useless since
* backups are disabled. */
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_NO_KEY, N_("DOS Format"),
IFHELP(nano_dos_msg, TOGGLE_DOS_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, NULL);
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_NO_KEY, N_("Mac Format"),
IFHELP(nano_mac_msg, TOGGLE_MAC_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, NULL);
#endif
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_NO_KEY, N_("Append"),
IFHELP(nano_append_msg, NANO_APPEND_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, NULL);
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_NO_KEY, N_("Prepend"),
IFHELP(nano_prepend_msg, NANO_PREPEND_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, NULL);
#ifndef NANO_TINY
/* Translators: try to keep this string under 16 characters long */
/* Translators: try to keep this string under 16 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&writefile_list, NANO_NO_KEY, N_("Backup File"),
IFHELP(nano_backup_msg, TOGGLE_BACKUP_KEY), NANO_NO_KEY,
@ -919,7 +944,8 @@ void shortcut_init(bool unjustify)
#ifndef NANO_TINY
/* If we're using restricted mode, command execution is disabled.
* It's useless since inserting files is disabled. */
/* Translators: try to keep this string under 22 characters long */
/* Translators: try to keep this string under 22 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&insertfile_list, NANO_TOOTHERINSERT_KEY,
N_("Execute Command"), IFHELP(nano_execute_msg,
@ -928,7 +954,8 @@ void shortcut_init(bool unjustify)
#ifdef ENABLE_MULTIBUFFER
/* If we're using restricted mode, the multibuffer toggle is
* disabled. It's useless since inserting files is disabled. */
/* Translators: try to keep this string under 22 characters long */
/* Translators: try to keep this string under 22 characters long. */
if (!ISSET(RESTRICTED))
sc_init_one(&insertfile_list, NANO_NO_KEY, new_buffer_msg,
IFHELP(nano_multibuffer_msg, TOGGLE_MULTIBUFFER_KEY),
@ -936,24 +963,6 @@ void shortcut_init(bool unjustify)
#endif
#endif
#ifndef DISABLE_SPELLER
free_shortcutage(&spell_list);
sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
#ifndef DISABLE_HELP
do_help
#else
nano_disabled_msg
#endif
);
sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
#ifndef NANO_TINY
free_shortcutage(&extcmd_list);
@ -982,6 +991,52 @@ void shortcut_init(bool unjustify)
#endif
#endif
#ifndef DISABLE_HELP
free_shortcutage(&help_list);
sc_init_one(&help_list, NANO_REFRESH_KEY, refresh_msg,
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_NEXTPAGE_KEY, next_page_msg,
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_PREVLINE_KEY, N_("Prev Line"),
IFHELP(nano_prevline_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
sc_init_one(&help_list, NANO_NEXTLINE_KEY, N_("Next Line"),
IFHELP(nano_nextline_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
#ifndef DISABLE_SPELLER
free_shortcutage(&spell_list);
sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
#ifndef DISABLE_HELP
do_help
#else
nano_disabled_msg
#endif
);
sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
#endif
#ifndef DISABLE_BROWSER
free_shortcutage(&browser_list);
@ -1007,7 +1062,7 @@ void shortcut_init(bool unjustify)
IFHELP(nano_nextpage_msg, NANO_NO_KEY), NANO_NEXTPAGE_FKEY,
NANO_NO_KEY, VIEW, NULL);
/* Translators: try to keep this string under 22 characters long */
/* Translators: try to keep this string under 22 characters long. */
sc_init_one(&browser_list, NANO_GOTOLINE_KEY, N_("Go To Dir"),
IFHELP(nano_gotodir_msg, NANO_GOTOLINE_ALTKEY),
NANO_GOTOLINE_FKEY, NANO_NO_KEY, VIEW, NULL);
@ -1071,6 +1126,7 @@ void toggle_init_one(int val, const char *desc, long flag)
u->next = NULL;
}
/* Initialize the global toggle list. */
void toggle_init(void)
{
/* There is no need to reinitialize the toggles. They can't
@ -1185,15 +1241,15 @@ void thanks_for_all_the_fish(void)
free_shortcutage(&gotoline_list);
free_shortcutage(&writefile_list);
free_shortcutage(&insertfile_list);
#ifndef NANO_TINY
free_shortcutage(&extcmd_list);
#endif
#ifndef DISABLE_HELP
free_shortcutage(&help_list);
#endif
#ifndef DISABLE_SPELLER
free_shortcutage(&spell_list);
#endif
#ifndef NANO_TINY
free_shortcutage(&extcmd_list);
#endif
#ifndef DISABLE_BROWSER
free_shortcutage(&browser_list);
free_shortcutage(&gotodir_list);

View File

@ -26,6 +26,7 @@
#include <string.h>
#include <ctype.h>
/* Move to the first line of the file. */
void do_first_line(void)
{
const filestruct *current_save = openfile->current;
@ -40,6 +41,7 @@ void do_first_line(void)
edit_redraw(current_save, pww_save);
}
/* Move to the last line of the file. */
void do_last_line(void)
{
const filestruct *current_save = openfile->current;
@ -55,6 +57,7 @@ void do_last_line(void)
edit_redraw(current_save, pww_save);
}
/* Move up one page. */
void do_page_up(void)
{
int i;
@ -95,6 +98,7 @@ void do_page_up(void)
edit_scroll(UP, editwinrows - 2);
}
/* Move down one page. */
void do_page_down(void)
{
int i;
@ -138,7 +142,8 @@ void do_page_down(void)
#ifndef DISABLE_JUSTIFY
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line. */
* before the current line. If allow_update is TRUE, update the screen
* afterwards. */
void do_para_begin(bool allow_update)
{
const filestruct *current_save = openfile->current;
@ -160,6 +165,8 @@ void do_para_begin(bool allow_update)
edit_redraw(current_save, pww_save);
}
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line, and update the screen afterwards. */
void do_para_begin_void(void)
{
do_para_begin(TRUE);
@ -167,9 +174,10 @@ void do_para_begin_void(void)
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not. A line is the last line of a
* paragraph if it is in a paragraph, and the next line either is a
* beginning-of-paragraph line or isn't in a paragraph. */
* end of the current line if not. If allow_update is TRUE, update the
* screen afterwards. A line is the last line of a paragraph if it is
* in a paragraph, and the next line either is the beginning line of a
* paragraph or isn't in a paragraph. */
void do_para_end(bool allow_update)
{
const filestruct *const current_save = openfile->current;
@ -201,6 +209,9 @@ void do_para_end(bool allow_update)
edit_redraw(current_save, pww_save);
}
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not, and update the screen afterwards. */
void do_para_end_void(void)
{
do_para_end(TRUE);
@ -208,10 +219,10 @@ void do_para_end_void(void)
#endif /* !DISABLE_JUSTIFY */
#ifndef NANO_TINY
/* Move to the next word in the current filestruct. If allow_punct is
* TRUE, treat punctuation as part of a word. If allow_update is TRUE,
* update the screen afterward. Return TRUE if we started on a word,
* and FALSE otherwise. */
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
@ -298,15 +309,18 @@ bool do_next_word(bool allow_punct, bool allow_update)
return started_on_word;
}
/* Move to the next word in the file, treating punctuation as part of a
* word if the WORD_BOUNDS flag is set, and update the screen
* afterwards. */
void do_next_word_void(void)
{
do_next_word(ISSET(WORD_BOUNDS), TRUE);
}
/* Move to the previous word in the current filestruct. If allow_punct
* is TRUE, treat punctuation as part of a word. If allow_update is
* TRUE, update the screen afterward. Return TRUE if we started on a
* word, and FALSE otherwise. */
/* Move to the previous word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_prev_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
@ -429,12 +443,19 @@ bool do_prev_word(bool allow_punct, bool allow_update)
return started_on_word;
}
/* Move to the previous word in the file, treating punctuation as part
* of a word if the WORD_BOUNDS flag is set, and update the screen
* afterwards. */
void do_prev_word_void(void)
{
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
}
#endif /* !NANO_TINY */
/* Move to the beginning of the current line. If the SMART_HOME flag is
* set, move to the first non-whitespace character of the current line
* if we're not already there, or to the beginning of the current line
* if we are. */
void do_home(void)
{
size_t pww_save = openfile->placewewant;
@ -464,6 +485,7 @@ void do_home(void)
update_line(openfile->current, openfile->current_x);
}
/* Move to the end of the current line. */
void do_end(void)
{
size_t pww_save = openfile->placewewant;
@ -477,6 +499,7 @@ void do_end(void)
update_line(openfile->current, openfile->current_x);
}
/* Move up one line. */
void do_up(void)
{
check_statusblank();
@ -516,6 +539,7 @@ void do_up(void)
}
#ifndef NANO_TINY
/* Scroll up one line without scrolling the cursor. */
void do_scroll_up(void)
{
check_statusblank();
@ -540,6 +564,7 @@ void do_scroll_up(void)
}
#endif /* !NANO_TINY */
/* Move down one line. */
void do_down(void)
{
check_statusblank();
@ -579,6 +604,7 @@ void do_down(void)
}
#ifndef NANO_TINY
/* Scroll down one line without scrolling the cursor. */
void do_scroll_down(void)
{
check_statusblank();
@ -603,6 +629,7 @@ void do_scroll_down(void)
}
#endif /* !NANO_TINY */
/* Move left one character. */
void do_left(void)
{
size_t pww_save = openfile->placewewant;
@ -623,6 +650,7 @@ void do_left(void)
update_line(openfile->current, openfile->current_x);
}
/* Move right one character. */
void do_right(void)
{
size_t pww_save = openfile->placewewant;

View File

@ -47,12 +47,14 @@
#include <setjmp.h>
#endif
static struct termios oldterm; /* The user's original term settings. */
static struct sigaction act; /* For all our fun signal handlers. */
static struct termios oldterm;
/* The user's original terminal settings. */
static struct sigaction act;
/* For all our fun signal handlers. */
#ifndef NANO_TINY
static sigjmp_buf jmpbuf; /* Used to return to main() after a
* SIGWINCH. */
static sigjmp_buf jmpbuf;
/* Used to return to main() after a SIGWINCH. */
#endif
/* Create a new filestruct node. Note that we specifically do not set
@ -523,6 +525,7 @@ void free_openfilestruct(openfilestruct *src)
}
#endif
/* Display a warning about a key disabled in view mode. */
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
@ -597,6 +600,8 @@ void die(const char *msg, ...)
exit(1);
}
/* Save the current file under the name spacified in die_filename, which
* is modified to be unique if necessary. */
void die_save_file(const char *die_filename)
{
char *retval;
@ -630,6 +635,7 @@ void die_save_file(const char *die_filename)
free(retval);
}
/* Initialize the three window portions nano uses. */
void window_init(void)
{
/* If the screen height is too small, get out. */
@ -668,6 +674,7 @@ void window_init(void)
}
#ifndef DISABLE_MOUSE
/* Initialize mouse support. */
void mouse_init(void)
{
if (ISSET(USE_MOUSE)) {
@ -710,6 +717,7 @@ void print1opt_full(const char *shortflag
printf("\n");
}
/* Explain how to properly use nano and its command line options. */
void usage(void)
{
#ifdef HAVE_GETOPT_LONG
@ -818,6 +826,9 @@ void usage(void)
exit(0);
}
/* Display the current version of nano, the date and time it was
* compiled, contact information for it, and the configuration options
* it was compiled with. */
void version(void)
{
printf(_(" GNU nano version %s (compiled %s, %s)\n"), VERSION,
@ -883,16 +894,23 @@ void version(void)
printf("\n");
}
/* Return 1 if the MORE_SPACE flag is set, and 0 otherwise. This is
* used to calculate the relative screen position while taking this flag
* into account, since it adds one line to the edit window. */
int no_more_space(void)
{
return ISSET(MORE_SPACE) ? 1 : 0;
}
/* Return 2 if the NO_HELP flag is set, and 0 otherwise. This is used
* to calculate the relative screen position while taking this flag into
* account, since it removes two lines from the edit window. */
int no_help(void)
{
return ISSET(NO_HELP) ? 2 : 0;
}
/* Indicate a disabled function on the statusbar. */
void nano_disabled_msg(void)
{
statusbar(_("Sorry, support for this function has been disabled"));
@ -902,11 +920,14 @@ void do_exit(void)
{
int i;
/* If the file hasn't been modified, pretend the user chose not to
* save. */
if (!openfile->modified)
/* Pretend the user chose not to save. */
i = 0;
/* If the TEMP_FILE flag is set, pretend the user chose to save. */
else if (ISSET(TEMP_FILE))
i = 1;
/* Otherwise, ask the user whether or not to save. */
else
i = do_yesno_prompt(FALSE,
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
@ -915,18 +936,22 @@ void do_exit(void)
dump_filestruct(openfile->fileage);
#endif
/* If the user chose not to save, or if the user chose to save and
* the save succeeded, we're ready to exit. */
if (i == 0 || (i == 1 && do_writeout(TRUE) == 0)) {
#ifdef ENABLE_MULTIBUFFER
/* Exit only if there are no more open file buffers. */
if (!close_buffer())
#endif
finish();
/* If the user canceled, we go on. */
} else if (i != 1)
statusbar(_("Cancelled"));
display_main_list();
}
/* Initialize the signal handlers. */
void signal_init(void)
{
/* Trap SIGINT and SIGQUIT because we want them to do useful
@ -1005,6 +1030,7 @@ RETSIGTYPE do_continue(int signal)
}
#ifndef NANO_TINY
/* Handler for SIGWINCH (window size change). */
RETSIGTYPE handle_sigwinch(int signal)
{
const char *tty = ttyname(0);
@ -1079,6 +1105,9 @@ RETSIGTYPE handle_sigwinch(int signal)
siglongjmp(jmpbuf, 1);
}
/* If allow is TRUE, block any SIGWINCH signals that we get, so that we
* can deal with them later. If allow is FALSE, unblock any SIGWINCH
* signals that we have, so that we can deal with them now. */
void allow_pending_sigwinch(bool allow)
{
sigset_t winch;
@ -1089,6 +1118,7 @@ void allow_pending_sigwinch(bool allow)
#endif /* !NANO_TINY */
#ifndef NANO_TINY
/* Handle the global toggle specified in which. */
void do_toggle(const toggle *which)
{
bool enabled;
@ -1139,6 +1169,8 @@ void do_toggle(const toggle *which)
}
#endif /* !NANO_TINY */
/* Disable extended input and output processing in our terminal
* settings. */
void disable_extended_io(void)
{
struct termios term;
@ -1149,6 +1181,8 @@ void disable_extended_io(void)
tcsetattr(0, TCSANOW, &term);
}
/* Disable interpretation of the special control keys in our terminal
* settings. */
void disable_signals(void)
{
struct termios term;
@ -1159,6 +1193,8 @@ void disable_signals(void)
}
#ifndef NANO_TINY
/* Enable interpretation of the special control keys in our terminal
* settings. */
void enable_signals(void)
{
struct termios term;
@ -1169,6 +1205,8 @@ void enable_signals(void)
}
#endif
/* Disable interpretation of the flow control characters in our terminal
* settings. */
void disable_flow_control(void)
{
struct termios term;
@ -1178,6 +1216,8 @@ void disable_flow_control(void)
tcsetattr(0, TCSANOW, &term);
}
/* Enable interpretation of the flow control characters in our terminal
* settings. */
void enable_flow_control(void)
{
struct termios term;
@ -1206,6 +1246,15 @@ void terminal_init(void)
disable_flow_control();
}
/* Read in a character, interpret it as a shortcut or toggle if
* necessary, and return it. Set meta_key to TRUE if the character is a
* meta sequence, set func_key to TRUE if the character is a function
* key, set s_or_t to TRUE if the character is a shortcut or toggle
* key, set ran_func to TRUE if we ran a function associated with a
* shortcut key, and set finished to TRUE if we're done after running
* or trying to run a function associated with a shortcut key. If
* allow_funcs is FALSE, don't actually run any functions associated
* with shortcut keys. */
int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
*ran_func, bool *finished, bool allow_funcs)
{
@ -1325,8 +1374,8 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
/* Handle the normal edit window shortcuts, setting
* ran_func to TRUE if we try to run their associated
* functions and setting finished to TRUE to indicate
* that we're done after trying to run their associated
* functions. */
* that we're done after running or trying to run their
* associated functions. */
default:
/* Blow away the text in the cutbuffer if we aren't
* cutting text. */
@ -1364,6 +1413,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
}
#ifndef DISABLE_MOUSE
/* Handle a mouse click on the edit window or the shortcut list. */
bool do_mouse(void)
{
int mouse_x, mouse_y;
@ -2095,5 +2145,6 @@ int main(int argc, char **argv)
TRUE);
}
/* We should never get here. */
assert(FALSE);
}

View File

@ -64,15 +64,17 @@
#endif
#ifdef USE_SLANG
/* Slang support enabled. */
/* Slang support. */
#include <slcurses.h>
/* Slang curses emulation brain damage, part 2: Slang doesn't define the
* curses equivalents of the Insert or Delete keys. */
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
/* Ncurses support. */
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else /* Uh oh. */
#else
/* Curses support. */
#include <curses.h>
#endif /* CURSES_H */
@ -172,120 +174,168 @@ typedef enum {
/* Structure types. */
typedef struct filestruct {
char *data;
struct filestruct *next; /* Next node. */
struct filestruct *prev; /* Previous node. */
ssize_t lineno; /* The line number. */
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
struct filestruct *next;
/* Next node. */
struct filestruct *prev;
/* Previous node. */
} filestruct;
typedef struct partition {
filestruct *fileage;
/* The top line of this portion of the file. */
filestruct *top_prev;
/* The line before the top line of this portion of the file. */
char *top_data;
/* The text before the beginning of the top line of this portion
* of the file. */
filestruct *filebot;
/* The bottom line of this portion of the file. */
filestruct *bot_next;
/* The line after the bottom line of this portion of the
* file. */
char *bot_data;
/* The text after the end of the bottom line of this portion of
* the file. */
} partition;
#ifdef ENABLE_COLOR
typedef struct colortype {
short fg; /* Foreground color. */
short bg; /* Background color. */
bool bright; /* Is this color A_BOLD? */
bool icase; /* Is this regex string case
* insensitive? */
int pairnum; /* Color pair number used for this
* foreground/background. */
char *start_regex; /* Start (or all) of the regex
* string. */
regex_t *start; /* Compiled start (or all) of the regex
* string. */
char *end_regex; /* End (if any) of the regex string. */
regex_t *end; /* Compiled end (if any) of the regex
* string. */
short fg;
/* This syntax's foreground color. */
short bg;
/* This syntax's background color. */
bool bright;
/* Is this color A_BOLD? */