From 02b697659eadbaee01dc6529714e5ed5b6f1e7f5 Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Fri, 4 Jun 1999 18:13:26 +0000 Subject: [PATCH] Don't adjust indentation after removing a box unless something was removed on the west side East Padding made dynamic, i.e. dependant on the east side size --- src/boxes.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/boxes.c b/src/boxes.c index 0bff1d1..99bb0f7 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -3,7 +3,7 @@ * Date created: March 18, 1999 (Thursday, 15:09h) * Author: Thomas Jensen * tsjensen@stud.informatik.uni-erlangen.de - * Version: $Id: boxes.c,v 1.10 1999/06/03 18:54:05 tsjensen Exp tsjensen $ + * Version: $Id: boxes.c,v 1.11 1999/06/03 19:24:14 tsjensen Exp tsjensen $ * Language: ANSI C * Platforms: sunos5/sparc, for now * World Wide Web: http://home.pages.de/~jensen/boxes/ @@ -18,6 +18,9 @@ * Revision History: * * $Log: boxes.c,v $ + * Revision 1.11 1999/06/03 19:24:14 tsjensen + * a few fixes related to box removal (as expected) + * * Revision 1.10 1999/06/03 18:54:05 tsjensen * lots of fixes * Added remove box functionality, which remains to be tested @@ -83,19 +86,12 @@ extern int optind, opterr, optopt; /* for getopt() */ static const char rcsid_boxes_c[] = - "$Id: boxes.c,v 1.10 1999/06/03 18:54:05 tsjensen Exp tsjensen $"; + "$Id: boxes.c,v 1.11 1999/06/03 19:24:14 tsjensen Exp tsjensen $"; extern FILE *yyin; /* lex input file */ -/* Number of spaces appended to all input lines prior to removing a box. - * A greater number takes more space and time, but enables the correct - * removal of boxes whose east sides consist of lots of spaces (the given - * value). - */ -#define EAST_PADDING 20 - /* max. allowed tab stop distance */ #define MAX_TABSTOP 16 @@ -1956,7 +1952,7 @@ static int output_box (const sentry_t *thebox) thebox[BRIG].chars[j]); } - obuf_len = strlen (obuf); /* TODO Can't we compute this?! */ + obuf_len = strlen (obuf); if (obuf_len > LINE_MAX) { size_t newlen = LINE_MAX; @@ -2493,8 +2489,9 @@ int remove_box() size_t textend = 0; /* index of 1st line of south side */ size_t boxstart = 0; /* index of 1st line of box */ size_t boxend = 0; /* index of 1st line trailing the box */ - int m; /* true if a match was found */ + int m; /* true if a match was found */ size_t j; /* loop counter */ + int did_something = 0; /* true if there was something to remove */ #ifdef DEBUG fprintf (stderr, "remove_box()\n"); @@ -2512,8 +2509,12 @@ int remove_box() /* * Add trailing spaces to input lines (needed for recognition) + * Also append a number of spaces to all input lines. A greater number + * takes more space and time, but enables the correct removal of boxes + * whose east sides consist of lots of spaces (the given value). So we + * add a number of spaces equal to the east side width. */ - input.maxline += EAST_PADDING; + input.maxline += opt.design->shape[NE].width; for (j=0; jshape[NW].width; ++c) { - if (input.lines[j].text[c] != ' ') - break; + } + + /* + * Remove as many spaces from the left side of the line as the west side + * of the box was wide. Don't do it if we never removed anything from the + * west side. Don't harm the line's text if there aren't enough spaces. + */ + if (did_something) { + for (j=textstart; jshape[NW].width; ++c) { + if (input.lines[j].text[c] != ' ') + break; + } + memmove (input.lines[j].text, input.lines[j].text + c, + input.lines[j].len - c); } - memmove (input.lines[j].text, input.lines[j].text + c, - input.lines[j].len - c); } /*