blob: f6cf80af514387b7133db68b524a5cbe17fff1f0 [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>
Chris Allegretta805c26d2000-09-06 13:39:17 +000025
26#ifdef HAVE_REGEX_H
Chris Allegretta9fc8d432000-07-07 01:49:52 +000027#include <regex.h>
Chris Allegretta805c26d2000-09-06 13:39:17 +000028#endif
29
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000030#include "nano.h"
31
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000032#ifndef DISABLE_WRAPJUSTIFY
Chris Allegretta6df90f52002-07-19 01:08:59 +000033extern int wrap_at;
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000034#endif
Chris Allegretta17dcb722001-01-20 21:40:07 +000035extern int editwinrows;
Chris Allegretta7162e3d2002-04-06 05:02:14 +000036extern int current_x, current_y, totlines;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000037extern int placewewant;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000038#ifndef NANO_SMALL
Chris Allegretta6df90f52002-07-19 01:08:59 +000039extern int mark_beginx;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000040#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +000041extern long totsize;
42extern int temp_opt;
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +000043extern int flags;
44extern int tabsize;
Chris Allegretta27eb13f2000-11-05 16:52:21 +000045extern int search_last_line;
Chris Allegretta7662c862003-01-13 01:35:15 +000046extern int search_offscreen;
Chris Allegretta6b58acd2001-04-12 03:01:53 +000047extern int currslen;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000048
Chris Allegrettae4f940d2002-03-03 22:36:36 +000049#ifndef DISABLE_JUSTIFY
Chris Allegretta45329a12002-03-10 01:22:21 +000050extern char *quotestr;
Chris Allegrettae4f940d2002-03-03 22:36:36 +000051#endif
52
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +000053#ifndef NANO_SMALL
54extern char *backup_dir;
55#endif
56
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +000057extern WINDOW *topwin, *edit, *bottomwin;
Chris Allegretta1a6e9042000-12-14 13:56:28 +000058extern char *filename;
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000059extern struct stat originalfilestat;
Chris Allegretta31925e42000-11-02 04:40:39 +000060extern char *answer;
Chris Allegretta6df90f52002-07-19 01:08:59 +000061extern char *hblank;
62#ifndef DISABLE_HELP
63extern char *help_text;
64#endif
Chris Allegretta27eb13f2000-11-05 16:52:21 +000065extern char *last_search;
66extern char *last_replace;
Chris Allegrettae1f14522001-09-19 03:19:43 +000067#ifndef DISABLE_OPERATINGDIR
68extern char *operating_dir;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +000069extern char *full_operating_dir;
Chris Allegrettae1f14522001-09-19 03:19:43 +000070#endif
Chris Allegretta8d8e0122001-04-18 04:28:54 +000071#ifndef DISABLE_SPELLER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +000072extern char *alt_speller;
Chris Allegretta6df90f52002-07-19 01:08:59 +000073#endif
74
Chris Allegretta65f075d2003-02-13 03:03:49 +000075extern int resetstatuspos;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000076extern struct stat fileinfo;
David Lawrence Ramseyb9775152004-03-19 02:15:42 +000077extern filestruct *current, *fileage, *edittop, *filebot;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000078extern filestruct *cutbuffer;
79#ifndef NANO_SMALL
80extern filestruct *mark_beginbuf;
81#endif
Chris Allegretta2d7893d2001-07-11 02:08:33 +000082
Chris Allegretta355fbe52001-07-14 19:32:47 +000083#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +000084extern openfilestruct *open_files;
Chris Allegretta2d7893d2001-07-11 02:08:33 +000085#endif
86
Chris Allegretta08893e02001-11-29 02:42:27 +000087#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +000088extern const colortype *colorstrings;
Chris Allegrettab6c5dc22002-05-04 03:47:33 +000089extern syntaxtype *syntaxes;
Chris Allegretta09900ff2002-05-04 04:23:30 +000090extern char *syntaxstr;
Chris Allegretta08893e02001-11-29 02:42:27 +000091#endif
92
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000093extern shortcut *shortcut_list;
Chris Allegrettaa8c22572002-02-15 19:17:02 +000094extern shortcut *main_list, *whereis_list;
95extern shortcut *replace_list, *goto_list;
96extern shortcut *writefile_list, *insertfile_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +000097extern shortcut *replace_list_2;
Chris Allegretta7162e3d2002-04-06 05:02:14 +000098#ifndef NANO_SMALL
99extern shortcut *extcmd_list;
100#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000101#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000102extern shortcut *help_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000103#endif
104#ifndef DISABLE_SPELLER
105extern shortcut *spell_list;
106#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000107#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000108extern shortcut *browser_list, *gotodir_list;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000109#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000110
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000111#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta6df90f52002-07-19 01:08:59 +0000112extern const shortcut *currshortcut;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000113#endif
Chris Allegretta805c26d2000-09-06 13:39:17 +0000114
115#ifdef HAVE_REGEX_H
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000116extern regex_t search_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000117extern regmatch_t regmatches[10];
Chris Allegretta3533a342002-03-24 23:19:32 +0000118#ifdef ENABLE_COLOR
Chris Allegrettab6c5dc22002-05-04 03:47:33 +0000119extern regex_t syntaxfile_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000120extern regmatch_t synfilematches[1];
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000121#endif /* ENABLE_COLOR */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000122#endif /* HAVE_REGEX_H */
123
124#ifndef NANO_SMALL
125extern toggle *toggles;
Chris Allegretta805c26d2000-09-06 13:39:17 +0000126#endif
127
Chris Allegretta5beed502003-01-05 20:41:21 +0000128#ifndef NANO_SMALL
129extern historyheadtype search_history;
130extern historyheadtype replace_history;
131#endif
132
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000133extern int curses_ended;
134
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000135/* Functions we want available. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000136
Chris Allegretta6df90f52002-07-19 01:08:59 +0000137/* Public functions in color.c */
138#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000139void set_colorpairs(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000140void do_colorinit(void);
141void update_color(void);
142#endif /* ENABLE_COLOR */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000143
Chris Allegretta6df90f52002-07-19 01:08:59 +0000144/* Public functions in cut.c */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000145filestruct *get_cutbottom(void);
David Lawrence Ramsey44e7f822004-03-30 04:17:10 +0000146void add_to_cutbuffer(filestruct *inptr, int allow_concat);
David Lawrence Ramsey82138502003-12-24 08:03:54 +0000147void cut_marked_segment(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000148int do_cut_text(void);
149int do_uncut_text(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000150
151/* Public functions in files.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000152void load_file(int update);
153void new_file(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000154filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
155 len);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000156int read_file(FILE *f, const char *filename, int quiet);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000157int open_file(const char *filename, int insert, int quiet);
158char *get_next_filename(const char *name);
159int do_insertfile(int loading_file);
160int do_insertfile_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000161#ifdef ENABLE_MULTIBUFFER
162openfilestruct *make_new_opennode(openfilestruct *prevnode);
163void splice_opennode(openfilestruct *begin, openfilestruct *newnode, openfilestruct *end);
164void unlink_opennode(const openfilestruct *fileptr);
165void delete_opennode(openfilestruct *fileptr);
166void free_openfilestruct(openfilestruct *src);
167int add_open_file(int update);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000168int load_open_file(void);
169int open_prevfile(int closing_file);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000170int open_prevfile_void(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000171int open_nextfile(int closing_file);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000172int open_nextfile_void(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000173int close_open_file(void);
174#endif
175#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000176char *get_full_path(const char *origpath);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000177#endif
178#ifndef DISABLE_SPELLER
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000179char *check_writable_directory(const char *path);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000180char *safe_tempnam(const char *dirname, const char *filename_prefix);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000181#endif
182#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000183void init_operating_dir(void);
184int check_operating_dir(const char *currpath, int allow_tabcomp);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000185#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000186#ifndef NANO_SMALL
187void init_backup_dir(void);
188#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000189int write_file(const char *name, int tmp, int append, int nonamechange);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000190#ifndef NANO_SMALL
David Lawrence Ramsey2f0d03b2004-05-28 00:15:28 +0000191int write_marked(const char *name, int tmp, int append);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000192#endif
David Lawrence Ramsey6aec4b82004-03-15 20:26:30 +0000193int do_writeout(int exiting);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000194int do_writeout_void(void);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000195char *real_dir_from_tilde(const char *buf);
Chris Allegretta7662c862003-01-13 01:35:15 +0000196#ifndef DISABLE_TABCOMP
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000197int append_slash_if_dir(char *buf, int *lastwastab, int *place);
198char **username_tab_completion(char *buf, int *num_matches);
199char **cwd_tab_completion(char *buf, int *num_matches);
200char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list);
Chris Allegretta7662c862003-01-13 01:35:15 +0000201#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000202const char *tail(const char *foo);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000203#ifndef DISABLE_BROWSER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000204int diralphasort(const void *va, const void *vb);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000205void free_charptrarray(char **array, size_t len);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000206void striponedir(char *foo);
Chris Allegretta858d9d92003-01-30 00:53:32 +0000207int readable_dir(const char *path);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000208char **browser_init(const char *path, int *longest, int *numents);
209char *do_browser(const char *inpath);
210char *do_browse_from(const char *inpath);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000211#endif
212
213/* Public functions in global.c */
Chris Allegrettadab017e2002-04-23 10:56:06 +0000214int length_of_list(const shortcut *s);
Chris Allegrettaf717f982003-02-13 22:25:01 +0000215void sc_init_one(shortcut **shortcutage, int key, const char *desc,
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000216#ifndef DISABLE_HELP
Chris Allegrettaf717f982003-02-13 22:25:01 +0000217 const char *help,
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000218#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000219 int metaval, int funcval, int miscval, int view, int
220 (*func)(void));
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000221#ifndef NANO_SMALL
222void toggle_init_one(int val, const char *desc, int flag);
223void toggle_init(void);
224#ifdef DEBUG
225void free_toggles(void);
226#endif
227#endif
228void free_shortcutage(shortcut **shortcutage);
Chris Allegrettadab017e2002-04-23 10:56:06 +0000229void shortcut_init(int unjustify);
Chris Allegretta6232d662002-05-12 19:52:15 +0000230#ifdef DEBUG
Chris Allegrettadab017e2002-04-23 10:56:06 +0000231void thanks_for_all_the_fish(void);
Chris Allegretta6232d662002-05-12 19:52:15 +0000232#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000233
Chris Allegretta6df90f52002-07-19 01:08:59 +0000234/* Public functions in move.c */
David Lawrence Ramsey4be15f02004-05-23 21:33:23 +0000235int do_first_line(void);
236int do_last_line(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000237int do_home(void);
238int do_end(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000239int do_page_up(void);
240int do_page_down(void);
Chris Allegrettabceb1b22000-06-19 04:22:15 +0000241int do_up(void);
242int do_down(void);
David Lawrence Ramsey2ed225f2004-05-28 20:44:09 +0000243int do_left(int allow_update);
244int do_left_void(void);
245int do_right(int allow_update);
246int do_right_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000247
248/* Public functions in nano.c */
David Lawrence Ramseyda141062004-05-25 19:41:11 +0000249void finish(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000250void die(const char *msg, ...);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000251void die_save_file(const char *die_filename);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000252void die_too_small(void);
253void print_view_warning(void);
254void global_init(int save_cutbuffer);
255void window_init(void);
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000256#ifndef DISABLE_MOUSE
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000257void mouse_init(void);
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000258#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000259#ifndef DISABLE_HELP
260void help_init(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000261#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000262filestruct *make_new_node(filestruct *prevnode);
263filestruct *copy_node(const filestruct *src);
264void splice_node(filestruct *begin, filestruct *newnode, filestruct *end);
265void unlink_node(const filestruct *fileptr);
266void delete_node(filestruct *fileptr);
267filestruct *copy_filestruct(const filestruct *src);
268void free_filestruct(filestruct *src);
269void renumber_all(void);
270void renumber(filestruct *fileptr);
271void print1opt(const char *shortflag, const char *longflag,
272 const char *desc);
273void usage(void);
274void version(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000275int no_help(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000276int nano_disabled_msg(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000277#ifndef NANO_SMALL
278RETSIGTYPE cancel_fork(int signal);
279int open_pipe(const char *command);
280#endif
281#ifndef DISABLE_MOUSE
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000282void do_mouse(void);
283#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000284void do_char(char ch);
David Lawrence Ramseya593f532003-11-28 19:47:42 +0000285int do_verbatim_input(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000286int do_backspace(void);
287int do_delete(void);
288int do_tab(void);
289int do_enter(void);
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000290#ifndef NANO_SMALL
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000291int do_next_word(void);
292int do_prev_word(void);
293int do_mark(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000294#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000295#ifndef DISABLE_WRAPPING
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000296void wrap_reset(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000297int do_wrap(filestruct *inptr);
298#endif
299#ifndef DISABLE_SPELLER
300int do_int_spell_fix(const char *word);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000301const char *do_int_speller(char *tempfile_name);
302const char *do_alt_speller(char *tempfile_name);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000303int do_spell(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000304#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000305#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
306size_t indent_length(const char *line);
307#endif
308#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey1cadddd2004-05-17 20:32:51 +0000309void justify_format(filestruct *line, size_t skip);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000310#ifdef HAVE_REGEX_H
311size_t quote_length(const char *line, const regex_t *qreg);
312#else
313size_t quote_length(const char *line);
314#endif
315#ifdef HAVE_REGEX_H
316# define IFREG(a, b) a, b
317#else
318# define IFREG(a, b) a
319#endif
David Lawrence Ramseyd4693cb2004-05-14 01:17:25 +0000320int quotes_match(const char *a_line, size_t a_quote, IFREG(const char
321 *b_line, const regex_t *qreg));
322size_t indents_match(const char *a_line, size_t a_indent, const char
323 *b_line, size_t b_indent);
324filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
325 quote_len);
Chris Allegrettacff6e6f2003-02-03 03:22:02 +0000326int breakable(const char *line, int goal);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000327int break_line(const char *line, int goal, int force);
David Lawrence Ramsey2e3aeae2004-05-24 05:52:35 +0000328int do_para_search(justbegend search_type, size_t *quote, size_t *par,
329 size_t *indent, int do_refresh);
David Lawrence Ramsey8faf3052003-09-04 20:25:29 +0000330int do_para_begin(void);
331int do_para_end(void);
David Lawrence Ramsey8d3e7f32004-05-13 17:28:03 +0000332int do_justify(int justify_all);
333int do_justify_void(void);
334int do_full_justify(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000335#endif /* !DISABLE_JUSTIFY */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000336int do_exit(void);
337void signal_init(void);
David Lawrence Ramsey2ab03f62002-10-17 02:19:31 +0000338RETSIGTYPE handle_hupterm(int signal);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000339RETSIGTYPE do_suspend(int signal);
340RETSIGTYPE do_cont(int signal);
341#ifndef NANO_SMALL
342void handle_sigwinch(int s);
David Lawrence Ramsey369732f2004-02-16 20:32:40 +0000343void allow_pending_sigwinch(int allow);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000344#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000345#ifndef NANO_SMALL
346void do_toggle(const toggle *which);
347#endif
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000348#if !defined(NANO_SMALL) || defined(USE_SLANG)
349void disable_signals(void);
350#endif
351#ifndef NANO_SMALL
352void enable_signals(void);
353#endif
354void disable_flow_control(void);
355void enable_flow_control(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000356
Chris Allegretta6df90f52002-07-19 01:08:59 +0000357/* Public functions in rcfile.c */
Chris Allegretta7a500092001-04-19 21:13:46 +0000358#ifdef ENABLE_NANORC
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000359void rcfile_error(const char *msg, ...);
360void rcfile_msg(const char *msg, ...);
361char *parse_next_word(char *ptr);
362char *parse_argument(char *ptr);
363#ifdef ENABLE_COLOR
364int colortoint(const char *colorname, int *bright);
365char *parse_next_regex(char *ptr);
Chris Allegrettace452fb2003-02-03 02:56:44 +0000366int nregcomp(regex_t *preg, const char *regex, int flags);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000367void parse_syntax(char *ptr);
368void parse_colors(char *ptr);
369#endif /* ENABLE_COLOR */
370void parse_rcfile(FILE *rcstream);
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000371void do_rcfile(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000372#endif /* ENABLE_NANORC */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000373
Chris Allegretta6df90f52002-07-19 01:08:59 +0000374/* Public functions in search.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000375#ifdef HAVE_REGEX_H
Chris Allegretta5d715142003-01-29 04:18:37 +0000376int regexp_init(const char *regexp);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000377void regexp_cleanup(void);
378#endif
379void not_found_msg(const char *str);
380void search_abort(void);
381void search_init_globals(void);
382int search_init(int replacing);
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000383int is_whole_word(int curr_pos, const char *datastr, const char
384 *searchword);
385int findnextstr(int can_display_wrap, int wholeword, const filestruct
386 *begin, size_t beginx, const char *needle, int no_sameline);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000387int do_search(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000388#ifndef NANO_SMALL
David Lawrence Ramseye0497062003-08-23 21:11:06 +0000389int do_research(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000390#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000391void replace_abort(void);
392#ifdef HAVE_REGEX_H
393int replace_regexp(char *string, int create_flag);
394#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000395char *replace_line(const char *needle);
396int do_replace_loop(const char *needle, const filestruct *real_current,
397 size_t *real_current_x, int wholewords);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000398int do_replace(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000399int do_gotoline(int line, int save_pos);
400int do_gotoline_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000401#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
402void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant);
403#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000404int do_find_bracket(void);
Chris Allegretta5beed502003-01-05 20:41:21 +0000405#ifndef NANO_SMALL
406void history_init(void);
407historytype *find_node(historytype *h, char *s);
408void remove_node(historytype *r);
409void insert_node(historytype *h, const char *s);
410void update_history(historyheadtype *h, char *s);
411char *get_history_older(historyheadtype *h);
412char *get_history_newer(historyheadtype *h);
413char *get_history_completion(historyheadtype *h, char *s);
414void free_history(historyheadtype *h);
Chris Allegrettaf3de8b52003-01-16 23:44:46 +0000415#ifdef ENABLE_NANORC
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000416void load_history(void);
Chris Allegrettaf3de8b52003-01-16 23:44:46 +0000417void save_history(void);
418#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000419#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000420
421/* Public functions in utils.c */
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000422#ifdef HAVE_REGEX_H
Chris Allegrettad8451932003-03-11 03:50:40 +0000423#ifdef BROKEN_REGEXEC
424int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
425 regmatch_t pmatch[], int eflags);
426#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000427int regexp_bol_or_eol(const regex_t *preg, const char *string);
428#endif
David Lawrence Ramsey9830d752004-05-13 17:19:54 +0000429#ifndef HAVE_ISBLANK
430int is_blank_char(int c);
431#endif
Chris Allegrettacf287c82002-07-20 13:57:41 +0000432int is_cntrl_char(int c);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000433int num_of_digits(int n);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000434void align(char **strp);
435void null_at(char **data, size_t index);
436void unsunder(char *str, size_t true_len);
437void sunder(char *str);
Chris Allegretta4f5335d2003-08-04 02:51:12 +0000438#ifndef HAVE_STRCASECMP
439int nstricmp(const char *s1, const char *s2);
440#endif
441#ifndef HAVE_STRNCASECMP
442int nstrnicmp(const char *s1, const char *s2, size_t n);
443#endif
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000444#ifndef HAVE_STRCASESTR
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000445const char *nstristr(const char *haystack, const char *needle);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000446#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000447#ifndef NANO_SMALL
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000448const char *revstrstr(const char *haystack, const char *needle, const
449 char *rev_start);
450const char *revstristr(const char *haystack, const char *needle, const
451 char *rev_start);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000452#endif
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000453#ifndef HAVE_STRNLEN
454size_t nstrnlen(const char *s, size_t maxlen);
455#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000456const char *strstrwrapper(const char *haystack, const char *needle,
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000457 const char *start);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000458void nperror(const char *s);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000459void *nmalloc(size_t howmuch);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000460void *nrealloc(void *ptr, size_t howmuch);
461char *mallocstrcpy(char *dest, const char *src);
462void new_magicline(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000463#ifndef NANO_SMALL
464void mark_order(const filestruct **top, size_t *top_x,
465 const filestruct **bot, size_t *bot_x);
466#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000467#ifndef DISABLE_TABCOMP
468int check_wildcard_match(const char *text, const char *pattern);
469#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000470
471/* Public functions in winio.c */
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000472#ifndef NANO_SMALL
473void reset_kbinput(void);
474#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000475int get_kbinput(WINDOW *win, int *meta_key);
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000476int get_translated_kbinput(int kbinput, int *es
477#ifndef NANO_SMALL
478 , int reset
479#endif
480 );
481int get_ascii_kbinput(int kbinput, size_t ascii_digits
482#ifndef NANO_SMALL
483 , int reset
484#endif
485 );
486int get_control_kbinput(int kbinput);
487int get_escape_seq_kbinput(int *escape_seq, size_t es_len);
David Lawrence Ramseyc2c5a512004-01-23 19:26:17 +0000488int get_escape_seq_abcd(int kbinput);
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000489int *get_verbatim_kbinput(WINDOW *win, int *verbatim_kbinput, size_t
490 *verbatim_len, int allow_ascii);
491int get_untranslated_kbinput(int kbinput, size_t position, int
492 allow_ascii
493#ifndef NANO_SMALL
494 , int reset
495#endif
496 );
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000497#ifndef DISABLE_MOUSE
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000498int get_mouseinput(int *mouse_x, int *mouse_y, int shortcut);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000499#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000500size_t xplustabs(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000501size_t actual_x(const char *str, size_t xplus);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000502size_t strnlenpt(const char *buf, size_t size);
503size_t strlenpt(const char *buf);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000504void blank_titlebar(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000505void blank_edit(void);
506void blank_statusbar(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000507void check_statblank(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000508void blank_bottombars(void);
509char *display_string(const char *buf, size_t start_col, size_t len);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000510void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
Chris Allegrettaf717f982003-02-13 22:25:01 +0000511int nanogetstr(int allowtabs, const char *buf, const char *def,
Chris Allegretta5beed502003-01-05 20:41:21 +0000512#ifndef NANO_SMALL
513 historyheadtype *history_list,
514#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000515 const shortcut *s
516#ifndef DISABLE_TABCOMP
517 , int *list
518#endif
Chris Allegretta65f075d2003-02-13 03:03:49 +0000519 );
Chris Allegrettaf717f982003-02-13 22:25:01 +0000520void titlebar(const char *path);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000521void set_modified(void);
522void statusbar(const char *msg, ...);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000523void bottombars(const shortcut *s);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000524void onekey(const char *keystroke, const char *desc, size_t len);
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000525#ifndef NDEBUG
526int check_linenumbers(const filestruct *fileptr);
527#endif
David Lawrence Ramsey2dd7ed12003-09-29 05:15:24 +0000528size_t get_page_start(size_t column);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000529void reset_cursor(void);
David Lawrence Ramsey07d3feb2004-04-16 05:15:11 +0000530void edit_add(const filestruct *fileptr, const char *converted, int
531 yval, size_t start);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000532void update_line(const filestruct *fileptr, size_t index);
David Lawrence Ramsey2ed225f2004-05-28 20:44:09 +0000533int need_horizontal_update(int old_placewewant);
534int need_vertical_update(int old_placewewant);
535void edit_scroll(updown direction, int nlines);
536void edit_redraw(const filestruct *old_current);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000537void edit_refresh(void);
David Lawrence Ramsey1356a0a2003-09-10 20:31:02 +0000538void edit_update(filestruct *fileptr, topmidnone location);
David Lawrence Ramsey6aec4b82004-03-15 20:26:30 +0000539int statusq(int allowtabs, const shortcut *s, const char *def,
Chris Allegretta5beed502003-01-05 20:41:21 +0000540#ifndef NANO_SMALL
541 historyheadtype *history_list,
542#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000543 const char *msg, ...);
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000544int do_yesno(int all, const char *msg);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000545int total_refresh(void);
546void display_main_list(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000547int do_cursorpos(int constant);
548int do_cursorpos_void(void);
Chris Allegretta4640fe32003-02-10 03:10:03 +0000549int line_len(const char *ptr);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000550int do_help(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000551void do_replace_highlight(int highlight_flag, const char *word);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000552#ifdef DEBUG
553void dump_buffer(const filestruct *inptr);
554void dump_buffer_reverse(void);
555#endif
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000556#ifdef NANO_EXTRA
Chris Allegretta34318ed2001-01-31 23:22:36 +0000557void do_credits(void);
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000558#endif