From 472b6995b79fccf29ef62b9fef113cbf64ed4ed5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 4 Nov 2022 15:26:01 +0900 Subject: [PATCH] [ui] Set passage text object start and size The text object covering the whole passage was not being initialized, thus center print tried to print rubbish when (incorrectly) printing the entire message. --- include/QF/ui/passage.h | 6 ++++++ libs/ui/passage.c | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/QF/ui/passage.h b/include/QF/ui/passage.h index 09a47b9ee..060c09948 100644 --- a/include/QF/ui/passage.h +++ b/include/QF/ui/passage.h @@ -35,6 +35,12 @@ */ ///@{ +enum { + passage_type_text_obj, + + passage_type_count +}; + typedef struct psg_text_s { /// beginning of text for this segment relative to passage_t.text uint32_t text; diff --git a/libs/ui/passage.c b/libs/ui/passage.c index fd112c56e..0157ee754 100644 --- a/libs/ui/passage.c +++ b/libs/ui/passage.c @@ -44,12 +44,6 @@ #include "QF/ui/passage.h" #include "QF/ui/view.h" -enum { - passage_type_text_obj, - - passage_type_count -}; - static const component_t passage_components[passage_type_count] = { [passage_type_text_obj] = { .size = sizeof (psg_text_t), @@ -112,6 +106,7 @@ Passage_ParseText (passage_t *passage, const char *text) unsigned num_paragraphs = 1; unsigned num_text_objects = 1; + psg_text_t root_text = {}; int parsing_space = Passage_IsSpace (text); for (const char *c = text; *c; c++) { int size; @@ -132,6 +127,7 @@ Passage_ParseText (passage_t *passage, const char *text) } parsing_space = 0; } + root_text.size = c - text; } passage->hierarchy = Hierarchy_New (passage->reg, &passage_type, 0); Hierarchy_Reserve (passage->hierarchy, @@ -152,6 +148,7 @@ Passage_ParseText (passage_t *passage, const char *text) psg_text_t *text_obj = &passage_obj[h->childIndex[1]]; *par_obj = *text_obj = (psg_text_t) { }; + *passage_obj = root_text; add_entity (passage->hierarchy, par_obj - passage_obj); parsing_space = Passage_IsSpace (text);