diff options
author | Matheus Santos <MatheusSantos> | 2022-04-07 07:32:21 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-04-07 08:17:04 +0300 |
commit | f49a736ff4023231483c7e535ca2a7f2869d641d (patch) | |
tree | 506407e67e86034329fed5c71c49435a29ec2b31 /source/blender/python/intern/bpy_rna_types_capi.c | |
parent | 7cd6bda206800218da47ee35c53066a71d25ef22 (diff) |
Text Editor: Get/Set region text API
Add the ability to get/set the selected text.
**Calling the new methods:**
- `bpy.data.texts["Text"].region_as_string()`
- `bpy.data.texts["Text"].region_from_string("Replacement")`
Diffstat (limited to 'source/blender/python/intern/bpy_rna_types_capi.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna_types_capi.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna_types_capi.c b/source/blender/python/intern/bpy_rna_types_capi.c index 34c1a8b5a36..a5299bc1616 100644 --- a/source/blender/python/intern/bpy_rna_types_capi.c +++ b/source/blender/python/intern/bpy_rna_types_capi.c @@ -24,6 +24,7 @@ #include "bpy_rna_callback.h" #include "bpy_rna_data.h" #include "bpy_rna_id_collection.h" +#include "bpy_rna_text.h" #include "bpy_rna_types_capi.h" #include "bpy_rna_ui.h" @@ -87,6 +88,16 @@ static struct PyMethodDef pyrna_operator_methods[] = { /** \} */ /* -------------------------------------------------------------------- */ +/** \name Text Editor + * \{ */ + +static struct PyMethodDef pyrna_text_methods[] = { + {NULL, NULL, 0, NULL}, /* #BPY_rna_region_as_string_method_def */ + {NULL, NULL, 0, NULL}, /* #BPY_rna_region_from_string_method_def */ + {NULL, NULL, 0, NULL}, +}; + +/* -------------------------------------------------------------------- */ /** \name Window Manager Clipboard Property * * Avoid using the RNA API because this value may change between checking its length @@ -228,6 +239,13 @@ void BPY_rna_types_extend_capi(void) /* Space */ pyrna_struct_type_extend_capi(&RNA_Space, pyrna_space_methods, NULL); + /* Text Editor */ + ARRAY_SET_ITEMS(pyrna_text_methods, + BPY_rna_region_as_string_method_def, + BPY_rna_region_from_string_method_def); + BLI_assert(ARRAY_SIZE(pyrna_text_methods) == 3); + pyrna_struct_type_extend_capi(&RNA_Text, pyrna_text_methods, NULL); + /* wmOperator */ ARRAY_SET_ITEMS(pyrna_operator_methods, BPY_rna_operator_poll_message_set_method_def); BLI_assert(ARRAY_SIZE(pyrna_operator_methods) == 2); |