Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-07-11 07:18:39 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-07-11 07:19:55 +0300
commita7ac40888f530c12f137b3f6249b6f1dcfae3ea3 (patch)
tree885ae80bcf0ca7b1b56d74fa152aa3ab4d90c4f9 /source/blender
parent676543d91f5c9f441cd0544d99aa34c933570347 (diff)
Text: buffer from text, optional length return arg
No functional changes (currently unused).
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_text.h4
-rw-r--r--source/blender/blenkernel/intern/text.c22
-rw-r--r--source/blender/editors/space_text/text_ops.c10
-rw-r--r--source/blender/python/intern/bpy_interface.c2
4 files changed, 27 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h
index d26b9a86635..c78faa9dd18 100644
--- a/source/blender/blenkernel/BKE_text.h
+++ b/source/blender/blenkernel/BKE_text.h
@@ -54,7 +54,7 @@ void BKE_text_write(struct Text *text, struct TextUndoBuf *utxt, const char *str
int BKE_text_file_modified_check(struct Text *text);
void BKE_text_file_modified_ignore(struct Text *text);
-char *txt_to_buf(struct Text *text);
+char *txt_to_buf(struct Text *text, int *r_buf_strlen);
void txt_clean_text(struct Text *text);
void txt_order_cursors(struct Text *text, const bool reverse);
int txt_find_string(struct Text *text, const char *findstr, int wrap, int match_case);
@@ -83,7 +83,7 @@ void txt_delete_selected(struct Text *text, struct TextUndoBuf *utxt);
void txt_sel_all(struct Text *text);
void txt_sel_clear(struct Text *text);
void txt_sel_line(struct Text *text);
-char *txt_sel_to_buf(struct Text *text);
+char *txt_sel_to_buf(struct Text *text, int *r_buf_strlen);
void txt_insert_buf(struct Text *text, struct TextUndoBuf *utxt, const char *in_buffer);
void txt_undo_add_op(struct Text *text, struct TextUndoBuf *utxt, int op);
void txt_do_undo(struct Text *text, struct TextUndoBuf *utxt);
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 7d5862c1fb6..1d6de646255 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1289,7 +1289,7 @@ static void txt_delete_sel(Text *text, TextUndoBuf *utxt)
txt_order_cursors(text, false);
if (!undoing) {
- buf = txt_sel_to_buf(text);
+ buf = txt_sel_to_buf(text, NULL);
txt_undo_add_blockop(text, utxt, UNDO_DBLOCK, buf);
MEM_freeN(buf);
}
@@ -1353,13 +1353,17 @@ void txt_sel_line(Text *text)
/* Cut and paste functions */
/***************************/
-char *txt_to_buf(Text *text)
+char *txt_to_buf(Text *text, int *r_buf_strlen)
{
int length;
TextLine *tmp, *linef, *linel;
int charf, charl;
char *buf;
+ if (r_buf_strlen) {
+ *r_buf_strlen = 0;
+ }
+
if (!text->curl) {
return NULL;
}
@@ -1419,6 +1423,10 @@ char *txt_to_buf(Text *text)
buf[length] = 0;
}
+ if (r_buf_strlen) {
+ *r_buf_strlen = length;
+ }
+
return buf;
}
@@ -1475,13 +1483,17 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case)
}
}
-char *txt_sel_to_buf(Text *text)
+char *txt_sel_to_buf(Text *text, int *r_buf_strlen)
{
char *buf;
int length = 0;
TextLine *tmp, *linef, *linel;
int charf, charl;
+ if (r_buf_strlen) {
+ *r_buf_strlen = 0;
+ }
+
if (!text->curl) {
return NULL;
}
@@ -1556,6 +1568,10 @@ char *txt_sel_to_buf(Text *text)
buf[length] = 0;
}
+ if (r_buf_strlen) {
+ *r_buf_strlen = length;
+ }
+
return buf;
}
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 63d4f3e3119..33bacb0a95f 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -932,7 +932,7 @@ static void txt_copy_clipboard(Text *text)
return;
}
- buf = txt_sel_to_buf(text);
+ buf = txt_sel_to_buf(text, NULL);
if (buf) {
WM_clipboard_text_set(buf, 0);
@@ -2994,7 +2994,7 @@ static void text_cursor_set_exit(bContext *C, wmOperator *op)
char *buffer;
if (txt_has_sel(text)) {
- buffer = txt_sel_to_buf(text);
+ buffer = txt_sel_to_buf(text, NULL);
WM_clipboard_text_set(buffer, 1);
MEM_freeN(buffer);
}
@@ -3308,7 +3308,7 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode)
/* Replace current */
if (mode != TEXT_FIND && txt_has_sel(text)) {
- tmp = txt_sel_to_buf(text);
+ tmp = txt_sel_to_buf(text, NULL);
if (flags & ST_MATCH_CASE) {
found = STREQ(st->findstr, tmp);
@@ -3406,7 +3406,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
Text *text = CTX_data_edit_text(C);
char *tmp;
- tmp = txt_sel_to_buf(text);
+ tmp = txt_sel_to_buf(text, NULL);
BLI_strncpy(st->findstr, tmp, ST_MAX_FIND_STR);
MEM_freeN(tmp);
@@ -3437,7 +3437,7 @@ static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op))
Text *text = CTX_data_edit_text(C);
char *tmp;
- tmp = txt_sel_to_buf(text);
+ tmp = txt_sel_to_buf(text, NULL);
BLI_strncpy(st->replacestr, tmp, ST_MAX_FIND_STR);
MEM_freeN(tmp);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index b34a41b5af6..71bc01d6b98 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -457,7 +457,7 @@ static bool python_script_exec(
fn_dummy_py = PyC_UnicodeFromByte(fn_dummy);
- buf = txt_to_buf(text);
+ buf = txt_to_buf(text, NULL);
text->compiled = Py_CompileStringObject(buf, fn_dummy_py, Py_file_input, NULL, -1);
MEM_freeN(buf);