DLR: prototype overhaul, etc.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1270 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2002-09-06 20:35:28 +00:00
parent f7c6811e36
commit ad40fdba59
12 changed files with 1603 additions and 1424 deletions

View File

@ -11,13 +11,27 @@ CVS code -
need to keep the translatable strings, and (b) added a
variable inspath to keep track of what the string was before
toggling. I'm sure there's bugs, have at it.
- Make sure all functions have prototypes in proto.h, and swap
some functions around to put similar functions closer
together (for this, rename clear_bottombars() to
blank_bottombars()). (DLR; suggested by David Benbennick)
- configure.ac:
- Added pt_BR to ALL_LINGUAS (Jordi).
- Changed --enable-color warning to be slightly less severe.
- Put the configure options in more or less alphabetical order,
and remove --enable-undo, since it doesn't do anything. (DLR)
- files.c:
open_file()
- String change: "File "x" is a directory" -> ""x" is a
directory". (Jordi)
do_insertfile()
- Disallow multibuffer toggling at the "Insert File" prompt if
we're in both view and multibuffer mode, so as to keep proper
integration between the two, and make sure the toggle
actually works all the time otherwise. Also, use
NANO_LOAD_KEY as an alias for TOGGLE_LOAD_KEY, so
--enable-tiny and --enable-multibuffer can be used together
again. (DLR)
open_prevfile_void(), open_nextfile_void()
- Return the return values of open_prevfile() and
open_nextfile(), respectively, instead of (incorrectly)
@ -29,6 +43,14 @@ CVS code -
- Most likely fixed the check marked with FIXME, so that tab
completion works properly when we're trying to tab-complete a
username and the string already contains data. (DLR)
- global.c:
shortcut_init()
- Use NANO_LOAD_KEY as an alias for TOGGLE_LOAD_KEY, so
--enable-tiny and --enable-multibuffer can be used together
again. (DLR)
thanks_for_all_the_fish()
- Make sure the reference to help_text is #ifdefed out when
--disable-help is used. (DLR)
- move.c:
page_up()
- Fix bug where current is moved up two lines when the up arrow
@ -42,6 +64,12 @@ CVS code -
off, pressing the down arrow on that last line centers the
cursor without updating the edit window. (Jeff DeFouw)
- nano.c:
version()
- Put the listed configure options in more or less alphabetical
order. (DLR)
open_pipe()
- If we're in view mode here (in which case we're also in
multibuffer mode), don't set the modification flag. (DLR)
do_next_word(), do_prev_word()
- If we're on the last/first line of the file, don't center the
screen; Pico doesn't in the former case. (DLR)
@ -65,6 +93,10 @@ CVS code -
do_justify()
- Fix cosmetic problems caused when justifying on the
magicline. (David Benbennick)
main()
- When searching through the main shortcut list looking for a
shortcut key, stop searching after finding one; this avoids a
rare segfault. (DLR)
- nano.h:
- Change search toggles for case sensitive searching and regexp
searching to M-C and M-R, respectively. (DLR; suggested by

View File

@ -29,44 +29,73 @@ if test "$debug_support" != "yes"; then
AC_DEFINE(NDEBUG, 1, [Shut up the assert warnings :-)])
fi
AC_ARG_ENABLE(tiny,
[ --enable-tiny Disable features for the sake of size
(currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.])
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.])
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
fi])
AC_ARG_ENABLE(extra,
[ --enable-extra Enable extra (optional) functions, including easter eggs],
[if test x$enableval = xyes; then
AC_DEFINE(NANO_EXTRA, 1, [Define this to enable the extra stuff.]) extra_support=yes
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
AC_DEFINE(ENABLE_UNDO, 1, [Define this to enable undoing... something]) undo_support=yes
fi])
AC_ARG_ENABLE(undo,
[ --enable-undo Enable undo support],
[if test x$enableval = xyes && test x$tiny_support != xyes; then
AC_DEFINE(ENABLE_UNDO, 1, [Define this to enable undoing... something.]) undo_support=yes
fi])
AC_ARG_ENABLE(multibuffer,
[ --enable-multibuffer Enable multiple file buffers],
AC_ARG_ENABLE(tiny,
[ --enable-tiny Disable features for the sake of size
(currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
AC_DEFINE(NANO_SMALL, 1, [Define this to make the nano executable as small as possible.]) tiny_support=yes
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.])
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.])
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!])
fi])
AC_ARG_ENABLE(nanorc,
[ --enable-nanorc Enable use of .nanorc file],
[if test x$enableval = xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use the .nanorc file.]) nanorc_support=yes
AC_ARG_ENABLE(browser,
[ --disable-browser Disable mini file browser],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
fi])
AC_ARG_ENABLE(help,
[ --disable-help Disable help function (^G)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.])
fi])
AC_ARG_ENABLE(justify,
[ --disable-justify Disable justify/unjustify function],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.])
fi])
AC_ARG_ENABLE(mouse,
[ --disable-mouse Disable mouse support (and -m flag)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
fi])
AC_ARG_ENABLE(operatingdir,
[ --disable-operatingdir Disable setting of operating directory (chroot of sorts)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
fi])
AC_ARG_ENABLE(speller,
[ --disable-speller Disable spell checker function],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
fi])
AC_ARG_ENABLE(tabcomp,
[ --disable-tabcomp Disable tab completion code for a smaller binary],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!])
fi])
AC_ARG_ENABLE(wrapping,
[ --disable-wrapping Disable all wrapping of text (and -w flag)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable any and all text wrapping.])
fi])
AC_ARG_ENABLE(color,
@ -83,52 +112,16 @@ AC_ARG_ENABLE(color,
])
fi])
AC_ARG_ENABLE(tabcomp,
[ --disable-tabcomp Disable tab completion code for a smaller binary],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define to disable the tab completion code Chris worked so hard on!])
AC_ARG_ENABLE(multibuffer,
[ --enable-multibuffer Enable multiple file buffers],
[if test x$enableval = xyes; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
fi])
AC_ARG_ENABLE(justify,
[ --disable-justify Disable justify/unjustify function],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routine.])
fi])
AC_ARG_ENABLE(speller,
[ --disable-speller Disable spell checker function],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the use(full|less) spelling functions.])
fi])
AC_ARG_ENABLE(help,
[ --disable-help Disable help function (^G)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the ^G help menu.])
fi])
AC_ARG_ENABLE(browser,
[ --disable-browser Disable mini file browser],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in (crappy) file browser.])
fi])
AC_ARG_ENABLE(wrapping,
[ --disable-wrapping Disable all wrapping of text (and -w flag)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable any and all text wrapping.])
fi])
AC_ARG_ENABLE(mouse,
[ --disable-mouse Disable mouse support (and -m flag)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse functions.])
fi])
AC_ARG_ENABLE(operatingdir,
[ --disable-operatingdir Disable setting of operating directory (chroot of sorts)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable setting of the operating directory (chroot of sorts).])
AC_ARG_ENABLE(nanorc,
[ --enable-nanorc Enable use of .nanorc file],
[if test x$enableval = xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use the .nanorc file.]) nanorc_support=yes
fi])
AC_MSG_CHECKING([whether to use slang])

