diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 08:31:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-26 08:31:46 +0400 |
commit | a934773475182feeddc4dd208dc5222975d9206a (patch) | |
tree | e7fc3c86507573791f38221827bebdb1b428af1c | |
parent | 117fdd8072fb6b8390d85498d8185c55a81f40e8 (diff) |
- console scrollback userpref
- copy coperator for the console (Ctrl+C and from the menu)
-rw-r--r-- | release/ui/space_console.py | 1 | ||||
-rw-r--r-- | release/ui/space_info.py | 1 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 47 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_userdef.c | 5 |
7 files changed, 59 insertions, 5 deletions
diff --git a/release/ui/space_console.py b/release/ui/space_console.py index 08695569748..cf5727cd3a2 100644 --- a/release/ui/space_console.py +++ b/release/ui/space_console.py @@ -50,6 +50,7 @@ class CONSOLE_MT_console(bpy.types.Menu): layout.column() layout.itemO("console.clear") + layout.itemO("console.copy") class CONSOLE_MT_report(bpy.types.Menu): __space_type__ = "CONSOLE" diff --git a/release/ui/space_info.py b/release/ui/space_info.py index 365bcada6b9..9e94be9b746 100644 --- a/release/ui/space_info.py +++ b/release/ui/space_info.py @@ -432,6 +432,7 @@ class INFO_PT_system(bpy.types.Panel): colsplitcol.itemR(system, "filter_file_extensions") colsplitcol.itemR(system, "hide_dot_files_datablocks") colsplitcol.itemR(system, "audio_mixing_buffer") + colsplitcol.itemR(lan, "scrollback", text="Console Scrollback") col = split.column() colsplit = col.split(percentage=0.85) 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! diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d8a943e1656..bda4355d30b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -293,7 +293,7 @@ typedef struct UserDef { short userpref, viewzoom; int mixbufsize; - int pad1; + int scrollback; /* console scrollback limit */ int dpi; /* range 48-128? */ short encoding; short transopts; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 3344489e389..c2017c1d939 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1922,6 +1922,11 @@ static void rna_def_userdef_language(BlenderRNA *brna) RNA_def_property_range(prop, 48, 128); RNA_def_property_ui_text(prop, "DPI", "Font size and resolution for display."); RNA_def_property_update(prop, NC_WINDOW, NULL); + + prop= RNA_def_property(srna, "scrollback", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "scrollback"); + RNA_def_property_range(prop, 32, 32768); + RNA_def_property_ui_text(prop, "Scrollback", "Maximum number of lines to store for the console buffer."); /* Language Selection */ |