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-16 04:50:27 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-16 04:50:27 +0400
commit2f74b5a2605d3bb83f6c7500f9d3899296bfbb59 (patch)
treec1b951cd060da50afce59791dbbd123347d18a46 /source/blender/windowmanager
parentce431c5c6e17877846812bab2d6bf9f8dc40fd48 (diff)
Console Space Type
* interactive console python console. * display reports and filter types. defaults to operator display so you can see the python commands for tools as you use them, eventually it should be possible to select commands and make macto/tools from them. Example use of autocomp. b<tab>, bpy.<tab>, bpy.<tab>, bpy.data.<tab> etc. basic instructions are printed when opening the console. Details... * Console exec and autocomp are done with operators written in python. * added CTX_wm_reports() to get the global report list. * The window manager had a report ListBase but reports have their own struct, switched to allocate and assign when initializing the WM since the type is not available in DNA. * changed report types flags for easier display filtering. * added report type RPT_OPERATOR * logging operators also adds a python-syntax report into CTX_wm_reports() so they can be displayed in the console as well as calling a notifier for console to redraw. * RnaAPI context.area.tag_redraw() to redraw the current area from a python operator. Todo... * better interactions with the console, scrolling, copy/paste. * the text displayed doesnt load back. * colors need to be themed. * scroll limit needs to be a user pref. * only tested with cmake and scons.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h5
-rw-r--r--source/blender/windowmanager/intern/wm.c13
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c6
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c21
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
-rw-r--r--source/blender/windowmanager/wm.h2
6 files changed, 43 insertions, 6 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index ab55f8a4459..3a646c5e799 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -131,6 +131,7 @@ typedef struct wmNotifier {
#define NC_WORLD (13<<24)
#define NC_FILE (14<<24)
#define NC_ANIMATION (15<<24)
+#define NC_CONSOLE (16<<24)
/* data type, 256 entries is enough, it can overlap */
#define NOTE_DATA 0x00FF0000
@@ -200,6 +201,10 @@ typedef struct wmNotifier {
#define ND_NLA_EDIT (76<<16)
#define ND_NLA_ACTCHANGE (77<<16)
+ /* console */
+#define ND_CONSOLE (78<<16) /* general redraw */
+#define ND_CONSOLE_REPORT (79<<16) /* update for reports, could spesify type */
+
/* subtype, 256 entries too */
#define NOTE_SUBTYPE 0x0000FF00
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 7dec14664ae..6b3b128d34b 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -79,9 +79,11 @@ void WM_operator_free(wmOperator *op)
/* all operations get registered in the windowmanager here */
/* called on event handling by event_system.c */
-void wm_operator_register(wmWindowManager *wm, wmOperator *op)
+void wm_operator_register(bContext *C, wmOperator *op)
{
+ wmWindowManager *wm= CTX_wm_manager(C);
int tot;
+ char *buf;
BLI_addtail(&wm->operators, op);
tot= BLI_countlist(&wm->operators);
@@ -92,6 +94,15 @@ void wm_operator_register(wmWindowManager *wm, wmOperator *op)
WM_operator_free(opt);
tot--;
}
+
+
+ /* Report the string representation of the operator */
+ buf = WM_operator_pystring(op);
+ BKE_report(wm->reports, RPT_OPERATOR, buf);
+ MEM_freeN(buf);
+
+ /* so the console is redrawn */
+ WM_event_add_notifier(C, NC_CONSOLE|ND_CONSOLE_REPORT, NULL);
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 3ef6e545dda..ffd1054d954 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -268,7 +268,7 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
if(repeat==0) {
if(op->type->flag & OPTYPE_REGISTER)
- wm_operator_register(CTX_wm_manager(C), op);
+ wm_operator_register(C, op);
else
WM_operator_free(op);
}
@@ -374,7 +374,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
ED_undo_push_op(C, op);
if(ot->flag & OPTYPE_REGISTER)
- wm_operator_register(wm, op);
+ wm_operator_register(C, op);
else
WM_operator_free(op);
}
@@ -697,7 +697,7 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
ED_undo_push_op(C, op);
if(ot->flag & OPTYPE_REGISTER)
- wm_operator_register(CTX_wm_manager(C), op);
+ wm_operator_register(C, op);
else
WM_operator_free(op);
handler->op= NULL;
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 0bc35ffa9b2..5938677afe7 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -51,6 +51,7 @@
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_mball.h"
+#include "BKE_report.h"
#include "BKE_utildefines.h"
#include "BKE_packedFile.h"
@@ -100,6 +101,22 @@ static void sound_init_listener(void)
G.listener->dopplervelocity = 340.29f;
}
+
+static void wm_init_reports(bContext *C)
+{
+ wmWindowManager *wm= CTX_wm_manager(C);
+ wm->reports= MEM_callocN(sizeof(ReportList), "wmReportList");
+ BKE_reports_init(wm->reports, RPT_STORE);
+}
+static void wm_free_reports(bContext *C)
+{
+ wmWindowManager *wm= CTX_wm_manager(C);
+ BKE_reports_clear(wm->reports);
+ MEM_freeN(wm->reports);
+}
+
+
+
/* only called once, for startup */
void WM_init(bContext *C)
{
@@ -124,6 +141,8 @@ void WM_init(bContext *C)
/* get the default database, plus a wm */
WM_read_homefile(C, NULL);
+ wm_init_reports(C); /* reports cant be initialized before the wm */
+
UI_init();
// clear_matcopybuf(); /* XXX */
@@ -256,6 +275,8 @@ void WM_exit(bContext *C)
RNA_exit();
+ wm_free_reports(C);
+
CTX_free(C);
if(MEM_get_memory_blocks_in_use()!=0) {
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index d7cac82ef90..4dbe26bb79f 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -165,7 +165,7 @@ char *WM_operator_pystring(wmOperator *op)
char *cstring, *buf;
int first_iter=1;
- BLI_dynstr_appendf(dynstr, "%s(", op->idname);
+ BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", op->idname);
iterprop= RNA_struct_iterator_property(op->ptr->type);
diff --git a/source/blender/windowmanager/wm.h b/source/blender/windowmanager/wm.h
index e91cbe6b204..36219cf3743 100644
--- a/source/blender/windowmanager/wm.h
+++ b/source/blender/windowmanager/wm.h
@@ -47,7 +47,7 @@ extern void wm_check(bContext *C);
extern void wm_clear_default_size(bContext *C);
/* register to windowmanager for redo or macro */
-void wm_operator_register(wmWindowManager *wm, wmOperator *op);
+void wm_operator_register(bContext *C, wmOperator *op);
extern void wm_report_free(wmReport *report);