mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-27 14:42:07 +00:00
9798400cfb
A passage object has a list of all the text objects in the given string, where the objects represent either white space or "words", as well as a view_t object representing the entire passage, with paragraphs split into child views of the passage view, and each paragraph has a child view for every text/space object in the paragraph. Paragraphs are split by '\n' (not included in any object). White space is grouped into clumps such that multiple adjacent spaces form a single object. The standard ASCII space (0x20) and all of the Unicode characters marked "WS;<compat> 0020" are counted as white space. Unless a white space object is the first in the paragraph, its view is marked for suppression by the view flow code. Contiguous non-white space characters are grouped into single objects, and their views are not suppressed. All text object views (both white space and "word") have their data pointer set to the psg_text_t object representing the text for that view. This should be suitable for simple text-mode unattributed display. More advanced rendering would probably want to create suitable objects and set the view data pointers to those objects. No assumption is made about text direction. Passage and paragraph views need to have their primary axis sizes set appropriately, as well as their resize flags. Their xlen and ylen are both set to 10, and xpos,ypos is 0,0. Paragraph views need their setgeometry pointer set to the appropriate view_flow_* function. However, they are set up to have their secondary axis set automatically when flowed. Text object views are set up for automatic flowing: grav_flow, 0,0 for xpos,ypos. However, xlen and ylen are also both 0, so need to be set by the renderer before attempting to flow the text.
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/*
|
|
passage.h
|
|
|
|
Text passage formatting.
|
|
|
|
Copyright (C) 2022 Bill Currie <bill@taniwha.org>
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to:
|
|
|
|
Free Software Foundation, Inc.
|
|
59 Temple Place - Suite 330
|
|
Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
|
|
#ifndef __QF_ui_passage_h
|
|
#define __QF_ui_passage_h
|
|
|
|
#include <stdint.h>
|
|
|
|
/** \defgroup passage Text passages
|
|
\ingroup utils
|
|
*/
|
|
///@{
|
|
|
|
typedef struct psg_text_s {
|
|
/// beginning of text for this segment relative to passage_t.text
|
|
uint32_t text;
|
|
/// length of text segment in bytes rather than chars as text may be utf-8
|
|
uint32_t size;
|
|
} psg_text_t;
|
|
|
|
typedef struct passage_s {
|
|
const char *text; ///< Not owned by passage
|
|
struct view_s *view; ///< hierarchy of views representing passage
|
|
psg_text_t *text_objects; ///< all text objects in passage
|
|
unsigned num_text_objects; ///< number of text objects in passage
|
|
} passage_t;
|
|
|
|
passage_t *Passage_ParseText (const char *text);
|
|
void Passage_Delete (passage_t *passage);
|
|
int Passage_IsSpace (const char *text) __attribute__((pure));
|
|
|
|
///@}
|
|
|
|
#endif//__QF_ui_passage_h
|