Blender V4.3
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
9#pragma once
10
11#include "BLI_span.hh"
12
13using blender::Span;
14
15struct Text;
16
17/* *** Flatten String *** */
19 char fixedbuf[256];
20 int fixedaccum[256];
21
22 char *buf;
23 int *accum;
24 int pos, len;
25};
26
30enum {
31 FMT_CONT_NOP = 0, /* no continuation */
32 FMT_CONT_QUOTESINGLE = (1 << 0), /* single quotes */
33 FMT_CONT_QUOTEDOUBLE = (1 << 1), /* double quotes */
34 FMT_CONT_TRIPLE = (1 << 2), /* triplets of quotes: """ or ''' */
37 FMT_CONT_COMMENT_C = (1 << 3) /* multi-line comments, OSL only (C style) */
38};
39#define FMT_CONT_ALL \
40 (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
41
42int flatten_string(const SpaceText *st, FlattenString *fs, const char *in);
47int flatten_string_strlen(FlattenString *fs, const char *str);
48
53int text_check_format_len(TextLine *line, unsigned int len);
60void text_format_fill(const char **str_p, char **fmt_p, char type, int len);
65void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len);
66
67/* *** Generalize Formatting *** */
70
71 char (*format_identifier)(const char *string);
72
73 /* Formats the specified line. If do_next is set, the process will move on to
74 * the succeeding line if it is affected (eg. multi-line strings). Format strings
75 * may contain any of the following characters:
76 *
77 * It is terminated with a null-terminator '\0' followed by a continuation
78 * flag indicating whether the line is part of a multi-line string.
79 *
80 * See: FMT_TYPE_ enums below
81 */
82 void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
83
84 const char **ext; /* Null terminated extensions. */
85
87 const char *comment_line;
88};
89
90enum {
111};
112
115
116/* formatters */
122
130int text_format_string_literal_find(Span<const char *> string_literals, const char *text);
131
132#ifndef NDEBUG
138
139#endif
int len
#define str(s)
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)
@ 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 flatten_string_free(FlattenString *fs)
@ 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
const 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)
void ED_text_format_register(TextFormatType *tft)
int text_format_string_literal_find(Span< const char * > string_literals, const char *text)
void ED_text_format_register_py()
int text_check_format_len(TextLine *line, unsigned int len)