fix for 'live edit', running python scripts as you type
- errors would jump to the line which gets in the way. - the window wouldn't always redraw.
This commit is contained in:
parent
a12315e4ec
commit
61235fcc8a
@ -32,6 +32,7 @@ base = abspath(base)
|
||||
|
||||
SIMPLE_PROJECTFILE = False
|
||||
|
||||
|
||||
def source_list(path, filename_check=None):
|
||||
for dirpath, dirnames, filenames in os.walk(path):
|
||||
|
||||
@ -85,7 +86,7 @@ def cmake_advanced_info():
|
||||
|
||||
includes = []
|
||||
defines = []
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@ -98,7 +99,7 @@ def cmake_advanced_info():
|
||||
sys.exit(1)
|
||||
|
||||
# create_eclipse_project(cmake_dir)
|
||||
|
||||
|
||||
from xml.dom.minidom import parse
|
||||
tree = parse(os.path.join(cmake_dir, ".cproject"))
|
||||
'''
|
||||
@ -106,12 +107,12 @@ def cmake_advanced_info():
|
||||
f.write(tree.toprettyxml(indent=" ", newl=""))
|
||||
'''
|
||||
ELEMENT_NODE = tree.ELEMENT_NODE
|
||||
|
||||
|
||||
cproject, = tree.getElementsByTagName("cproject")
|
||||
for storage in cproject.childNodes:
|
||||
if storage.nodeType != ELEMENT_NODE:
|
||||
continue
|
||||
|
||||
|
||||
if storage.attributes["moduleId"].value == "org.eclipse.cdt.core.settings":
|
||||
cconfig = storage.getElementsByTagName("cconfiguration")[0]
|
||||
for substorage in cconfig.childNodes:
|
||||
@ -139,7 +140,7 @@ def cmake_advanced_info():
|
||||
# <pathentry include="/data/src/blender/blender/source/blender/editors/include" kind="inc" path="" system="true"/>
|
||||
includes.append(path.attributes["include"].value)
|
||||
else:
|
||||
print(kind)
|
||||
pass
|
||||
|
||||
return includes, defines
|
||||
|
||||
@ -169,7 +170,7 @@ def main():
|
||||
f.write("// ADD PREDEFINED MACROS HERE!\n")
|
||||
else:
|
||||
includes, defines = cmake_advanced_info()
|
||||
|
||||
|
||||
PROJECT_NAME = "Blender"
|
||||
f = open(join(base, "%s.files" % PROJECT_NAME), 'w')
|
||||
f.write("\n".join(files_rel))
|
||||
|
@ -565,6 +565,35 @@ static int run_script_poll(bContext *C)
|
||||
return (CTX_data_edit_text(C) != NULL);
|
||||
}
|
||||
|
||||
static int run_script(bContext *C, ReportList *reports)
|
||||
{
|
||||
Text *text= CTX_data_edit_text(C);
|
||||
const short is_live= (reports == NULL);
|
||||
|
||||
/* only for comparison */
|
||||
void *curl_prev= text->curl;
|
||||
int curc_prev= text->curc;
|
||||
|
||||
if (BPY_text_exec(C, text, reports, !is_live)) {
|
||||
if(is_live) {
|
||||
/* for nice live updates */
|
||||
WM_event_add_notifier(C, NC_WINDOW|NA_EDITED, NULL);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
/* Dont report error messages while live editing */
|
||||
if(!is_live) {
|
||||
if(text->curl != curl_prev || curc_prev != text->curc) {
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text);
|
||||
}
|
||||
|
||||
BKE_report(reports, RPT_ERROR, "Python script fail, look in the console for now...");
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static int run_script_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
#ifndef WITH_PYTHON
|
||||
@ -574,26 +603,7 @@ static int run_script_exec(bContext *C, wmOperator *op)
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
#else
|
||||
Text *text= CTX_data_edit_text(C);
|
||||
SpaceText *st= CTX_wm_space_text(C);
|
||||
|
||||
/* only for comparison */
|
||||
void *curl_prev= text->curl;
|
||||
int curc_prev= text->curc;
|
||||
|
||||
if (BPY_text_exec(C, text, op->reports))
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
/* Dont report error messages while live editing */
|
||||
if(!(st && st->live_edit)) {
|
||||
if(text->curl != curl_prev || curc_prev != text->curc) {
|
||||
text_update_cursor_moved(C);
|
||||
WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text);
|
||||
}
|
||||
|
||||
BKE_report(op->reports, RPT_ERROR, "Python script fail, look in the console for now...");
|
||||
}
|
||||
return OPERATOR_CANCELLED;
|
||||
return run_script(C, op->reports);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -776,7 +786,7 @@ static int paste_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if(CTX_wm_space_text(C)->live_edit)
|
||||
run_script_exec(C, op);
|
||||
run_script(C, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -833,7 +843,7 @@ void TEXT_OT_copy(wmOperatorType *ot)
|
||||
|
||||
/******************* cut operator *********************/
|
||||
|
||||
static int cut_exec(bContext *C, wmOperator *op)
|
||||
static int cut_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Text *text= CTX_data_edit_text(C);
|
||||
|
||||
@ -847,7 +857,7 @@ static int cut_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if(CTX_wm_space_text(C)->live_edit)
|
||||
run_script_exec(C, op);
|
||||
run_script(C, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -1983,7 +1993,7 @@ static int delete_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if(CTX_wm_space_text(C)->live_edit)
|
||||
run_script_exec(C, op);
|
||||
run_script(C, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -2776,7 +2786,7 @@ static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
/* run the script while editing, evil but useful */
|
||||
if(ret==OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit)
|
||||
run_script_exec(C, op);
|
||||
run_script(C, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void BPY_python_end( void );
|
||||
|
||||
/* 2.5 UI Scripts */
|
||||
int BPY_filepath_exec(struct bContext *C, const char *filepath, struct ReportList *reports);
|
||||
int BPY_text_exec(struct bContext *C, struct Text *text, struct ReportList *reports);
|
||||
int BPY_text_exec(struct bContext *C, struct Text *text, struct ReportList *reports, const short do_jump);
|
||||
void BPY_text_free_code(struct Text *text);
|
||||
void BPY_modules_update(struct bContext *C); // XXX - annoying, need this for pointers that get out of date
|
||||
void BPY_modules_load_user(struct bContext *C);
|
||||
|
@ -353,7 +353,7 @@ typedef struct {
|
||||
} PyModuleObject;
|
||||
#endif
|
||||
|
||||
static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports)
|
||||
static int python_script_exec(bContext *C, const char *fn, struct Text *text, struct ReportList *reports, const short do_jump)
|
||||
{
|
||||
PyObject *main_mod= NULL;
|
||||
PyObject *py_dict= NULL, *py_result= NULL;
|
||||
@ -382,7 +382,9 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
MEM_freeN( buf );
|
||||
|
||||
if(PyErr_Occurred()) {
|
||||
python_script_error_jump_text(text);
|
||||
if(do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
BPY_text_free_code(text);
|
||||
}
|
||||
}
|
||||
@ -429,7 +431,9 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
|
||||
if (!py_result) {
|
||||
if(text) {
|
||||
python_script_error_jump_text(text);
|
||||
if(do_jump) {
|
||||
python_script_error_jump_text(text);
|
||||
}
|
||||
}
|
||||
BPy_errors_to_report(reports);
|
||||
} else {
|
||||
@ -459,13 +463,13 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
|
||||
/* Can run a file or text block */
|
||||
int BPY_filepath_exec(bContext *C, const char *filepath, struct ReportList *reports)
|
||||
{
|
||||
return python_script_exec(C, filepath, NULL, reports);
|
||||
return python_script_exec(C, filepath, NULL, reports, FALSE);
|
||||
}
|
||||
|
||||
|
||||
int BPY_text_exec(bContext *C, struct Text *text, struct ReportList *reports)
|
||||
int BPY_text_exec(bContext *C, struct Text *text, struct ReportList *reports, const short do_jump)
|
||||
{
|
||||
return python_script_exec(C, NULL, text, reports);
|
||||
return python_script_exec(C, NULL, text, reports, do_jump);
|
||||
}
|
||||
|
||||
void BPY_DECREF(void *pyob_ptr)
|
||||
|
Loading…
Reference in New Issue
Block a user