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:
Diffstat (limited to 'source/blender/editors/space_text/text_ops.c')
-rw-r--r--source/blender/editors/space_text/text_ops.c82
1 files changed, 51 insertions, 31 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 065b4ffcc48..95970798e53 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -521,10 +521,13 @@ static int run_script_exec(bContext *C, wmOperator *op)
#else
Text *text= CTX_data_edit_text(C);
- if (BPY_run_python_script( C, NULL, text ))
+ if (BPY_run_python_script(C, NULL, text, op->reports))
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;
}
@@ -961,9 +972,9 @@ void TEXT_OT_uncomment(wmOperatorType *ot)
enum { TO_SPACES, TO_TABS };
static EnumPropertyItem whitespace_type_items[]= {
- {TO_SPACES, "SPACES", "To Spaces", NULL},
- {TO_TABS, "TABS", "To Tabs", NULL},
- {0, NULL, NULL, NULL}};
+ {TO_SPACES, "SPACES", 0, "To Spaces", NULL},
+ {TO_TABS, "TABS", 0, "To Tabs", NULL},
+ {0, NULL, 0, NULL, NULL}};
static int convert_whitespace_exec(bContext *C, wmOperator *op)
{
@@ -1259,19 +1270,19 @@ void TEXT_OT_markers_clear(wmOperatorType *ot)
/************************ move operator ************************/
static EnumPropertyItem move_type_items[]= {
- {LINE_BEGIN, "LINE_BEGIN", "Line Begin", ""},
- {LINE_END, "LINE_END", "Line End", ""},
- {FILE_TOP, "FILE_TOP", "File Top", ""},
- {FILE_BOTTOM, "FILE_BOTTOM", "File Bottom", ""},
- {PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""},
- {NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""},
- {PREV_WORD, "PREVIOUS_WORD", "Previous Word", ""},
- {NEXT_WORD, "NEXT_WORD", "Next Word", ""},
- {PREV_LINE, "PREVIOUS_LINE", "Previous Line", ""},
- {NEXT_LINE, "NEXT_LINE", "Next Line", ""},
- {PREV_PAGE, "PREVIOUS_PAGE", "Previous Page", ""},
- {NEXT_PAGE, "NEXT_PAGE", "Next Page", ""},
- {0, NULL, NULL, NULL}};
+ {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
+ {LINE_END, "LINE_END", 0, "Line End", ""},
+ {FILE_TOP, "FILE_TOP", 0, "File Top", ""},
+ {FILE_BOTTOM, "FILE_BOTTOM", 0, "File Bottom", ""},
+ {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
+ {NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
+ {PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
+ {NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
+ {PREV_LINE, "PREVIOUS_LINE", 0, "Previous Line", ""},
+ {NEXT_LINE, "NEXT_LINE", 0, "Next Line", ""},
+ {PREV_PAGE, "PREVIOUS_PAGE", 0, "Previous Page", ""},
+ {NEXT_PAGE, "NEXT_PAGE", 0, "Next Page", ""},
+ {0, NULL, 0, NULL, NULL}};
static void wrap_move_bol(SpaceText *st, ARegion *ar, short sel)
{
@@ -1602,11 +1613,11 @@ void TEXT_OT_jump(wmOperatorType *ot)
/******************* delete operator **********************/
static EnumPropertyItem delete_type_items[]= {
- {DEL_NEXT_CHAR, "NEXT_CHARACTER", "Next Character", ""},
- {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", "Previous Character", ""},
- {DEL_NEXT_WORD, "NEXT_WORD", "Next Word", ""},
- {DEL_PREV_WORD, "PREVIOUS_WORD", "Previous Word", ""},
- {0, NULL, NULL, NULL}};
+ {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
+ {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""},
+ {DEL_NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
+ {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
+ {0, NULL, 0, NULL, NULL}};
static int delete_exec(bContext *C, wmOperator *op)
{
@@ -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)
@@ -2449,11 +2469,11 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot)
enum { RESOLVE_IGNORE, RESOLVE_RELOAD, RESOLVE_SAVE, RESOLVE_MAKE_INTERNAL };
static EnumPropertyItem resolution_items[]= {
- {RESOLVE_IGNORE, "IGNORE", "Ignore", ""},
- {RESOLVE_RELOAD, "RELOAD", "Reload", ""},
- {RESOLVE_SAVE, "SAVE", "Save", ""},
- {RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", "Make Internal", ""},
- {0, NULL, NULL, NULL}};
+ {RESOLVE_IGNORE, "IGNORE", 0, "Ignore", ""},
+ {RESOLVE_RELOAD, "RELOAD", 0, "Reload", ""},
+ {RESOLVE_SAVE, "SAVE", 0, "Save", ""},
+ {RESOLVE_MAKE_INTERNAL, "MAKE_INTERNAL", 0, "Make Internal", ""},
+ {0, NULL, 0, NULL, NULL}};
/* returns 0 if file on disk is the same or Text is in memory only
returns 1 if file has been modified on disk since last local edit