119
files.c
View File

@ -103,7 +103,6 @@ void new_file(void)
#ifdef ENABLE_COLOR
update_color();
#endif
}
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len)
@ -453,14 +452,11 @@ int do_insertfile(int loading_file)
i = statusq(1, insertfile_list, inspath, _("File to insert [from ./] "));
if (i != -1) {
inspath = mallocstrcpy(inspath, answer);
#ifdef DEBUG
fprintf(stderr, _("filename is %s\n"), answer);
#endif
#ifndef DISABLE_TABCOMP
realname = real_dir_from_tilde(answer);
#else
@ -494,9 +490,12 @@ int do_insertfile(int loading_file)
#endif
#ifdef ENABLE_MULTIBUFFER
if (i == TOGGLE_LOAD_KEY) {
TOGGLE(MULTIBUFFER);
return do_insertfile(loading_file);
if (i == NANO_LOAD_KEY) {
/* don't allow toggling if we're in both view mode and
multibuffer mode now */
if (!ISSET(VIEW_MODE) || !ISSET(MULTIBUFFER))
TOGGLE(MULTIBUFFER);
return do_insertfile(ISSET(MULTIBUFFER));
}
#endif
#ifndef NANO_SMALL
@ -574,8 +573,6 @@ int do_insertfile(int loading_file)
}
#endif
/* If we've gone off the bottom, recenter; otherwise, just redraw */
if (current->lineno > editbot->lineno)
edit_update(current, CENTER);
@ -1139,8 +1136,8 @@ char *get_full_path(char *origpath)
* get_full_path()). On error, if the path doesn't reference a
* directory, or if the directory isn't writable, it returns NULL.
*/
char *check_writable_directory(char *path) {
char *check_writable_directory(char *path)
{
char *full_path = get_full_path(path);
int writable;
struct stat fileinfo;
@ -1178,8 +1175,8 @@ char *check_writable_directory(char *path) {
* implementation is to go on generating random filenames regardless of
* it.
*/
char *safe_tempnam(const char *dirname, const char *filename_prefix) {
char *safe_tempnam(const char *dirname, const char *filename_prefix)
{
char *buf, *tempdir = NULL, *full_tempdir = NULL;
int filedesc;
@ -2221,6 +2218,12 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
buf = mallocstrcpy(buf, tmp);
matches = username_tab_completion(tmp, &num_matches);
}
/* If we're in the middle of the original line, copy the string
only up to the cursor position into buf, so tab completion
will result in buf's containing only the tab-completed
path/filename. */
else if (strlen(buf) > strlen(tmp))
buf = mallocstrcpy(buf, tmp);
/* Try to match everything in the current working directory that
* matches. */
@ -2416,51 +2419,6 @@ int diralphasort(const void *va, const void *vb)
}
/* Initialize the browser code, including the list of files in *path */
char **browser_init(char *path, int *longest, int *numents)
{
DIR *dir;
struct dirent *next;
char **filelist = (char **) NULL;
int i = 0;
dir = opendir(path);
if (!dir)
return NULL;
*numents = 0;
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
(*numents)++;
if (strlen(next->d_name) > *longest)
*longest = strlen(next->d_name);
}
rewinddir(dir);
*longest += 10;
filelist = nmalloc(*numents * sizeof (char *));
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
filelist[i] = charalloc(strlen(next->d_name) + strlen(path) + 2);
if (!strcmp(path, "/"))
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1,
"%s%s", path, next->d_name);
else
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 2,
"%s/%s", path, next->d_name);
i++;
}
if (*longest > COLS - 1)
*longest = COLS - 1;
return filelist;
}
/* Free our malloc()ed memory */
void free_charptrarray(char **array, int len)
{
@ -2513,6 +2471,51 @@ void striponedir(char *foo)
return;
}
/* Initialize the browser code, including the list of files in *path */
char **browser_init(char *path, int *longest, int *numents)
{
DIR *dir;
struct dirent *next;
char **filelist = (char **) NULL;
int i = 0;
dir = opendir(path);
if (!dir)
return NULL;
*numents = 0;
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
(*numents)++;
if (strlen(next->d_name) > *longest)
*longest = strlen(next->d_name);
}
rewinddir(dir);
*longest += 10;
filelist = nmalloc(*numents * sizeof (char *));
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
filelist[i] = charalloc(strlen(next->d_name) + strlen(path) + 2);
if (!strcmp(path, "/"))
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1,
"%s%s", path, next->d_name);
else
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 2,
"%s/%s", path, next->d_name);
i++;
}
if (*longest > COLS - 1)
*longest = COLS - 1;
return filelist;
}
/* Our browser function. inpath is the path to start browsing from */
char *do_browser(char *inpath)
{

View File

@ -217,19 +217,6 @@ void toggle_init_one(int val, const char *desc, int flag)
u->next = NULL;
}
#ifdef DEBUG
/* Deallocate all of the toggles. */
void free_toggles(void)
{
while (toggles != NULL) {
toggle *pt = toggles; /* Think "previous toggle" */
toggles = toggles->next;
free(pt);
}
}
#endif
void toggle_init(void)
{
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
@ -288,6 +275,19 @@ void toggle_init(void)
toggle_init_one(TOGGLE_BACKUP_KEY, toggle_backup_msg, BACKUP_FILE);
toggle_init_one(TOGGLE_SMOOTH_KEY, toggle_smooth_msg, SMOOTHSCROLL);
}
#ifdef DEBUG
/* Deallocate all of the toggles. */
void free_toggles(void)
{
while (toggles != NULL) {
toggle *pt = toggles; /* Think "previous toggle" */
toggles = toggles->next;
free(pt);
}
}
#endif
#endif /* !NANO_SMALL */
/* Deallocate the given shortcut. */
@ -325,8 +325,8 @@ void shortcut_init(int unjustify)
"", *nano_backup_msg = "";
#ifdef ENABLE_MULTIBUFFER
char *nano_openprev_msg = "", *nano_opennext_msg = "",
*nano_multibuffer_msg = "";
char *nano_openprev_msg = "", *nano_opennext_msg =
"", *nano_multibuffer_msg = "";
#endif
#ifdef HAVE_REGEX_H
char *nano_regexp_msg = "", *nano_bracket_msg = "";
@ -727,7 +727,7 @@ void shortcut_init(int unjustify)
IFHELP(nano_execute_msg, 0), 0, 0, NOVIEW, 0);
#endif
#ifdef ENABLE_MULTIBUFFER
sc_init_one(&insertfile_list, TOGGLE_LOAD_KEY, _("New Buffer"),
sc_init_one(&insertfile_list, NANO_LOAD_KEY, _("New Buffer"),
IFHELP(nano_multibuffer_msg, 0), 0, 0, NOVIEW, 0);
#endif
@ -811,8 +811,10 @@ void thanks_for_all_the_fish(void)
if (alt_speller != NULL)
free(alt_speller);
#endif
#ifndef DISABLE_HELP
if (help_text != NULL)
free(help_text);
#endif
if (filename != NULL)
free(filename);
if (answer != NULL)

104
move.c
View File

@ -35,43 +35,6 @@
#define _(string) (string)
#endif
int do_page_down(void)
{
wrap_reset();
current_x = 0;
placewewant = 0;
if (current == filebot)
return 0;
/* AHEM, if we only have a screen or less of text, DON'T do an
edit_update, just move the cursor to editbot! */
if (edittop == fileage && editbot == filebot && totlines < editwinrows) {
current = editbot;
reset_cursor();
} else if (editbot != filebot || edittop == fileage) {
current_y = 0;
current = editbot;
if (current->prev != NULL)
current = current->prev;
if (current->prev != NULL)
current = current->prev;
edit_update(current, TOP);
} else {
while (current != filebot) {
current = current->next;
current_y++;
}
edit_update(edittop, TOP);
}
update_cursor();
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
int do_home(void)
{
UNSET(KEEP_CUTBUFFER);
@ -138,6 +101,43 @@ int do_page_up(void)
return 1;
}
int do_page_down(void)
{
wrap_reset();
current_x = 0;
placewewant = 0;
if (current == filebot)
return 0;
/* AHEM, if we only have a screen or less of text, DON'T do an
edit_update, just move the cursor to editbot! */
if (edittop == fileage && editbot == filebot && totlines < editwinrows) {
current = editbot;
reset_cursor();
} else if (editbot != filebot || edittop == fileage) {
current_y = 0;
current = editbot;
if (current->prev != NULL)
current = current->prev;
if (current->prev != NULL)
current = current->prev;
edit_update(current, TOP);
} else {
while (current != filebot) {
current = current->next;
current_y++;
}
edit_update(edittop, TOP);
}
update_cursor();
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
int do_up(void)
{
wrap_reset();
@ -197,6 +197,21 @@ int do_down(void) {
return 1;
}
int do_left(void)
{
if (current_x > 0)
current_x--;
else if (current != fileage) {
do_up();
current_x = strlen(current->data);
}
placewewant = xplustabs();
update_line(current, current_x);
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
int do_right(void)
{
assert(current_x <= strlen(current->data));
@ -213,18 +228,3 @@ int do_right(void)
check_statblank();
return 1;
}
int do_left(void)
{
if (current_x > 0)
current_x--;
else if (current != fileage) {
do_up();
current_x = strlen(current->data);
}
placewewant = xplustabs();
update_line(current, current_x);
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}

1817
nano.c

File diff suppressed because it is too large Load Diff

1
nano.h
View File

@ -326,6 +326,7 @@ know what you're doing */
#define NANO_TOFILES_KEY NANO_CONTROL_T
#define NANO_APPEND_KEY NANO_ALT_A
#define NANO_PREPEND_KEY NANO_ALT_P
#define NANO_LOAD_KEY NANO_ALT_F
#define NANO_OPENPREV_KEY NANO_ALT_LCARAT
#define NANO_OPENNEXT_KEY NANO_ALT_RCARAT
#define NANO_OPENPREV_ALTKEY NANO_ALT_COMMA

343
proto.h
View File

@ -59,13 +59,7 @@ extern char *operating_dir;
extern char *full_operating_dir;
#endif
#ifndef DISABLE_SPELLER
extern char *alt_speller;
#endif
#ifndef DISABLE_TABCOMP
char *real_dir_from_tilde(char *buf);
#endif
#ifndef DISABLE_BROWSER
char *do_browse_from(char *inpath);
extern char *alt_speller;
#endif
extern struct stat fileinfo;
@ -116,23 +110,28 @@ extern toggle *toggles;
/* Public functions in color.c */
#ifdef ENABLE_COLOR
void set_colorpairs(void);
void do_colorinit(void);
void update_color(void);
#endif /* ENABLE_COLOR */
/* Public functions in cut.c */
int do_cut_text(void);
int do_uncut_text(void);
filestruct *get_cutbottom(void);
void add_to_cutbuffer(filestruct *inptr);
void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
size_t bot_x, int destructive);
int do_cut_text(void);
int do_uncut_text(void);
/* Public functions in files.c */
void load_file(int update);
void new_file(void);
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len);
int write_file(char *name, int tmpfile, int append, int nonamechange);
int open_file(const char *filename, int insert, int quiet);
int read_file(FILE *f, const char *filename, int quiet);
int open_file(const char *filename, int insert, int quiet);
char *get_next_filename(const char *name);
int do_insertfile(int loading_file);
int do_insertfile_void(void);
#ifdef ENABLE_MULTIBUFFER
openfilestruct *make_new_opennode(openfilestruct *prevnode);
void splice_opennode(openfilestruct *begin, openfilestruct *newnode, openfilestruct *end);
@ -140,157 +139,299 @@ void unlink_opennode(const openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
void free_openfilestruct(openfilestruct *src);
int add_open_file(int update);
int close_open_file(void);
int load_open_file(void);
int open_prevfile(int closing_file);
int open_prevfile_void(void);
int open_nextfile(int closing_file);
int open_nextfile_void(void);
int close_open_file(void);
#endif
#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
char *get_full_path(char *origpath);
#endif
#ifndef DISABLE_SPELLER
char *check_writable_directory(char *path);
char *safe_tempnam(const char *dirname, const char *filename_prefix);
#endif
#ifndef DISABLE_OPERATINGDIR
int check_operating_dir(char *currpath, int allow_tabcomp);
#endif
int write_file(char *name, int tmp, int append, int nonamechange);
int do_writeout(char *path, int exiting, int append);
char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list);
void new_file(void);
int do_writeout_void(void);
int do_insertfile_void(void);
char *get_next_filename(const char *name);
#ifndef DISABLE_SPELLER
char *safe_tempnam(const char *dirname, const char *filename_prefix);
#ifndef DISABLE_TABCOMP
char *real_dir_from_tilde(char *buf);
#endif
int append_slash_if_dir(char *buf, int *lastwastab, int *place);
char **username_tab_completion(char *buf, int *num_matches);
char **cwd_tab_completion(char *buf, int *num_matches);
char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list);
#ifndef DISABLE_BROWSER
struct stat filestat(const char *path);
int diralphasort(const void *va, const void *vb);
void free_charptrarray(char **array, int len);
char *tail(char *foo);
void striponedir(char *foo);
char **browser_init(char *path, int *longest, int *numents);
char *do_browser(char *inpath);
char *do_browse_from(char *inpath);
#endif
/* Public functions in global.c */
int length_of_list(const shortcut *s);
void sc_init_one(shortcut **shortcutage, int key, const char *desc,
#ifndef DISABLE_HELP
const char *help,
#endif
int alt, int misc1, int misc2, int view, int (*func) (void));
#ifndef NANO_SMALL
void toggle_init_one(int val, const char *desc, int flag);
void toggle_init(void);
#ifdef DEBUG
void free_toggles(void);
#endif
#endif
void free_shortcutage(shortcut **shortcutage);
void shortcut_init(int unjustify);
#ifdef DEBUG
void thanks_for_all_the_fish(void);
#endif
/* Public functions in move.c */
int do_first_line(void);
int do_last_line(void);
size_t xplustabs(void);
size_t actual_x(const filestruct *fileptr, size_t xplus);
size_t strnlenpt(const char *buf, size_t size);
size_t strlenpt(const char *buf);
void reset_cursor(void);
void blank_bottombars(void);
void blank_edit(void);
void blank_statusbar(void);
void blank_statusbar_refresh(void);
void check_statblank(void);
void titlebar(const char *path);
void bottombars(const shortcut *s);
void set_modified(void);
int do_home(void);
int do_end(void);
void page_up(void);
int do_page_up(void);
int do_page_down(void);
int do_up(void);
int do_down(void);
int do_left(void);
int do_right(void);
void page_up(void);
int do_page_up(void);
int do_page_down(void);
int do_home(void);
int do_end(void);
/* Public functions in nano.c */
void renumber(filestruct *fileptr);
void free_filestruct(filestruct *src);
int no_help(void);
void renumber_all(void);
int open_pipe(const char *command);
int do_prev_word(void);
int do_next_word(void);
void delete_node(filestruct *fileptr);
void wrap_reset(void);
void do_early_abort(void);
RETSIGTYPE finish(int sigage);
void die(const char *msg, ...);
void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
void nano_disabled_msg(void);
void window_init(void);
void do_mouse(void);
void print_view_warning(void);
int do_exit(void);
int do_spell(void);
int do_mark(void);
int do_delete(void);
int do_backspace(void);
int do_tab(void);
int do_justify(void);
int do_enter(void);
int do_wrap(filestruct *inptr);
void signal_init(void);
void handle_sigwinch(int s);
void die_save_file(const char *die_filename);
size_t indent_length(const char *line);
filestruct *copy_node(const filestruct *src);
filestruct *copy_filestruct(const filestruct *src);
filestruct *make_new_node(filestruct *prevnode);
void die_too_small(void);
void print_view_warning(void);
void global_init(int save_cutbuffer);
void window_init(void);
void mouse_init(void);
#ifndef DISABLE_HELP
void help_init(void);
#endif
filestruct *make_new_node(filestruct *prevnode);
filestruct *copy_node(const filestruct *src);
void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
void unlink_node(const filestruct *fileptr);
void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src);
void renumber_all(void);
void renumber(filestruct *fileptr);
void print1opt(const char *shortflag, const char *longflag,
const char *desc);
void usage(void);
void version(void);
void do_early_abort(void);
int no_help(void);
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP) || defined(NANO_SMALL)
void nano_disabled_msg(void);
#endif
#ifndef NANO_SMALL
RETSIGTYPE cancel_fork(int signal);
int open_pipe(const char *command);
#endif
#ifndef DISABLE_MOUSE
#ifdef NCURSES_MOUSE_VERSION
void do_mouse(void);
#endif
#endif
void do_char(char ch);
int do_backspace(void);
int do_delete(void);
int do_tab(void);
int do_enter(void);
int do_next_word(void);
int do_prev_word(void);
int do_mark(void);
void wrap_reset(void);
#ifndef DISABLE_WRAPPING
int do_wrap(filestruct *inptr);
#endif
#ifndef DISABLE_SPELLER
int do_int_spell_fix(const char *word);
int do_int_speller(char *tempfile_name);
int do_alt_speller(char *tempfile_name);
#endif
int do_spell(void);
#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
size_t indent_length(const char *line);
#endif
#ifndef DISABLE_JUSTIFY
int justify_format(int changes_allowed, filestruct *line, size_t skip);
#ifdef HAVE_REGEX_H
size_t quote_length(const char *line, const regex_t *qreg);
#else
size_t quote_length(const char *line);
#endif
#ifdef HAVE_REGEX_H
# define IFREG(a, b) a, b
#else
# define IFREG(a, b) a
#endif
int quotes_match(const char *a_line, size_t a_quote,
IFREG(const char *b_line, const regex_t *qreg));
size_t indents_match(const char *a_line, size_t a_indent,
const char *b_line, size_t b_indent);
filestruct *backup_lines(filestruct *first_line, size_t par_len,
size_t quote_len);
int break_line(const char *line, int goal, int force);
#endif /* !DISABLE_JUSTIFY */
int do_justify(void);
int do_exit(void);
void signal_init(void);
RETSIGTYPE handle_hup(int signal);
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_cont(int signal);
#ifndef NANO_SMALL
void handle_sigwinch(int s);
#endif
void print_numlock_warning(void);
#ifndef NANO_SMALL
void do_toggle(const toggle *which);
#endif
int ABCD(int input);
/* Public functions in rcfile.c */
#ifdef ENABLE_NANORC
void rcfile_error(const char *msg, ...);
void rcfile_msg(const char *msg, ...);
char *parse_next_word(char *ptr);
char *parse_argument(char *ptr);
#ifdef ENABLE_COLOR
int colortoint(const char *colorname, int *bright);
char *parse_next_regex(char *ptr);
void parse_syntax(char *ptr);
void parse_colors(char *ptr);
#endif /* ENABLE_COLOR */
void parse_rcfile(FILE *rcstream);
void do_rcfile(void);
#endif
#endif /* ENABLE_NANORC */
/* Public functions in search.c */
int do_gotoline(int line, int save_pos);
#ifdef HAVE_REGEX_H
void regexp_init(const char *regexp);
void regexp_cleanup(void);
#endif
void not_found_msg(const char *str);
void search_abort(void);
void search_init_globals(void);
int search_init(int replacing);
int is_whole_word(int curr_pos, const char *datastr, const char *searchword);
filestruct *findnextstr(int quiet, int bracket_mode,
const filestruct *begin, int beginx,
const char *needle);
int do_search(void);
void replace_abort(void);
#ifdef HAVE_REGEX_H
int replace_regexp(char *string, int create_flag);
#endif
char *replace_line(void);
void print_replaced(int num);
int do_replace_loop(const char *prevanswer, const filestruct *begin,
int *beginx, int wholewords, int *i);
int do_find_bracket(void);
int do_replace(void);
void goto_abort(void);
int do_gotoline(int line, int save_pos);
int do_gotoline_void(void);
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant);
#endif
void search_init_globals(void);
void replace_abort(void);
int do_gotoline_void(void);
int do_search(void);
int do_replace(void);
filestruct *findnextstr(int quiet, int bracket_mode, const filestruct *begin,
int beginx, const char *needle);
int do_find_bracket(void);
/* Public functions in utils.c */
const char *stristr(const char *haystack, const char *needle);
const char *strstrwrapper(const char *haystack, const char *needle,
const char *rev_start, int line_pos);
int is_cntrl_char(int c);
int num_of_digits(int n);
int check_wildcard_match(const char *text, const char *pattern);
void align(char **strp);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
#ifndef NANO_SMALL
const char *revstrstr(const char *haystack, const char *needle,
const char *rev_start);
const char *revstristr(const char *haystack, const char *needle,
const char *rev_start);
#endif
const char *stristr(const char *haystack, const char *needle);
const char *strstrwrapper(const char *haystack, const char *needle,
const char *rev_start, int line_pos);
void nperror(const char *s);
char *mallocstrcpy(char *dest, const char *src);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
void new_magicline(void);
char *charalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
char *mallocstrcpy(char *dest, const char *src);
void new_magicline(void);
#ifndef DISABLE_TABCOMP
int check_wildcard_match(const char *text, const char *pattern);
#endif
/* Public functions in winio.c */
int do_yesno(int all, int leavecursor, const char *msg, ...);
int statusq(int allowtabs, const shortcut *s, const char *def,
const char *msg, ...);
void do_replace_highlight(int highlight_flag, const char *word);
int do_first_line(void);
int do_last_line(void);
int xpt(const filestruct *fileptr, int index);
size_t xplustabs(void);
size_t actual_x(const filestruct *fileptr, size_t xplus);
size_t strnlenpt(const char *buf, size_t size);
size_t strlenpt(const char *buf);
void blank_bottombars(void);
void blank_bottomwin(void);
void blank_edit(void);
void blank_statusbar(void);
void blank_statusbar_refresh(void);
void check_statblank(void);
void nanoget_repaint(const char *buf, const char *inputbuf, int x);
int nanogetstr(int allowtabs, const char *buf, const char *def,
const shortcut *s
#ifndef DISABLE_TABCOMP
, int *list
#endif
);
void set_modified(void);
void titlebar(const char *path);
void bottombars(const shortcut *s);
void onekey(const char *keystroke, const char *desc, int len);
int get_page_start_virtual(int page);
int get_page_from_virtual(int virtual);
int get_page_end_virtual(int page);
int get_page_start(int column);
void reset_cursor(void);
void add_marked_sameline(int begin, int end, filestruct *fileptr, int y,
int virt_cur_x, int this_page);
void edit_add(filestruct *fileptr, int yval, int start, int virt_cur_x,
int virt_mark_beginx, int this_page);
void update_line(filestruct *fileptr, int index);
void update_cursor(void);
void center_cursor(void);
void edit_refresh(void);
void edit_refresh_clearok(void);
void edit_update(filestruct *fileptr, topmidbotnone location);
void update_cursor(void);
int statusq(int tabs, const shortcut *s, const char *def,
const char *msg, ...);
int do_yesno(int all, int leavecursor, const char *msg, ...);
int total_refresh(void);
void display_main_list(void);
void statusbar(const char *msg, ...);
int do_cursorpos(int constant);
int do_cursorpos_void(void);
int do_help(void);
int keypad_on(WINDOW *win, int newval);
void do_replace_highlight(int highlight_flag, const char *word);
void fix_editbot(void);
#ifdef DEBUG
void dump_buffer(const filestruct *inptr);
void dump_buffer_reverse(void);
#endif
void update_line(filestruct *fileptr, int index);
void fix_editbot(void);
void statusbar(const char *msg, ...);
void center_cursor(void);
void display_main_list(void);
#ifdef NANO_EXTRA
void do_credits(void);
#endif
int do_cursorpos(int constant);
int do_cursorpos_void(void);
int total_refresh(void);
int do_help(void);
int keypad_on(WINDOW *win, int newval);

