1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 /** \file
20  * \ingroup DNA
21  *
22  * Text blocks used for Python-Scripts, OpenShadingLanguage
23  * and arbitrary text data to store in blend files.
24  */
25 
26 #pragma once
27 
28 #include "DNA_ID.h"
29 #include "DNA_listBase.h"
30 
31 typedef struct TextLine {
32   struct TextLine *next, *prev;
33 
34   char *line;
35   /** May be NULL if syntax is off or not yet formatted. */
36   char *format;
37   /** Blen unused. */
38   int len;
39   char _pad0[4];
40 } TextLine;
41 
42 typedef struct Text {
43   ID id;
44 
45   /**
46    * Optional file path, when NULL text is considered internal.
47    * Otherwise this path will be used when saving/reloading.
48    *
49    * When set this is where the file will or has been saved.
50    */
51   char *filepath;
52 
53   /**
54    * Python code object for this text (cached result of #Py_CompileStringObject).
55    */
56   void *compiled;
57 
58   int flags;
59   char _pad0[4];
60 
61   ListBase lines;
62   TextLine *curl, *sell;
63   int curc, selc;
64 
65   double mtime;
66 } Text;
67 
68 #define TXT_TABSIZE 4
69 
70 /** #Text.flags */
71 enum {
72   /** Set if the file in run-time differs from the file on disk, or if there is no file on disk. */
73   TXT_ISDIRTY = 1 << 0,
74   /** When the text hasn't been written to a file. #Text.filepath may be NULL or invalid. */
75   TXT_ISMEM = 1 << 2,
76   /** Should always be set if the Text is not to be written into the `.blend`. */
77   TXT_ISEXT = 1 << 3,
78   /** Load the script as a Python module when loading the `.blend` file. */
79   TXT_ISSCRIPT = 1 << 4,
80 
81   TXT_FLAG_UNUSED_8 = 1 << 8, /* cleared */
82   TXT_FLAG_UNUSED_9 = 1 << 9, /* cleared */
83 
84   /** Use space instead of tabs. */
85   TXT_TABSTOSPACES = 1 << 10,
86 };
87