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>2009-07-26 08:31:46 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-26 08:31:46 +0400
commita934773475182feeddc4dd208dc5222975d9206a (patch)
treee7fc3c86507573791f38221827bebdb1b428af1c /source/blender/editors/space_console
parent117fdd8072fb6b8390d85498d8185c55a81f40e8 (diff)
- console scrollback userpref
- copy coperator for the console (Ctrl+C and from the menu)
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_intern.h5
-rw-r--r--source/blender/editors/space_console/console_ops.c47
-rw-r--r--source/blender/editors/space_console/space_console.c3
3 files changed, 51 insertions, 4 deletions
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 3c6eeb63505..0a80059fc65 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -34,9 +34,6 @@ struct ConsoleLine;
struct wmOperatorType;
struct ReportList;
-/* TODO, make into a pref */
-#define CONSOLE_SCROLLBACK_LIMIT 128
-
/* console_draw.c */
void console_text_main(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports);
int console_text_height(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); /* needed to calculate the scrollbar */
@@ -62,8 +59,10 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot);
void CONSOLE_OT_clear(wmOperatorType *ot);
void CONSOLE_OT_history_cycle(wmOperatorType *ot);
+void CONSOLE_OT_copy(wmOperatorType *ot);
void CONSOLE_OT_zoom(wmOperatorType *ot);
+
/* console_report.c */
void CONSOLE_OT_select_pick(wmOperatorType *ot); /* report selection */
void CONSOLE_OT_select_all_toggle(wmOperatorType *ot);
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index ca6e3983eac..70570f6208a 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -37,9 +37,11 @@
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "DNA_userdef_types.h"
#include "DNA_windowmanager_types.h"
#include "BLI_blenlib.h"
+#include "BLI_dynstr.h"
#include "PIL_time.h"
#include "BKE_utildefines.h"
@@ -79,7 +81,10 @@ void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
void console_scrollback_limit(SpaceConsole *sc)
{
int tot;
- for(tot= BLI_countlist(&sc->scrollback); tot > CONSOLE_SCROLLBACK_LIMIT; tot--)
+
+ if (U.scrollback < 32) U.scrollback= 128; // XXX - save in user defaults
+
+ for(tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--)
console_scrollback_free(sc, sc->scrollback.first);
}
@@ -548,6 +553,46 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", console_line_type_items, CONSOLE_LINE_OUTPUT, "Type", "Console output type.");
}
+
+static int copy_exec(bContext *C, wmOperator *op)
+{
+ SpaceConsole *sc= CTX_wm_space_console(C);
+
+ DynStr *buf_dyn= BLI_dynstr_new();
+ char *buf_str;
+
+ ConsoleLine *cl;
+
+ for(cl= sc->scrollback.last; cl; cl= cl->prev) {
+ BLI_dynstr_append(buf_dyn, cl->line);
+ BLI_dynstr_append(buf_dyn, "\n");
+ }
+
+ buf_str= BLI_dynstr_get_cstring(buf_dyn);
+ BLI_dynstr_free(buf_dyn);
+
+ WM_clipboard_text_set(buf_str, 0);
+
+ MEM_freeN(buf_str);
+ return OPERATOR_FINISHED;
+}
+
+void CONSOLE_OT_copy(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Copy to Clipboard";
+ ot->idname= "CONSOLE_OT_copy";
+
+ /* api callbacks */
+ ot->poll= console_edit_poll;
+ ot->exec= copy_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER;
+
+ /* properties */
+}
+
static int zoom_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index db70eff386f..c50fef7faf6 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -214,6 +214,7 @@ void console_operatortypes(void)
WM_operatortype_append(CONSOLE_OT_clear);
WM_operatortype_append(CONSOLE_OT_history_cycle);
+ WM_operatortype_append(CONSOLE_OT_copy);
WM_operatortype_append(CONSOLE_OT_zoom);
@@ -292,6 +293,8 @@ void console_keymap(struct wmWindowManager *wm)
WM_keymap_add_item(keymap, "CONSOLE_OT_report_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CONSOLE_OT_report_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "CONSOLE_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0);
+
+ WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
RNA_string_set(WM_keymap_add_item(keymap, "CONSOLE_OT_insert", TABKEY, KM_PRESS, 0, 0)->ptr, "text", " "); /* fake tabs */
WM_keymap_add_item(keymap, "CONSOLE_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!