mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-20 17:58:56 +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)
|
||||
* Author: Copyright (C) 1999 Thomas Jensen
|
||||
* 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
|
||||
* World Wide Web: http://home.pages.de/~jensen/boxes/
|
||||
* Purpose: Box generation, i.e. the drawing of boxes
|
||||
@ -25,6 +25,9 @@
|
||||
* Revision History:
|
||||
*
|
||||
* $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
|
||||
* Added GNU GPL disclaimer
|
||||
* Bugfix: When doing the line justification in output_box(), the padding
|
||||
@ -55,7 +58,7 @@
|
||||
#include "generate.h"
|
||||
|
||||
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,13 +700,12 @@ 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
|
||||
*
|
||||
* line line to justify
|
||||
* topwidth width of top box part
|
||||
* skew difference in spaces right/left of text block (hpr-hpl)
|
||||
* line line to justify
|
||||
* skew difference in spaces right/left of text block (hpr-hpl)
|
||||
*
|
||||
* 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;
|
||||
|
||||
case 'c':
|
||||
shift = (topwidth - newlen) / 2;
|
||||
if ((topwidth - newlen) % 2 && skew == 1)
|
||||
shift = (input.maxline - newlen) / 2;
|
||||
if ((input.maxline - newlen) % 2 && skew == 1)
|
||||
++shift;
|
||||
newtext = (char *) calloc (shift + newlen + 1, sizeof(char));
|
||||
if (newtext == NULL) {
|
||||
@ -752,6 +754,10 @@ static int justify_line (line_t *line, const size_t topwidth, const int skew)
|
||||
}
|
||||
memset (spaces, ' ', shift);
|
||||
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);
|
||||
strncat (newtext, p, newlen);
|
||||
newtext[shift+newlen] = '\0';
|
||||
@ -985,17 +991,11 @@ int output_box (const sentry_t *thebox)
|
||||
else if (j < nol-thebox[BBOT].height) {
|
||||
long ti = j - thebox[BTOP].height - (vfill-vfill2);
|
||||
if (ti < (long) input.anz_lines) { /* box content (lines) */
|
||||
size_t refwidth = thebox[BTOP].width;
|
||||
refwidth -= (int) hpr > opt.design->padding[BRIG]?
|
||||
opt.design->padding[BRIG]: hpr;
|
||||
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);
|
||||
#if defined(DEBUG) && 0
|
||||
fprintf (stderr, "justify_line ({\"%s\",%d}, %d);\n",
|
||||
input.lines[ti].text, input.lines[ti].len, hpr-hpl);
|
||||
#endif
|
||||
rc = justify_line (input.lines+ti, refwidth, hpr-hpl);
|
||||
rc = justify_line (input.lines+ti, hpr-hpl);
|
||||
if (rc)
|
||||
return rc;
|
||||
r = input.maxline - input.lines[ti].len;
|
||||
|
Loading…
x
Reference in New Issue
Block a user