mirror of
https://github.com/ascii-boxes/boxes.git
synced 2024-12-12 09:51:10 +01:00
Add first test case for a UTF-8 config file
This commit is contained in:
parent
4cce7ae461
commit
d36380268d
@ -208,7 +208,7 @@ static char *locate_config_common(int *error_printed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISCOVERY_DEBUG
|
#ifdef DISCOVERY_DEBUG
|
||||||
fprintf(stderr, "locate_config_common() - exit -> [%s]\n", result);
|
fprintf(stderr, "locate_config_common() - exit -> [%s]\n", result != NULL ? result : "(null)");
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
12
src/list.c
12
src/list.c
@ -166,15 +166,17 @@ static void print_tags(tagstats_t *tagstats, size_t num_tags)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bxstr_t *escape(const bxstr_t *org, const int pLength)
|
static bxstr_t *escape(bxstr_t *org)
|
||||||
{
|
{
|
||||||
const ucs4_t char_backslash = to_utf32('\\');
|
const ucs4_t char_backslash = to_utf32('\\');
|
||||||
const ucs4_t char_quote = to_utf32('"');
|
const ucs4_t char_quote = to_utf32('"');
|
||||||
|
|
||||||
uint32_t *temp = (uint32_t *) calloc(2 * org->num_chars + 1, sizeof(uint32_t));
|
uint32_t *temp = (uint32_t *) calloc(2 * org->num_chars + 1, sizeof(uint32_t));
|
||||||
int orgIdx, resultIdx;
|
size_t orgIdx, resultIdx;
|
||||||
for (orgIdx = 0, resultIdx = 0; orgIdx < pLength; ++orgIdx, ++resultIdx) {
|
for (orgIdx = 0, resultIdx = 0; orgIdx < org->num_chars; ++orgIdx, ++resultIdx) {
|
||||||
if (is_char_at(org->memory, orgIdx, char_backslash) || is_char_at(org->memory, orgIdx, char_quote)) {
|
if ((is_char_at(org->memory, orgIdx, char_backslash) || is_char_at(org->memory, orgIdx, char_quote))
|
||||||
|
&& bxs_is_visible_char(org, orgIdx))
|
||||||
|
{
|
||||||
set_char_at(temp, resultIdx++, char_backslash);
|
set_char_at(temp, resultIdx++, char_backslash);
|
||||||
}
|
}
|
||||||
set_char_at(temp, resultIdx, org->memory[orgIdx]);
|
set_char_at(temp, resultIdx, org->memory[orgIdx]);
|
||||||
@ -336,7 +338,7 @@ static void print_design_details(design_t *d)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (size_t w = 0; w < d->shape[i].height; ++w) {
|
for (size_t w = 0; w < d->shape[i].height; ++w) {
|
||||||
bxstr_t *escaped_line = escape(d->shape[i].mbcs[w], d->shape[i].width);
|
bxstr_t *escaped_line = escape(d->shape[i].mbcs[w]);
|
||||||
fprintf(opt.outfile, "%-24s%3s%c \"%s\"%c%s",
|
fprintf(opt.outfile, "%-24s%3s%c \"%s\"%c%s",
|
||||||
(first_shape == 1 && w == 0 ? "Defined Shapes:" : ""),
|
(first_shape == 1 && w == 0 ? "Defined Shapes:" : ""),
|
||||||
(w == 0 ? shape_name[i] : ""), (w == 0 ? ':' : ' '),
|
(w == 0 ? shape_name[i] : ""), (w == 0 ? ':' : ' '),
|
||||||
|
49
test/175_utf8_happy_design_info.cfg
Normal file
49
test/175_utf8_happy_design_info.cfg
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# This config contains UTF-8-encoded elements used correctly, and a simple colored box design.
|
||||||
|
|
||||||
|
BOX designA
|
||||||
|
|
||||||
|
author "沐宸" # in a value
|
||||||
|
|
||||||
|
designer "John Doe"
|
||||||
|
|
||||||
|
𝕂𝕖𝕪𝕨𝕠𝕣𝕕 "value" # in a keyword
|
||||||
|
Mix𝕖𝕕 "value"
|
||||||
|
|
||||||
|
sample
|
||||||
|
┏━ [38;5;154m沐[0m[38;5;184m宸[0m[38;5;184m [0m[38;5;184m若[0m[38;5;214m汐[0m ━┓
|
||||||
|
┃ ⧹
|
||||||
|
┃ ╱
|
||||||
|
┗━━━━━━━━━━━━━┛
|
||||||
|
ends
|
||||||
|
|
||||||
|
# Monochrome sample (with UTF-8):
|
||||||
|
# ┏━ 沐宸 若汐 ━┓
|
||||||
|
# ┃ ⧹
|
||||||
|
# ┃ ╱
|
||||||
|
# ┗━━━━━━━━━━━━━┛
|
||||||
|
|
||||||
|
shapes {
|
||||||
|
n (" [38;5;154m沐[0m[38;5;184m宸[0m[38;5;184m [0m[38;5;184m若[0m[38;5;214m汐[0m ")
|
||||||
|
nw ("┏")
|
||||||
|
nnw ("━")
|
||||||
|
nne ("━")
|
||||||
|
ne ("┓")
|
||||||
|
e ("┃")
|
||||||
|
w ("⧹", "╱")
|
||||||
|
se ("┗")
|
||||||
|
s ("━")
|
||||||
|
sw ("┛")
|
||||||
|
}
|
||||||
|
|
||||||
|
elastic (
|
||||||
|
nnw, nne, e, w, s
|
||||||
|
)
|
||||||
|
|
||||||
|
padding {
|
||||||
|
horiz 1
|
||||||
|
}
|
||||||
|
|
||||||
|
replace "ä" with "ö"
|
||||||
|
reverse "ö" to "ä"
|
||||||
|
|
||||||
|
END designA
|
33
test/175_utf8_happy_design_info.txt
Normal file
33
test/175_utf8_happy_design_info.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
:ARGS
|
||||||
|
-f 175_utf8_happy_design_info.cfg -d designA -l
|
||||||
|
:INPUT
|
||||||
|
:OUTPUT-FILTER
|
||||||
|
:EXPECTED
|
||||||
|
Complete Design Information for "designA":
|
||||||
|
------------------------------------------
|
||||||
|
Alias Names: none
|
||||||
|
Author: 沐宸
|
||||||
|
Original Designer: John Doe
|
||||||
|
Creation Date: (unknown)
|
||||||
|
Current Revision: (unknown)
|
||||||
|
Configuration File: 175_utf8_happy_design_info.cfg
|
||||||
|
Indentation Mode: box (indent box)
|
||||||
|
Replacement Rules: 1. (glob) "ä" WITH "ö"
|
||||||
|
Reversion Rules: 1. (glob) "ö" TO "ä"
|
||||||
|
Minimum Box Dimensions: 15 x 4 (width x height)
|
||||||
|
Default Padding: left 1, right 1
|
||||||
|
Default Killblank: yes
|
||||||
|
Tags: none
|
||||||
|
Elastic Shapes: NNW, NNE, E, S, W
|
||||||
|
Defined Shapes: NW: "┏"
|
||||||
|
NNW: "━"
|
||||||
|
N: " [38;5;154m沐[0m[38;5;184m宸[0m[38;5;184m [0m[38;5;184m若[0m[38;5;214m汐[0m "
|
||||||
|
NNE: "━"
|
||||||
|
NE: "┓"
|
||||||
|
E: "┃"
|
||||||
|
SE: "┗"
|
||||||
|
S: "━"
|
||||||
|
SW: "┛"
|
||||||
|
W: "⧹",
|
||||||
|
"╱"
|
||||||
|
:EOF
|
Loading…
Reference in New Issue
Block a user