diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-11 07:18:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-07-11 07:19:55 +0300 |
commit | a7ac40888f530c12f137b3f6249b6f1dcfae3ea3 (patch) | |
tree | 885ae80bcf0ca7b1b56d74fa152aa3ab4d90c4f9 /source/blender/blenkernel/intern/text.c | |
parent | 676543d91f5c9f441cd0544d99aa34c933570347 (diff) |
Text: buffer from text, optional length return arg
No functional changes (currently unused).
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 22 |
1 files changed, 19 insertions, 3 deletions
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; } |