diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-06-13 10:42:12 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-06-13 10:42:12 +0400 |
commit | d35d04a78961946145be256ed1ff45342f7633b8 (patch) | |
tree | 495c965c07bb372e03e42d74d6ed17d813014432 /source/blender/editors/space_text | |
parent | fe329792b4087add019508b0cb02aed0034c3651 (diff) |
text live_edit feature useful for UI scripts (run python scripts on every keystroke, careful with the os module)
http://www.graphicall.org/ftp/ideasman42/realtime_ui.ogv
current kerning makes this a bit cryptic.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 065b4ffcc48..ebb42aa2098 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -524,7 +524,10 @@ static int run_script_exec(bContext *C, wmOperator *op) if (BPY_run_python_script( C, NULL, text )) return OPERATOR_FINISHED; - BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now..."); + /* Dont report error messages while live editing */ + if(!CTX_wm_space_text(C)->live_edit) + BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now..."); + return OPERATOR_CANCELLED; #endif } @@ -699,6 +702,10 @@ static int paste_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -765,6 +772,10 @@ static int cut_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -1627,6 +1638,10 @@ static int delete_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); + /* run the script while editing, evil but useful */ + if(CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + return OPERATOR_FINISHED; } @@ -2224,7 +2239,7 @@ static int insert_exec(bContext *C, wmOperator *op) static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event) { char str[2]; - + int ret; /* XXX old code from winqreadtextspace, is it still needed somewhere? */ /* smartass code to prevent the CTRL/ALT events below from not working! */ /*if(qual & (LR_ALTKEY|LR_CTRLKEY)) @@ -2235,8 +2250,13 @@ static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event) str[1]= '\0'; RNA_string_set(op->ptr, "text", str); - - return insert_exec(C, op); + ret = insert_exec(C, op); + + /* run the script while editing, evil but useful */ + if(ret==OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) + run_script_exec(C, op); + + return ret; } void TEXT_OT_insert(wmOperatorType *ot) |