layout.column()
layout.itemO("console.clear")
+ layout.itemO("console.copy")
class CONSOLE_MT_report(bpy.types.Menu):
__space_type__ = "CONSOLE"
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)
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 */
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);
#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"
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);
}
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);
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);
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!
short userpref, viewzoom;
int mixbufsize;
- int pad1;
+ int scrollback; /* console scrollback limit */
int dpi; /* range 48-128? */
short encoding;
short transopts;
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 */