- console scrollback userpref
authorCampbell Barton <ideasman42@gmail.com>
Sun, 26 Jul 2009 04:31:46 +0000 (04:31 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 26 Jul 2009 04:31:46 +0000 (04:31 +0000)
- copy coperator for the console (Ctrl+C and from the menu)

release/ui/space_console.py
release/ui/space_info.py
source/blender/editors/space_console/console_intern.h
source/blender/editors/space_console/console_ops.c
source/blender/editors/space_console/space_console.c
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 08695569748ce7109ca98e5e262536deeae2315a..cf5727cd3a2737e87ea0500f39273e4b6bfd6f26 100644 (file)
@@ -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"
index 365bcada6b91d93d55fe96d7e9ca49f17d50ed28..9e94be9b746e7807d83f5d357c6fa03c48998cce 100644 (file)
@@ -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)
index 3c6eeb63505e6885b114611ba505fb4f644bd244..0a80059fc6589b1ff047504828e7efb512355ad9 100644 (file)
@@ -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);
index ca6e3983eacb24fe9304af6efb77b8f557fdd74f..70570f6208a468082a3c78d352afc2c035112d84 100644 (file)
 #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);
index db70eff386f0ecc3eededd3f3e48546e94285730..c50fef7faf657eb00d228f483e22052f970dc701 100644 (file)
@@ -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!
index d8a943e165663b6da125287b4aea493478f2e098..bda4355d30bdd483800f081ead9d1f77e538e081 100644 (file)
@@ -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;
index 3344489e3896e2002208389a64d7403b77fe342d..c2017c1d9395c6650748e77aa4752abc699d9d93 100644 (file)
@@ -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 */