mirror of
https://github.com/ascii-boxes/boxes.git
synced 2025-06-19 08:16:45 +02:00
Remove undocumented contentpos feature
It is no longer needed, as we have MBCS support for input now.
This commit is contained in:
parent
09d5ebcbb4
commit
04283eb697
@ -1488,7 +1488,6 @@ static int read_all_input(const int use_stdin)
|
|||||||
*/
|
*/
|
||||||
input.lines[input.anz_lines].text = NULL; /* we haven't used it yet! */
|
input.lines[input.anz_lines].text = NULL; /* we haven't used it yet! */
|
||||||
analyze_line_ascii(input.lines + input.anz_lines);
|
analyze_line_ascii(input.lines + input.anz_lines);
|
||||||
input.lines[input.anz_lines].num_leading_blanks = 0;
|
|
||||||
|
|
||||||
++input.anz_lines;
|
++input.anz_lines;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,6 @@ typedef struct {
|
|||||||
|
|
||||||
size_t *tabpos; /* tab positions in expanded work strings, or NULL if not needed */
|
size_t *tabpos; /* tab positions in expanded work strings, or NULL if not needed */
|
||||||
size_t tabpos_len; /* number of tabs in a line */
|
size_t tabpos_len; /* number of tabs in a line */
|
||||||
size_t num_leading_blanks; /* number of spaces at the start of the line after justification */
|
|
||||||
size_t *posmap; /* for each character in `text`, position of corresponding char in `mbtext`. Needed for box removal. */
|
size_t *posmap; /* for each character in `text`, position of corresponding char in `mbtext`. Needed for box removal. */
|
||||||
} line_t;
|
} line_t;
|
||||||
|
|
||||||
|
@ -718,11 +718,9 @@ static int justify_line(line_t *line, int skew)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (empty_line(line)) {
|
if (empty_line(line)) {
|
||||||
line->num_leading_blanks = SIZE_MAX;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (opt.justify == '\0') {
|
if (opt.justify == '\0') {
|
||||||
line->num_leading_blanks = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,11 +740,9 @@ static int justify_line(line_t *line, int skew)
|
|||||||
case 'l':
|
case 'l':
|
||||||
if (opt.design->indentmode == 't') {
|
if (opt.design->indentmode == 't') {
|
||||||
/* text indented inside of box */
|
/* text indented inside of box */
|
||||||
line->num_leading_blanks = input.indent;
|
|
||||||
result = (int) input.indent - (int) initial_space_size;
|
result = (int) input.indent - (int) initial_space_size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
line->num_leading_blanks = 0;
|
|
||||||
result = -1 * (int) initial_space_size;
|
result = -1 * (int) initial_space_size;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -766,24 +762,21 @@ static int justify_line(line_t *line, int skew)
|
|||||||
++shift;
|
++shift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
line->num_leading_blanks = shift;
|
|
||||||
result = (int) shift - (int) initial_space_size;
|
result = (int) shift - (int) initial_space_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
shift = input.maxline - newlen;
|
shift = input.maxline - newlen;
|
||||||
line->num_leading_blanks = shift;
|
|
||||||
result = (int) shift - (int) initial_space_size;
|
result = (int) shift - (int) initial_space_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: internal error (unknown justify option: %c)\n", PROJECT, opt.justify);
|
fprintf(stderr, "%s: internal error (unknown justify option: %c)\n", PROJECT, opt.justify);
|
||||||
line->num_leading_blanks = 0;
|
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEBUG) || 0
|
#if defined(DEBUG) || 0
|
||||||
fprintf (stderr, " -> %d (%d leading spaces)\n", result, (int) line->num_leading_blanks);
|
fprintf (stderr, " -> %d\n", result);
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -807,7 +800,7 @@ int output_box(const sentry_t *thebox)
|
|||||||
size_t nol = thebox[BRIG].height; /* number of output lines */
|
size_t nol = thebox[BRIG].height; /* number of output lines */
|
||||||
char *indentspc;
|
char *indentspc;
|
||||||
int indentspclen;
|
int indentspclen;
|
||||||
size_t vfill, vfill1, vfill1_save, vfill2; /* empty lines/columns in box */
|
size_t vfill, vfill1, vfill2; /* empty lines/columns in box */
|
||||||
size_t hfill;
|
size_t hfill;
|
||||||
char *hfill1, *hfill2; /* space before/after text */
|
char *hfill1, *hfill2; /* space before/after text */
|
||||||
size_t hpl, hpr;
|
size_t hpl, hpr;
|
||||||
@ -818,7 +811,6 @@ int output_box(const sentry_t *thebox)
|
|||||||
size_t skip_left; /* true if left box part is to be skipped */
|
size_t skip_left; /* true if left box part is to be skipped */
|
||||||
int ntabs, nspcs; /* needed for unexpand of tabs */
|
int ntabs, nspcs; /* needed for unexpand of tabs */
|
||||||
char *restored_indent;
|
char *restored_indent;
|
||||||
size_t *contentPos; /* column of first char of input text in output text */
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf (stderr, "Padding used: left %d, top %d, right %d, bottom %d\n",
|
fprintf (stderr, "Padding used: left %d, top %d, right %d, bottom %d\n",
|
||||||
@ -883,7 +875,6 @@ int output_box(const sentry_t *thebox)
|
|||||||
vfill1 += opt.design->padding[BTOP];
|
vfill1 += opt.design->padding[BTOP];
|
||||||
vfill2 += opt.design->padding[BBOT];
|
vfill2 += opt.design->padding[BBOT];
|
||||||
vfill += opt.design->padding[BTOP] + opt.design->padding[BBOT];
|
vfill += opt.design->padding[BTOP] + opt.design->padding[BBOT];
|
||||||
vfill1_save = vfill1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provide strings for horizontal text alignment.
|
* Provide strings for horizontal text alignment.
|
||||||
@ -962,7 +953,6 @@ int output_box(const sentry_t *thebox)
|
|||||||
/*
|
/*
|
||||||
* Generate actual output
|
* Generate actual output
|
||||||
*/
|
*/
|
||||||
contentPos = calloc(input.anz_lines, sizeof(size_t));
|
|
||||||
for (j = skip_start; j < nol - skip_end; ++j) {
|
for (j = skip_start; j < nol - skip_end; ++j) {
|
||||||
|
|
||||||
if (j < thebox[BTOP].height) { /* box top */
|
if (j < thebox[BTOP].height) { /* box top */
|
||||||
@ -985,14 +975,6 @@ int output_box(const sentry_t *thebox)
|
|||||||
if (ti < (long) input.anz_lines) { /* box content (lines) */
|
if (ti < (long) input.anz_lines) { /* box content (lines) */
|
||||||
int shift = justify_line(input.lines + ti, hpr - hpl);
|
int shift = justify_line(input.lines + ti, hpr - hpl);
|
||||||
restored_indent = tabbify_indent(ti, indentspc, indentspclen);
|
restored_indent = tabbify_indent(ti, indentspc, indentspclen);
|
||||||
if (input.lines[ti].num_leading_blanks == SIZE_MAX) {
|
|
||||||
contentPos[ti] = SIZE_MAX;
|
|
||||||
} else {
|
|
||||||
contentPos[ti] = strlen(restored_indent)
|
|
||||||
+ (skip_left ? 0 : strlen(thebox[BLEF].chars[j]))
|
|
||||||
+ strlen(hfill1)
|
|
||||||
+ input.lines[ti].num_leading_blanks;
|
|
||||||
}
|
|
||||||
uint32_t *mbtext_shifted = advance32(input.lines[ti].mbtext, shift < 0 ? (size_t) (-shift) : 0);
|
uint32_t *mbtext_shifted = advance32(input.lines[ti].mbtext, shift < 0 ? (size_t) (-shift) : 0);
|
||||||
concat_strings(obuf, LINE_MAX_BYTES + 1, 8, restored_indent,
|
concat_strings(obuf, LINE_MAX_BYTES + 1, 8, restored_indent,
|
||||||
skip_left ? "" : thebox[BLEF].chars[j], hfill1,
|
skip_left ? "" : thebox[BLEF].chars[j], hfill1,
|
||||||
@ -1033,17 +1015,6 @@ int output_box(const sentry_t *thebox)
|
|||||||
fprintf(opt.outfile, "%s%s", obuf, (input.final_newline || j < nol - skip_end - 1 ? "\n" : ""));
|
fprintf(opt.outfile, "%s%s", obuf, (input.final_newline || j < nol - skip_end - 1 ? "\n" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add info line for web ui if requested with -q */
|
|
||||||
if (query_is_undoc()) {
|
|
||||||
fprintf(opt.outfile, "%d ", (int) (thebox[BTOP].height + vfill1_save - skip_start));
|
|
||||||
for (j = 0; j < input.anz_lines; j++) {
|
|
||||||
fprintf(opt.outfile, "%d%s",
|
|
||||||
(contentPos[j] == SIZE_MAX ? (int) -1 : (int) contentPos[j]),
|
|
||||||
j < input.anz_lines - 1 ? " " : "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BFREE (contentPos);
|
|
||||||
BFREE (indentspc);
|
BFREE (indentspc);
|
||||||
BFREE (hfill1);
|
BFREE (hfill1);
|
||||||
BFREE (hfill2);
|
BFREE (hfill2);
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-ac -q (undoc) -s 12
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/**********/
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/**********/
|
|
||||||
1 4 4
|
|
||||||
:EOF
|
|
@ -1,13 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-ar -q (undoc) -s 12
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/**********/
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/**********/
|
|
||||||
1 6 5
|
|
||||||
:EOF
|
|
@ -1,13 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-q (undoc) -s 12
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/**********/
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/**********/
|
|
||||||
1 3 3
|
|
||||||
:EOF
|
|
@ -1,14 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-ac -q (undoc) -s 18x5 -p h3
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/****************/
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/* */
|
|
||||||
/****************/
|
|
||||||
1 7 7
|
|
||||||
:EOF
|
|
@ -1,19 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-ac -q (undoc) -s 18 -p a3 -i box
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/****************/
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/****************/
|
|
||||||
4 9 9
|
|
||||||
:EOF
|
|
@ -1,25 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-ac -q (undoc) -p a3 -d diamonds -i text
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/\ /\ /\
|
|
||||||
/\//\\/\ /\//\\/\ /\//\\/\
|
|
||||||
/\//\\\///\\/\//\\\///\\/\//\\\///\\/\
|
|
||||||
//\\\//\/\\///\\\//\/\\///\\\//\/\\///\\
|
|
||||||
\\//\/ \/\\//
|
|
||||||
\/ \/
|
|
||||||
/\ /\
|
|
||||||
//\\ foo //\\
|
|
||||||
\\// barf \\//
|
|
||||||
\/ \/
|
|
||||||
/\ /\
|
|
||||||
//\\/\ /\//\\
|
|
||||||
\\///\\/\//\\\///\\/\//\\\///\\/\//\\\//
|
|
||||||
\/\\///\\\//\/\\///\\\//\/\\///\\\//\/
|
|
||||||
\/\\//\/ \/\\//\/ \/\\//\/
|
|
||||||
\/ \/ jgs \/
|
|
||||||
7 20 20
|
|
||||||
:EOF
|
|
@ -1,13 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-q (undoc) -t 8k
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
barf
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/********/
|
|
||||||
/* foo */
|
|
||||||
/* barf */
|
|
||||||
/********/
|
|
||||||
1 4 4
|
|
||||||
:EOF
|
|
@ -1,21 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-q (undoc) -s 12
|
|
||||||
:INPUT
|
|
||||||
f
|
|
||||||
fo
|
|
||||||
|
|
||||||
foo
|
|
||||||
fooo
|
|
||||||
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/**********/
|
|
||||||
/* f */
|
|
||||||
/* fo */
|
|
||||||
/* */
|
|
||||||
/* foo */
|
|
||||||
/* fooo */
|
|
||||||
/* */
|
|
||||||
/**********/
|
|
||||||
1 3 3 -1 3 3 -1
|
|
||||||
:EOF
|
|
@ -1,21 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-q (undoc) -s 12 -al
|
|
||||||
:INPUT
|
|
||||||
f
|
|
||||||
fo
|
|
||||||
|
|
||||||
foo
|
|
||||||
fooo
|
|
||||||
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
/**********/
|
|
||||||
/* f */
|
|
||||||
/* fo */
|
|
||||||
/* */
|
|
||||||
/* foo */
|
|
||||||
/* fooo */
|
|
||||||
/* */
|
|
||||||
/**********/
|
|
||||||
1 3 3 -1 3 3 -1
|
|
||||||
:EOF
|
|
@ -1,13 +0,0 @@
|
|||||||
:ARGS
|
|
||||||
-q (undoc) -d right
|
|
||||||
:INPUT
|
|
||||||
foo
|
|
||||||
|
|
||||||
bar
|
|
||||||
:OUTPUT-FILTER
|
|
||||||
:EXPECTED
|
|
||||||
foo /* XX */
|
|
||||||
/* XX */
|
|
||||||
bar /* XX */
|
|
||||||
0 0 -1 0
|
|
||||||
:EOF
|
|
Loading…
x
Reference in New Issue
Block a user