blob: 108a9c62ade2a8840a209c65a9b065362a5e1af7 [file] [log] [blame]
Chris Allegretta11b00112000-08-06 21:13:45 +00001/* $Id$ */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00002/**************************************************************************
3 * proto.h *
4 * *
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +00005 * Copyright (C) 1999-2004 Chris Allegretta *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00006 * 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 Allegretta3a24f3f2001-10-24 11:33:54 +00008 * the Free Software Foundation; either version 2, or (at your option) *
Chris Allegrettaa2ea1932000-06-06 05:53:49 +00009 * 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 Ramseyf28f50e2004-01-09 23:04:55 +000022/* Externs. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000023
24#include <sys/stat.h>
David Lawrence Ramseyfd3039a2004-07-17 19:49:12 +000025#include <sys/types.h>
Chris Allegretta805c26d2000-09-06 13:39:17 +000026#ifdef HAVE_REGEX_H
Chris Allegretta9fc8d432000-07-07 01:49:52 +000027#include <regex.h>
Chris Allegretta805c26d2000-09-06 13:39:17 +000028#endif
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000029#include "nano.h"
30
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000031#ifndef DISABLE_WRAPJUSTIFY
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000032extern ssize_t wrap_at;
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000033#endif
Chris Allegretta17dcb722001-01-20 21:40:07 +000034extern int editwinrows;
David Lawrence Ramsey7a97e182004-10-30 01:03:15 +000035extern size_t current_x;
36extern int current_y;
37extern int totlines;
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +000038extern size_t placewewant;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000039#ifndef NANO_SMALL
David Lawrence Ramsey687776b2004-10-30 01:16:08 +000040extern size_t mark_beginx;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000041#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +000042extern long totsize;
David Lawrence Ramseyedab0cc2004-07-03 03:09:12 +000043extern long flags;
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000044extern ssize_t tabsize;
Chris Allegretta6b58acd2001-04-12 03:01:53 +000045extern int currslen;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000046
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000047#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
48extern char *whitespace;
49#endif
50
Chris Allegrettae4f940d2002-03-03 22:36:36 +000051#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey2c62b072004-05-29 16:38:57 +000052extern char *punct;
53extern char *brackets;
Chris Allegretta45329a12002-03-10 01:22:21 +000054extern char *quotestr;
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +000055#ifdef HAVE_REGEX_H
56extern regex_t quotereg;
57extern int quoterc;
58extern char *quoteerr;
59#else
60extern size_t quotelen;
61#endif
Chris Allegrettae4f940d2002-03-03 22:36:36 +000062#endif
63
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +000064#ifndef NANO_SMALL
65extern char *backup_dir;
66#endif
67
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +000068extern WINDOW *topwin, *edit, *bottomwin;
Chris Allegretta1a6e9042000-12-14 13:56:28 +000069extern char *filename;
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000070extern struct stat originalfilestat;
Chris Allegretta31925e42000-11-02 04:40:39 +000071extern char *answer;
Chris Allegretta6df90f52002-07-19 01:08:59 +000072extern char *hblank;
73#ifndef DISABLE_HELP
74extern char *help_text;
75#endif
Chris Allegretta27eb13f2000-11-05 16:52:21 +000076extern char *last_search;
77extern char *last_replace;
Chris Allegrettae1f14522001-09-19 03:19:43 +000078#ifndef DISABLE_OPERATINGDIR
79extern char *operating_dir;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +000080extern char *full_operating_dir;
Chris Allegrettae1f14522001-09-19 03:19:43 +000081#endif
Chris Allegretta8d8e0122001-04-18 04:28:54 +000082#ifndef DISABLE_SPELLER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +000083extern char *alt_speller;
Chris Allegretta6df90f52002-07-19 01:08:59 +000084#endif
85
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000086extern struct stat fileinfo;
David Lawrence Ramseyb9775152004-03-19 02:15:42 +000087extern filestruct *current, *fileage, *edittop, *filebot;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000088extern filestruct *cutbuffer;
89#ifndef NANO_SMALL
90extern filestruct *mark_beginbuf;
91#endif
Chris Allegretta2d7893d2001-07-11 02:08:33 +000092
Chris Allegretta355fbe52001-07-14 19:32:47 +000093#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +000094extern openfilestruct *open_files;
Chris Allegretta2d7893d2001-07-11 02:08:33 +000095#endif
96
Chris Allegretta08893e02001-11-29 02:42:27 +000097#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +000098extern const colortype *colorstrings;
Chris Allegrettab6c5dc22002-05-04 03:47:33 +000099extern syntaxtype *syntaxes;
Chris Allegretta09900ff2002-05-04 04:23:30 +0000100extern char *syntaxstr;
Chris Allegretta08893e02001-11-29 02:42:27 +0000101#endif
102
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000103extern shortcut *shortcut_list;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000104extern shortcut *main_list, *whereis_list;
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000105extern shortcut *replace_list, *gotoline_list;
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000106extern shortcut *writefile_list, *insertfile_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000107extern shortcut *replace_list_2;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000108#ifndef NANO_SMALL
109extern shortcut *extcmd_list;
110#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000111#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000112extern shortcut *help_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000113#endif
114#ifndef DISABLE_SPELLER
115extern shortcut *spell_list;
116#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000117#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000118extern shortcut *browser_list, *gotodir_list;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000119#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000120
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000121#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta6df90f52002-07-19 01:08:59 +0000122extern const shortcut *currshortcut;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000123#endif
Chris Allegretta805c26d2000-09-06 13:39:17 +0000124
125#ifdef HAVE_REGEX_H
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000126extern regex_t search_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000127extern regmatch_t regmatches[10];
Chris Allegretta3533a342002-03-24 23:19:32 +0000128#ifdef ENABLE_COLOR
Chris Allegrettab6c5dc22002-05-04 03:47:33 +0000129extern regex_t syntaxfile_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000130extern regmatch_t synfilematches[1];
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000131#endif /* ENABLE_COLOR */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000132#endif /* HAVE_REGEX_H */
133
134#ifndef NANO_SMALL
135extern toggle *toggles;
Chris Allegretta805c26d2000-09-06 13:39:17 +0000136#endif
137
Chris Allegretta5beed502003-01-05 20:41:21 +0000138#ifndef NANO_SMALL
139extern historyheadtype search_history;
140extern historyheadtype replace_history;
141#endif
142
David Lawrence Ramsey76356bd2004-08-12 04:30:22 +0000143extern bool curses_ended;
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000144
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000145#ifdef ENABLE_NANORC
146extern char *homedir;
147#endif
148
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000149/* Functions we want available. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000150
Chris Allegretta6df90f52002-07-19 01:08:59 +0000151/* Public functions in color.c */
152#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000153void set_colorpairs(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000154void do_colorinit(void);
155void update_color(void);
156#endif /* ENABLE_COLOR */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000157
Chris Allegretta6df90f52002-07-19 01:08:59 +0000158/* Public functions in cut.c */
David Lawrence Ramseyc833d9e2004-05-29 15:36:58 +0000159void cutbuffer_reset(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000160filestruct *get_cutbottom(void);
David Lawrence Ramsey76356bd2004-08-12 04:30:22 +0000161void add_to_cutbuffer(filestruct *inptr, bool allow_concat);
David Lawrence Ramsey82138502003-12-24 08:03:54 +0000162void cut_marked_segment(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000163void do_cut_text(void);
164void do_uncut_text(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000165
166/* Public functions in files.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000167void new_file(void);
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000168filestruct *read_line(char *buf, filestruct *prev, bool *first_line_ins,
169 size_t len);
170void load_file(void);
171void read_file(FILE *f, const char *filename);
172int open_file(const char *filename, bool newfie, FILE **f);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000173char *get_next_filename(const char *name);
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000174#ifndef NANO_SMALL
175void execute_command(const char *command);
176#endif
177void load_buffer(const char *name);
David Lawrence Ramseybe908f62004-10-01 18:34:30 +0000178void do_insertfile(
179#ifndef NANO_SMALL
180 bool execute
181#else
182 void
183#endif
184 );
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000185void do_insertfile_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000186#ifdef ENABLE_MULTIBUFFER
187openfilestruct *make_new_opennode(openfilestruct *prevnode);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000188void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
189 openfilestruct *end);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000190void unlink_opennode(const openfilestruct *fileptr);
191void delete_opennode(openfilestruct *fileptr);
192void free_openfilestruct(openfilestruct *src);
David Lawrence Ramsey3e189a82004-10-03 19:18:48 +0000193void add_open_file(bool update);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000194void load_open_file(void);
David Lawrence Ramsey3e189a82004-10-03 19:18:48 +0000195void open_prevfile(bool closing_file);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000196void open_prevfile_void(void);
David Lawrence Ramsey3e189a82004-10-03 19:18:48 +0000197void open_nextfile(bool closing_file);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000198void open_nextfile_void(void);
David Lawrence Ramsey3e189a82004-10-03 19:18:48 +0000199bool close_open_file(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000200#endif
201#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000202char *get_full_path(const char *origpath);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000203#endif
204#ifndef DISABLE_SPELLER
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000205char *check_writable_directory(const char *path);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000206char *safe_tempnam(const char *dirname, const char *filename_prefix);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000207#endif
208#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000209void init_operating_dir(void);
210int check_operating_dir(const char *currpath, int allow_tabcomp);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000211#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000212#ifndef NANO_SMALL
213void init_backup_dir(void);
214#endif
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000215int copy_file(FILE *inn, FILE *out);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000216int write_file(const char *name, int tmp, int append, int nonamechange);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000217#ifndef NANO_SMALL
David Lawrence Ramsey2f0d03b2004-05-28 00:15:28 +0000218int write_marked(const char *name, int tmp, int append);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000219#endif
David Lawrence Ramsey951d7142004-10-04 15:23:47 +0000220int do_writeout(bool exiting);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000221void do_writeout_void(void);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000222char *real_dir_from_tilde(const char *buf);
Chris Allegretta7662c862003-01-13 01:35:15 +0000223#ifndef DISABLE_TABCOMP
David Lawrence Ramsey4d44d2d2004-08-01 22:35:31 +0000224int append_slash_if_dir(char *buf, bool *lastwastab, int *place);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000225char **username_tab_completion(char *buf, int *num_matches);
226char **cwd_tab_completion(char *buf, int *num_matches);
David Lawrence Ramsey4d44d2d2004-08-01 22:35:31 +0000227char *input_tab(char *buf, int place, bool *lastwastab, int *newplace,
228 bool *list);
Chris Allegretta7662c862003-01-13 01:35:15 +0000229#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000230const char *tail(const char *foo);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000231#ifndef DISABLE_BROWSER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000232int diralphasort(const void *va, const void *vb);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000233void free_charptrarray(char **array, size_t len);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000234void striponedir(char *foo);
Chris Allegretta858d9d92003-01-30 00:53:32 +0000235int readable_dir(const char *path);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000236char **browser_init(const char *path, int *longest, int *numents);
237char *do_browser(const char *inpath);
238char *do_browse_from(const char *inpath);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000239#endif
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000240#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000241char *histfilename(void);
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000242void load_history(void);
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000243bool writehist(FILE *hist, historyheadtype *histhead);
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000244void save_history(void);
245#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000246
247/* Public functions in global.c */
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000248size_t length_of_list(const shortcut *s);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000249#ifndef NANO_SMALL
David Lawrence Ramsey2ad32092004-07-07 14:36:44 +0000250void toggle_init_one(int val, const char *desc, long flag);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000251void toggle_init(void);
252#ifdef DEBUG
253void free_toggles(void);
254#endif
255#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000256void sc_init_one(shortcut **shortcutage, int key, const char *desc,
257#ifndef DISABLE_HELP
258 const char *help,
259#endif
260 int metaval, int funcval, int miscval, int view, void
261 (*func)(void));
Chris Allegrettadab017e2002-04-23 10:56:06 +0000262void shortcut_init(int unjustify);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000263void free_shortcutage(shortcut **shortcutage);
Chris Allegretta6232d662002-05-12 19:52:15 +0000264#ifdef DEBUG
Chris Allegrettadab017e2002-04-23 10:56:06 +0000265void thanks_for_all_the_fish(void);
Chris Allegretta6232d662002-05-12 19:52:15 +0000266#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000267
Chris Allegretta6df90f52002-07-19 01:08:59 +0000268/* Public functions in move.c */
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000269void do_first_line(void);
270void do_last_line(void);
271void do_home(void);
272void do_end(void);
273void do_page_up(void);
274void do_page_down(void);
275void do_up(void);
276void do_down(void);
277void do_left(int allow_update);
278void do_left_void(void);
279void do_right(int allow_update);
280void do_right_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000281
282/* Public functions in nano.c */
David Lawrence Ramseyda141062004-05-25 19:41:11 +0000283void finish(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000284void die(const char *msg, ...);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000285void die_save_file(const char *die_filename);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000286void die_too_small(void);
287void print_view_warning(void);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000288void global_init(bool save_cutbuffer);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000289void window_init(void);
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000290#ifndef DISABLE_MOUSE
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000291void mouse_init(void);
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000292#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000293#ifndef DISABLE_HELP
294void help_init(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000295#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000296filestruct *make_new_node(filestruct *prevnode);
297filestruct *copy_node(const filestruct *src);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000298void splice_node(filestruct *begin, filestruct *newnode, filestruct
299 *end);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000300void unlink_node(const filestruct *fileptr);
301void delete_node(filestruct *fileptr);
302filestruct *copy_filestruct(const filestruct *src);
303void free_filestruct(filestruct *src);
304void renumber_all(void);
305void renumber(filestruct *fileptr);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000306void print1opt(const char *shortflag, const char *longflag, const char
307 *desc);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000308void usage(void);
309void version(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000310int no_help(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000311void nano_disabled_msg(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000312#ifndef NANO_SMALL
313RETSIGTYPE cancel_fork(int signal);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000314bool open_pipe(const char *command);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000315#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000316void do_char(char ch);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000317void do_verbatim_input(void);
318void do_backspace(void);
319void do_delete(void);
320void do_tab(void);
321void do_enter(void);
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000322#ifndef NANO_SMALL
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000323void do_next_word(void);
324void do_prev_word(void);
325void do_mark(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000326#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000327#ifndef DISABLE_WRAPPING
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000328void wrap_reset(void);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000329bool do_wrap(filestruct *inptr);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000330#endif
331#ifndef DISABLE_SPELLER
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000332bool do_int_spell_fix(const char *word);
333const char *do_int_speller(const char *tempfile_name);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000334const char *do_alt_speller(char *tempfile_name);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000335void do_spell(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000336#endif
David Lawrence Ramseybb50b302004-08-12 21:43:00 +0000337#if !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000338size_t indent_length(const char *line);
339#endif
340#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey1cadddd2004-05-17 20:32:51 +0000341void justify_format(filestruct *line, size_t skip);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000342size_t quote_length(const char *line);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000343bool quotes_match(const char *a_line, size_t a_quote, const char
344 *b_line);
345bool indents_match(const char *a_line, size_t a_indent, const char
David Lawrence Ramseyd4693cb2004-05-14 01:17:25 +0000346 *b_line, size_t b_indent);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000347bool begpar(const filestruct *const foo);
348void do_para_begin(void);
349bool inpar(const char *str);
350void do_para_end(void);
David Lawrence Ramseyd4693cb2004-05-14 01:17:25 +0000351filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
352 quote_len);
David Lawrence Ramseyd08348b2004-09-18 22:02:21 +0000353bool breakable(const char *line, ssize_t goal);
354ssize_t break_line(const char *line, ssize_t goal, bool force);
David Lawrence Ramsey819c7f02004-07-30 03:54:34 +0000355bool do_para_search(size_t *const quote, size_t *const par);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000356void do_justify(bool full_justify);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000357void do_justify_void(void);
358void do_full_justify(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000359#endif /* !DISABLE_JUSTIFY */
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000360void do_exit(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000361void signal_init(void);
David Lawrence Ramsey2ab03f62002-10-17 02:19:31 +0000362RETSIGTYPE handle_hupterm(int signal);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000363RETSIGTYPE do_suspend(int signal);
364RETSIGTYPE do_cont(int signal);
365#ifndef NANO_SMALL
366void handle_sigwinch(int s);
David Lawrence Ramseyce62e822004-08-05 22:10:22 +0000367void allow_pending_sigwinch(bool allow);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000368#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000369#ifndef NANO_SMALL
370void do_toggle(const toggle *which);
371#endif
David Lawrence Ramsey013344c2004-09-22 22:45:08 +0000372void disable_extended_input(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000373void disable_signals(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000374#ifndef NANO_SMALL
375void enable_signals(void);
376#endif
377void disable_flow_control(void);
378void enable_flow_control(void);
David Lawrence Ramsey8aaf0302004-07-27 16:46:35 +0000379void terminal_init(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000380
Chris Allegretta6df90f52002-07-19 01:08:59 +0000381/* Public functions in rcfile.c */
Chris Allegretta7a500092001-04-19 21:13:46 +0000382#ifdef ENABLE_NANORC
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000383void rcfile_error(const char *msg, ...);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000384char *parse_next_word(char *ptr);
385char *parse_argument(char *ptr);
386#ifdef ENABLE_COLOR
387int colortoint(const char *colorname, int *bright);
388char *parse_next_regex(char *ptr);
David Lawrence Ramseyedab0cc2004-07-03 03:09:12 +0000389int nregcomp(regex_t *preg, const char *regex, int eflags);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000390void parse_syntax(char *ptr);
391void parse_colors(char *ptr);
392#endif /* ENABLE_COLOR */
393void parse_rcfile(FILE *rcstream);
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000394void do_rcfile(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000395#endif /* ENABLE_NANORC */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000396
Chris Allegretta6df90f52002-07-19 01:08:59 +0000397/* Public functions in search.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000398#ifdef HAVE_REGEX_H
Chris Allegretta5d715142003-01-29 04:18:37 +0000399int regexp_init(const char *regexp);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000400void regexp_cleanup(void);
401#endif
402void not_found_msg(const char *str);
403void search_abort(void);
404void search_init_globals(void);
David Lawrence Ramseyd532f192004-10-04 22:37:56 +0000405int search_init(bool replacing, bool use_answer);
David Lawrence Ramseyc5100422004-08-27 20:28:34 +0000406bool is_whole_word(int curr_pos, const char *datastr, const char
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000407 *searchword);
David Lawrence Ramseyc5100422004-08-27 20:28:34 +0000408bool findnextstr(bool can_display_wrap, bool wholeword, bool
409 no_sameline, const filestruct *begin, size_t beginx, const char
David Lawrence Ramsey77b284a2004-10-27 02:21:01 +0000410 *needle, size_t *needle_len);
David Lawrence Ramseye5e88fd2004-10-31 13:20:30 +0000411void findnextstr_wrap_reset(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000412void do_search(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000413#ifndef NANO_SMALL
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000414void do_research(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000415#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000416void replace_abort(void);
417#ifdef HAVE_REGEX_H
David Lawrence Ramseyc5100422004-08-27 20:28:34 +0000418int replace_regexp(char *string, bool create_flag);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000419#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000420char *replace_line(const char *needle);
David Lawrence Ramsey182b2c92004-11-03 16:02:41 +0000421ssize_t do_replace_loop(const char *needle, const filestruct
422 *real_current, size_t *real_current_x, bool wholewords, bool
423 *canceled);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000424void do_replace(void);
David Lawrence Ramseyc53ab2a2004-08-04 18:24:53 +0000425void do_gotoline(int line, bool save_pos);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000426void do_gotoline_void(void);
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000427#if defined(ENABLE_MULTIBUFFER) || !defined(DISABLE_SPELLER)
David Lawrence Ramsey7a97e182004-10-30 01:03:15 +0000428void do_gotopos(int line, size_t pos_x, int pos_y, size_t pos_pww);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000429#endif
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000430void do_find_bracket(void);
Chris Allegretta5beed502003-01-05 20:41:21 +0000431#ifndef NANO_SMALL
432void history_init(void);
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000433historytype *find_node(historytype *h, const char *s);
Chris Allegretta5beed502003-01-05 20:41:21 +0000434void remove_node(historytype *r);
435void insert_node(historytype *h, const char *s);
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000436void update_history(historyheadtype *h, const char *s);
Chris Allegretta5beed502003-01-05 20:41:21 +0000437char *get_history_older(historyheadtype *h);
438char *get_history_newer(historyheadtype *h);
439char *get_history_completion(historyheadtype *h, char *s);
David Lawrence Ramsey6420d442004-08-11 05:13:08 +0000440#ifdef DEBUG
Chris Allegretta5beed502003-01-05 20:41:21 +0000441void free_history(historyheadtype *h);
Chris Allegrettaf3de8b52003-01-16 23:44:46 +0000442#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000443#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000444
445/* Public functions in utils.c */
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000446#ifdef HAVE_REGEX_H
Chris Allegrettad8451932003-03-11 03:50:40 +0000447#ifdef BROKEN_REGEXEC
448int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
449 regmatch_t pmatch[], int eflags);
450#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000451int regexp_bol_or_eol(const regex_t *preg, const char *string);
452#endif
David Lawrence Ramsey9830d752004-05-13 17:19:54 +0000453#ifndef HAVE_ISBLANK
454int is_blank_char(int c);
455#endif
Chris Allegrettacf287c82002-07-20 13:57:41 +0000456int is_cntrl_char(int c);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000457int num_of_digits(int n);
David Lawrence Ramseyc53ab2a2004-08-04 18:24:53 +0000458bool parse_num(const char *str, ssize_t *val);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000459void align(char **strp);
460void null_at(char **data, size_t index);
461void unsunder(char *str, size_t true_len);
462void sunder(char *str);
Chris Allegretta4f5335d2003-08-04 02:51:12 +0000463#ifndef HAVE_STRCASECMP
464int nstricmp(const char *s1, const char *s2);
465#endif
466#ifndef HAVE_STRNCASECMP
467int nstrnicmp(const char *s1, const char *s2, size_t n);
468#endif
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000469#ifndef HAVE_STRCASESTR
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000470const char *nstristr(const char *haystack, const char *needle);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000471#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000472#ifndef NANO_SMALL
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000473const char *revstrstr(const char *haystack, const char *needle, const
474 char *rev_start);
475const char *revstristr(const char *haystack, const char *needle, const
476 char *rev_start);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000477#endif
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000478#ifndef HAVE_STRNLEN
479size_t nstrnlen(const char *s, size_t maxlen);
480#endif
David Lawrence Ramseya8834702004-08-17 20:34:57 +0000481#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
David Lawrence Ramseya27bd652004-08-17 05:23:38 +0000482#ifndef HAVE_GETLINE
483ssize_t ngetline(char **lineptr, size_t *n, FILE *stream);
484#endif
485#ifndef HAVE_GETDELIM
486ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
487#endif
David Lawrence Ramseya8834702004-08-17 20:34:57 +0000488#endif /* !NANO_SMALL && ENABLE_NANORC */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000489const char *strstrwrapper(const char *haystack, const char *needle,
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000490 const char *start);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000491void nperror(const char *s);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000492void *nmalloc(size_t howmuch);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000493void *nrealloc(void *ptr, size_t howmuch);
David Lawrence Ramsey4a1fc552004-11-02 15:18:30 +0000494char *mallocstrncpy(char *dest, const char *src, size_t n);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000495char *mallocstrcpy(char *dest, const char *src);
David Lawrence Ramsey02517e02004-09-05 21:40:31 +0000496char *mallocstrassn(char *dest, char *src);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000497void new_magicline(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000498#ifndef NANO_SMALL
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000499void mark_order(const filestruct **top, size_t *top_x, const filestruct
500 **bot, size_t *bot_x);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000501#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000502#ifndef DISABLE_TABCOMP
503int check_wildcard_match(const char *text, const char *pattern);
504#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000505
506/* Public functions in winio.c */
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000507#ifndef NANO_SMALL
508void reset_kbinput(void);
509#endif
David Lawrence Ramseyc59979f2004-10-23 02:47:39 +0000510void unget_kbinput(int kbinput, bool meta_key, bool func_key);
David Lawrence Ramseyeb16f432004-09-27 01:04:50 +0000511int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
David Lawrence Ramsey4e8e4952004-10-14 21:59:45 +0000512int get_translated_kbinput(int kbinput, seq_type *seq
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000513#ifndef NANO_SMALL
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000514 , bool reset
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000515#endif
516 );
517int get_ascii_kbinput(int kbinput, size_t ascii_digits
518#ifndef NANO_SMALL
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000519 , bool reset
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000520#endif
521 );
522int get_control_kbinput(int kbinput);
David Lawrence Ramsey5780b242004-10-14 20:48:38 +0000523int get_escape_seq_kbinput(const int *escape_seq, size_t es_len, bool
David Lawrence Ramseye65e6392004-06-04 18:18:17 +0000524 *ignore_seq);
David Lawrence Ramseyc2c5a512004-01-23 19:26:17 +0000525int get_escape_seq_abcd(int kbinput);
David Lawrence Ramsey6da969e2004-08-28 15:51:07 +0000526int *get_verbatim_kbinput(WINDOW *win, int first, int *v_kbinput, size_t
527 *v_len, bool allow_ascii);
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000528int get_untranslated_kbinput(int kbinput, size_t position, bool
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000529 allow_ascii
530#ifndef NANO_SMALL
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000531 , bool reset
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000532#endif
533 );
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000534#ifndef DISABLE_MOUSE
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000535bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
536#endif
537const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
David Lawrence Ramseyeb16f432004-09-27 01:04:50 +0000538 *meta_key, bool *func_key);
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000539#ifndef NANO_SMALL
540const toggle *get_toggle(int kbinput, bool meta_key);
541#endif
David Lawrence Ramseyeb16f432004-09-27 01:04:50 +0000542int get_edit_input(bool *meta_key, bool *func_key, bool allow_funcs);
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000543#ifndef DISABLE_MOUSE
544bool get_edit_mouse(void);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000545#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000546size_t xplustabs(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000547size_t actual_x(const char *str, size_t xplus);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000548size_t strnlenpt(const char *buf, size_t size);
549size_t strlenpt(const char *buf);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000550void blank_titlebar(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000551void blank_edit(void);
552void blank_statusbar(void);
David Lawrence Ramseye5d8f322004-09-30 22:07:21 +0000553void check_statusblank(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000554void blank_bottombars(void);
555char *display_string(const char *buf, size_t start_col, size_t len);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000556void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
David Lawrence Ramsey045883a2004-10-05 20:11:31 +0000557int nanogetstr(bool allow_tabs, const char *buf, const char *def,
Chris Allegretta5beed502003-01-05 20:41:21 +0000558#ifndef NANO_SMALL
559 historyheadtype *history_list,
560#endif
David Lawrence Ramsey045883a2004-10-05 20:11:31 +0000561 const shortcut *s
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000562#ifndef DISABLE_TABCOMP
David Lawrence Ramsey4d44d2d2004-08-01 22:35:31 +0000563 , bool *list
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000564#endif
Chris Allegretta65f075d2003-02-13 03:03:49 +0000565 );
David Lawrence Ramsey045883a2004-10-05 20:11:31 +0000566int statusq(bool allow_tabs, const shortcut *s, const char *def,
567#ifndef NANO_SMALL
568 historyheadtype *history_list,
569#endif
570 const char *msg, ...);
571void statusq_abort(void);
Chris Allegrettaf717f982003-02-13 22:25:01 +0000572void titlebar(const char *path);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000573void set_modified(void);
574void statusbar(const char *msg, ...);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000575void bottombars(const shortcut *s);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000576void onekey(const char *keystroke, const char *desc, size_t len);
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000577#ifndef NDEBUG
578int check_linenumbers(const filestruct *fileptr);
579#endif
David Lawrence Ramsey2dd7ed12003-09-29 05:15:24 +0000580size_t get_page_start(size_t column);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000581void reset_cursor(void);
David Lawrence Ramsey07d3feb2004-04-16 05:15:11 +0000582void edit_add(const filestruct *fileptr, const char *converted, int
583 yval, size_t start);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000584void update_line(const filestruct *fileptr, size_t index);
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +0000585int need_horizontal_update(size_t old_pww);
586int need_vertical_update(size_t old_pww);
David Lawrence Ramsey2ed225f2004-05-28 20:44:09 +0000587void edit_scroll(updown direction, int nlines);
David Lawrence Ramsey86e851b2004-07-28 20:46:25 +0000588void edit_redraw(const filestruct *old_current, size_t old_pww);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000589void edit_refresh(void);
David Lawrence Ramsey20b83502004-08-26 18:07:58 +0000590void edit_update(topmidnone location);
David Lawrence Ramsey045883a2004-10-05 20:11:31 +0000591int do_yesno(bool all, const char *msg);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000592void total_refresh(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000593void display_main_list(void);
David Lawrence Ramseya0b5ba22004-08-25 15:39:10 +0000594void do_cursorpos(bool constant);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000595void do_cursorpos_void(void);
David Lawrence Ramsey8037fe02004-07-23 12:30:40 +0000596#ifndef DISABLE_HELP
597int help_line_len(const char *ptr);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000598void do_help(void);
David Lawrence Ramsey8037fe02004-07-23 12:30:40 +0000599#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000600void do_replace_highlight(int highlight_flag, const char *word);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000601#ifdef DEBUG
602void dump_buffer(const filestruct *inptr);
603void dump_buffer_reverse(void);
604#endif
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000605#ifdef NANO_EXTRA
Chris Allegretta34318ed2001-01-31 23:22:36 +0000606void do_credits(void);
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000607#endif