- console scrollback userpref

- copy coperator for the console (Ctrl+C and from the menu)
This commit is contained in:
2009-07-26 04:31:46 +00:00
parent 117fdd8072
commit a934773475
7 changed files with 59 additions and 5 deletions

View File

@@ -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);