2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup DNA
|
2013-03-02 08:27:19 +01:00
|
|
|
*
|
|
|
|
* Text blocks used for Python-Scripts, OpenShadingLanguage
|
|
|
|
* and arbitrary text data to store in blend files.
|
2011-02-17 21:48:12 +01:00
|
|
|
*/
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2011-12-30 08:25:49 +01:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
#include "DNA_ID.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_listBase.h"
|
2002-10-12 13:37:38 +02:00
|
|
|
|
|
|
|
typedef struct TextLine {
|
|
|
|
struct TextLine *next, *prev;
|
|
|
|
|
|
|
|
char *line;
|
2019-01-07 12:19:13 +01:00
|
|
|
/** May be NULL if syntax is off or not yet formatted. */
|
|
|
|
char *format;
|
2019-11-27 14:58:34 +01:00
|
|
|
int len;
|
|
|
|
char _pad0[4];
|
2002-10-12 13:37:38 +02:00
|
|
|
} TextLine;
|
|
|
|
|
|
|
|
typedef struct Text {
|
|
|
|
ID id;
|
2018-06-17 17:04:09 +02:00
|
|
|
|
2020-06-23 06:09:13 +02:00
|
|
|
/**
|
|
|
|
* Optional file path, when NULL text is considered internal.
|
|
|
|
* Otherwise this path will be used when saving/reloading.
|
|
|
|
*
|
|
|
|
* When set this is where the file will or has been saved.
|
|
|
|
*/
|
2020-06-23 01:54:14 +02:00
|
|
|
char *filepath;
|
2020-06-23 06:09:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Python code object for this text (cached result of #Py_CompileStringObject).
|
|
|
|
*/
|
2017-12-14 15:12:05 +01:00
|
|
|
void *compiled;
|
2008-06-26 20:28:33 +02:00
|
|
|
|
2020-06-23 05:48:19 +02:00
|
|
|
int flags;
|
|
|
|
char _pad0[4];
|
2018-06-17 17:04:09 +02:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
ListBase lines;
|
|
|
|
TextLine *curl, *sell;
|
|
|
|
int curc, selc;
|
2018-06-17 17:04:09 +02:00
|
|
|
|
2008-07-23 20:19:56 +02:00
|
|
|
double mtime;
|
2002-10-12 13:37:38 +02:00
|
|
|
} Text;
|
|
|
|
|
|
|
|
#define TXT_TABSIZE 4
|
|
|
|
|
2020-06-23 06:09:13 +02:00
|
|
|
/** #Text.flags */
|
2019-03-15 00:42:39 +01:00
|
|
|
enum {
|
2020-06-23 06:09:13 +02:00
|
|
|
/** Set if the file in run-time differs from the file on disk, or if there is no file on disk. */
|
2019-03-15 00:42:39 +01:00
|
|
|
TXT_ISDIRTY = 1 << 0,
|
2020-06-23 06:09:13 +02:00
|
|
|
/** When the text hasn't been written to a file. #Text.filepath may be NULL or invalid. */
|
2019-03-15 00:42:39 +01:00
|
|
|
TXT_ISMEM = 1 << 2,
|
2020-06-23 06:09:13 +02:00
|
|
|
/** Should always be set if the Text is not to be written into the `.blend`. */
|
2019-03-15 00:42:39 +01:00
|
|
|
TXT_ISEXT = 1 << 3,
|
2020-06-23 06:09:13 +02:00
|
|
|
/** Load the script as a Python module when loading the `.blend` file. */
|
2019-03-15 00:42:39 +01:00
|
|
|
TXT_ISSCRIPT = 1 << 4,
|
|
|
|
|
2019-03-17 00:28:08 +01:00
|
|
|
TXT_FLAG_UNUSED_8 = 1 << 8, /* cleared */
|
|
|
|
TXT_FLAG_UNUSED_9 = 1 << 9, /* cleared */
|
2019-03-15 00:42:39 +01:00
|
|
|
|
|
|
|
/** Use space instead of tabs. */
|
|
|
|
TXT_TABSTOSPACES = 1 << 10,
|
|
|
|
};
|