diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-03-04 16:26:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-03-04 16:26:33 +0300 |
commit | 36c3ed2350bb504b1b0a7a378d2d40a73bc3a769 (patch) | |
tree | f50dde4d57eb7ebbbb4b041e5930b55ca3be2ce9 /source/blender/editors/space_text | |
parent | 7d5ef14d5fa7301778ae9f0d80b68a04107e4ef2 (diff) |
run script in the text editor is back. UI scripts dont work yet.
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 6e7a507b35b..a77bea4c640 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -78,6 +78,11 @@ static int text_new_poll(bContext *C) return 1; } +static int text_valid_poll(bContext *C) +{ + return CTX_data_edit_text(C) ? 1:0; +} + static int text_edit_poll(bContext *C) { Text *text= CTX_data_edit_text(C); @@ -435,31 +440,12 @@ static int run_script_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; #else Text *text= CTX_data_edit_text(C); - char *py_filename; - - if(0) { // XXX !BPY_txt_do_python_Text(text)) { - int lineno = 0; // XXX BPY_Err_getLinenumber(); - // jump to error if happened in current text: - py_filename = (char*) NULL; // XXX BPY_Err_getFilename(); - /* st->text can become NULL: user called Blender.Load(blendfile) - * before the end of the script. */ - text= CTX_data_edit_text(C); - - if(!strcmp(py_filename, text->id.name+2)) { - // XXX error_pyscript( ); - if(lineno >= 0) { - txt_move_toline(text, lineno-1, 0); - txt_sel_line(text); - - WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); - } - } - else - BKE_report(op->reports, RPT_ERROR, "Error in other (possibly external) file, check console."); - } - - return OPERATOR_FINISHED; + 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..."); + return OPERATOR_CANCELLED; #endif } @@ -474,6 +460,7 @@ void TEXT_OT_run_script(wmOperatorType *ot) ot->poll= text_edit_poll; } + /******************* refresh pyconstraints operator *********************/ static int refresh_pyconstraints_exec(bContext *C, wmOperator *op) @@ -2541,6 +2528,7 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) RNA_def_boolean(ot->srna, "split_lines", 0, "Split Lines", "Create one object per line in the text."); } + /************************ undo ******************************/ void ED_text_undo_step(bContext *C, int step) |