Chris Allegretta | 11b0011 | 2000-08-06 21:13:45 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 2 | /************************************************************************** |
| 3 | * proto.h * |
| 4 | * * |
David Lawrence Ramsey | f28f50e | 2004-01-09 23:04:55 +0000 | [diff] [blame] | 5 | * Copyright (C) 1999-2004 Chris Allegretta * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
Chris Allegretta | 3a24f3f | 2001-10-24 11:33:54 +0000 | [diff] [blame] | 8 | * the Free Software Foundation; either version 2, or (at your option) * |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 9 | * any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the Free Software * |
| 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * |
| 19 | * * |
| 20 | **************************************************************************/ |
| 21 | |
David Lawrence Ramsey | f28f50e | 2004-01-09 23:04:55 +0000 | [diff] [blame] | 22 | /* Externs. */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 23 | |
David Lawrence Ramsey | fd3039a | 2004-07-17 19:49:12 +0000 | [diff] [blame] | 24 | #include <sys/types.h> |
David Lawrence Ramsey | 84d0d59 | 2004-11-04 03:53:11 +0000 | [diff] [blame] | 25 | #include <sys/stat.h> |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 26 | #ifdef HAVE_REGEX_H |
Chris Allegretta | 9fc8d43 | 2000-07-07 01:49:52 +0000 | [diff] [blame] | 27 | #include <regex.h> |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 28 | #endif |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 29 | #include "nano.h" |
| 30 | |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 31 | #ifndef DISABLE_WRAPJUSTIFY |
David Lawrence Ramsey | 49c3f24 | 2004-07-12 16:07:14 +0000 | [diff] [blame] | 32 | extern ssize_t wrap_at; |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 33 | #endif |
Chris Allegretta | 17dcb72 | 2001-01-20 21:40:07 +0000 | [diff] [blame] | 34 | extern int editwinrows; |
David Lawrence Ramsey | 7a97e18 | 2004-10-30 01:03:15 +0000 | [diff] [blame] | 35 | extern size_t current_x; |
| 36 | extern int current_y; |
| 37 | extern int totlines; |
David Lawrence Ramsey | 86e851b | 2004-07-28 20:46:25 +0000 | [diff] [blame] | 38 | extern size_t placewewant; |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 39 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 687776b | 2004-10-30 01:16:08 +0000 | [diff] [blame] | 40 | extern size_t mark_beginx; |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 41 | #endif |
Chris Allegretta | b3655b4 | 2001-10-22 03:15:31 +0000 | [diff] [blame] | 42 | extern long totsize; |
David Lawrence Ramsey | edab0cc | 2004-07-03 03:09:12 +0000 | [diff] [blame] | 43 | extern long flags; |
David Lawrence Ramsey | 49c3f24 | 2004-07-12 16:07:14 +0000 | [diff] [blame] | 44 | extern ssize_t tabsize; |
Chris Allegretta | 6b58acd | 2001-04-12 03:01:53 +0000 | [diff] [blame] | 45 | extern int currslen; |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 46 | |
David Lawrence Ramsey | 89bb937 | 2004-05-29 16:47:52 +0000 | [diff] [blame] | 47 | #if !defined(NANO_SMALL) && defined(ENABLE_NANORC) |
| 48 | extern char *whitespace; |
| 49 | #endif |
| 50 | |
Chris Allegretta | e4f940d | 2002-03-03 22:36:36 +0000 | [diff] [blame] | 51 | #ifndef DISABLE_JUSTIFY |
David Lawrence Ramsey | 2c62b07 | 2004-05-29 16:38:57 +0000 | [diff] [blame] | 52 | extern char *punct; |
| 53 | extern char *brackets; |
Chris Allegretta | 45329a1 | 2002-03-10 01:22:21 +0000 | [diff] [blame] | 54 | extern char *quotestr; |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 55 | #ifdef HAVE_REGEX_H |
| 56 | extern regex_t quotereg; |
| 57 | extern int quoterc; |
| 58 | extern char *quoteerr; |
| 59 | #else |
| 60 | extern size_t quotelen; |
| 61 | #endif |
Chris Allegretta | e4f940d | 2002-03-03 22:36:36 +0000 | [diff] [blame] | 62 | #endif |
| 63 | |
David Lawrence Ramsey | 04e42a6 | 2004-02-28 16:24:31 +0000 | [diff] [blame] | 64 | #ifndef NANO_SMALL |
| 65 | extern char *backup_dir; |
| 66 | #endif |
| 67 | |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 68 | extern WINDOW *topwin, *edit, *bottomwin; |
Chris Allegretta | 1a6e904 | 2000-12-14 13:56:28 +0000 | [diff] [blame] | 69 | extern char *filename; |
David Lawrence Ramsey | 5db0cdc | 2002-06-28 22:45:14 +0000 | [diff] [blame] | 70 | extern struct stat originalfilestat; |
Chris Allegretta | 31925e4 | 2000-11-02 04:40:39 +0000 | [diff] [blame] | 71 | extern char *answer; |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 72 | extern char *hblank; |
| 73 | #ifndef DISABLE_HELP |
| 74 | extern char *help_text; |
| 75 | #endif |
Chris Allegretta | 27eb13f | 2000-11-05 16:52:21 +0000 | [diff] [blame] | 76 | extern char *last_search; |
| 77 | extern char *last_replace; |
Chris Allegretta | e1f1452 | 2001-09-19 03:19:43 +0000 | [diff] [blame] | 78 | #ifndef DISABLE_OPERATINGDIR |
| 79 | extern char *operating_dir; |
Chris Allegretta | f5de33a | 2002-02-27 04:14:16 +0000 | [diff] [blame] | 80 | extern char *full_operating_dir; |
Chris Allegretta | e1f1452 | 2001-09-19 03:19:43 +0000 | [diff] [blame] | 81 | #endif |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 82 | #ifndef DISABLE_SPELLER |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 83 | extern char *alt_speller; |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 86 | extern struct stat fileinfo; |
David Lawrence Ramsey | b977515 | 2004-03-19 02:15:42 +0000 | [diff] [blame] | 87 | extern filestruct *current, *fileage, *edittop, *filebot; |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 88 | extern filestruct *cutbuffer; |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 89 | #ifndef DISABLE_JUSTIFY |
| 90 | extern filestruct *jusbuffer; |
| 91 | #endif |
David Lawrence Ramsey | 40bdb68 | 2004-11-03 22:03:41 +0000 | [diff] [blame] | 92 | extern partition *filepart; |
David Lawrence Ramsey | b73c0c0 | 2004-11-05 15:25:53 +0000 | [diff] [blame] | 93 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 94 | extern filestruct *mark_beginbuf; |
| 95 | #endif |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 96 | |
Chris Allegretta | 355fbe5 | 2001-07-14 19:32:47 +0000 | [diff] [blame] | 97 | #ifdef ENABLE_MULTIBUFFER |
Chris Allegretta | f2387fb | 2002-04-10 02:31:20 +0000 | [diff] [blame] | 98 | extern openfilestruct *open_files; |
Chris Allegretta | 2d7893d | 2001-07-11 02:08:33 +0000 | [diff] [blame] | 99 | #endif |
| 100 | |
Chris Allegretta | 08893e0 | 2001-11-29 02:42:27 +0000 | [diff] [blame] | 101 | #ifdef ENABLE_COLOR |
David Lawrence Ramsey | 1f28b8f | 2002-09-27 14:21:59 +0000 | [diff] [blame] | 102 | extern const colortype *colorstrings; |
Chris Allegretta | b6c5dc2 | 2002-05-04 03:47:33 +0000 | [diff] [blame] | 103 | extern syntaxtype *syntaxes; |
Chris Allegretta | 09900ff | 2002-05-04 04:23:30 +0000 | [diff] [blame] | 104 | extern char *syntaxstr; |
Chris Allegretta | 08893e0 | 2001-11-29 02:42:27 +0000 | [diff] [blame] | 105 | #endif |
| 106 | |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 107 | extern shortcut *shortcut_list; |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 108 | extern shortcut *main_list, *whereis_list; |
David Lawrence Ramsey | e5d8f32 | 2004-09-30 22:07:21 +0000 | [diff] [blame] | 109 | extern shortcut *replace_list, *gotoline_list; |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 110 | extern shortcut *writefile_list, *insertfile_list; |
Chris Allegretta | 201f1d9 | 2003-02-05 02:51:19 +0000 | [diff] [blame] | 111 | extern shortcut *replace_list_2; |
Chris Allegretta | 7162e3d | 2002-04-06 05:02:14 +0000 | [diff] [blame] | 112 | #ifndef NANO_SMALL |
| 113 | extern shortcut *extcmd_list; |
| 114 | #endif |
Chris Allegretta | 201f1d9 | 2003-02-05 02:51:19 +0000 | [diff] [blame] | 115 | #ifndef DISABLE_HELP |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 116 | extern shortcut *help_list; |
Chris Allegretta | 201f1d9 | 2003-02-05 02:51:19 +0000 | [diff] [blame] | 117 | #endif |
| 118 | #ifndef DISABLE_SPELLER |
| 119 | extern shortcut *spell_list; |
| 120 | #endif |
Rocco Corsi | af5c302 | 2001-01-12 07:51:05 +0000 | [diff] [blame] | 121 | #ifndef DISABLE_BROWSER |
Chris Allegretta | a8c2257 | 2002-02-15 19:17:02 +0000 | [diff] [blame] | 122 | extern shortcut *browser_list, *gotodir_list; |
Chris Allegretta | f4b9601 | 2001-01-03 07:11:47 +0000 | [diff] [blame] | 123 | #endif |
Chris Allegretta | 201f1d9 | 2003-02-05 02:51:19 +0000 | [diff] [blame] | 124 | |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 125 | #if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE) |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 126 | extern const shortcut *currshortcut; |
Chris Allegretta | 201f1d9 | 2003-02-05 02:51:19 +0000 | [diff] [blame] | 127 | #endif |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 128 | |
| 129 | #ifdef HAVE_REGEX_H |
Chris Allegretta | 9fc8d43 | 2000-07-07 01:49:52 +0000 | [diff] [blame] | 130 | extern regex_t search_regexp; |
David Lawrence Ramsey | c372488 | 2004-05-27 18:39:16 +0000 | [diff] [blame] | 131 | extern regmatch_t regmatches[10]; |
Chris Allegretta | 3533a34 | 2002-03-24 23:19:32 +0000 | [diff] [blame] | 132 | #ifdef ENABLE_COLOR |
Chris Allegretta | b6c5dc2 | 2002-05-04 03:47:33 +0000 | [diff] [blame] | 133 | extern regex_t syntaxfile_regexp; |
David Lawrence Ramsey | c372488 | 2004-05-27 18:39:16 +0000 | [diff] [blame] | 134 | extern regmatch_t synfilematches[1]; |
Chris Allegretta | 7162e3d | 2002-04-06 05:02:14 +0000 | [diff] [blame] | 135 | #endif /* ENABLE_COLOR */ |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 136 | #endif /* HAVE_REGEX_H */ |
| 137 | |
| 138 | #ifndef NANO_SMALL |
| 139 | extern toggle *toggles; |
Chris Allegretta | 805c26d | 2000-09-06 13:39:17 +0000 | [diff] [blame] | 140 | #endif |
| 141 | |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 142 | #ifndef NANO_SMALL |
| 143 | extern historyheadtype search_history; |
| 144 | extern historyheadtype replace_history; |
| 145 | #endif |
| 146 | |
David Lawrence Ramsey | 76356bd | 2004-08-12 04:30:22 +0000 | [diff] [blame] | 147 | extern bool curses_ended; |
Chris Allegretta | a0d8997 | 2003-02-03 03:32:08 +0000 | [diff] [blame] | 148 | |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 149 | #ifdef ENABLE_NANORC |
| 150 | extern char *homedir; |
| 151 | #endif |
| 152 | |
David Lawrence Ramsey | f28f50e | 2004-01-09 23:04:55 +0000 | [diff] [blame] | 153 | /* Functions we want available. */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 154 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 155 | /* Public functions in color.c. */ |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 156 | #ifdef ENABLE_COLOR |
David Lawrence Ramsey | 1f28b8f | 2002-09-27 14:21:59 +0000 | [diff] [blame] | 157 | void set_colorpairs(void); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 158 | void do_colorinit(void); |
| 159 | void update_color(void); |
| 160 | #endif /* ENABLE_COLOR */ |
Chris Allegretta | a2ea193 | 2000-06-06 05:53:49 +0000 | [diff] [blame] | 161 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 162 | /* Public functions in cut.c. */ |
David Lawrence Ramsey | c833d9e | 2004-05-29 15:36:58 +0000 | [diff] [blame] | 163 | void cutbuffer_reset(void); |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 164 | void cut_line(void); |
David Lawrence Ramsey | 50af6ea | 2004-11-07 15:29:40 +0000 | [diff] [blame] | 165 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 166 | void cut_marked(void); |
David Lawrence Ramsey | 50af6ea | 2004-11-07 15:29:40 +0000 | [diff] [blame] | 167 | #endif |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 168 | void cut_to_eol(void); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 169 | void do_cut_text(void); |
| 170 | void do_uncut_text(void); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 171 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 172 | /* Public functions in files.c. */ |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 173 | void new_file(void); |
David Lawrence Ramsey | 02517e0 | 2004-09-05 21:40:31 +0000 | [diff] [blame] | 174 | filestruct *read_line(char *buf, filestruct *prev, bool *first_line_ins, |
| 175 | size_t len); |
| 176 | void load_file(void); |
| 177 | void read_file(FILE *f, const char *filename); |
| 178 | int open_file(const char *filename, bool newfie, FILE **f); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 179 | char *get_next_filename(const char *name); |
David Lawrence Ramsey | 02517e0 | 2004-09-05 21:40:31 +0000 | [diff] [blame] | 180 | #ifndef NANO_SMALL |
| 181 | void execute_command(const char *command); |
| 182 | #endif |
| 183 | void load_buffer(const char *name); |
David Lawrence Ramsey | be908f6 | 2004-10-01 18:34:30 +0000 | [diff] [blame] | 184 | void do_insertfile( |
| 185 | #ifndef NANO_SMALL |
| 186 | bool execute |
| 187 | #else |
| 188 | void |
| 189 | #endif |
| 190 | ); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 191 | void do_insertfile_void(void); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 192 | #ifdef ENABLE_MULTIBUFFER |
David Lawrence Ramsey | 5b3dd0f | 2004-11-25 04:39:07 +0000 | [diff] [blame^] | 193 | openfilestruct *make_new_opennode(void); |
David Lawrence Ramsey | f708037 | 2004-07-08 17:15:10 +0000 | [diff] [blame] | 194 | void splice_opennode(openfilestruct *begin, openfilestruct *newnode, |
| 195 | openfilestruct *end); |
David Lawrence Ramsey | 5b3dd0f | 2004-11-25 04:39:07 +0000 | [diff] [blame^] | 196 | void unlink_opennode(openfilestruct *fileptr); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 197 | void delete_opennode(openfilestruct *fileptr); |
David Lawrence Ramsey | 5b3dd0f | 2004-11-25 04:39:07 +0000 | [diff] [blame^] | 198 | #ifdef DEBUG |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 199 | void free_openfilestruct(openfilestruct *src); |
David Lawrence Ramsey | 5b3dd0f | 2004-11-25 04:39:07 +0000 | [diff] [blame^] | 200 | #endif |
David Lawrence Ramsey | 3e189a8 | 2004-10-03 19:18:48 +0000 | [diff] [blame] | 201 | void add_open_file(bool update); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 202 | void load_open_file(void); |
David Lawrence Ramsey | 5b3dd0f | 2004-11-25 04:39:07 +0000 | [diff] [blame^] | 203 | void open_prevnext_file(bool next); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 204 | void open_prevfile_void(void); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 205 | void open_nextfile_void(void); |
David Lawrence Ramsey | 3e189a8 | 2004-10-03 19:18:48 +0000 | [diff] [blame] | 206 | bool close_open_file(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 207 | #endif |
| 208 | #if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR) |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 209 | char *get_full_path(const char *origpath); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 210 | #endif |
| 211 | #ifndef DISABLE_SPELLER |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 212 | char *check_writable_directory(const char *path); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 213 | char *safe_tempnam(const char *dirname, const char *filename_prefix); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 214 | #endif |
| 215 | #ifndef DISABLE_OPERATINGDIR |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 216 | void init_operating_dir(void); |
| 217 | int check_operating_dir(const char *currpath, int allow_tabcomp); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 218 | #endif |
David Lawrence Ramsey | 04e42a6 | 2004-02-28 16:24:31 +0000 | [diff] [blame] | 219 | #ifndef NANO_SMALL |
| 220 | void init_backup_dir(void); |
| 221 | #endif |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 222 | int copy_file(FILE *inn, FILE *out); |
David Lawrence Ramsey | 8c16bac | 2004-11-06 15:10:57 +0000 | [diff] [blame] | 223 | int write_file(const char *name, bool tmp, int append, bool |
| 224 | nonamechange); |
David Lawrence Ramsey | 35961c4 | 2004-01-23 19:34:03 +0000 | [diff] [blame] | 225 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 8c16bac | 2004-11-06 15:10:57 +0000 | [diff] [blame] | 226 | int write_marked(const char *name, bool tmp, int append); |
David Lawrence Ramsey | 35961c4 | 2004-01-23 19:34:03 +0000 | [diff] [blame] | 227 | #endif |
David Lawrence Ramsey | 951d714 | 2004-10-04 15:23:47 +0000 | [diff] [blame] | 228 | int do_writeout(bool exiting); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 229 | void do_writeout_void(void); |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 230 | char *real_dir_from_tilde(const char *buf); |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 231 | #ifndef DISABLE_TABCOMP |
David Lawrence Ramsey | 4d44d2d | 2004-08-01 22:35:31 +0000 | [diff] [blame] | 232 | int append_slash_if_dir(char *buf, bool *lastwastab, int *place); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 233 | char **username_tab_completion(char *buf, int *num_matches); |
| 234 | char **cwd_tab_completion(char *buf, int *num_matches); |
David Lawrence Ramsey | 4d44d2d | 2004-08-01 22:35:31 +0000 | [diff] [blame] | 235 | char *input_tab(char *buf, int place, bool *lastwastab, int *newplace, |
| 236 | bool *list); |
Chris Allegretta | 7662c86 | 2003-01-13 01:35:15 +0000 | [diff] [blame] | 237 | #endif |
David Lawrence Ramsey | 04e42a6 | 2004-02-28 16:24:31 +0000 | [diff] [blame] | 238 | const char *tail(const char *foo); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 239 | #ifndef DISABLE_BROWSER |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 240 | int diralphasort(const void *va, const void *vb); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 241 | void free_charptrarray(char **array, size_t len); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 242 | void striponedir(char *foo); |
Chris Allegretta | 858d9d9 | 2003-01-30 00:53:32 +0000 | [diff] [blame] | 243 | int readable_dir(const char *path); |
David Lawrence Ramsey | e21adfa | 2002-09-13 18:14:04 +0000 | [diff] [blame] | 244 | char **browser_init(const char *path, int *longest, int *numents); |
| 245 | char *do_browser(const char *inpath); |
| 246 | char *do_browse_from(const char *inpath); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 247 | #endif |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 248 | #if !defined(NANO_SMALL) && defined(ENABLE_NANORC) |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 249 | char *histfilename(void); |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 250 | void load_history(void); |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 251 | bool writehist(FILE *hist, historyheadtype *histhead); |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 252 | void save_history(void); |
| 253 | #endif |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 254 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 255 | /* Public functions in global.c. */ |
David Lawrence Ramsey | ebd0d7c | 2004-07-01 18:59:52 +0000 | [diff] [blame] | 256 | size_t length_of_list(const shortcut *s); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 257 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 2ad3209 | 2004-07-07 14:36:44 +0000 | [diff] [blame] | 258 | void toggle_init_one(int val, const char *desc, long flag); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 259 | void toggle_init(void); |
| 260 | #ifdef DEBUG |
| 261 | void free_toggles(void); |
| 262 | #endif |
| 263 | #endif |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 264 | void sc_init_one(shortcut **shortcutage, int key, const char *desc, |
| 265 | #ifndef DISABLE_HELP |
| 266 | const char *help, |
| 267 | #endif |
| 268 | int metaval, int funcval, int miscval, int view, void |
| 269 | (*func)(void)); |
David Lawrence Ramsey | 1f1ebb8 | 2004-11-11 21:50:01 +0000 | [diff] [blame] | 270 | void shortcut_init(bool unjustify); |
David Lawrence Ramsey | 576bf33 | 2004-07-12 03:10:30 +0000 | [diff] [blame] | 271 | void free_shortcutage(shortcut **shortcutage); |
Chris Allegretta | 6232d66 | 2002-05-12 19:52:15 +0000 | [diff] [blame] | 272 | #ifdef DEBUG |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 273 | void thanks_for_all_the_fish(void); |
Chris Allegretta | 6232d66 | 2002-05-12 19:52:15 +0000 | [diff] [blame] | 274 | #endif |
Chris Allegretta | dab017e | 2002-04-23 10:56:06 +0000 | [diff] [blame] | 275 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 276 | /* Public functions in move.c. */ |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 277 | void do_first_line(void); |
| 278 | void do_last_line(void); |
| 279 | void do_home(void); |
| 280 | void do_end(void); |
| 281 | void do_page_up(void); |
| 282 | void do_page_down(void); |
| 283 | void do_up(void); |
| 284 | void do_down(void); |
| 285 | void do_left(int allow_update); |
| 286 | void do_left_void(void); |
| 287 | void do_right(int allow_update); |
| 288 | void do_right_void(void); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 289 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 290 | /* Public functions in nano.c. */ |
David Lawrence Ramsey | da14106 | 2004-05-25 19:41:11 +0000 | [diff] [blame] | 291 | void finish(void); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 292 | void die(const char *msg, ...); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 293 | void die_save_file(const char *die_filename); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 294 | void die_too_small(void); |
| 295 | void print_view_warning(void); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 296 | void global_init(bool save_cutbuffer); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 297 | void window_init(void); |
David Lawrence Ramsey | f5b256b | 2003-10-03 20:26:25 +0000 | [diff] [blame] | 298 | #ifndef DISABLE_MOUSE |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 299 | void mouse_init(void); |
David Lawrence Ramsey | 9b13ff3 | 2002-12-22 16:30:00 +0000 | [diff] [blame] | 300 | #endif |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 301 | #ifndef DISABLE_HELP |
| 302 | void help_init(void); |
Chris Allegretta | f2387fb | 2002-04-10 02:31:20 +0000 | [diff] [blame] | 303 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 304 | filestruct *make_new_node(filestruct *prevnode); |
| 305 | filestruct *copy_node(const filestruct *src); |
David Lawrence Ramsey | f708037 | 2004-07-08 17:15:10 +0000 | [diff] [blame] | 306 | void splice_node(filestruct *begin, filestruct *newnode, filestruct |
| 307 | *end); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 308 | void unlink_node(const filestruct *fileptr); |
| 309 | void delete_node(filestruct *fileptr); |
| 310 | filestruct *copy_filestruct(const filestruct *src); |
| 311 | void free_filestruct(filestruct *src); |
David Lawrence Ramsey | 40bdb68 | 2004-11-03 22:03:41 +0000 | [diff] [blame] | 312 | partition *partition_filestruct(filestruct *top, size_t top_x, |
| 313 | filestruct *bot, size_t bot_x); |
David Lawrence Ramsey | 74d8707 | 2004-11-22 00:16:23 +0000 | [diff] [blame] | 314 | void unpartition_filestruct(partition **p); |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 315 | void move_to_filestruct(filestruct **file_top, filestruct **file_bot, |
| 316 | filestruct *top, size_t top_x, filestruct *bot, size_t bot_x); |
| 317 | void copy_from_filestruct(filestruct *file_top, filestruct *file_bot); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 318 | void renumber_all(void); |
| 319 | void renumber(filestruct *fileptr); |
David Lawrence Ramsey | f708037 | 2004-07-08 17:15:10 +0000 | [diff] [blame] | 320 | void print1opt(const char *shortflag, const char *longflag, const char |
| 321 | *desc); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 322 | void usage(void); |
| 323 | void version(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 324 | int no_help(void); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 325 | void nano_disabled_msg(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 326 | #ifndef NANO_SMALL |
| 327 | RETSIGTYPE cancel_fork(int signal); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 328 | bool open_pipe(const char *command); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 329 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 330 | void do_char(char ch); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 331 | void do_verbatim_input(void); |
| 332 | void do_backspace(void); |
| 333 | void do_delete(void); |
| 334 | void do_tab(void); |
| 335 | void do_enter(void); |
David Lawrence Ramsey | c97acfb | 2003-09-10 20:08:00 +0000 | [diff] [blame] | 336 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 337 | void do_next_word(void); |
| 338 | void do_prev_word(void); |
| 339 | void do_mark(void); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 340 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 341 | #ifndef DISABLE_WRAPPING |
David Lawrence Ramsey | c97acfb | 2003-09-10 20:08:00 +0000 | [diff] [blame] | 342 | void wrap_reset(void); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 343 | bool do_wrap(filestruct *inptr); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 344 | #endif |
| 345 | #ifndef DISABLE_SPELLER |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 346 | bool do_int_spell_fix(const char *word); |
| 347 | const char *do_int_speller(const char *tempfile_name); |
David Lawrence Ramsey | fa39404 | 2004-05-23 21:11:14 +0000 | [diff] [blame] | 348 | const char *do_alt_speller(char *tempfile_name); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 349 | void do_spell(void); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 350 | #endif |
David Lawrence Ramsey | bb50b30 | 2004-08-12 21:43:00 +0000 | [diff] [blame] | 351 | #if !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY) |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 352 | size_t indent_length(const char *line); |
| 353 | #endif |
| 354 | #ifndef DISABLE_JUSTIFY |
David Lawrence Ramsey | 1cadddd | 2004-05-17 20:32:51 +0000 | [diff] [blame] | 355 | void justify_format(filestruct *line, size_t skip); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 356 | size_t quote_length(const char *line); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 357 | bool quotes_match(const char *a_line, size_t a_quote, const char |
| 358 | *b_line); |
| 359 | bool indents_match(const char *a_line, size_t a_indent, const char |
David Lawrence Ramsey | d4693cb | 2004-05-14 01:17:25 +0000 | [diff] [blame] | 360 | *b_line, size_t b_indent); |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 361 | bool begpar(const filestruct *const foo); |
| 362 | void do_para_begin(void); |
| 363 | bool inpar(const char *str); |
| 364 | void do_para_end(void); |
David Lawrence Ramsey | d4693cb | 2004-05-14 01:17:25 +0000 | [diff] [blame] | 365 | filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t |
| 366 | quote_len); |
David Lawrence Ramsey | d08348b | 2004-09-18 22:02:21 +0000 | [diff] [blame] | 367 | bool breakable(const char *line, ssize_t goal); |
| 368 | ssize_t break_line(const char *line, ssize_t goal, bool force); |
David Lawrence Ramsey | 819c7f0 | 2004-07-30 03:54:34 +0000 | [diff] [blame] | 369 | bool do_para_search(size_t *const quote, size_t *const par); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 370 | void do_justify(bool full_justify); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 371 | void do_justify_void(void); |
| 372 | void do_full_justify(void); |
David Lawrence Ramsey | d893fa9 | 2004-04-30 04:49:02 +0000 | [diff] [blame] | 373 | #endif /* !DISABLE_JUSTIFY */ |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 374 | void do_exit(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 375 | void signal_init(void); |
David Lawrence Ramsey | 2ab03f6 | 2002-10-17 02:19:31 +0000 | [diff] [blame] | 376 | RETSIGTYPE handle_hupterm(int signal); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 377 | RETSIGTYPE do_suspend(int signal); |
| 378 | RETSIGTYPE do_cont(int signal); |
| 379 | #ifndef NANO_SMALL |
| 380 | void handle_sigwinch(int s); |
David Lawrence Ramsey | ce62e82 | 2004-08-05 22:10:22 +0000 | [diff] [blame] | 381 | void allow_pending_sigwinch(bool allow); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 382 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 383 | #ifndef NANO_SMALL |
| 384 | void do_toggle(const toggle *which); |
| 385 | #endif |
David Lawrence Ramsey | 013344c | 2004-09-22 22:45:08 +0000 | [diff] [blame] | 386 | void disable_extended_input(void); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 387 | void disable_signals(void); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 388 | #ifndef NANO_SMALL |
| 389 | void enable_signals(void); |
| 390 | #endif |
| 391 | void disable_flow_control(void); |
| 392 | void enable_flow_control(void); |
David Lawrence Ramsey | 8aaf030 | 2004-07-27 16:46:35 +0000 | [diff] [blame] | 393 | void terminal_init(void); |
Chris Allegretta | f2387fb | 2002-04-10 02:31:20 +0000 | [diff] [blame] | 394 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 395 | /* Public functions in rcfile.c. */ |
Chris Allegretta | 7a50009 | 2001-04-19 21:13:46 +0000 | [diff] [blame] | 396 | #ifdef ENABLE_NANORC |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 397 | void rcfile_error(const char *msg, ...); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 398 | char *parse_next_word(char *ptr); |
| 399 | char *parse_argument(char *ptr); |
| 400 | #ifdef ENABLE_COLOR |
| 401 | int colortoint(const char *colorname, int *bright); |
| 402 | char *parse_next_regex(char *ptr); |
David Lawrence Ramsey | edab0cc | 2004-07-03 03:09:12 +0000 | [diff] [blame] | 403 | int nregcomp(regex_t *preg, const char *regex, int eflags); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 404 | void parse_syntax(char *ptr); |
| 405 | void parse_colors(char *ptr); |
| 406 | #endif /* ENABLE_COLOR */ |
| 407 | void parse_rcfile(FILE *rcstream); |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 408 | void do_rcfile(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 409 | #endif /* ENABLE_NANORC */ |
Chris Allegretta | 8d8e012 | 2001-04-18 04:28:54 +0000 | [diff] [blame] | 410 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 411 | /* Public functions in search.c. */ |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 412 | #ifdef HAVE_REGEX_H |
Chris Allegretta | 5d71514 | 2003-01-29 04:18:37 +0000 | [diff] [blame] | 413 | int regexp_init(const char *regexp); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 414 | void regexp_cleanup(void); |
| 415 | #endif |
| 416 | void not_found_msg(const char *str); |
| 417 | void search_abort(void); |
| 418 | void search_init_globals(void); |
David Lawrence Ramsey | d532f19 | 2004-10-04 22:37:56 +0000 | [diff] [blame] | 419 | int search_init(bool replacing, bool use_answer); |
David Lawrence Ramsey | c510042 | 2004-08-27 20:28:34 +0000 | [diff] [blame] | 420 | bool is_whole_word(int curr_pos, const char *datastr, const char |
David Lawrence Ramsey | 1044d74 | 2004-02-24 20:41:39 +0000 | [diff] [blame] | 421 | *searchword); |
David Lawrence Ramsey | c510042 | 2004-08-27 20:28:34 +0000 | [diff] [blame] | 422 | bool findnextstr(bool can_display_wrap, bool wholeword, bool |
| 423 | no_sameline, const filestruct *begin, size_t beginx, const char |
David Lawrence Ramsey | 77b284a | 2004-10-27 02:21:01 +0000 | [diff] [blame] | 424 | *needle, size_t *needle_len); |
David Lawrence Ramsey | e5e88fd | 2004-10-31 13:20:30 +0000 | [diff] [blame] | 425 | void findnextstr_wrap_reset(void); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 426 | void do_search(void); |
David Lawrence Ramsey | 5aa3983 | 2004-05-05 21:36:50 +0000 | [diff] [blame] | 427 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 428 | void do_research(void); |
David Lawrence Ramsey | 5aa3983 | 2004-05-05 21:36:50 +0000 | [diff] [blame] | 429 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 430 | void replace_abort(void); |
| 431 | #ifdef HAVE_REGEX_H |
David Lawrence Ramsey | c510042 | 2004-08-27 20:28:34 +0000 | [diff] [blame] | 432 | int replace_regexp(char *string, bool create_flag); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 433 | #endif |
David Lawrence Ramsey | 1044d74 | 2004-02-24 20:41:39 +0000 | [diff] [blame] | 434 | char *replace_line(const char *needle); |
David Lawrence Ramsey | 182b2c9 | 2004-11-03 16:02:41 +0000 | [diff] [blame] | 435 | ssize_t do_replace_loop(const char *needle, const filestruct |
| 436 | *real_current, size_t *real_current_x, bool wholewords, bool |
| 437 | *canceled); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 438 | void do_replace(void); |
David Lawrence Ramsey | c53ab2a | 2004-08-04 18:24:53 +0000 | [diff] [blame] | 439 | void do_gotoline(int line, bool save_pos); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 440 | void do_gotoline_void(void); |
David Lawrence Ramsey | 02517e0 | 2004-09-05 21:40:31 +0000 | [diff] [blame] | 441 | #if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER) |
David Lawrence Ramsey | 7a97e18 | 2004-10-30 01:03:15 +0000 | [diff] [blame] | 442 | void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 443 | #endif |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 444 | void do_find_bracket(void); |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 445 | #ifndef NANO_SMALL |
| 446 | void history_init(void); |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 447 | historytype *find_node(historytype *h, const char *s); |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 448 | void remove_node(historytype *r); |
| 449 | void insert_node(historytype *h, const char *s); |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 450 | void update_history(historyheadtype *h, const char *s); |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 451 | char *get_history_older(historyheadtype *h); |
| 452 | char *get_history_newer(historyheadtype *h); |
| 453 | char *get_history_completion(historyheadtype *h, char *s); |
David Lawrence Ramsey | 6420d44 | 2004-08-11 05:13:08 +0000 | [diff] [blame] | 454 | #ifdef DEBUG |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 455 | void free_history(historyheadtype *h); |
Chris Allegretta | f3de8b5 | 2003-01-16 23:44:46 +0000 | [diff] [blame] | 456 | #endif |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 457 | #endif |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 458 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 459 | /* Public functions in utils.c. */ |
David Lawrence Ramsey | 1044d74 | 2004-02-24 20:41:39 +0000 | [diff] [blame] | 460 | #ifdef HAVE_REGEX_H |
Chris Allegretta | d845193 | 2003-03-11 03:50:40 +0000 | [diff] [blame] | 461 | #ifdef BROKEN_REGEXEC |
| 462 | int regexec_safe(const regex_t *preg, const char *string, size_t nmatch, |
| 463 | regmatch_t pmatch[], int eflags); |
| 464 | #endif |
David Lawrence Ramsey | 1044d74 | 2004-02-24 20:41:39 +0000 | [diff] [blame] | 465 | int regexp_bol_or_eol(const regex_t *preg, const char *string); |
| 466 | #endif |
David Lawrence Ramsey | 9830d75 | 2004-05-13 17:19:54 +0000 | [diff] [blame] | 467 | #ifndef HAVE_ISBLANK |
| 468 | int is_blank_char(int c); |
| 469 | #endif |
Chris Allegretta | cf287c8 | 2002-07-20 13:57:41 +0000 | [diff] [blame] | 470 | int is_cntrl_char(int c); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 471 | int num_of_digits(int n); |
David Lawrence Ramsey | c53ab2a | 2004-08-04 18:24:53 +0000 | [diff] [blame] | 472 | bool parse_num(const char *str, ssize_t *val); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 473 | void align(char **strp); |
| 474 | void null_at(char **data, size_t index); |
| 475 | void unsunder(char *str, size_t true_len); |
| 476 | void sunder(char *str); |
Chris Allegretta | 4f5335d | 2003-08-04 02:51:12 +0000 | [diff] [blame] | 477 | #ifndef HAVE_STRCASECMP |
| 478 | int nstricmp(const char *s1, const char *s2); |
| 479 | #endif |
| 480 | #ifndef HAVE_STRNCASECMP |
| 481 | int nstrnicmp(const char *s1, const char *s2, size_t n); |
| 482 | #endif |
David Lawrence Ramsey | 14bf803 | 2004-05-22 20:19:15 +0000 | [diff] [blame] | 483 | #ifndef HAVE_STRCASESTR |
David Lawrence Ramsey | a3370c4 | 2004-04-05 01:08:14 +0000 | [diff] [blame] | 484 | const char *nstristr(const char *haystack, const char *needle); |
David Lawrence Ramsey | 14bf803 | 2004-05-22 20:19:15 +0000 | [diff] [blame] | 485 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 486 | #ifndef NANO_SMALL |
David Lawrence Ramsey | a3370c4 | 2004-04-05 01:08:14 +0000 | [diff] [blame] | 487 | const char *revstrstr(const char *haystack, const char *needle, const |
| 488 | char *rev_start); |
| 489 | const char *revstristr(const char *haystack, const char *needle, const |
| 490 | char *rev_start); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 491 | #endif |
David Lawrence Ramsey | fa39404 | 2004-05-23 21:11:14 +0000 | [diff] [blame] | 492 | #ifndef HAVE_STRNLEN |
| 493 | size_t nstrnlen(const char *s, size_t maxlen); |
| 494 | #endif |
David Lawrence Ramsey | a883470 | 2004-08-17 20:34:57 +0000 | [diff] [blame] | 495 | #if !defined(NANO_SMALL) && defined(ENABLE_NANORC) |
David Lawrence Ramsey | a27bd65 | 2004-08-17 05:23:38 +0000 | [diff] [blame] | 496 | #ifndef HAVE_GETLINE |
| 497 | ssize_t ngetline(char **lineptr, size_t *n, FILE *stream); |
| 498 | #endif |
| 499 | #ifndef HAVE_GETDELIM |
| 500 | ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
| 501 | #endif |
David Lawrence Ramsey | a883470 | 2004-08-17 20:34:57 +0000 | [diff] [blame] | 502 | #endif /* !NANO_SMALL && ENABLE_NANORC */ |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 503 | const char *strstrwrapper(const char *haystack, const char *needle, |
David Lawrence Ramsey | 1044d74 | 2004-02-24 20:41:39 +0000 | [diff] [blame] | 504 | const char *start); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 505 | void nperror(const char *s); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 506 | void *nmalloc(size_t howmuch); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 507 | void *nrealloc(void *ptr, size_t howmuch); |
David Lawrence Ramsey | 4a1fc55 | 2004-11-02 15:18:30 +0000 | [diff] [blame] | 508 | char *mallocstrncpy(char *dest, const char *src, size_t n); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 509 | char *mallocstrcpy(char *dest, const char *src); |
David Lawrence Ramsey | 02517e0 | 2004-09-05 21:40:31 +0000 | [diff] [blame] | 510 | char *mallocstrassn(char *dest, char *src); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 511 | void new_magicline(void); |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 512 | #ifndef NANO_SMALL |
David Lawrence Ramsey | 40bdb68 | 2004-11-03 22:03:41 +0000 | [diff] [blame] | 513 | void remove_magicline(void); |
David Lawrence Ramsey | f708037 | 2004-07-08 17:15:10 +0000 | [diff] [blame] | 514 | void mark_order(const filestruct **top, size_t *top_x, const filestruct |
David Lawrence Ramsey | 90e59c1 | 2004-11-05 23:03:03 +0000 | [diff] [blame] | 515 | **bot, size_t *bot_x, bool *right_side_up); |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 516 | #endif |
David Lawrence Ramsey | 93c8405 | 2004-11-23 04:08:28 +0000 | [diff] [blame] | 517 | void get_totals(const filestruct *begin, const filestruct *end, int |
| 518 | *lines, long *size); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 519 | #ifndef DISABLE_TABCOMP |
| 520 | int check_wildcard_match(const char *text, const char *pattern); |
| 521 | #endif |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 522 | |
David Lawrence Ramsey | 8001e27 | 2004-11-12 00:48:18 +0000 | [diff] [blame] | 523 | /* Public functions in winio.c. */ |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 524 | #ifndef NANO_SMALL |
| 525 | void reset_kbinput(void); |
| 526 | #endif |
David Lawrence Ramsey | c59979f | 2004-10-23 02:47:39 +0000 | [diff] [blame] | 527 | void unget_kbinput(int kbinput, bool meta_key, bool func_key); |
David Lawrence Ramsey | eb16f43 | 2004-09-27 01:04:50 +0000 | [diff] [blame] | 528 | int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key); |
David Lawrence Ramsey | 4e8e495 | 2004-10-14 21:59:45 +0000 | [diff] [blame] | 529 | int get_translated_kbinput(int kbinput, seq_type *seq |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 530 | #ifndef NANO_SMALL |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 531 | , bool reset |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 532 | #endif |
| 533 | ); |
| 534 | int get_ascii_kbinput(int kbinput, size_t ascii_digits |
| 535 | #ifndef NANO_SMALL |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 536 | , bool reset |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 537 | #endif |
| 538 | ); |
| 539 | int get_control_kbinput(int kbinput); |
David Lawrence Ramsey | 5780b24 | 2004-10-14 20:48:38 +0000 | [diff] [blame] | 540 | int get_escape_seq_kbinput(const int *escape_seq, size_t es_len, bool |
David Lawrence Ramsey | e65e639 | 2004-06-04 18:18:17 +0000 | [diff] [blame] | 541 | *ignore_seq); |
David Lawrence Ramsey | c2c5a51 | 2004-01-23 19:26:17 +0000 | [diff] [blame] | 542 | int get_escape_seq_abcd(int kbinput); |
David Lawrence Ramsey | 6da969e | 2004-08-28 15:51:07 +0000 | [diff] [blame] | 543 | int *get_verbatim_kbinput(WINDOW *win, int first, int *v_kbinput, size_t |
| 544 | *v_len, bool allow_ascii); |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 545 | int get_untranslated_kbinput(int kbinput, size_t position, bool |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 546 | allow_ascii |
| 547 | #ifndef NANO_SMALL |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 548 | , bool reset |
David Lawrence Ramsey | 48ae986 | 2004-05-28 17:23:33 +0000 | [diff] [blame] | 549 | #endif |
| 550 | ); |
David Lawrence Ramsey | 14bf803 | 2004-05-22 20:19:15 +0000 | [diff] [blame] | 551 | #ifndef DISABLE_MOUSE |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 552 | bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts); |
| 553 | #endif |
| 554 | const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool |
David Lawrence Ramsey | eb16f43 | 2004-09-27 01:04:50 +0000 | [diff] [blame] | 555 | *meta_key, bool *func_key); |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 556 | #ifndef NANO_SMALL |
| 557 | const toggle *get_toggle(int kbinput, bool meta_key); |
| 558 | #endif |
David Lawrence Ramsey | d994ad5 | 2004-11-23 21:40:26 +0000 | [diff] [blame] | 559 | int get_edit_input(bool *meta_key, bool *func_key, bool allow_funcs); |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 560 | #ifndef DISABLE_MOUSE |
| 561 | bool get_edit_mouse(void); |
David Lawrence Ramsey | 14bf803 | 2004-05-22 20:19:15 +0000 | [diff] [blame] | 562 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 563 | size_t xplustabs(void); |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 564 | size_t actual_x(const char *str, size_t xplus); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 565 | size_t strnlenpt(const char *buf, size_t size); |
| 566 | size_t strlenpt(const char *buf); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 567 | void blank_titlebar(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 568 | void blank_edit(void); |
| 569 | void blank_statusbar(void); |
David Lawrence Ramsey | e5d8f32 | 2004-09-30 22:07:21 +0000 | [diff] [blame] | 570 | void check_statusblank(void); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 571 | void blank_bottombars(void); |
| 572 | char *display_string(const char *buf, size_t start_col, size_t len); |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 573 | void nanoget_repaint(const char *buf, const char *inputbuf, size_t x); |
David Lawrence Ramsey | 045883a | 2004-10-05 20:11:31 +0000 | [diff] [blame] | 574 | int nanogetstr(bool allow_tabs, const char *buf, const char *def, |
Chris Allegretta | 5beed50 | 2003-01-05 20:41:21 +0000 | [diff] [blame] | 575 | #ifndef NANO_SMALL |
| 576 | historyheadtype *history_list, |
| 577 | #endif |
David Lawrence Ramsey | 045883a | 2004-10-05 20:11:31 +0000 | [diff] [blame] | 578 | const shortcut *s |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 579 | #ifndef DISABLE_TABCOMP |
David Lawrence Ramsey | 4d44d2d | 2004-08-01 22:35:31 +0000 | [diff] [blame] | 580 | , bool *list |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 581 | #endif |
Chris Allegretta | 65f075d | 2003-02-13 03:03:49 +0000 | [diff] [blame] | 582 | ); |
David Lawrence Ramsey | 045883a | 2004-10-05 20:11:31 +0000 | [diff] [blame] | 583 | int statusq(bool allow_tabs, const shortcut *s, const char *def, |
| 584 | #ifndef NANO_SMALL |
| 585 | historyheadtype *history_list, |
| 586 | #endif |
| 587 | const char *msg, ...); |
| 588 | void statusq_abort(void); |
Chris Allegretta | f717f98 | 2003-02-13 22:25:01 +0000 | [diff] [blame] | 589 | void titlebar(const char *path); |
David Lawrence Ramsey | d7fd200 | 2004-05-18 01:20:36 +0000 | [diff] [blame] | 590 | void set_modified(void); |
| 591 | void statusbar(const char *msg, ...); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 592 | void bottombars(const shortcut *s); |
David Lawrence Ramsey | fa39404 | 2004-05-23 21:11:14 +0000 | [diff] [blame] | 593 | void onekey(const char *keystroke, const char *desc, size_t len); |
David Lawrence Ramsey | 1f28b8f | 2002-09-27 14:21:59 +0000 | [diff] [blame] | 594 | #ifndef NDEBUG |
| 595 | int check_linenumbers(const filestruct *fileptr); |
| 596 | #endif |
David Lawrence Ramsey | 2dd7ed1 | 2003-09-29 05:15:24 +0000 | [diff] [blame] | 597 | size_t get_page_start(size_t column); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 598 | void reset_cursor(void); |
David Lawrence Ramsey | 07d3feb | 2004-04-16 05:15:11 +0000 | [diff] [blame] | 599 | void edit_add(const filestruct *fileptr, const char *converted, int |
| 600 | yval, size_t start); |
David Lawrence Ramsey | 5ffbec5 | 2003-09-16 01:16:49 +0000 | [diff] [blame] | 601 | void update_line(const filestruct *fileptr, size_t index); |
David Lawrence Ramsey | 86e851b | 2004-07-28 20:46:25 +0000 | [diff] [blame] | 602 | int need_horizontal_update(size_t old_pww); |
| 603 | int need_vertical_update(size_t old_pww); |
David Lawrence Ramsey | 2ed225f | 2004-05-28 20:44:09 +0000 | [diff] [blame] | 604 | void edit_scroll(updown direction, int nlines); |
David Lawrence Ramsey | 86e851b | 2004-07-28 20:46:25 +0000 | [diff] [blame] | 605 | void edit_redraw(const filestruct *old_current, size_t old_pww); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 606 | void edit_refresh(void); |
David Lawrence Ramsey | 20b8350 | 2004-08-26 18:07:58 +0000 | [diff] [blame] | 607 | void edit_update(topmidnone location); |
David Lawrence Ramsey | 045883a | 2004-10-05 20:11:31 +0000 | [diff] [blame] | 608 | int do_yesno(bool all, const char *msg); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 609 | void total_refresh(void); |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 610 | void display_main_list(void); |
David Lawrence Ramsey | a0b5ba2 | 2004-08-25 15:39:10 +0000 | [diff] [blame] | 611 | void do_cursorpos(bool constant); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 612 | void do_cursorpos_void(void); |
David Lawrence Ramsey | 8037fe0 | 2004-07-23 12:30:40 +0000 | [diff] [blame] | 613 | #ifndef DISABLE_HELP |
| 614 | int help_line_len(const char *ptr); |
David Lawrence Ramsey | 72e51ab | 2004-07-02 14:31:03 +0000 | [diff] [blame] | 615 | void do_help(void); |
David Lawrence Ramsey | 8037fe0 | 2004-07-23 12:30:40 +0000 | [diff] [blame] | 616 | #endif |
David Lawrence Ramsey | ad40fdb | 2002-09-06 20:35:28 +0000 | [diff] [blame] | 617 | void do_replace_highlight(int highlight_flag, const char *word); |
Chris Allegretta | 6df90f5 | 2002-07-19 01:08:59 +0000 | [diff] [blame] | 618 | #ifdef DEBUG |
| 619 | void dump_buffer(const filestruct *inptr); |
| 620 | void dump_buffer_reverse(void); |
| 621 | #endif |
Chris Allegretta | 8a0de3b | 2000-11-24 20:45:14 +0000 | [diff] [blame] | 622 | #ifdef NANO_EXTRA |
Chris Allegretta | 34318ed | 2001-01-31 23:22:36 +0000 | [diff] [blame] | 623 | void do_credits(void); |
Chris Allegretta | 8a0de3b | 2000-11-24 20:45:14 +0000 | [diff] [blame] | 624 | #endif |