blob: 32ac485521c6395cf75cc8d74090ed33c7b2bbfa [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;
Chris Allegretta7162e3d2002-04-06 05:02:14 +000035extern int current_x, current_y, totlines;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000036extern int placewewant;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000037#ifndef NANO_SMALL
Chris Allegretta6df90f52002-07-19 01:08:59 +000038extern int mark_beginx;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000039#endif
Chris Allegrettab3655b42001-10-22 03:15:31 +000040extern long totsize;
David Lawrence Ramseyedab0cc2004-07-03 03:09:12 +000041extern long flags;
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +000042extern ssize_t tabsize;
Chris Allegretta27eb13f2000-11-05 16:52:21 +000043extern int search_last_line;
Chris Allegretta6b58acd2001-04-12 03:01:53 +000044extern int currslen;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000045
David Lawrence Ramsey89bb9372004-05-29 16:47:52 +000046#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
47extern char *whitespace;
48#endif
49
Chris Allegrettae4f940d2002-03-03 22:36:36 +000050#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey2c62b072004-05-29 16:38:57 +000051extern char *punct;
52extern char *brackets;
Chris Allegretta45329a12002-03-10 01:22:21 +000053extern char *quotestr;
Chris Allegrettae4f940d2002-03-03 22:36:36 +000054#endif
55
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +000056#ifndef NANO_SMALL
57extern char *backup_dir;
58#endif
59
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +000060extern WINDOW *topwin, *edit, *bottomwin;
Chris Allegretta1a6e9042000-12-14 13:56:28 +000061extern char *filename;
David Lawrence Ramsey5db0cdc2002-06-28 22:45:14 +000062extern struct stat originalfilestat;
Chris Allegretta31925e42000-11-02 04:40:39 +000063extern char *answer;
Chris Allegretta6df90f52002-07-19 01:08:59 +000064extern char *hblank;
65#ifndef DISABLE_HELP
66extern char *help_text;
67#endif
Chris Allegretta27eb13f2000-11-05 16:52:21 +000068extern char *last_search;
69extern char *last_replace;
Chris Allegrettae1f14522001-09-19 03:19:43 +000070#ifndef DISABLE_OPERATINGDIR
71extern char *operating_dir;
Chris Allegrettaf5de33a2002-02-27 04:14:16 +000072extern char *full_operating_dir;
Chris Allegrettae1f14522001-09-19 03:19:43 +000073#endif
Chris Allegretta8d8e0122001-04-18 04:28:54 +000074#ifndef DISABLE_SPELLER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +000075extern char *alt_speller;
Chris Allegretta6df90f52002-07-19 01:08:59 +000076#endif
77
Chris Allegretta65f075d2003-02-13 03:03:49 +000078extern int resetstatuspos;
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000079extern struct stat fileinfo;
David Lawrence Ramseyb9775152004-03-19 02:15:42 +000080extern filestruct *current, *fileage, *edittop, *filebot;
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +000081extern filestruct *cutbuffer;
82#ifndef NANO_SMALL
83extern filestruct *mark_beginbuf;
84#endif
Chris Allegretta2d7893d2001-07-11 02:08:33 +000085
Chris Allegretta355fbe52001-07-14 19:32:47 +000086#ifdef ENABLE_MULTIBUFFER
Chris Allegrettaf2387fb2002-04-10 02:31:20 +000087extern openfilestruct *open_files;
Chris Allegretta2d7893d2001-07-11 02:08:33 +000088#endif
89
Chris Allegretta08893e02001-11-29 02:42:27 +000090#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +000091extern const colortype *colorstrings;
Chris Allegrettab6c5dc22002-05-04 03:47:33 +000092extern syntaxtype *syntaxes;
Chris Allegretta09900ff2002-05-04 04:23:30 +000093extern char *syntaxstr;
Chris Allegretta08893e02001-11-29 02:42:27 +000094#endif
95
Chris Allegrettaa2ea1932000-06-06 05:53:49 +000096extern shortcut *shortcut_list;
Chris Allegrettaa8c22572002-02-15 19:17:02 +000097extern shortcut *main_list, *whereis_list;
98extern shortcut *replace_list, *goto_list;
99extern shortcut *writefile_list, *insertfile_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000100extern shortcut *replace_list_2;
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000101#ifndef NANO_SMALL
102extern shortcut *extcmd_list;
103#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000104#ifndef DISABLE_HELP
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000105extern shortcut *help_list;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000106#endif
107#ifndef DISABLE_SPELLER
108extern shortcut *spell_list;
109#endif
Rocco Corsiaf5c3022001-01-12 07:51:05 +0000110#ifndef DISABLE_BROWSER
Chris Allegrettaa8c22572002-02-15 19:17:02 +0000111extern shortcut *browser_list, *gotodir_list;
Chris Allegrettaf4b96012001-01-03 07:11:47 +0000112#endif
Chris Allegretta201f1d92003-02-05 02:51:19 +0000113
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000114#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
Chris Allegretta6df90f52002-07-19 01:08:59 +0000115extern const shortcut *currshortcut;
Chris Allegretta201f1d92003-02-05 02:51:19 +0000116#endif
Chris Allegretta805c26d2000-09-06 13:39:17 +0000117
118#ifdef HAVE_REGEX_H
Chris Allegretta9fc8d432000-07-07 01:49:52 +0000119extern regex_t search_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000120extern regmatch_t regmatches[10];
Chris Allegretta3533a342002-03-24 23:19:32 +0000121#ifdef ENABLE_COLOR
Chris Allegrettab6c5dc22002-05-04 03:47:33 +0000122extern regex_t syntaxfile_regexp;
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000123extern regmatch_t synfilematches[1];
Chris Allegretta7162e3d2002-04-06 05:02:14 +0000124#endif /* ENABLE_COLOR */
Chris Allegretta6df90f52002-07-19 01:08:59 +0000125#endif /* HAVE_REGEX_H */
126
127#ifndef NANO_SMALL
128extern toggle *toggles;
Chris Allegretta805c26d2000-09-06 13:39:17 +0000129#endif
130
Chris Allegretta5beed502003-01-05 20:41:21 +0000131#ifndef NANO_SMALL
132extern historyheadtype search_history;
133extern historyheadtype replace_history;
134#endif
135
Chris Allegrettaa0d89972003-02-03 03:32:08 +0000136extern int curses_ended;
137
David Lawrence Ramseyf28f50e2004-01-09 23:04:55 +0000138/* Functions we want available. */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000139
Chris Allegretta6df90f52002-07-19 01:08:59 +0000140/* Public functions in color.c */
141#ifdef ENABLE_COLOR
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000142void set_colorpairs(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000143void do_colorinit(void);
144void update_color(void);
145#endif /* ENABLE_COLOR */
Chris Allegrettaa2ea1932000-06-06 05:53:49 +0000146
Chris Allegretta6df90f52002-07-19 01:08:59 +0000147/* Public functions in cut.c */
David Lawrence Ramseyc833d9e2004-05-29 15:36:58 +0000148void cutbuffer_reset(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000149filestruct *get_cutbottom(void);
David Lawrence Ramsey44e7f822004-03-30 04:17:10 +0000150void add_to_cutbuffer(filestruct *inptr, int allow_concat);
David Lawrence Ramsey82138502003-12-24 08:03:54 +0000151void cut_marked_segment(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000152void do_cut_text(void);
153void do_uncut_text(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000154
155/* Public functions in files.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000156void load_file(int update);
157void new_file(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000158filestruct *read_line(char *buf, filestruct *prev, int *line1ins, size_t
159 len);
David Lawrence Ramseyd717d4b2004-07-10 16:53:17 +0000160void read_file(FILE *f, const char *filename, int quiet);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000161int open_file(const char *filename, int insert, int quiet);
162char *get_next_filename(const char *name);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000163void do_insertfile(int loading_file);
164void do_insertfile_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000165#ifdef ENABLE_MULTIBUFFER
166openfilestruct *make_new_opennode(openfilestruct *prevnode);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000167void splice_opennode(openfilestruct *begin, openfilestruct *newnode,
168 openfilestruct *end);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000169void unlink_opennode(const openfilestruct *fileptr);
170void delete_opennode(openfilestruct *fileptr);
171void free_openfilestruct(openfilestruct *src);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000172void add_open_file(int update);
173void load_open_file(void);
174void open_prevfile(int closing_file);
175void open_prevfile_void(void);
176void open_nextfile(int closing_file);
177void open_nextfile_void(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000178int close_open_file(void);
179#endif
180#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000181char *get_full_path(const char *origpath);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000182#endif
183#ifndef DISABLE_SPELLER
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000184char *check_writable_directory(const char *path);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000185char *safe_tempnam(const char *dirname, const char *filename_prefix);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000186#endif
187#ifndef DISABLE_OPERATINGDIR
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000188void init_operating_dir(void);
189int check_operating_dir(const char *currpath, int allow_tabcomp);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000190#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000191#ifndef NANO_SMALL
192void init_backup_dir(void);
193#endif
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000194int write_file(const char *name, int tmp, int append, int nonamechange);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000195#ifndef NANO_SMALL
David Lawrence Ramsey2f0d03b2004-05-28 00:15:28 +0000196int write_marked(const char *name, int tmp, int append);
David Lawrence Ramsey35961c42004-01-23 19:34:03 +0000197#endif
David Lawrence Ramsey6aec4b82004-03-15 20:26:30 +0000198int do_writeout(int exiting);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000199void do_writeout_void(void);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000200char *real_dir_from_tilde(const char *buf);
Chris Allegretta7662c862003-01-13 01:35:15 +0000201#ifndef DISABLE_TABCOMP
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000202int append_slash_if_dir(char *buf, int *lastwastab, int *place);
203char **username_tab_completion(char *buf, int *num_matches);
204char **cwd_tab_completion(char *buf, int *num_matches);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000205char *input_tab(char *buf, int place, int *lastwastab, int *newplace,
206 int *list);
Chris Allegretta7662c862003-01-13 01:35:15 +0000207#endif
David Lawrence Ramsey04e42a62004-02-28 16:24:31 +0000208const char *tail(const char *foo);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000209#ifndef DISABLE_BROWSER
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000210int diralphasort(const void *va, const void *vb);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000211void free_charptrarray(char **array, size_t len);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000212void striponedir(char *foo);
Chris Allegretta858d9d92003-01-30 00:53:32 +0000213int readable_dir(const char *path);
David Lawrence Ramseye21adfa2002-09-13 18:14:04 +0000214char **browser_init(const char *path, int *longest, int *numents);
215char *do_browser(const char *inpath);
216char *do_browse_from(const char *inpath);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000217#endif
218
219/* Public functions in global.c */
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000220size_t length_of_list(const shortcut *s);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000221#ifndef NANO_SMALL
David Lawrence Ramsey2ad32092004-07-07 14:36:44 +0000222void toggle_init_one(int val, const char *desc, long flag);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000223void toggle_init(void);
224#ifdef DEBUG
225void free_toggles(void);
226#endif
227#endif
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000228void sc_init_one(shortcut **shortcutage, int key, const char *desc,
229#ifndef DISABLE_HELP
230 const char *help,
231#endif
232 int metaval, int funcval, int miscval, int view, void
233 (*func)(void));
Chris Allegrettadab017e2002-04-23 10:56:06 +0000234void shortcut_init(int unjustify);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000235void free_shortcutage(shortcut **shortcutage);
Chris Allegretta6232d662002-05-12 19:52:15 +0000236#ifdef DEBUG
Chris Allegrettadab017e2002-04-23 10:56:06 +0000237void thanks_for_all_the_fish(void);
Chris Allegretta6232d662002-05-12 19:52:15 +0000238#endif
Chris Allegrettadab017e2002-04-23 10:56:06 +0000239
Chris Allegretta6df90f52002-07-19 01:08:59 +0000240/* Public functions in move.c */
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000241void do_first_line(void);
242void do_last_line(void);
243void do_home(void);
244void do_end(void);
245void do_page_up(void);
246void do_page_down(void);
247void do_up(void);
248void do_down(void);
249void do_left(int allow_update);
250void do_left_void(void);
251void do_right(int allow_update);
252void do_right_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000253
254/* Public functions in nano.c */
David Lawrence Ramseyda141062004-05-25 19:41:11 +0000255void finish(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000256void die(const char *msg, ...);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000257void die_save_file(const char *die_filename);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000258void die_too_small(void);
259void print_view_warning(void);
260void global_init(int save_cutbuffer);
261void window_init(void);
David Lawrence Ramseyf5b256b2003-10-03 20:26:25 +0000262#ifndef DISABLE_MOUSE
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000263void mouse_init(void);
David Lawrence Ramsey9b13ff32002-12-22 16:30:00 +0000264#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000265#ifndef DISABLE_HELP
266void help_init(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000267#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000268filestruct *make_new_node(filestruct *prevnode);
269filestruct *copy_node(const filestruct *src);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000270void splice_node(filestruct *begin, filestruct *newnode, filestruct
271 *end);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000272void unlink_node(const filestruct *fileptr);
273void delete_node(filestruct *fileptr);
274filestruct *copy_filestruct(const filestruct *src);
275void free_filestruct(filestruct *src);
276void renumber_all(void);
277void renumber(filestruct *fileptr);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000278void print1opt(const char *shortflag, const char *longflag, const char
279 *desc);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000280void usage(void);
281void version(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000282int no_help(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000283void nano_disabled_msg(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000284#ifndef NANO_SMALL
285RETSIGTYPE cancel_fork(int signal);
286int open_pipe(const char *command);
287#endif
288#ifndef DISABLE_MOUSE
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000289void do_mouse(void);
290#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000291void do_char(char ch);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000292void do_verbatim_input(void);
293void do_backspace(void);
294void do_delete(void);
295void do_tab(void);
296void do_enter(void);
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000297#ifndef NANO_SMALL
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000298void do_next_word(void);
299void do_prev_word(void);
300void do_mark(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000301#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000302#ifndef DISABLE_WRAPPING
David Lawrence Ramseyc97acfb2003-09-10 20:08:00 +0000303void wrap_reset(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000304int do_wrap(filestruct *inptr);
305#endif
306#ifndef DISABLE_SPELLER
307int do_int_spell_fix(const char *word);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000308const char *do_int_speller(char *tempfile_name);
309const char *do_alt_speller(char *tempfile_name);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000310void do_spell(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000311#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000312#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
313size_t indent_length(const char *line);
314#endif
315#ifndef DISABLE_JUSTIFY
David Lawrence Ramsey1cadddd2004-05-17 20:32:51 +0000316void justify_format(filestruct *line, size_t skip);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000317#ifdef HAVE_REGEX_H
318size_t quote_length(const char *line, const regex_t *qreg);
319#else
320size_t quote_length(const char *line);
321#endif
322#ifdef HAVE_REGEX_H
323# define IFREG(a, b) a, b
324#else
325# define IFREG(a, b) a
326#endif
David Lawrence Ramseyd4693cb2004-05-14 01:17:25 +0000327int quotes_match(const char *a_line, size_t a_quote, IFREG(const char
328 *b_line, const regex_t *qreg));
329size_t indents_match(const char *a_line, size_t a_indent, const char
330 *b_line, size_t b_indent);
331filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
332 quote_len);
Chris Allegrettacff6e6f2003-02-03 03:22:02 +0000333int breakable(const char *line, int goal);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000334int break_line(const char *line, int goal, int force);
David Lawrence Ramsey2e3aeae2004-05-24 05:52:35 +0000335int do_para_search(justbegend search_type, size_t *quote, size_t *par,
336 size_t *indent, int do_refresh);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000337void do_para_begin(void);
338void do_para_end(void);
339void do_justify(int full_justify);
340void do_justify_void(void);
341void do_full_justify(void);
David Lawrence Ramseyd893fa92004-04-30 04:49:02 +0000342#endif /* !DISABLE_JUSTIFY */
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000343void do_exit(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000344void signal_init(void);
David Lawrence Ramsey2ab03f62002-10-17 02:19:31 +0000345RETSIGTYPE handle_hupterm(int signal);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000346RETSIGTYPE do_suspend(int signal);
347RETSIGTYPE do_cont(int signal);
348#ifndef NANO_SMALL
349void handle_sigwinch(int s);
David Lawrence Ramsey369732f2004-02-16 20:32:40 +0000350void allow_pending_sigwinch(int allow);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000351#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000352#ifndef NANO_SMALL
353void do_toggle(const toggle *which);
354#endif
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000355#if !defined(NANO_SMALL) || defined(USE_SLANG)
356void disable_signals(void);
357#endif
358#ifndef NANO_SMALL
359void enable_signals(void);
360#endif
361void disable_flow_control(void);
362void enable_flow_control(void);
Chris Allegrettaf2387fb2002-04-10 02:31:20 +0000363
Chris Allegretta6df90f52002-07-19 01:08:59 +0000364/* Public functions in rcfile.c */
Chris Allegretta7a500092001-04-19 21:13:46 +0000365#ifdef ENABLE_NANORC
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000366void rcfile_error(const char *msg, ...);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000367char *parse_next_word(char *ptr);
368char *parse_argument(char *ptr);
369#ifdef ENABLE_COLOR
370int colortoint(const char *colorname, int *bright);
371char *parse_next_regex(char *ptr);
David Lawrence Ramseyedab0cc2004-07-03 03:09:12 +0000372int nregcomp(regex_t *preg, const char *regex, int eflags);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000373void parse_syntax(char *ptr);
374void parse_colors(char *ptr);
375#endif /* ENABLE_COLOR */
376void parse_rcfile(FILE *rcstream);
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000377void do_rcfile(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000378#endif /* ENABLE_NANORC */
Chris Allegretta8d8e0122001-04-18 04:28:54 +0000379
Chris Allegretta6df90f52002-07-19 01:08:59 +0000380/* Public functions in search.c */
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000381#ifdef HAVE_REGEX_H
Chris Allegretta5d715142003-01-29 04:18:37 +0000382int regexp_init(const char *regexp);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000383void regexp_cleanup(void);
384#endif
385void not_found_msg(const char *str);
386void search_abort(void);
387void search_init_globals(void);
388int search_init(int replacing);
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000389int is_whole_word(int curr_pos, const char *datastr, const char
390 *searchword);
391int findnextstr(int can_display_wrap, int wholeword, const filestruct
392 *begin, size_t beginx, const char *needle, int no_sameline);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000393void do_search(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000394#ifndef NANO_SMALL
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000395void do_research(void);
David Lawrence Ramsey5aa39832004-05-05 21:36:50 +0000396#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000397void replace_abort(void);
398#ifdef HAVE_REGEX_H
399int replace_regexp(char *string, int create_flag);
400#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000401char *replace_line(const char *needle);
402int do_replace_loop(const char *needle, const filestruct *real_current,
403 size_t *real_current_x, int wholewords);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000404void do_replace(void);
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +0000405void do_gotoline(ssize_t line, int save_pos);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000406void do_gotoline_void(void);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000407#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
408void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant);
409#endif
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000410void do_find_bracket(void);
Chris Allegretta5beed502003-01-05 20:41:21 +0000411#ifndef NANO_SMALL
412void history_init(void);
413historytype *find_node(historytype *h, char *s);
414void remove_node(historytype *r);
415void insert_node(historytype *h, const char *s);
416void update_history(historyheadtype *h, char *s);
417char *get_history_older(historyheadtype *h);
418char *get_history_newer(historyheadtype *h);
419char *get_history_completion(historyheadtype *h, char *s);
420void free_history(historyheadtype *h);
Chris Allegrettaf3de8b52003-01-16 23:44:46 +0000421#ifdef ENABLE_NANORC
David Lawrence Ramseyc3724882004-05-27 18:39:16 +0000422void load_history(void);
Chris Allegrettaf3de8b52003-01-16 23:44:46 +0000423void save_history(void);
424#endif
Chris Allegretta5beed502003-01-05 20:41:21 +0000425#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000426
427/* Public functions in utils.c */
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000428#ifdef HAVE_REGEX_H
Chris Allegrettad8451932003-03-11 03:50:40 +0000429#ifdef BROKEN_REGEXEC
430int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
431 regmatch_t pmatch[], int eflags);
432#endif
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000433int regexp_bol_or_eol(const regex_t *preg, const char *string);
434#endif
David Lawrence Ramsey9830d752004-05-13 17:19:54 +0000435#ifndef HAVE_ISBLANK
436int is_blank_char(int c);
437#endif
Chris Allegrettacf287c82002-07-20 13:57:41 +0000438int is_cntrl_char(int c);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000439int num_of_digits(int n);
David Lawrence Ramsey49c3f242004-07-12 16:07:14 +0000440int parse_num(const char *str, ssize_t *val);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000441void align(char **strp);
442void null_at(char **data, size_t index);
443void unsunder(char *str, size_t true_len);
444void sunder(char *str);
Chris Allegretta4f5335d2003-08-04 02:51:12 +0000445#ifndef HAVE_STRCASECMP
446int nstricmp(const char *s1, const char *s2);
447#endif
448#ifndef HAVE_STRNCASECMP
449int nstrnicmp(const char *s1, const char *s2, size_t n);
450#endif
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000451#ifndef HAVE_STRCASESTR
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000452const char *nstristr(const char *haystack, const char *needle);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000453#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000454#ifndef NANO_SMALL
David Lawrence Ramseya3370c42004-04-05 01:08:14 +0000455const char *revstrstr(const char *haystack, const char *needle, const
456 char *rev_start);
457const char *revstristr(const char *haystack, const char *needle, const
458 char *rev_start);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000459#endif
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000460#ifndef HAVE_STRNLEN
461size_t nstrnlen(const char *s, size_t maxlen);
462#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000463const char *strstrwrapper(const char *haystack, const char *needle,
David Lawrence Ramsey1044d742004-02-24 20:41:39 +0000464 const char *start);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000465void nperror(const char *s);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000466void *nmalloc(size_t howmuch);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000467void *nrealloc(void *ptr, size_t howmuch);
468char *mallocstrcpy(char *dest, const char *src);
469void new_magicline(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000470#ifndef NANO_SMALL
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000471void mark_order(const filestruct **top, size_t *top_x, const filestruct
472 **bot, size_t *bot_x);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000473#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000474#ifndef DISABLE_TABCOMP
475int check_wildcard_match(const char *text, const char *pattern);
476#endif
Chris Allegretta6df90f52002-07-19 01:08:59 +0000477
478/* Public functions in winio.c */
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000479#ifndef NANO_SMALL
480void reset_kbinput(void);
481#endif
David Lawrence Ramsey1576d532004-03-19 21:46:34 +0000482int get_kbinput(WINDOW *win, int *meta_key);
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000483int get_translated_kbinput(int kbinput, int *es
484#ifndef NANO_SMALL
485 , int reset
486#endif
487 );
488int get_ascii_kbinput(int kbinput, size_t ascii_digits
489#ifndef NANO_SMALL
490 , int reset
491#endif
492 );
493int get_control_kbinput(int kbinput);
David Lawrence Ramseye65e6392004-06-04 18:18:17 +0000494int get_escape_seq_kbinput(int *escape_seq, size_t es_len, int
495 *ignore_seq);
David Lawrence Ramseyc2c5a512004-01-23 19:26:17 +0000496int get_escape_seq_abcd(int kbinput);
David Lawrence Ramseyf7080372004-07-08 17:15:10 +0000497int *get_verbatim_kbinput(WINDOW *win, int *v_kbinput, size_t *v_len,
498 int allow_ascii);
David Lawrence Ramsey48ae9862004-05-28 17:23:33 +0000499int get_untranslated_kbinput(int kbinput, size_t position, int
500 allow_ascii
501#ifndef NANO_SMALL
502 , int reset
503#endif
504 );
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000505#ifndef DISABLE_MOUSE
David Lawrence Ramseyebd0d7c2004-07-01 18:59:52 +0000506int get_mouseinput(int *mouse_x, int *mouse_y, int allow_shortcuts);
David Lawrence Ramsey14bf8032004-05-22 20:19:15 +0000507#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000508size_t xplustabs(void);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000509size_t actual_x(const char *str, size_t xplus);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000510size_t strnlenpt(const char *buf, size_t size);
511size_t strlenpt(const char *buf);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000512void blank_titlebar(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000513void blank_edit(void);
514void blank_statusbar(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000515void check_statblank(void);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000516void blank_bottombars(void);
517char *display_string(const char *buf, size_t start_col, size_t len);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000518void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
Chris Allegrettaf717f982003-02-13 22:25:01 +0000519int nanogetstr(int allowtabs, const char *buf, const char *def,
Chris Allegretta5beed502003-01-05 20:41:21 +0000520#ifndef NANO_SMALL
521 historyheadtype *history_list,
522#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000523 const shortcut *s
524#ifndef DISABLE_TABCOMP
525 , int *list
526#endif
Chris Allegretta65f075d2003-02-13 03:03:49 +0000527 );
Chris Allegrettaf717f982003-02-13 22:25:01 +0000528void titlebar(const char *path);
David Lawrence Ramseyd7fd2002004-05-18 01:20:36 +0000529void set_modified(void);
530void statusbar(const char *msg, ...);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000531void bottombars(const shortcut *s);
David Lawrence Ramseyfa394042004-05-23 21:11:14 +0000532void onekey(const char *keystroke, const char *desc, size_t len);
David Lawrence Ramsey1f28b8f2002-09-27 14:21:59 +0000533#ifndef NDEBUG
534int check_linenumbers(const filestruct *fileptr);
535#endif
David Lawrence Ramsey2dd7ed12003-09-29 05:15:24 +0000536size_t get_page_start(size_t column);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000537void reset_cursor(void);
David Lawrence Ramsey07d3feb2004-04-16 05:15:11 +0000538void edit_add(const filestruct *fileptr, const char *converted, int
539 yval, size_t start);
David Lawrence Ramsey5ffbec52003-09-16 01:16:49 +0000540void update_line(const filestruct *fileptr, size_t index);
David Lawrence Ramsey2ed225f2004-05-28 20:44:09 +0000541int need_horizontal_update(int old_placewewant);
542int need_vertical_update(int old_placewewant);
543void edit_scroll(updown direction, int nlines);
David Lawrence Ramseyc21790d2004-05-30 03:19:52 +0000544void edit_redraw(const filestruct *old_current, int old_pww);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000545void edit_refresh(void);
David Lawrence Ramsey1356a0a2003-09-10 20:31:02 +0000546void edit_update(filestruct *fileptr, topmidnone location);
David Lawrence Ramsey6aec4b82004-03-15 20:26:30 +0000547int statusq(int allowtabs, const shortcut *s, const char *def,
Chris Allegretta5beed502003-01-05 20:41:21 +0000548#ifndef NANO_SMALL
549 historyheadtype *history_list,
550#endif
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000551 const char *msg, ...);
David Lawrence Ramseyf4276942003-12-24 03:33:09 +0000552int do_yesno(int all, const char *msg);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000553void total_refresh(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000554void display_main_list(void);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000555void do_cursorpos(int constant);
556void do_cursorpos_void(void);
David Lawrence Ramsey576bf332004-07-12 03:10:30 +0000557size_t line_len(const char *ptr);
David Lawrence Ramsey72e51ab2004-07-02 14:31:03 +0000558void do_help(void);
David Lawrence Ramseyad40fdb2002-09-06 20:35:28 +0000559void do_replace_highlight(int highlight_flag, const char *word);
Chris Allegretta6df90f52002-07-19 01:08:59 +0000560#ifdef DEBUG
561void dump_buffer(const filestruct *inptr);
562void dump_buffer_reverse(void);
563#endif
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000564#ifdef NANO_EXTRA
Chris Allegretta34318ed2001-01-31 23:22:36 +0000565void do_credits(void);
Chris Allegretta8a0de3b2000-11-24 20:45:14 +0000566#endif