~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/space_text/text_format.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version. 
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software Foundation,
 
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 *
 
18
 * The Original Code is Copyright (C) 2009 Blender Foundation.
 
19
 * All rights reserved.
 
20
 *
 
21
 * 
 
22
 * Contributor(s): Blender Foundation
 
23
 *
 
24
 * ***** END GPL LICENSE BLOCK *****
 
25
 */
 
26
 
 
27
/** \file blender/editors/space_text/text_format.h
 
28
 *  \ingroup sptext
 
29
 */
 
30
 
 
31
#ifndef __TEXT_FORMAT_H__
 
32
#define __TEXT_FORMAT_H__
 
33
 
 
34
/* *** Flatten String *** */
 
35
typedef struct FlattenString {
 
36
        char fixedbuf[256];
 
37
        int fixedaccum[256];
 
38
 
 
39
        char *buf;
 
40
        int *accum;
 
41
        int pos, len;
 
42
} FlattenString;
 
43
 
 
44
/* format continuation flags (stored just after the NULL terminator) */
 
45
enum {
 
46
        FMT_CONT_NOP                = 0,  /* no continuation */
 
47
        FMT_CONT_QUOTESINGLE        = (1 << 0),  /* single quotes */
 
48
        FMT_CONT_QUOTEDOUBLE        = (1 << 1),  /* double quotes */
 
49
        FMT_CONT_TRIPLE             = (1 << 2),  /* triplets of quotes: """ or ''' */
 
50
        FMT_CONT_QUOTESINGLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTESINGLE),
 
51
        FMT_CONT_QUOTEDOUBLE_TRIPLE = (FMT_CONT_TRIPLE | FMT_CONT_QUOTEDOUBLE),
 
52
        FMT_CONT_COMMENT_C          = (1 << 3)   /* multi-line comments, OSL only (C style) */
 
53
};
 
54
#define FMT_CONT_ALL \
 
55
        (FMT_CONT_QUOTESINGLE | FMT_CONT_QUOTEDOUBLE | FMT_CONT_TRIPLE | FMT_CONT_COMMENT_C)
 
56
 
 
57
int  flatten_string(struct SpaceText *st, FlattenString *fs, const char *in);
 
58
void flatten_string_free(FlattenString *fs);
 
59
int  flatten_string_strlen(FlattenString *fs, const char *str);
 
60
 
 
61
int  text_check_format_len(TextLine *line, unsigned int len);
 
62
void text_format_fill(const char **str_p, char **fmt_p, const char type, const int len);
 
63
void text_format_fill_ascii(const char **str_p, char **fmt_p, const char type, const int len);
 
64
 
 
65
/* *** Generalize Formatting *** */
 
66
typedef struct TextFormatType {
 
67
        struct TextFormatType *next, *prev;
 
68
 
 
69
        char (*format_identifier)(const char *string);
 
70
 
 
71
        /* Formats the specified line. If do_next is set, the process will move on to
 
72
         * the succeeding line if it is affected (eg. multiline strings). Format strings
 
73
         * may contain any of the following characters:
 
74
         *
 
75
         * It is terminated with a null-terminator '\0' followed by a continuation
 
76
         * flag indicating whether the line is part of a multi-line string.
 
77
         *
 
78
         * See: FMT_TYPE_ enums below
 
79
         */
 
80
        void (*format_line)(SpaceText *st, TextLine *line, int do_next);
 
81
 
 
82
        const char **ext;  /* NULL terminated extensions */
 
83
} TextFormatType;
 
84
 
 
85
enum {
 
86
        FMT_TYPE_WHITESPACE = '_',  /* Whitespace */
 
87
        FMT_TYPE_COMMENT    = '#',  /* Comment text */
 
88
        FMT_TYPE_SYMBOL     = '!',  /* Punctuation and other symbols */
 
89
        FMT_TYPE_NUMERAL    = 'n',  /* Numerals */
 
90
        FMT_TYPE_STRING     = 'l',  /* String letters */
 
91
        FMT_TYPE_DIRECTIVE  = 'd',  /* Decorator / Preprocessor directive */
 
92
        FMT_TYPE_SPECIAL    = 'v',  /* Special variables (class, def) */
 
93
        FMT_TYPE_RESERVED   = 'r',  /* Reserved keywords currently not in use, but still prohibited (OSL -> switch e.g.) */
 
94
        FMT_TYPE_KEYWORD    = 'b',  /* Built-in names (return, for, etc.) */
 
95
        FMT_TYPE_DEFAULT    = 'q',  /* Regular text (identifiers, etc.) */
 
96
};
 
97
 
 
98
TextFormatType *ED_text_format_get(Text *text);
 
99
void            ED_text_format_register(TextFormatType *tft);
 
100
 
 
101
/* formatters */
 
102
void ED_text_format_register_py(void);
 
103
void ED_text_format_register_osl(void);
 
104
void ED_text_format_register_lua(void);
 
105
 
 
106
#define STR_LITERAL_STARTSWITH(str, str_literal, len_var) \
 
107
        (strncmp(str, str_literal, len_var = (sizeof(str_literal) - 1)) == 0)
 
108
 
 
109
#endif  /* __TEXT_FORMAT_H__ */