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
This commit is contained in:
@@ -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); */
|
||||
}
|
||||
|
||||
/* --------------- */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user