mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-21 02:08:02 +02:00
Bugfix: justify_line() still didn't work right. It should now. (Man, I got
a strong sense of dja vu! Weird ...)
This commit is contained in:
parent
4a6025908d
commit
3a59866e97
@ -4,7 +4,7 @@
|
|||||||
* Date created: June 23, 1999 (Wednesday, 20:10h)
|
* Date created: June 23, 1999 (Wednesday, 20:10h)
|
||||||
* Author: Copyright (C) 1999 Thomas Jensen
|
* Author: Copyright (C) 1999 Thomas Jensen
|
||||||
* tsjensen@stud.informatik.uni-erlangen.de
|
* tsjensen@stud.informatik.uni-erlangen.de
|
||||||
* Version: $Id: generate.c,v 1.4 1999/07/21 16:50:48 tsjensen Exp tsjensen $
|
* Version: $Id: generate.c,v 1.5 1999/08/16 18:30:32 tsjensen Exp tsjensen $
|
||||||
* Language: ANSI C
|
* Language: ANSI C
|
||||||
* World Wide Web: http://home.pages.de/~jensen/boxes/
|
* World Wide Web: http://home.pages.de/~jensen/boxes/
|
||||||
* Purpose: Box generation, i.e. the drawing of boxes
|
* Purpose: Box generation, i.e. the drawing of boxes
|
||||||
@ -25,6 +25,9 @@
|
|||||||
* Revision History:
|
* Revision History:
|
||||||
*
|
*
|
||||||
* $Log: generate.c,v $
|
* $Log: generate.c,v $
|
||||||
|
* Revision 1.5 1999/08/16 18:30:32 tsjensen
|
||||||
|
* Bugfix: justify_line() still didn't work right. It should now.
|
||||||
|
*
|
||||||
* Revision 1.4 1999/07/21 16:50:48 tsjensen
|
* Revision 1.4 1999/07/21 16:50:48 tsjensen
|
||||||
* Added GNU GPL disclaimer
|
* Added GNU GPL disclaimer
|
||||||
* Bugfix: When doing the line justification in output_box(), the padding
|
* Bugfix: When doing the line justification in output_box(), the padding
|
||||||
@ -55,7 +58,7 @@
|
|||||||
#include "generate.h"
|
#include "generate.h"
|
||||||
|
|
||||||
static const char rcsid_generate_c[] =
|
static const char rcsid_generate_c[] =
|
||||||
"$Id: generate.c,v 1.4 1999/07/21 16:50:48 tsjensen Exp tsjensen $";
|
"$Id: generate.c,v 1.5 1999/08/16 18:30:32 tsjensen Exp tsjensen $";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -697,12 +700,11 @@ err:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int justify_line (line_t *line, const size_t topwidth, const int skew)
|
static int justify_line (line_t *line, const int skew)
|
||||||
/*
|
/*
|
||||||
* Justify input line according to specified justification
|
* Justify input line according to specified justification
|
||||||
*
|
*
|
||||||
* line line to justify
|
* line line to justify
|
||||||
* topwidth width of top box part
|
|
||||||
* skew difference in spaces right/left of text block (hpr-hpl)
|
* skew difference in spaces right/left of text block (hpr-hpl)
|
||||||
*
|
*
|
||||||
* line is assumed to be already free of trailing whitespace.
|
* line is assumed to be already free of trailing whitespace.
|
||||||
@ -736,8 +738,8 @@ static int justify_line (line_t *line, const size_t topwidth, const int skew)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
shift = (topwidth - newlen) / 2;
|
shift = (input.maxline - newlen) / 2;
|
||||||
if ((topwidth - newlen) % 2 && skew == 1)
|
if ((input.maxline - newlen) % 2 && skew == 1)
|
||||||
++shift;
|
++shift;
|
||||||
newtext = (char *) calloc (shift + newlen + 1, sizeof(char));
|
newtext = (char *) calloc (shift + newlen + 1, sizeof(char));
|
||||||
if (newtext == NULL) {
|
if (newtext == NULL) {
|
||||||
@ -752,6 +754,10 @@ static int justify_line (line_t *line, const size_t topwidth, const int skew)
|
|||||||
}
|
}
|
||||||
memset (spaces, ' ', shift);
|
memset (spaces, ' ', shift);
|
||||||
spaces[shift] = '\0';
|
spaces[shift] = '\0';
|
||||||
|
#if defined(DEBUG) && 0
|
||||||
|
fprintf (stderr, "j(c): newlen=%d, shift=%d, spaces=\"%s\"\n",
|
||||||
|
newlen, shift, spaces);
|
||||||
|
#endif
|
||||||
strncpy (newtext, spaces, shift);
|
strncpy (newtext, spaces, shift);
|
||||||
strncat (newtext, p, newlen);
|
strncat (newtext, p, newlen);
|
||||||
newtext[shift+newlen] = '\0';
|
newtext[shift+newlen] = '\0';
|
||||||
@ -985,17 +991,11 @@ int output_box (const sentry_t *thebox)
|
|||||||
else if (j < nol-thebox[BBOT].height) {
|
else if (j < nol-thebox[BBOT].height) {
|
||||||
long ti = j - thebox[BTOP].height - (vfill-vfill2);
|
long ti = j - thebox[BTOP].height - (vfill-vfill2);
|
||||||
if (ti < (long) input.anz_lines) { /* box content (lines) */
|
if (ti < (long) input.anz_lines) { /* box content (lines) */
|
||||||
size_t refwidth = thebox[BTOP].width;
|
#if defined(DEBUG) && 0
|
||||||
refwidth -= (int) hpr > opt.design->padding[BRIG]?
|
fprintf (stderr, "justify_line ({\"%s\",%d}, %d);\n",
|
||||||
opt.design->padding[BRIG]: hpr;
|
input.lines[ti].text, input.lines[ti].len, hpr-hpl);
|
||||||
refwidth -= (int) hpl > opt.design->padding[BLEF]?
|
|
||||||
opt.design->padding[BLEF]: hpl;
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf (stderr, "justify_line ({\"%s\",%d}, %d, %d);\n",
|
|
||||||
input.lines[ti].text, input.lines[ti].len,
|
|
||||||
refwidth, hpr-hpl);
|
|
||||||
#endif
|
#endif
|
||||||
rc = justify_line (input.lines+ti, refwidth, hpr-hpl);
|
rc = justify_line (input.lines+ti, hpr-hpl);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
r = input.maxline - input.lines[ti].len;
|
r = input.maxline - input.lines[ti].len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user