Commit 819c7f03 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

add DB's overhaul of the paragraph searching code and some of the

justify code, as it makes some code much more understandable and fixes a
bug where searching for the previous paragraph would move the cursor too
high in one case


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1873 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 235 additions and 240 deletions
+235 -240
......@@ -52,6 +52,14 @@ CVS code -
- Convert placewewant to a size_t, and convert some functions
that use it as a parameter to use size_t as well. (David
Benbennick and DLR)
- Overhaul the paragraph searching code and some of the justify
code to clarify it and fix a bug where searches from the
previous paragraph would move up too far. Also make
quotestr-related variables global so that they only have to be
compiled once, and remove the no-longer-needed IFREG() macro.
New functions begpar() and inpar(); changes to quote_length(),
quotes_match(), do_para_search(), do_para_begin(),
do_para_end(), and do_justify(). (David Benbennick)
- files.c:
close_open_file()
- Tweak to no longer rely on the return values of
......@@ -106,11 +114,13 @@ CVS code -
- nano.h:
- Reassign the key for full justification to Ctrl-U, for
compatibility with the current version of Pico. (DLR)
- Remove justbegend enum, as it's no longer needed. (DLR)
- proto.h:
- Change the variables in the prototypes for do_justify(),
get_verbatim_kbinput(), and get_mouseinput() to match the ones
used in the actual functions. (DLR)
- Remove unused declaration of temp_opt. (David Benbennick)
- Add missing copy_file() prototype. (David Benbennick)
- rcfile.c:
rcfile_msg()
- Removed along with the related static int errors, and replaced
......
......@@ -80,6 +80,13 @@ char *brackets = NULL; /* Closing brackets that can follow
sentences. */
char *quotestr = NULL; /* Quote string. The default value is
set in main(). */
#ifdef HAVE_REGEX_H
regex_t quotereg; /* Compiled quotestr regular expression. */
int quoterc; /* Did it compile? */
char *quoteerr = NULL; /* The error message. */
#else
size_t quotelen; /* strlen(quotestr) */
#endif
#endif
#ifndef NANO_SMALL
......@@ -1073,6 +1080,10 @@ void thanks_for_all_the_fish(void)
#ifndef DISABLE_JUSTIFY
if (quotestr != NULL)
free(quotestr);
#ifdef HAVE_REGEX_H
regfree(&quotereg);
free(quoteerr);
#endif
#endif
#ifndef NANO_SMALL
if (backup_dir != NULL)
......
This diff is collapsed.
......@@ -465,10 +465,6 @@ typedef struct historyheadtype {
#define VIEW TRUE
#define NOVIEW FALSE
typedef enum {
JUSTIFY, BEGIN, END
} justbegend;
typedef enum {
UP, DOWN
} updown;
......
......@@ -51,6 +51,13 @@ extern char *whitespace;
extern char *punct;
extern char *brackets;
extern char *quotestr;
#ifdef HAVE_REGEX_H
extern regex_t quotereg;
extern int quoterc;
extern char *quoteerr;
#else
extern size_t quotelen;
#endif
#endif
#ifndef NANO_SMALL
......@@ -191,6 +198,7 @@ int check_operating_dir(const char *currpath, int allow_tabcomp);
#ifndef NANO_SMALL
void init_backup_dir(void);
#endif
int copy_file(FILE *inn, FILE *out);
int write_file(const char *name, int tmp, int append, int nonamechange);
#ifndef NANO_SMALL
int write_marked(const char *name, int tmp, int append);
......@@ -314,28 +322,19 @@ size_t indent_length(const char *line);
#endif
#ifndef DISABLE_JUSTIFY
void justify_format(filestruct *line, size_t skip);
#ifdef HAVE_REGEX_H
size_t quote_length(const char *line, const regex_t *qreg);
#else
size_t quote_length(const char *line);
#endif
#ifdef HAVE_REGEX_H
# define IFREG(a, b) a, b
#else
# define IFREG(a, b) a
#endif
int quotes_match(const char *a_line, size_t a_quote, IFREG(const char
*b_line, const regex_t *qreg));
int quotes_match(const char *a_line, size_t a_quote, const char *b_line);
size_t indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent);
bool begpar(const filestruct *const foo);
void do_para_begin(void);
bool inpar(const char *str);
void do_para_end(void);
filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t
quote_len);
int breakable(const char *line, int goal);
int break_line(const char *line, int goal, int force);
int do_para_search(justbegend search_type, size_t *quote, size_t *par,
size_t *indent, int do_refresh);
void do_para_begin(void);
void do_para_end(void);
bool do_para_search(size_t *const quote, size_t *const par);
void do_justify(int full_justify);
void do_justify_void(void);
void do_full_justify(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment