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
(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)
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,
- 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)
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;
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;
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
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
}
#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;
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);
}
}
+/* 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;
/* 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. */
-#endif
-
-char *last_search = NULL; /* Last string we searched for */
-char *last_replace = NULL; /* Last replacement string */
-
-long flags = 0; /* Our flag containing many options */
-WINDOW *topwin; /* Top subwindow */
-WINDOW *edit; /* The file portion of the editor */
-WINDOW *bottomwin; /* Bottom subwindow */
-
-int editwinrows = 0; /* How many rows long is the edit
- window? */
-filestruct *cutbuffer = NULL; /* A place to store cut text */
+ /* 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;
+ /* The last string we searched for. */
+char *last_replace = NULL;
+ /* The last replacement string we searched for. */
+
+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? */
+
+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) */
-#endif
+size_t quotelen;
+ /* The length of the quoting string in bytes. */
#endif
-
-#ifndef NANO_TINY
-char *backup_dir = NULL; /* Backup directory. */
#endif
-char *answer = NULL; /* The answer string for statusbar
- * questions. */
+char *answer = NULL;
+ /* The answer string used in the statusbar prompt. */
-ssize_t tabsize = -1; /* Our internal tabsize variable. The
- default value is set in main(). */
+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;
+ /* The directory where we store backup files. */
+#endif
#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;
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");
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,
#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 ?
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,
);
/* 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,
, !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);
/* 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,
#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);
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);
#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);
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);
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,
#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,
* 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,
#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,
#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),
#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);
#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);
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);
u->next = NULL;
}
+/* Initialize the global toggle list. */
void toggle_init(void)
{
/* There is no need to reinitialize the toggles. They can't
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);
#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;
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;
edit_redraw(current_save, pww_save);
}
+/* Move up one page. */
void do_page_up(void)
{
int i;
edit_scroll(UP, editwinrows - 2);
}
+/* Move down one page. */
void do_page_down(void)
{
int i;
#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;
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);
/* 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;
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);
#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;
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;
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;
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;
update_line(openfile->current, openfile->current_x);
}
+/* Move up one line. */
void do_up(void)
{
check_statusblank();
}
#ifndef NANO_TINY
+/* Scroll up one line without scrolling the cursor. */
void do_scroll_up(void)
{
check_statusblank();
}
#endif /* !NANO_TINY */
+/* Move down one line. */
void do_down(void)
{
check_statusblank();
}
#ifndef NANO_TINY
+/* Scroll down one line without scrolling the cursor. */
void do_scroll_down(void)
{
check_statusblank();
}
#endif /* !NANO_TINY */
+/* Move left one character. */
void do_left(void)
{
size_t pww_save = openfile->placewewant;
update_line(openfile->current, openfile->current_x);
}
+/* Move right one character. */
void do_right(void)
{
size_t pww_save = openfile->placewewant;
#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
}
#endif
+/* Display a warning about a key disabled in view mode. */
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
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;
free(retval);
}
+/* Initialize the three window portions nano uses. */
void window_init(void)
{
/* If the screen height is too small, get out. */
}
#ifndef DISABLE_MOUSE
+/* Initialize mouse support. */
void mouse_init(void)
{
if (ISSET(USE_MOUSE)) {
printf("\n");
}
+/* Explain how to properly use nano and its command line options. */
void usage(void)
{
#ifdef HAVE_GETOPT_LONG
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,
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"));
{
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) ? "));
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
}
#ifndef NANO_TINY
+/* Handler for SIGWINCH (window size change). */
RETSIGTYPE handle_sigwinch(int signal)
{
const char *tty = ttyname(0);
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;
#endif /* !NANO_TINY */
#ifndef NANO_TINY
+/* Handle the global toggle specified in which. */
void do_toggle(const toggle *which)
{
bool enabled;
}
#endif /* !NANO_TINY */
+/* Disable extended input and output processing in our terminal
+ * settings. */
void disable_extended_io(void)
{
struct termios term;
tcsetattr(0, TCSANOW, &term);
}
+/* Disable interpretation of the special control keys in our terminal
+ * settings. */
void disable_signals(void)
{
struct termios term;
}
#ifndef NANO_TINY
+/* Enable interpretation of the special control keys in our terminal
+ * settings. */
void enable_signals(void)
{
struct termios term;
}
#endif
+/* Disable interpretation of the flow control characters in our terminal
+ * settings. */
void disable_flow_control(void)
{
struct termios term;
tcsetattr(0, TCSANOW, &term);
}
+/* Enable interpretation of the flow control characters in our terminal
+ * settings. */
void enable_flow_control(void)
{
struct termios term;
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)
{
/* 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. */
}
#ifndef DISABLE_MOUSE
+/* Handle a mouse click on the edit window or the shortcut list. */
bool do_mouse(void)
{
int mouse_x, mouse_y;
TRUE);
}
+ /* We should never get here. */
assert(FALSE);
}
#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 */
/* 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? */
+ bool icase;
+ /* Is this regex string case insensitive? */
+ int pairnum;
+ /* The color pair number used for this foreground color and
+ * background color. */
+ char *start_regex;
+ /* The start (or all) of the regex string. */
+ regex_t *start;
+ /* The compiled start (or all) of the regex string. */
+ char *end_regex;
+ /* The end (if any) of the regex string. */
+ regex_t *end;
+ /* The compiled end (if any) of the regex string. */
struct colortype *next;
+ /* Next set of colors. */
} colortype;
typedef struct exttype {
- char *ext_regex; /* Extensions that match this syntax. */
- regex_t *ext; /* Compiled extensions that match this
- * syntax. */
+ char *ext_regex;
+ /* The extensions that match this syntax. */
+ regex_t *ext;
+ /* The compiled extensions that match this syntax. */
struct exttype *next;
+ /* Next set of extensions. */
} exttype;
typedef struct syntaxtype {
- char *desc; /* Name of this syntax type. */
- exttype *extensions; /* List of extensions that this syntax
- * applies to. */
- colortype *color; /* Color struct for this syntax. */
+ char *desc;
+ /* The name of this syntax. */
+ exttype *extensions;
+ /* The list of extensions that this syntax applies to. */
+ colortype *color;
+ /* The colors used in this syntax. */
struct syntaxtype *next;
+ /* Next syntax. */
} syntaxtype;
#endif /* ENABLE_COLOR */
typedef struct openfilestruct {
- char *filename; /* Current file's name. */
- filestruct *fileage; /* Current file's first line. */
- filestruct *filebot; /* Current file's last line. */
- filestruct *edittop; /* Current top of edit window. */
- filestruct *current; /* Current file's line. */
- size_t totsize; /* Current file's total number of
- * characters. */
- size_t current_x; /* Current file's x-coordinate
- * position. */
- size_t placewewant; /* Current file's place we want. */
- ssize_t current_y; /* Current file's y-coordinate
- * position. */
- bool modified; /* Current file's modification
- * status. */
+ char *filename;
+ /* The current file's name. */
+ filestruct *fileage;
+ /* The current file's first line. */
+ filestruct *filebot;
+ /* The current file's last line. */
+ filestruct *edittop;
+ /* The current top of the edit window. */
+ filestruct *current;
+ /* The current file's current line. */
+ size_t totsize;
+ /* The current file's total number of characters. */
+ size_t current_x;
+ /* The current file's x-coordinate position. */
+ size_t placewewant;
+ /* The current file's place we want. */
+ ssize_t current_y;
+ /* The current file's y-coordinate position. */
+ bool modified;
+ /* Whether the current file has been modified. */
#ifndef NANO_TINY
- bool mark_set; /* Current file's marking status. */
- filestruct *mark_begin; /* Current file's beginning marked
- * line. */
- size_t mark_begin_x; /* Current file's beginning marked
- * line's x-coordinate position. */
- file_format fmt; /* Current file's format. */
- struct stat *current_stat; /* Current file's stat. */
+ bool mark_set;
+ /* Whether the mark is on in the current file. */
+ filestruct *mark_begin;
+ /* The current file's beginning marked line, if any. */
+ size_t mark_begin_x;
+ /* The current file's beginning marked line's x-coordinate
+ * position, if any. */
+ file_format fmt;
+ /* The current file's format. */
+ struct stat *current_stat;
+ /* The current file's stat. */
#endif
#ifdef ENABLE_COLOR
- colortype *colorstrings; /* Current file's associated colors. */
+ colortype *colorstrings;
+ /* The current file's associated colors. */
#endif
struct openfilestruct *next;
- /* Next node. */
+ /* Next node. */
struct openfilestruct *prev;
- /* Previous node. */
+ /* Previous node. */
} openfilestruct;
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
- * bound. */
- int metaval; /* Meta key we want bound. */
- int funcval; /* Function key we want bound. */
- int miscval; /* Other Meta key we want bound. */
- bool viewok; /* Is this function legal in view mode? */
- void (*func)(void); /* Function to call when we catch this key. */
- const char *desc; /* Description, e.g. "Page Up". */
+ int ctrlval;
+ /* The special sentinel key or control key we want bound, if
+ * any. */
+ int metaval;
+ /* The meta key we want bound, if any. */
+ int funcval;
+ /* The function key we want bound, if any. */
+ int miscval;
+ /* The other meta key we want bound, if any. */
+ bool viewok;
+ /* Is this function allowed when in view mode? */
+ void (*func)(void);
+ /* The function to call when we get this key. */
+ const char *desc;
+ /* The function's description, e.g. "Page Up". */
#ifndef DISABLE_HELP
- const char *help; /* Help file entry text. */
+ const char *help;
+ /* The help file entry text for this function. */
#endif
struct shortcut *next;
+ /* Next shortcut. */
} shortcut;
#ifndef NANO_TINY
typedef struct toggle {
- int val; /* Sequence to toggle the key. Should only need
- * one. */
- const char *desc; /* Description for when toggle is, uh, toggled,
- * e.g. "Cut to end"; we'll append Enabled or
- * Disabled. */
- long flag; /* What flag actually gets toggled. */
+ int val;
+ /* The sequence to toggle the key. We should only need one. */
+ const char *desc;
+ /* The description for when the toggle is, uh, toggled, e.g.
+ * "Cut to end"; we'll append Enabled or Disabled. */
+ long flag;
+ /* Which flag actually gets toggled. */
struct toggle *next;
+ /* Next toggle. */
} toggle;
#endif
#ifdef ENABLE_NANORC
typedef struct rcoption {
const char *name;
+ /* The name of the rcfile option. */
long flag;
+ /* The flag associated with it, if any. */
} rcoption;
#endif
#define NANO_REFRESH_KEY NANO_CONTROL_L
#define NANO_JUSTIFY_KEY NANO_CONTROL_J
#define NANO_JUSTIFY_FKEY KEY_F(4)
-#define NANO_UNJUSTIFY_KEY NANO_UNCUT_KEY /* Same key as uncut. */
-#define NANO_UNJUSTIFY_FKEY NANO_UNCUT_FKEY /* Same key as uncut. */
+#define NANO_UNJUSTIFY_KEY NANO_UNCUT_KEY /* Same key as UnCut. */
+#define NANO_UNJUSTIFY_FKEY NANO_UNCUT_FKEY /* Same key as UnCut. */
#define NANO_PREVLINE_KEY NANO_CONTROL_P
#define NANO_NEXTLINE_KEY NANO_CONTROL_N
#define NANO_FORWARD_KEY NANO_CONTROL_F
#define VIEW TRUE
#define NOVIEW FALSE
-/* Minimum editor window columns and rows required for nano to work
+/* The minimum editor window columns and rows required for nano to work
* correctly. */
#define MIN_EDITOR_COLS 4
#define MIN_EDITOR_ROWS 1
-/* Default number of characters from end-of-line where text wrapping
- * occurs. */
+/* The default number of characters from the end of the line where
+ * wrapping occurs. */
#define CHARS_FROM_EOL 8
-/* Default width of a tab. */
+/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
-/* Maximum number of search/replace history strings saved, not counting
- * the blank lines at their ends. */
+/* The maximum number of search/replace history strings saved, not
+ * counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
-/* Maximum number of bytes we read from a file at one time. */
+/* The maximum number of bytes we read from a file at one time. */
#define MAX_BUF_SIZE 128
#endif /* !NANO_H */
/* Should we reset the cursor position
* at the statusbar prompt? */
+/* 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_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
bool *ran_func, bool *finished, bool allow_funcs)
{
* statusbar prompt shortcut, set have_shortcut to TRUE. */
have_shortcut = (s != NULL || input == NANO_REFRESH_KEY ||
input == NANO_HOME_KEY || input == NANO_END_KEY ||
- input == NANO_FORWARD_KEY || input == NANO_BACK_KEY ||
+ input == NANO_BACK_KEY || input == NANO_FORWARD_KEY ||
input == NANO_BACKSPACE_KEY || input == NANO_DELETE_KEY ||
input == NANO_CUT_KEY ||
#ifndef NANO_TINY
case NANO_END_KEY:
do_statusbar_end();
break;
- case NANO_FORWARD_KEY:
- do_statusbar_right();
- break;
case NANO_BACK_KEY:
do_statusbar_left();
break;
+ case NANO_FORWARD_KEY:
+ do_statusbar_right();
+ break;
case NANO_BACKSPACE_KEY:
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
/* Handle the normal statusbar prompt 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:
if (s->func != NULL) {
*ran_func = TRUE;
}
#ifndef DISABLE_MOUSE
+/* Handle a mouse click on the statusbar prompt or the shortcut list. */
bool do_statusbar_mouse(void)
{
int mouse_x, mouse_y;
update_statusbar_line(answer, statusbar_x);
}
+/* Move to the beginning of the prompt text. If the SMART_HOME flag is
+ * set, move to the first non-whitespace character of the prompt text if
+ * we're not already there, or to the beginning of the prompt text if we
+ * are. */
void do_statusbar_home(void)
{
size_t pww_save = statusbar_pww;
update_statusbar_line(answer, statusbar_x);
}
+/* Move to the end of the prompt text. */
void do_statusbar_end(void)
{
size_t pww_save = statusbar_pww;
update_statusbar_line(answer, statusbar_x);
}
-void do_statusbar_right(void)
+/* Move left one character. */
+void do_statusbar_left(void)
{
- if (statusbar_x < strlen(answer)) {
+ if (statusbar_x > 0) {
size_t pww_save = statusbar_pww;
- statusbar_x = move_mbright(answer, statusbar_x);
+ statusbar_x = move_mbleft(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
}
}
-void do_statusbar_left(void)
+/* Move right one character. */
+void do_statusbar_right(void)
{
- if (statusbar_x > 0) {
+ if (statusbar_x < strlen(answer)) {
size_t pww_save = statusbar_pww;
- statusbar_x = move_mbleft(answer, statusbar_x);
+ statusbar_x = move_mbright(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
if (need_statusbar_horizontal_update(pww_save))
}
}
+/* Backspace over one character. */
void do_statusbar_backspace(void)
{
if (statusbar_x > 0) {
}
}
+/* Delete one character. */
void do_statusbar_delete(void)
{
statusbar_pww = statusbar_xplustabs();
}
}
-/* Move text from the statusbar prompt into oblivion. */
+/* Move text from the prompt into oblivion. */
void do_statusbar_cut_text(void)
{
assert(answer != NULL);
}
#ifndef NANO_TINY
-/* Move to the next word at the statusbar prompt. If allow_punct is
- * TRUE, treat punctuation as part of a word. Return TRUE if we started
- * on a word, and FALSE otherwise. */
+/* Move to the next word in the prompt text. If allow_punct is TRUE,
+ * treat punctuation as part of a word. Return TRUE if we started on a
+ * word, and FALSE otherwise. */
bool do_statusbar_next_word(bool allow_punct)
{
size_t pww_save = statusbar_pww;
return started_on_word;
}
-/* Move to the previous word at the statusbar prompt. If allow_punct is
+/* Move to the previous word in the prompt text. If allow_punct is
* TRUE, treat punctuation as part of a word. Return TRUE if we started
* on a word, and FALSE otherwise. */
bool do_statusbar_prev_word(bool allow_punct)
}
#endif /* !NANO_TINY */
+/* Get verbatim input. Set got_enter to TRUE if we got the Enter key as
+ * part of the verbatim input. */
void do_statusbar_verbatim_input(bool *got_enter)
{
int *kbinput;
}
#ifndef NANO_TINY
+/* Search for a match to one of the two characters in bracket_set. If
+ * reverse is TRUE, search backwards for the leftmost bracket.
+ * Otherwise, search forwards for the rightmost bracket. Return TRUE if
+ * we found a match, and FALSE otherwise. */
bool find_statusbar_bracket_match(bool reverse, const char
*bracket_set)
{
return TRUE;
}
+/* Search for a match to the bracket at the current cursor position, if
+ * there is one. */
void do_statusbar_find_bracket(void)
{
size_t statusbar_x_save, pww_save;
#ifndef PROTO_H
#define PROTO_H 1
-/* Public externs. */
#include "nano.h"
+/* Public externs. See global.c for descriptions of them. */
#ifndef DISABLE_WRAPJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at;
#endif
-extern int editwinrows;
+
+extern char *last_search;
+extern char *last_replace;
+
extern long flags;
-extern ssize_t tabsize;
-extern int currslen;
+extern WINDOW *topwin;
+extern WINDOW *edit;
+extern WINDOW *bottomwin;
+extern int editwinrows;
+
+extern filestruct *cutbuffer;
+#ifndef DISABLE_JUSTIFY
+extern filestruct *jusbuffer;
+#endif
+extern partition *filepart;
+extern openfilestruct *openfile;
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
extern char *whitespace;
#endif
#endif
+extern char *answer;
+
+extern ssize_t tabsize;
+
#ifndef NANO_TINY
extern char *backup_dir;
#endif
-
-extern WINDOW *topwin, *edit, *bottomwin;
-extern char *answer;
-extern char *last_search;
-extern char *last_replace;
#ifndef DISABLE_OPERATINGDIR
extern char *operating_dir;
extern char *full_operating_dir;
#endif
+
#ifndef DISABLE_SPELLER
extern char *alt_speller;
#endif
-extern struct stat fileinfo;
-extern filestruct *cutbuffer;
-#ifndef DISABLE_JUSTIFY
-extern filestruct *jusbuffer;
-#endif
-extern partition *filepart;
-
-extern openfilestruct *openfile;
-
-#ifdef ENABLE_COLOR
-extern syntaxtype *syntaxes;
-extern char *syntaxstr;
-#endif
-
-extern shortcut *shortcut_list;
-extern shortcut *main_list, *whereis_list;
-extern shortcut *replace_list, *gotoline_list;
-extern shortcut *writefile_list, *insertfile_list;
+extern shortcut *main_list;
+extern shortcut *whereis_list;
+extern shortcut *replace_list;
extern shortcut *replace_list_2;
+extern shortcut *gotoline_list;
+extern shortcut *writefile_list;
+extern shortcut *insertfile_list;
#ifndef NANO_TINY
extern shortcut *extcmd_list;
#endif
extern shortcut *spell_list;
#endif
#ifndef DISABLE_BROWSER
-extern shortcut *browser_list, *gotodir_list;
+extern shortcut *browser_list;
+extern shortcut *gotodir_list;
#endif
-extern const shortcut *currshortcut;
-
-#ifdef HAVE_REGEX_H
-extern regex_t search_regexp;
-extern regmatch_t regmatches[10];
#ifdef ENABLE_COLOR
-extern regex_t syntaxfile_regexp;
-extern regmatch_t synfilematches[1];
-#endif
+extern syntaxtype *syntaxes;
+extern char *syntaxstr;
#endif
+extern const shortcut *currshortcut;
#ifndef NANO_TINY
extern toggle *toggles;
#endif
extern filestruct *replacebot;
#endif
+#ifdef HAVE_REGEX_H
+extern regex_t search_regexp;
+extern regmatch_t regmatches[10];
+#endif
+
extern bool curses_ended;
extern char *homedir;
-/* The functions we want available. */
-
/* Public functions in browser.c. */
#ifndef DISABLE_BROWSER
char *do_browser(char *path, DIR *dir);
*got_enter, bool allow_cntrls);
void do_statusbar_home(void);
void do_statusbar_end(void);
-void do_statusbar_right(void);
void do_statusbar_left(void);
+void do_statusbar_right(void);
void do_statusbar_backspace(void);
void do_statusbar_delete(void);
void do_statusbar_cut_text(void);
void regexp_cleanup(void);
#endif
void not_found_msg(const char *str);
-void search_abort(void);
+void search_replace_abort(void);
void search_init_globals(void);
int search_init(bool replacing, bool use_answer);
bool findnextstr(
#ifndef NANO_TINY
void do_research(void);
#endif
-void replace_abort(void);
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, bool create);
#endif
bool interactive, bool save_pos, bool allow_update);
void do_gotolinecolumn_void(void);
#ifndef DISABLE_SPELLER
-void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t
+void do_gotopos(ssize_t pos_line, size_t pos_x, ssize_t pos_y, size_t
pos_pww);
#endif
#ifndef NANO_TINY
int safe_regexec(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags);
#endif
-int regexp_bol_or_eol(const regex_t *preg, const char *string);
+bool regexp_bol_or_eol(const regex_t *preg, const char *string);
#endif
#ifndef DISABLE_SPELLER
bool is_whole_word(size_t pos, const char *buf, const char *word);
};
static bool errors = FALSE;
+ /* Whether we got any errors while parsing an rcfile. */
static size_t lineno = 0;
+ /* If we did, the line number where the current error
+ * occurred. */
static char *nanorc = NULL;
+ /* The path to the rcfile we're parsing. */
#ifdef ENABLE_COLOR
static syntaxtype *endsyntax = NULL;
/* The end of the list of syntaxes. */
}
#ifdef ENABLE_COLOR
+/* Return the short value corresponding to the color named in colorname,
+ * and set bright to TRUE if that color is bright. */
short color_to_short(const char *colorname, bool *bright)
{
short mcolor = -1;
return mcolor;
}
+/* Parse the next regex string from the line at ptr, and return it. */
char *parse_next_regex(char *ptr)
{
assert(ptr != NULL);
return (rc == 0);
}
+/* Parse the next syntax string from the line at ptr, and add it to the
+ * global list of color syntaxes. */
void parse_syntax(char *ptr)
{
const char *fileregptr = NULL, *nameptr = NULL;
}
}
-/* Parse the color stuff into the colorstrings array. If icase is TRUE,
- * treat the color stuff as case insensitive. */
+/* Parse the color string in the line at ptr, and add it to the current
+ * file's associated colors. If icase is TRUE, treat the color string
+ * as case insensitive. */
void parse_colors(char *ptr, bool icase)
{
short fg, bg;
}
#endif /* ENABLE_COLOR */
-/* Parse the rcfile, once it has been opened successfully. */
+/* Parse the rcfile, once it has been opened successfully at
+ * rcstream. */
void parse_rcfile(FILE *rcstream)
{
char *buf = NULL;
return 1;
}
+/* Decompile the compiled regular expression we used in the last
+ * search, if any. */
void regexp_cleanup(void)
{
if (regexp_compiled) {
}
#endif
+/* Indicate on the statusbar that the string at str was not found by the
+ * last search. */
void not_found_msg(const char *str)
{
char *disp;
free(disp);
}
-void search_abort(void)
+/* Abort the current search or replace. Clean up by displaying the main
+ * shortcut list, updating the screen if the mark was on before, and
+ * decompiling the compiled regular expression we used in the last
+ * search, if any. */
+void search_replace_abort(void)
{
display_main_list();
#ifndef NANO_TINY
#endif
}
+/* Initialize the global search and replace strings. */
void search_init_globals(void)
{
if (last_search == NULL)
return TRUE;
}
+/* Clear the flag indicating that a search reached the last line of the
+ * file. We need to do this just before a new search. */
void findnextstr_wrap_reset(void)
{
search_last_line = FALSE;
i = search_init(FALSE, FALSE);
if (i == -1) /* Cancel, Go to Line, blank search string, or
* regcomp() failed. */
- search_abort();
+ search_replace_abort();
else if (i == -2) /* Replace. */
do_replace();
#if !defined(NANO_TINY) || defined(HAVE_REGEX_H)
openfile->placewewant = xplustabs();
edit_redraw(fileptr, old_pww);
- search_abort();
+ search_replace_abort();
}
#ifndef NANO_TINY
-/* Search for the next string without prompting. */
+/* Search for the last string without prompting. */
void do_research(void)
{
filestruct *fileptr = openfile->current;
openfile->placewewant = xplustabs();
edit_redraw(fileptr, old_pww);
- search_abort();
+ search_replace_abort();
}
#endif
-void replace_abort(void)
-{
- /* For now, we do the same thing as search_abort(). */
- search_abort();
-}
-
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, bool create)
{
if (ISSET(VIEW_MODE)) {
print_view_warning();
- replace_abort();
+ search_replace_abort();
return;
}
i = search_init(TRUE, FALSE);
if (i == -1) { /* Cancel, Go to Line, blank search
* string, or regcomp() failed. */
- replace_abort();
+ search_replace_abort();
return;
} else if (i == -2) { /* No Replace. */
do_search();
answer = mallocstrcpy(answer, last_replace);
statusbar(_("Cancelled"));
}
- replace_abort();
+ search_replace_abort();
return;
}
"Replaced %lu occurrences", (unsigned long)numreplaced),
(unsigned long)numreplaced);
- replace_abort();
+ search_replace_abort();
}
/* Go to the specified line and column, or ask for them if interactive
display_main_list();
}
+/* Go to the specified line and column, asking for them beforehand. */
void do_gotolinecolumn_void(void)
{
do_gotolinecolumn(openfile->current->lineno,
}
#ifndef DISABLE_SPELLER
-void do_gotopos(ssize_t line, size_t pos_x, ssize_t pos_y, size_t
+/* Go to the line with the number specified in pos_line, the
+ * x-coordinate specified in pos_x, the y-coordinate specified in pos_y,
+ * and the place we want specified in pos_pww. */
+void do_gotopos(ssize_t pos_line, size_t pos_x, ssize_t pos_y, size_t
pos_pww)
{
/* Since do_gotolinecolumn() resets the x-coordinate but not the
* y-coordinate, set the coordinates up this way. */
openfile->current_y = pos_y;
- do_gotolinecolumn(line, pos_x + 1, FALSE, FALSE, TRUE, TRUE);
+ do_gotolinecolumn(pos_line, pos_x + 1, FALSE, FALSE, TRUE, TRUE);
/* Set the rest of the coordinates up. */
openfile->placewewant = pos_pww;
#ifndef NANO_TINY
/* Search for a match to one of the two characters in bracket_set. If
- * reverse is TRUE, search backwards. Otherwise, search forwards.
- * Return TRUE if we found a match, or FALSE otherwise. */
+ * reverse is TRUE, search backwards for the leftmost bracket.
+ * Otherwise, search forwards for the rightmost bracket. Return TRUE if
+ * we found a match, and FALSE otherwise. */
bool find_bracket_match(bool reverse, const char *bracket_set)
{
filestruct *fileptr = openfile->current;
#ifndef NANO_TINY
static pid_t pid = -1;
- /* The PID of the newly forked process in execute_command(), for
- * use with the cancel_command() signal handler. */
+ /* The PID of the forked process in execute_command(), for use
+ * with the cancel_command() signal handler. */
#endif
#ifndef DISABLE_WRAPPING
static bool prepend_wrap = FALSE;
#endif
#ifndef NANO_TINY
+/* Toggle the mark. */
void do_mark(void)
{
openfile->mark_set = !openfile->mark_set;
}
#endif /* !NANO_TINY */
+/* Delete one character. */
void do_delete(void)
{
bool do_refresh = FALSE;
update_line(openfile->current, openfile->current_x);
}
+/* Backspace over one character. */
void do_backspace(void)
{
if (openfile->current != openfile->fileage ||
}
}
+/* Insert a tab. If the TABS_TO_SPACES flag is set, insert the number
+ * of spaces that a tab would normally take up. */
void do_tab(void)
{
#ifndef NANO_TINY
#endif
}
-/* Someone hits Enter *gasp!* */
+/* Someone hits Enter/Return *gasp!* */
void do_enter(void)
{
filestruct *newnode = make_new_node(openfile->current);
}
#ifndef NANO_TINY
+/* Send a SIGKILL (unconditional kill) to the forked process in
+ * execute_command(). */
RETSIGTYPE cancel_command(int signal)
{
if (kill(pid, SIGKILL) == -1)
#endif /* !NANO_TINY */
#ifndef DISABLE_WRAPPING
+/* Clear the prepend_wrap flag. We need to do this as soon as we do
+ * something other than type text. */
void wrap_reset(void)
{
prepend_wrap = FALSE;
display_main_list();
}
+/* Justify the current paragraph. */
void do_justify_void(void)
{
do_justify(FALSE);
}
+/* Justify the entire file. */
void do_full_justify(void)
{
do_justify(TRUE);
return !canceled;
}
-/* Integrated spell checking using the spell program, filtered through
- * the sort and uniq programs. Return NULL for normal termination,
- * and the error string otherwise. */
+/* Internal (integrated) spell checking using the spell program,
+ * filtered through the sort and uniq programs. Return NULL for normal
+ * termination, and the error string otherwise. */
const char *do_int_speller(const char *tempfile_name)
{
char *read_buff, *read_buff_ptr, *read_buff_word;
do_int_spell_fix(read_buff_word);
free(read_buff);
- replace_abort();
+ search_replace_abort();
edit_refresh();
/* Process the end of the spell process. */
exit(1);
}
-/* External spell checking. Return value: NULL for normal termination,
- * otherwise the error string. */
+/* External (alternate) spell checking. Return NULL for normal
+ * termination, and the error string otherwise. */
const char *do_alt_speller(char *tempfile_name)
{
int alt_spell_status;
return NULL;
}
+/* Spell check the current file. If an alternate spell checker is
+ * specified, use it. Otherwise, use the internal spell checker. */
void do_spell(void)
{
int i;
}
#endif /* !NANO_TINY */
+/* Get verbatim input. */
void do_verbatim_input(void)
{
int *kbinput;
#include <ctype.h>
#include <errno.h>
+/* Return the number of decimal digits in n. */
int digits(size_t n)
{
int i = 1;
}
#endif
-int regexp_bol_or_eol(const regex_t *preg, const char *string)
+/* Do the compiled regex in preg and the regex in string match the
+ * beginning or end of a line? */
+bool regexp_bol_or_eol(const regex_t *preg, const char *string)
{
return (regexec(preg, string, 0, NULL, 0) == 0 &&
regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) ==
}
}
-/* Thanks, BG, many people have been asking for this... */
+/* This is a wrapper for the malloc() function that properly handles
+ * things when we run out of memory. Thanks, BG, many people have been
+ * asking for this... */
void *nmalloc(size_t howmuch)
{
void *r = malloc(howmuch);
return r;
}
+/* This is a wrapper for the realloc() function that properly handles
+ * things when we run out of memory. */
void *nrealloc(void *ptr, size_t howmuch)
{
void *r = realloc(ptr, howmuch);
#ifndef NANO_TINY
/* Remove the magicline from filebot, if there is one and it isn't the
- * only line in the file. */
+ * only line in the file. Assume that edittop and current are not at
+ * filebot. */
void remove_magicline(void)
{
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->fileage) {
+ assert(openfile->filebot != openfile->edittop && openfile->filebot != openfile->current);
+
openfile->filebot = openfile->filebot->prev;
free_filestruct(openfile->filebot->next);
openfile->filebot->next = NULL;
}
#endif /* !DISABLE_MOUSE */
+/* Return the shortcut corresponding to the values of kbinput (the key
+ * itself), meta_key (whether the key is a meta sequence), and func_key
+ * (whether the key is a function key), if any. The shortcut will be
+ * the first one in the list (control key, meta key sequence, function
+ * key, other meta key sequence) for the corresponding function. For
+ * example, passing in a meta key sequence that corresponds to a
+ * function with a control key, a function key, and a meta key sequence
+ * will return the control key corresponding to that function. */
const shortcut *get_shortcut(const shortcut *s_list, int *kbinput, bool
*meta_key, bool *func_key)
{
}
#ifndef NANO_TINY
+/* Return the global toggle corresponding to the values of kbinput (the
+ * key itself) and meta_key (whether the key is a meta sequence), if
+ * any. */
const toggle *get_toggle(int kbinput, bool meta_key)
{
const toggle *t = toggles;
waddch(win, ' ');
}
+/* Blank the first line of the top portion of the window. */
void blank_titlebar(void)
{
blank_line(topwin, 0, 0, COLS);
}
+/* If the MORE_SPACE flag isn't set, blank the second line of the top
+ * portion of the window. */
void blank_topbar(void)
{
if (!ISSET(MORE_SPACE))
blank_line(topwin, 1, 0, COLS);
}
+/* Blank all the lines of the middle portion of the window, i.e, the
+ * edit window. */
void blank_edit(void)
{
int i;
blank_line(edit, i, 0, COLS);
}
+/* Blank the first line of the bottom portion of the window. */
void blank_statusbar(void)
{
blank_line(bottomwin, 0, 0, COLS);
}
+/* If the NO_HELP flag isn't set, blank the last two lines of the bottom
+ * portion of the window. */
void blank_bottombars(void)
{
if (!ISSET(NO_HELP)) {
}
}
+/* Check if the number of keystrokes needed to blank the statusbar has
+ * been pressed. If so, blank the statusbar, unless constant cursor
+ * position display is on. */
void check_statusblank(void)
{
if (statusblank > 0)
return converted;
}
+/* Display the path specified in path on the titlebar, along with the
+ * current version of nano and whether the current file has been
+ * modified. If path is NULL, assume we're in normal editing mode and
+ * display the current filename instead. Otherwise, assume we're in the
+ * file browser, and don't display whether the current file has been
+ * modified. */
void titlebar(const char *path)
{
int space = COLS;
wnoutrefresh(edit);
}
-/* Set the modified flag if it isn't already set, and then update the
- * titlebar. */
+/* Mark the current file as modified if it isn't already, and then
+ * update the titlebar to display the file's new status. */
void set_modified(void)
{
if (!openfile->modified) {
25;
}
+/* Display the shortcut list in s on the last two rows of the bottom
+ * portion of the window. */
void bottombars(const shortcut *s)
{
size_t i, colwidth, slen;
openfile->edittop = foo;
}
+/* Unconditionally redraw the entire screen. */
void total_redraw(void)
{
#ifdef USE_SLANG
#endif
}
+/* Unconditionally redraw the entire screen, and then refresh it using
+ * the current file. */
void total_refresh(void)
{
total_redraw();
bottombars(currshortcut);
}
+/* Display the main shortcut list on the last two rows of the bottom
+ * portion of the window. */
void display_main_list(void)
{
bottombars(main_list);
disable_cursorpos = FALSE;
}
+/* Unconditionally display the current cursor position. */
void do_cursorpos_void(void)
{
do_cursorpos(FALSE);