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-18 20:27:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-18 20:27:25 +0400
commit119844eb23718870df614a68a035573e9c5e4e11 (patch)
tree0bc4f587f970c88b5c60c948fdfa8e420f4920ea /source/blender
parent75b8badda5b044f56b512cd2874d80d7af1fd012 (diff)
fixes for errors on startup and compiler errors and draw speedup.
* Drawing the console text now skips all lines outside the view bounds. * Added dummy C operators for console.exec and console.autocomplete so blender wont complain at startup, its not really a problem but people testing reported it a few times. Eventually we should have some way python operators are initialized before the spaces operators are checked. * reordered the imports so the "ui" dir is imported before "io", for now this means bpy.ops is defined before exporters and importers need to use it, was causing a python error on startup. * fixed all compiler warnings for the console (gcc4.4) * stopped operators were printing out the return flag. * removed references to ACT_OT_test, TEXT_OT_console_exec and TEXT_OT_console_autocomplete
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_action/action_ops.c2
-rw-r--r--source/blender/editors/space_console/console_draw.c28
-rw-r--r--source/blender/editors/space_console/console_intern.h13
-rw-r--r--source/blender/editors/space_console/console_ops.c43
-rw-r--r--source/blender/editors/space_console/space_console.c11
-rw-r--r--source/blender/editors/space_text/space_text.c4
-rw-r--r--source/blender/python/intern/bpy_interface.c2
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c3
8 files changed, 65 insertions, 41 deletions
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 490f301e9e8..f18b6197eb3 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -156,7 +156,7 @@ static void action_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
transform_keymap_for_space(wm, keymap, SPACE_ACTION);
/* test */
- WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0);
+ /* WM_keymap_add_item(keymap, "ACT_OT_test", QKEY, KM_PRESS, 0, 0); */
}
/* --------------- */
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 96641fd8fbd..65e18beabbc 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -109,23 +109,28 @@ static void console_report_color(unsigned char *fg, int type)
static int console_draw_string( char *str, int str_len,
int console_width, int lheight,
unsigned char *fg, unsigned char *bg,
- int winx, int winy,
+ int winx,
+ int ymin, int ymax,
int *x, int *y, int draw)
{
int rct_ofs= lheight/4;
- int tot_lines = (str_len/console_width)+1; /* total number of lines for wrapping */
+ int tot_lines = (str_len/console_width)+1; /* total number of lines for wrapping */
+ int y_next = (str_len > console_width) ? (*y)+lheight*tot_lines : (*y)+lheight;
/* just advance the height */
if(draw==0) {
- if(str_len > console_width) (*y) += tot_lines * lheight;
- else (*y) += lheight;
-
+ *y= y_next;
+ return 1;
+ }
+ else if (y_next-lheight < ymin) {
+ /* have not reached the drawable area so don't break */
+ *y= y_next;
return 1;
}
if(str_len > console_width) { /* wrap? */
char *line_stride= str + ((tot_lines-1) * console_width); /* advance to the last line and draw it first */
- char eol; /* baclup the end of wrapping */
+ char eol; /* baclup the end of wrapping */
if(bg) {
glColor3ub(bg[0], bg[1], bg[2]);
@@ -149,7 +154,7 @@ static int console_draw_string( char *str, int str_len,
line_stride[console_width] = eol; /* restore */
/* check if were out of view bounds */
- if(*y > winy)
+ if(*y > ymax)
return 0;
}
}
@@ -165,7 +170,7 @@ static int console_draw_string( char *str, int str_len,
BLF_position(*x, *y, 0); (*y) += lheight;
BLF_draw(str);
- if(*y > winy)
+ if(*y > ymax)
return 0;
}
@@ -230,7 +235,8 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
if(!console_draw_string( cl->line, cl->len,
console_width, sc->lheight,
fg, NULL,
- ar->winx-CONSOLE_DRAW_MARGIN, v2d->cur.ymax,
+ ar->winx-CONSOLE_DRAW_MARGIN,
+ v2d->cur.ymin, v2d->cur.ymax,
&x, &y, draw))
{
/* when drawing, if we pass v2d->cur.ymax, then quit */
@@ -268,7 +274,8 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
if(!console_draw_string( report->message, report->len,
console_width, sc->lheight,
fg, bool?bg:NULL,
- ar->winx-CONSOLE_DRAW_MARGIN, v2d->cur.ymax,
+ ar->winx-CONSOLE_DRAW_MARGIN,
+ v2d->cur.ymin, v2d->cur.ymax,
&x, &y, draw))
{
/* when drawing, if we pass v2d->cur.ymax, then quit */
@@ -279,7 +286,6 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
bool = !(bool);
}
-
}
}
y += sc->lheight*2;
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index 2e5af9c5ffd..0a911fb546a 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -61,16 +61,11 @@ void CONSOLE_OT_clear(wmOperatorType *ot);
void CONSOLE_OT_history_cycle(wmOperatorType *ot);
void CONSOLE_OT_zoom(wmOperatorType *ot);
+/* DUMMY OPS. python will replace */
+void CONSOLE_OT_exec(wmOperatorType *ot);
+void CONSOLE_OT_autocomplete(wmOperatorType *ot);
+
enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD };
enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL };
-/* defined in DNA_space_types.h */
-static EnumPropertyItem console_line_type_items[] = {
- {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
- {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
- {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
- {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
- {0, NULL, 0, NULL, NULL}};
-
#endif /* ED_CONSOLE_INTERN_H */
-
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index c82463eb768..359202ba022 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -128,12 +128,14 @@ static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from)
return console_lb_add__internal(&sc->history, from);
}
+#if 0 /* may use later ? */
static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
{
SpaceConsole *sc= CTX_wm_space_console(C);
return console_lb_add__internal(&sc->scrollback, from);
}
+#endif
static ConsoleLine *console_lb_add_str__internal(ListBase *lb, const bContext *C, char *str, int own)
{
@@ -198,7 +200,7 @@ static int console_line_insert(ConsoleLine *ci, char *str)
return len;
}
-static int console_edit_poll(const bContext *C)
+static int console_edit_poll(bContext *C)
{
SpaceConsole *sc= CTX_wm_space_console(C);
@@ -221,7 +223,7 @@ static EnumPropertyItem move_type_items[]= {
{NEXT_WORD, "NEXT_WORD", 0, "Next Word", ""},
{0, NULL, 0, NULL, NULL}};
-static int move_exec(const bContext *C, wmOperator *op)
+static int move_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci= console_history_verify(C);
@@ -268,7 +270,7 @@ void CONSOLE_OT_move(wmOperatorType *ot)
}
-static int insert_exec(const bContext *C, wmOperator *op)
+static int insert_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci= console_history_verify(C);
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0);
@@ -285,7 +287,7 @@ static int insert_exec(const bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
-static int insert_invoke(const bContext *C, wmOperator *op, wmEvent *event)
+static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
if(!RNA_property_is_set(op->ptr, "text")) {
char str[2] = {event->ascii, '\0'};
@@ -320,7 +322,7 @@ static EnumPropertyItem delete_type_items[]= {
// {DEL_PREV_WORD, "PREVIOUS_WORD", 0, "Previous Word", ""},
{0, NULL, 0, NULL, NULL}};
-static int delete_exec(const bContext *C, wmOperator *op)
+static int delete_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci= console_history_verify(C);
@@ -380,7 +382,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot)
/* the python exec operator uses this */
-static int clear_exec(const bContext *C, wmOperator *op)
+static int clear_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
@@ -425,7 +427,7 @@ void CONSOLE_OT_clear(wmOperatorType *ot)
/* the python exec operator uses this */
-static int history_cycle_exec(const bContext *C, wmOperator *op)
+static int history_cycle_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ConsoleLine *ci= console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */
@@ -467,7 +469,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot)
/* the python exec operator uses this */
-static int history_append_exec(const bContext *C, wmOperator *op)
+static int history_append_exec(bContext *C, wmOperator *op)
{
ConsoleLine *ci= console_history_verify(C);
@@ -503,7 +505,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot)
/* the python exec operator uses this */
-static int scrollback_append_exec(const bContext *C, wmOperator *op)
+static int scrollback_append_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
ConsoleLine *ci= console_history_verify(C);
@@ -523,6 +525,14 @@ static int scrollback_append_exec(const bContext *C, wmOperator *op)
void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
{
+ /* defined in DNA_space_types.h */
+ static EnumPropertyItem console_line_type_items[] = {
+ {CONSOLE_LINE_OUTPUT, "OUTPUT", 0, "Output", ""},
+ {CONSOLE_LINE_INPUT, "INPUT", 0, "Input", ""},
+ {CONSOLE_LINE_INFO, "INFO", 0, "Information", ""},
+ {CONSOLE_LINE_ERROR, "ERROR", 0, "Error", ""},
+ {0, NULL, 0, NULL, NULL}};
+
/* identifiers */
ot->name= "Scrollback Append";
ot->idname= "CONSOLE_OT_scrollback_append";
@@ -539,7 +549,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", console_line_type_items, CONSOLE_LINE_OUTPUT, "Type", "Console output type.");
}
-static int zoom_exec(const bContext *C, wmOperator *op)
+static int zoom_exec(bContext *C, wmOperator *op)
{
SpaceConsole *sc= CTX_wm_space_console(C);
@@ -570,3 +580,16 @@ void CONSOLE_OT_zoom(wmOperatorType *ot)
RNA_def_int(ot->srna, "delta", 0, 0, INT_MAX, "Delta", "Scale the view font.", 0, 1000);
}
+/* Dummy operators, python will replace these, so blender can start without any errors */
+void CONSOLE_OT_exec(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "CONSOLE_OT_exec dummy";
+ ot->idname= "CONSOLE_OT_exec";
+}
+void CONSOLE_OT_autocomplete(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "CONSOLE_OT_autocomplete dummy";
+ ot->idname= "CONSOLE_OT_autocomplete";
+}
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 6bc948a880a..5551a303ead 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -215,6 +215,10 @@ void console_operatortypes(void)
WM_operatortype_append(CONSOLE_OT_clear);
WM_operatortype_append(CONSOLE_OT_history_cycle);
WM_operatortype_append(CONSOLE_OT_zoom);
+
+ /* Dummy, defined in space_console.py */
+ WM_operatortype_append(CONSOLE_OT_exec);
+ WM_operatortype_append(CONSOLE_OT_autocomplete);
}
void console_keymap(struct wmWindowManager *wm)
@@ -345,10 +349,7 @@ void ED_spacetype_console(void)
art->draw= console_header_area_draw;
BLI_addhead(&sc->regiontypes, art);
-
-
-
- BKE_spacetype_register(sc);
-}
+ BKE_spacetype_register(sc);
+}
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 68848c39c25..c260fe05093 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -285,10 +285,6 @@ static void text_keymap(struct wmWindowManager *wm)
WM_keymap_add_item(keymap, "TEXT_OT_to_3d_object", MKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TEXT_OT_line_break", RETKEY, KM_PRESS, 0, 0);
-#ifndef DISABLE_PYTHON
- WM_keymap_add_item(keymap, "TEXT_OT_console_exec", RETKEY, KM_PRESS, KM_SHIFT, 0); /* python operator - space_text.py */
- WM_keymap_add_item(keymap, "TEXT_OT_console_autocomplete", RETKEY, KM_PRESS, KM_ALT, 0); /* python operator - space_text.py */
-#endif
WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0);
WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 8fcd69c67c7..18dae972db4 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -452,7 +452,7 @@ void BPY_run_ui_scripts(bContext *C, int reload)
char *file_extension;
char *dirname;
char path[FILE_MAX];
- char *dirs[] = {"io", "ui", NULL};
+ char *dirs[] = {"ui", "io", NULL};
int a;
PyGILState_STATE gilstate;
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 33d276ba5b3..9f4137a15c0 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -191,6 +191,8 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
Py_DECREF(ret);
}
+#if 0 /* only for testing */
+
/* print operator return value */
if (mode != PYOP_POLL) {
char flag_str[100];
@@ -216,6 +218,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve
fprintf(stderr, "%s's %s returned %s\n", class_name, mode == PYOP_EXEC ? "execute" : "invoke", flag_str);
}
+#endif
PyGILState_Release(gilstate);
bpy_import_main_set(NULL);