[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32303] trunk/blender/source/blender/ editors/space_console: fix for copy in the console ( wasnt taking the prompt into account)
Campbell Barton
ideasman42 at gmail.com
Mon Oct 4 14:02:18 CEST 2010
Revision: 32303
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32303
Author: campbellbarton
Date: 2010-10-04 14:02:18 +0200 (Mon, 04 Oct 2010)
Log Message:
-----------
fix for copy in the console (wasnt taking the prompt into account)
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_console/console_draw.c
trunk/blender/source/blender/editors/space_console/console_intern.h
trunk/blender/source/blender/editors/space_console/console_ops.c
Modified: trunk/blender/source/blender/editors/space_console/console_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_draw.c 2010-10-04 11:42:39 UTC (rev 32302)
+++ trunk/blender/source/blender/editors/space_console/console_draw.c 2010-10-04 12:02:18 UTC (rev 32303)
@@ -286,6 +286,24 @@
#undef STEP_SEL
}
+void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
+{
+ /* fake the edit line being in the scroll buffer */
+ ConsoleLine *cl= sc->history.last;
+ cl_dummy->type= CONSOLE_LINE_INPUT;
+ cl_dummy->len= cl_dummy->len_alloc= strlen(sc->prompt) + cl->len;
+ cl_dummy->len_alloc= cl_dummy->len + 1;
+ cl_dummy->line= MEM_mallocN(cl_dummy->len_alloc, "cl_dummy");
+ memcpy(cl_dummy->line, sc->prompt, (cl_dummy->len_alloc - cl->len));
+ memcpy(cl_dummy->line + ((cl_dummy->len_alloc - cl->len)) - 1, cl->line, cl->len + 1);
+ BLI_addtail(&sc->scrollback, cl_dummy);
+}
+void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
+{
+ MEM_freeN(cl_dummy->line);
+ BLI_remlink(&sc->scrollback, cl_dummy);
+}
+
#define CONSOLE_DRAW_MARGIN 4
#define CONSOLE_DRAW_SCROLL 16
@@ -349,16 +367,8 @@
xy[0]= x_orig; /* remove prompt offset */
}
- /* fake the edit line being in the scroll buffer */
- cl_dummy.type= CONSOLE_LINE_INPUT;
- cl_dummy.len= cl_dummy.len_alloc= prompt_len + cl->len;
- cl_dummy.len_alloc= cl_dummy.len + 1;
- cl_dummy.line= MEM_mallocN(cl_dummy.len_alloc, "cl_dummy");
- memcpy(cl_dummy.line, sc->prompt, (cl_dummy.len_alloc - cl->len));
- memcpy(cl_dummy.line + ((cl_dummy.len_alloc - cl->len)) - 1, cl->line, cl->len + 1);
- BLI_addtail(&sc->scrollback, &cl_dummy);
+ console_scrollback_prompt_begin(sc, &cl_dummy);
-
for(cl= sc->scrollback.last; cl; cl= cl->prev) {
y_prev= xy[1];
@@ -378,9 +388,7 @@
}
}
- /* temp line end */
- MEM_freeN(cl_dummy.line);
- BLI_remlink(&sc->scrollback, &cl_dummy);
+ console_scrollback_prompt_end(sc, &cl_dummy);
}
else {
Report *report;
Modified: trunk/blender/source/blender/editors/space_console/console_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_intern.h 2010-10-04 11:42:39 UTC (rev 32302)
+++ trunk/blender/source/blender/editors/space_console/console_intern.h 2010-10-04 12:02:18 UTC (rev 32303)
@@ -41,6 +41,9 @@
void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports, int mouse_y); /* needed for selection */
int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mval[2]);
+void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
+void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
+
/* console_ops.c */
void console_history_free(SpaceConsole *sc, ConsoleLine *cl);
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl);
Modified: trunk/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_ops.c 2010-10-04 11:42:39 UTC (rev 32302)
+++ trunk/blender/source/blender/editors/space_console/console_ops.c 2010-10-04 12:02:18 UTC (rev 32303)
@@ -705,6 +705,8 @@
int sel[2];
int offset= 0;
+ ConsoleLine cl_dummy= {0};
+
#if 0
/* copy whole file */
for(cl= sc->scrollback.first; cl; cl= cl->next) {
@@ -716,15 +718,17 @@
if(sc->sel_start == sc->sel_end)
return OPERATOR_CANCELLED;
+ console_scrollback_prompt_begin(sc, &cl_dummy);
for(cl= sc->scrollback.first; cl; cl= cl->next) {
offset += cl->len + 1;
}
- if(offset==0)
+ if(offset==0) {
+ console_scrollback_prompt_end(sc, &cl_dummy);
return OPERATOR_CANCELLED;
+ }
-
offset -= 1;
sel[0]= offset - sc->sel_end;
sel[1]= offset - sc->sel_start;
@@ -750,6 +754,9 @@
WM_clipboard_text_set(buf_str, 0);
MEM_freeN(buf_str);
+
+ console_scrollback_prompt_end(sc, &cl_dummy);
+
return OPERATOR_FINISHED;
}
More information about the Bf-blender-cvs
mailing list