diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-07-18 20:27:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-07-18 20:27:25 +0400 |
commit | 119844eb23718870df614a68a035573e9c5e4e11 (patch) | |
tree | 0bc4f587f970c88b5c60c948fdfa8e420f4920ea /source/blender/editors/space_console | |
parent | 75b8badda5b044f56b512cd2874d80d7af1fd012 (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/editors/space_console')
4 files changed, 60 insertions, 35 deletions
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); +} |