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>2014-01-08 10:39:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-01-08 10:39:12 +0400
commit2dba2e72b76ba2933d6ca7d3e79ad669c430e3a5 (patch)
tree19e2d2af6a5923952d29151d5ae43a69b11508e4 /source/blender/editors/interface
parent3fbd63c52e25344f115b5cd67a218436bc4007cf (diff)
Code Cleanup: de-duplicate text pasting which only used the first line
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_handlers.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 470c042e7c7..79ae8536acc 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1402,15 +1402,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if (mode == 'v') {
/* extract first line from clipboard in case of multi-line copies */
- char *p, *pbuf = WM_clipboard_text_get(0);
- p = pbuf;
- if (p) {
- int i = 0;
- while (*p && *p != '\r' && *p != '\n' && i < UI_MAX_DRAW_STR) {
- buf[i++] = *p;
- p++;
- }
- buf[i] = 0;
+ int pbuf_len;
+ char *pbuf = WM_clipboard_text_get_firstline(false, &pbuf_len);
+ if (pbuf) {
+ BLI_strncpy(buf, pbuf, sizeof(buf));
MEM_freeN(pbuf);
}
}
@@ -1997,7 +1992,7 @@ enum {
static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const int mode)
{
- char *str, *p, *pbuf;
+ char *str, *pbuf;
int x;
bool changed = false;
int str_len, buf_len;
@@ -2009,17 +2004,13 @@ static bool ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, const in
if (mode == UI_TEXTEDIT_PASTE) {
/* TODO, ensure UTF8 ui_is_but_utf8() - campbell */
/* extract the first line from the clipboard */
- p = pbuf = WM_clipboard_text_get(0);
+ pbuf = WM_clipboard_text_get_firstline(false, &buf_len);
- if (p && p[0]) {
+ if (pbuf) {
char buf[UI_MAX_DRAW_STR] = {0};
unsigned int y;
- buf_len = 0;
- while (*p && *p != '\r' && *p != '\n' && buf_len < UI_MAX_DRAW_STR - 1) {
- buf[buf_len++] = *p;
- p++;
- }
- buf[buf_len] = 0;
+
+ buf_len = BLI_strncpy_rlen(buf, pbuf, sizeof(buf));
/* paste over the current selection */
if ((but->selend - but->selsta) > 0) {