Blender V5.0
text_format.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_span.hh"
12
13using blender::Span;
14
15struct SpaceText;
16struct Text;
17struct TextLine;
18
19/* *** Flatten String *** */
21 char fixedbuf[256];
22 int fixedaccum[256];
23
24 char *buf;
25 int *accum;
26 int pos, len;
27};
28
32enum {
40 FMT_CONT_TRIPLE = (1 << 2),
45};
46#define FMT_CONT_ALL \
47 (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
48
49int flatten_string(const SpaceText *st, FlattenString *fs, const char *in);
54int flatten_string_strlen(FlattenString *fs, const char *str);
55
60int text_check_format_len(TextLine *line, unsigned int len);
67void text_format_fill(const char **str_p, char **fmt_p, char type, int len);
72void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len);
73
74/* *** Generalize Formatting *** */
77
78 char (*format_identifier)(const char *string);
79
80 /* Formats the specified line. If do_next is set, the process will move on to
81 * the succeeding line if it is affected (eg. multi-line strings). Format strings
82 * may contain any of the following characters:
83 *
84 * It is terminated with a null-terminator `\0 followed by a continuation
85 * flag indicating whether the line is part of a multi-line string.
86 *
87 * See: FMT_TYPE_ enums below
88 */
89 void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
90
91 const char **ext; /* Null terminated extensions. */
92
94 const char *comment_line;
95};
96
97enum {
118};
119
122
123/* Formatters. */
124
130
138int text_format_string_literal_find(Span<const char *> string_literals, const char *text);
139
140#ifndef NDEBUG
146
147#endif
#define str(s)
#define in
int fixedaccum[256]
char fixedbuf[256]
TextFormatType * prev
TextFormatType * next
const char * comment_line
char(* format_identifier)(const char *string)
const char ** ext
void(* format_line)(SpaceText *st, TextLine *line, bool do_next)
int flatten_string_strlen(FlattenString *fs, const char *str)
void text_format_fill(const char **str_p, char **fmt_p, char type, int len)
void ED_text_format_register_pov()
int flatten_string(const SpaceText *st, FlattenString *fs, const char *in)
void flatten_string_free(FlattenString *fs)
bool text_format_string_literals_check_sorted_array(Span< const char * > string_literals)
void ED_text_format_register_pov_ini()
void ED_text_format_register_glsl()
void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len)
void ED_text_format_register_osl()
TextFormatType * ED_text_format_get(Text *text)
@ FMT_TYPE_DIRECTIVE
@ FMT_TYPE_STRING
@ FMT_TYPE_COMMENT
@ FMT_TYPE_SPECIAL
@ FMT_TYPE_DEFAULT
@ FMT_TYPE_KEYWORD
@ FMT_TYPE_WHITESPACE
@ FMT_TYPE_NUMERAL
@ FMT_TYPE_RESERVED
@ FMT_TYPE_SYMBOL
void ED_text_format_register(TextFormatType *tft)
int text_format_string_literal_find(Span< const char * > string_literals, const char *text)
@ FMT_CONT_QUOTEDOUBLE
@ FMT_CONT_QUOTESINGLE_TRIPLE
@ FMT_CONT_QUOTEDOUBLE_TRIPLE
@ FMT_CONT_QUOTESINGLE
@ FMT_CONT_TRIPLE
@ FMT_CONT_NOP
@ FMT_CONT_COMMENT_C
void ED_text_format_register_py()
int text_check_format_len(TextLine *line, unsigned int len)
uint len