Blender V4.5
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 {
33 FMT_CONT_NOP = 0, /* no continuation */
34 FMT_CONT_QUOTESINGLE = (1 << 0), /* single quotes */
35 FMT_CONT_QUOTEDOUBLE = (1 << 1), /* double quotes */
36 FMT_CONT_TRIPLE = (1 << 2), /* triplets of quotes: """ or ''' */
39 FMT_CONT_COMMENT_C = (1 << 3) /* multi-line comments, OSL only (C style) */
40};
41#define FMT_CONT_ALL \
42 (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
43
44int flatten_string(const SpaceText *st, FlattenString *fs, const char *in);
49int flatten_string_strlen(FlattenString *fs, const char *str);
50
55int text_check_format_len(TextLine *line, unsigned int len);
62void text_format_fill(const char **str_p, char **fmt_p, char type, int len);
67void text_format_fill_ascii(const char **str_p, char **fmt_p, char type, int len);
68
69/* *** Generalize Formatting *** */
72
73 char (*format_identifier)(const char *string);
74
75 /* Formats the specified line. If do_next is set, the process will move on to
76 * the succeeding line if it is affected (eg. multi-line strings). Format strings
77 * may contain any of the following characters:
78 *
79 * It is terminated with a null-terminator '\0' followed by a continuation
80 * flag indicating whether the line is part of a multi-line string.
81 *
82 * See: FMT_TYPE_ enums below
83 */
84 void (*format_line)(SpaceText *st, TextLine *line, bool do_next);
85
86 const char **ext; /* Null terminated extensions. */
87
89 const char *comment_line;
90};
91
92enum {
113};
114
117
118/* formatters */
124
132int text_format_string_literal_find(Span<const char *> string_literals, const char *text);
133
134#ifndef NDEBUG
140
141#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)
@ 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 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()
@ 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
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)
uint len