View File

@ -188,24 +188,6 @@ char *parse_argument(char *ptr)
#ifdef ENABLE_COLOR
char *parse_next_regex(char *ptr)
{
while ((*ptr != '"' || (*(ptr + 1) != ' ' && *(ptr + 1) != '\n'))
&& *ptr != '\n' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
return NULL;
/* Null terminate and advance ptr */
*ptr++ = '\0';
while (*ptr == ' ' || *ptr == '\t')
ptr++;
return ptr;
}
int colortoint(const char *colorname, int *bright)
{
int mcolor = 0;
@ -245,6 +227,24 @@ int colortoint(const char *colorname, int *bright)
return mcolor;
}
char *parse_next_regex(char *ptr)
{
while ((*ptr != '"' || (*(ptr + 1) != ' ' && *(ptr + 1) != '\n'))
&& *ptr != '\n' && *ptr != '\0')
ptr++;
if (*ptr == '\0')
return NULL;
/* Null terminate and advance ptr */
*ptr++ = '\0';
while (*ptr == ' ' || *ptr == '\t')
ptr++;
return ptr;
}
void parse_syntax(char *ptr)
{
syntaxtype *tmpsyntax = NULL;

View File

@ -53,6 +53,33 @@ void regexp_cleanup(void)
}
#endif
void not_found_msg(const char *str)
{
if (strlen(str) <= COLS / 2)
statusbar(_("\"%s\" not found"), str);
else {
char *foo = mallocstrcpy(NULL, str);
foo[COLS / 2] = '\0';
statusbar(_("\"%s...\" not found"), foo);
free(foo);
}
}
void search_abort(void)
{
UNSET(KEEP_CUTBUFFER);
display_main_list();
wrefresh(bottomwin);
if (ISSET(MARK_ISSET))
edit_refresh_clearok();
#ifdef HAVE_REGEX_H
if (ISSET(REGEXP_COMPILED))
regexp_cleanup();
#endif
}
void search_init_globals(void)
{
if (last_search == NULL) {
@ -67,10 +94,11 @@ void search_init_globals(void)
/* Set up the system variables for a search or replace. Returns -1 on
abort, 0 on success, and 1 on rerun calling program
Return -2 to run opposite program (search -> replace, replace -> search)
Return -2 to run opposite program (search -> replace, replace ->
search).
replacing = 1 if we call from do_replace, 0 if called from do_search func.
*/
replacing = 1 if we call from do_replace, 0 if called from do_search
func. */
int search_init(int replacing)
{
int i = 0;
@ -196,19 +224,6 @@ int search_init(int replacing)
return 0;
}
void not_found_msg(const char *str)
{
if (strlen(str) <= COLS / 2)
statusbar(_("\"%s\" not found"), str);
else {
char *foo = mallocstrcpy(NULL, str);
foo[COLS / 2] = '\0';
statusbar(_("\"%s...\" not found"), foo);
free(foo);
}
}
int is_whole_word(int curr_pos, const char *datastr, const char *searchword)
{
size_t sln = curr_pos + strlen(searchword);
@ -223,7 +238,8 @@ static int past_editbuff;
/* findnextstr() is now searching lines not displayed */
filestruct *findnextstr(int quiet, int bracket_mode,
const filestruct *begin, int beginx, const char *needle)
const filestruct *begin, int beginx,
const char *needle)
{
filestruct *fileptr = current;
const char *searchstr, *rev_start = NULL, *found = NULL;
@ -363,20 +379,6 @@ filestruct *findnextstr(int quiet, int bracket_mode,
return fileptr;
}
void search_abort(void)
{
UNSET(KEEP_CUTBUFFER);
display_main_list();
wrefresh(bottomwin);
if (ISSET(MARK_ISSET))
edit_refresh_clearok();
#ifdef HAVE_REGEX_H
if (ISSET(REGEXP_COMPILED))
regexp_cleanup();
#endif
}
/* Search for a string. */
int do_search(void)
{
@ -430,14 +432,6 @@ int do_search(void)
return 1;
}
void print_replaced(int num)
{
if (num > 1)
statusbar(_("Replaced %d occurrences"), num);
else if (num == 1)
statusbar(_("Replaced 1 occurrence"));
}
void replace_abort(void)
{
/* Identical to search_abort, so we'll call it here. If it
@ -561,6 +555,14 @@ char *replace_line(void)
return copy;
}
void print_replaced(int num)
{
if (num > 1)
statusbar(_("Replaced %d occurrences"), num);
else if (num == 1)
statusbar(_("Replaced 1 occurrence"));
}
/* step through each replace word and prompt user before replacing word */
int do_replace_loop(const char *prevanswer, const filestruct *begin,
int *beginx, int wholewords, int *i)

View File

@ -97,7 +97,7 @@ void sunder(char *str)
/* None of this is needed if we're using NANO_SMALL! */
#ifndef NANO_SMALL
const char *revstrstr(const char *haystack, const char *needle,
const char *rev_start)
const char *rev_start)
{
for(; rev_start >= haystack ; rev_start--) {
const char *r, *q;
@ -111,7 +111,7 @@ const char *revstrstr(const char *haystack, const char *needle,
}
const char *revstristr(const char *haystack, const char *needle,
const char *rev_start)
const char *rev_start)
{
for (; rev_start >= haystack; rev_start--) {
const char *r = rev_start, *q = needle;
@ -147,7 +147,7 @@ const char *stristr(const char *haystack, const char *needle)
}
const char *strstrwrapper(const char *haystack, const char *needle,
const char *rev_start, int line_pos)
const char *rev_start, int line_pos)
{
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
@ -195,7 +195,8 @@ const char *strstrwrapper(const char *haystack, const char *needle,
/* This is a wrapper for the perror function. The wrapper takes care of
* ncurses, calls perror (which writes to STDERR), then refreshes the
* screen. Note that nperror causes the window to flicker once. */
void nperror(const char *s) {
void nperror(const char *s)
{
/* leave ncurses mode, go to the terminal */
if (endwin() != ERR) {
perror(s); /* print the error */

313
winio.c
View File

@ -155,6 +155,15 @@ void blank_bottombars(void)
}
}
void blank_bottomwin(void)
{
if (ISSET(NO_HELP))
return;
mvwaddstr(bottomwin, 1, 0, hblank);
mvwaddstr(bottomwin, 2, 0, hblank);
}
void blank_edit(void)
{
int i;
@ -210,11 +219,11 @@ void nanoget_repaint(const char *buf, const char *inputbuf, int x)
/* Get the input from the kb; this should only be called from
* statusq(). */
int nanogetstr(int allowtabs, const char *buf, const char *def,
const shortcut *s
const shortcut *s
#ifndef DISABLE_TABCOMP
, int *list
, int *list
#endif
)
)
{
int kbinput;
int x;
@ -241,7 +250,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
nanoget_repaint(buf, answer, x);
/* Make sure any editor screen updates are displayed before getting input */
/* Make sure any editor screen updates are displayed before getting
input */
wrefresh(edit);
while ((kbinput = wgetch(bottomwin)) != 13) {
@ -253,7 +263,8 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
if (kbinput == t->val && kbinput < 32) {
#ifndef DISABLE_HELP
/* Have to do this here, it would be too late to do it in statusq */
/* Have to do this here, it would be too late to do it
in statusq() */
if (kbinput == NANO_HELP_KEY || kbinput == NANO_HELP_FKEY) {
do_help();
break;
@ -435,6 +446,16 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
return 0;
}
/* If modified is not already set, set it and update titlebar. */
void set_modified(void)
{
if (!ISSET(MODIFIED)) {
SET(MODIFIED);
titlebar(NULL);
wrefresh(topwin);
}
}
void titlebar(const char *path)
{
int namelen, space;
@ -483,35 +504,6 @@ void titlebar(const char *path)
reset_cursor();
}
/* Write a shortcut key to the help area at the bottom of the window.
* keystroke is e.g. "^G" and desc is e.g. "Get Help".
* We are careful to write exactly len characters, even if len is
* very small and keystroke and desc are long. */
void onekey(const char *keystroke, const char *desc, int len)
{
wattron(bottomwin, A_REVERSE);
waddnstr(bottomwin, keystroke, len);
wattroff(bottomwin, A_REVERSE);
len -= strlen(keystroke);
if (len > 0) {
waddch(bottomwin, ' ');
len--;
waddnstr(bottomwin, desc, len);
len -= strlen(desc);
for (; len > 0; len--)
waddch(bottomwin, ' ');
}
}
void clear_bottomwin(void)
{
if (ISSET(NO_HELP))
return;
mvwaddstr(bottomwin, 1, 0, hblank);
mvwaddstr(bottomwin, 2, 0, hblank);
}
void bottombars(const shortcut *s)
{
int i, j, numcols;
@ -530,7 +522,7 @@ void bottombars(const shortcut *s)
/* There will be this many columns of shortcuts */
numcols = (slen + (slen % 2)) / 2;
clear_bottomwin();
blank_bottomwin();
for (i = 0; i < numcols; i++) {
for (j = 0; j <= 1; j++) {
@ -562,20 +554,30 @@ void bottombars(const shortcut *s)
wrefresh(bottomwin);
}
/* If modified is not already set, set it and update titlebar. */
void set_modified(void)
/* Write a shortcut key to the help area at the bottom of the window.
* keystroke is e.g. "^G" and desc is e.g. "Get Help".
* We are careful to write exactly len characters, even if len is
* very small and keystroke and desc are long. */
void onekey(const char *keystroke, const char *desc, int len)
{
if (!ISSET(MODIFIED)) {
SET(MODIFIED);
titlebar(NULL);
wrefresh(topwin);
wattron(bottomwin, A_REVERSE);
waddnstr(bottomwin, keystroke, len);
wattroff(bottomwin, A_REVERSE);
len -= strlen(keystroke);
if (len > 0) {
waddch(bottomwin, ' ');
len--;
waddnstr(bottomwin, desc, len);
len -= strlen(desc);
for (; len > 0; len--)
waddch(bottomwin, ' ');
}
}
/* And so start the display update routines */
/* Given a column, this returns the "page" it is on */
/* "page" in the case of the display columns, means which set of 80 */
/* characters is viewable (e.g.: page 1 shows from 1 to COLS) */
/* And so start the display update routines. Given a column, this
* returns the "page" it is on. "page", in the case of the display
* columns, means which set of 80 characters is viewable (e.g. page 1
* shows from 1 to COLS). */
int get_page_from_virtual(int virtual)
{
int page = 2;
@ -637,12 +639,10 @@ void reset_cursor(void)
}
#ifndef NANO_SMALL
/* This takes care of the case where there is a mark that covers only */
/* the current line. */
/* It expects a line with no tab characters (i.e.: the type that edit_add */
/* deals with */
void add_marked_sameline(int begin, int end, filestruct * fileptr, int y,
/* This takes care of the case where there is a mark that covers only
* the current line. It expects a line with no tab characters (i.e.
* the type that edit_add() deals with. */
void add_marked_sameline(int begin, int end, filestruct *fileptr, int y,
int virt_cur_x, int this_page)
{
/*
@ -691,12 +691,10 @@ void add_marked_sameline(int begin, int end, filestruct * fileptr, int y,
}
#endif
/* edit_add takes care of the job of actually painting a line into the
* edit window.
*
* Called only from update_line. Expects a converted-to-not-have-tabs
* line */
void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
/* edit_add() takes care of the job of actually painting a line into
* the edit window. Called only from update_line(). Expects a
* converted-to-not-have-tabs line. */
void edit_add(filestruct *fileptr, int yval, int start, int virt_cur_x,
int virt_mark_beginx, int this_page)
{
@ -1007,12 +1005,10 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
/*
* Just update one line in the edit buffer. Basically a wrapper for
* edit_add
*
* index gives us a place in the string to update starting from.
* Likely args are current_x or 0.
* edit_add(). index gives us a place in the string to update starting
* from. Likely args are current_x or 0.
*/
void update_line(filestruct * fileptr, int index)
void update_line(filestruct *fileptr, int index)
{
filestruct *filetmp;
int line = 0, col = 0;
@ -1112,6 +1108,28 @@ void update_line(filestruct * fileptr, int index)
free(tmp);
}
/* This function updates current, based on where current_y is;
* reset_cursor() does the opposite. */
void update_cursor(void)
{
int i = 0;
#ifdef DEBUG
fprintf(stderr, _("Moved to (%d, %d) in edit buffer\n"), current_y,
current_x);
#endif
current = edittop;
while (i < current_y && current->next != NULL) {
current = current->next;
i++;
}
#ifdef DEBUG
fprintf(stderr, _("current->data = \"%s\"\n"), current->data);
#endif
}
void center_cursor(void)
{
current_y = editwinrows / 2;
@ -1194,28 +1212,6 @@ void edit_update(filestruct *fileptr, topmidbotnone location)
edit_refresh();
}
/* This function updates current, based on where current_y is;
* reset_cursor() does the opposite. */
void update_cursor(void)
{
int i = 0;
#ifdef DEBUG
fprintf(stderr, _("Moved to (%d, %d) in edit buffer\n"), current_y,
current_x);
#endif
current = edittop;
while (i < current_y && current->next != NULL) {
current = current->next;
i++;
}
#ifdef DEBUG
fprintf(stderr, _("current->data = \"%s\"\n"), current->data);
#endif
}
/*
* Ask a question on the statusbar. Answer will be stored in answer
* global. Returns -1 on aborted enter, -2 on a blank string, and 0
@ -1278,8 +1274,9 @@ int statusq(int tabs, const shortcut *s, const char *def,
}
/*
* Ask a simple yes/no question on the statusbar. Returns 1 for Y, 0 for
* N, 2 for All (if all is non-zero when passed in) and -1 for abort (^C)
* Ask a simple yes/no question on the statusbar. Returns 1 for Y, 0
* for N, 2 for All (if all is non-zero when passed in) and -1 for
* abort (^C).
*/
int do_yesno(int all, int leavecursor, const char *msg, ...)
{
@ -1303,7 +1300,7 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
allstr = _("Aa");
/* Write the bottom of the screen */
clear_bottomwin();
blank_bottomwin();
/* Remove gettext call for keybindings until we clear the thing up */
if (!ISSET(NO_HELP)) {
@ -1412,6 +1409,28 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
return ok;
}
int total_refresh(void)
{
clearok(edit, TRUE);
clearok(topwin, TRUE);
clearok(bottomwin, TRUE);
wnoutrefresh(edit);
wnoutrefresh(topwin);
wnoutrefresh(bottomwin);
doupdate();
clearok(edit, FALSE);
clearok(topwin, FALSE);
clearok(bottomwin, FALSE);
edit_refresh();
titlebar(NULL);
return 1;
}
void display_main_list(void)
{
bottombars(main_list);
}
void statusbar(const char *msg, ...)
{
va_list ap;
@ -1452,28 +1471,6 @@ void statusbar(const char *msg, ...)
statblank = 25;
}
void display_main_list(void)
{
bottombars(main_list);
}
int total_refresh(void)
{
clearok(edit, TRUE);
clearok(topwin, TRUE);
clearok(bottomwin, TRUE);
wnoutrefresh(edit);
wnoutrefresh(topwin);
wnoutrefresh(bottomwin);
doupdate();
clearok(edit, FALSE);
clearok(topwin, FALSE);
clearok(bottomwin, FALSE);
edit_refresh();
titlebar(NULL);
return 1;
}
int do_cursorpos(int constant)
{
filestruct *fileptr;
@ -1703,45 +1700,20 @@ int do_help(void)
return 1;
}
#ifdef DEBUG
/* Dump the current file structure to stderr */
void dump_buffer(const filestruct *inptr) {
if (inptr == fileage)
fprintf(stderr, _("Dumping file buffer to stderr...\n"));
else if (inptr == cutbuffer)
fprintf(stderr, _("Dumping cutbuffer to stderr...\n"));
else
fprintf(stderr, _("Dumping a buffer to stderr...\n"));
while (inptr != NULL) {
fprintf(stderr, "(%d) %s\n", inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
#endif /* DEBUG */
#ifdef DEBUG
void dump_buffer_reverse(void) {
const filestruct *fileptr = filebot;
while (fileptr != NULL) {
fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
fileptr = fileptr->prev;
}
}
#endif /* DEBUG */
/* Fix editbot, based on the assumption that edittop is correct */
void fix_editbot(void)
int keypad_on(WINDOW * win, int newval)
{
int i;
editbot = edittop;
for (i = 0; i < editwinrows && editbot->next != NULL; i++)
editbot = editbot->next;
/* This is taken right from aumix. Don't sue me. */
#ifdef HAVE_USEKEYPAD
int old = win->_use_keypad;
keypad(win, newval);
return old;
#else
keypad(win, newval);
return 1;
#endif /* HAVE_USEKEYPAD */
}
/* highlight the current word being replaced or spell checked */
/* Highlight the current word being replaced or spell checked. */
void do_replace_highlight(int highlight_flag, const char *word)
{
char *highlight_word = NULL;
@ -1786,6 +1758,44 @@ void do_replace_highlight(int highlight_flag, const char *word)
free(highlight_word);
}
/* Fix editbot, based on the assumption that edittop is correct. */
void fix_editbot(void)
{
int i;
editbot = edittop;
for (i = 0; i < editwinrows && editbot->next != NULL; i++)
editbot = editbot->next;
}
#ifdef DEBUG
/* Dump the current file structure to stderr */
void dump_buffer(const filestruct *inptr) {
if (inptr == fileage)
fprintf(stderr, _("Dumping file buffer to stderr...\n"));
else if (inptr == cutbuffer)
fprintf(stderr, _("Dumping cutbuffer to stderr...\n"));
else
fprintf(stderr, _("Dumping a buffer to stderr...\n"));
while (inptr != NULL) {
fprintf(stderr, "(%d) %s\n", inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
#endif /* DEBUG */
#ifdef DEBUG
void dump_buffer_reverse(void) {
const filestruct *fileptr = filebot;
while (fileptr != NULL) {
fprintf(stderr, "(%d) %s\n", fileptr->lineno, fileptr->data);
fileptr = fileptr->prev;
}
}
#endif /* DEBUG */
#ifdef NANO_EXTRA
#define CREDIT_LEN 52
#define XLCREDIT_LEN 8
@ -1904,16 +1914,3 @@ void do_credits(void)
total_refresh();
}
#endif
int keypad_on(WINDOW * win, int newval)
{
/* This is taken right from aumix. Don't sue me. */
#ifdef HAVE_USEKEYPAD
int old = win->_use_keypad;
keypad(win, newval);
return old;
#else
keypad(win, newval);
return 1;
#endif /* HAVE_USEKEYPAD */
}