diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-28 15:53:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-28 15:53:18 +0400 |
commit | ed61bfc9a6580360805a3daae1003df43a7f2c11 (patch) | |
tree | 29ee3248e82a5109b241127b1c2397ca11bf7bcb /source/blender/editors/space_console | |
parent | ca8d262e89c25d15368ec4eb2fe80111e732e1f7 (diff) |
style cleanup
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 126 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 374 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 100 |
3 files changed, 301 insertions, 299 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 1bfdcee1aae..2897c5d7d67 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -59,19 +59,19 @@ static void console_line_color(unsigned char fg[3], int type) { - switch(type) { - case CONSOLE_LINE_OUTPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); - break; - case CONSOLE_LINE_INPUT: - UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); - break; - case CONSOLE_LINE_INFO: - UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); - break; - case CONSOLE_LINE_ERROR: - UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); - break; + switch (type) { + case CONSOLE_LINE_OUTPUT: + UI_GetThemeColor3ubv(TH_CONSOLE_OUTPUT, fg); + break; + case CONSOLE_LINE_INPUT: + UI_GetThemeColor3ubv(TH_CONSOLE_INPUT, fg); + break; + case CONSOLE_LINE_INFO: + UI_GetThemeColor3ubv(TH_CONSOLE_INFO, fg); + break; + case CONSOLE_LINE_ERROR: + UI_GetThemeColor3ubv(TH_CONSOLE_ERROR, fg); + break; } } @@ -93,11 +93,11 @@ typedef struct ConsoleDrawContext { void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy) { /* fake the edit line being in the scroll buffer */ - ConsoleLine *cl= sc->history.last; - cl_dummy->type= CONSOLE_LINE_INPUT; - cl_dummy->len= cl_dummy->len_alloc= strlen(sc->prompt) + cl->len; - cl_dummy->len_alloc= cl_dummy->len + 1; - cl_dummy->line= MEM_mallocN(cl_dummy->len_alloc, "cl_dummy"); + ConsoleLine *cl = sc->history.last; + cl_dummy->type = CONSOLE_LINE_INPUT; + cl_dummy->len = cl_dummy->len_alloc = strlen(sc->prompt) + cl->len; + cl_dummy->len_alloc = cl_dummy->len + 1; + cl_dummy->line = MEM_mallocN(cl_dummy->len_alloc, "cl_dummy"); memcpy(cl_dummy->line, sc->prompt, (cl_dummy->len_alloc - cl->len)); memcpy(cl_dummy->line + ((cl_dummy->len_alloc - cl->len)) - 1, cl->line, cl->len + 1); BLI_addtail(&sc->scrollback, cl_dummy); @@ -116,73 +116,73 @@ void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dumm /* console textview callbacks */ static int console_textview_begin(TextViewContext *tvc) { - SpaceConsole *sc= (SpaceConsole *)tvc->arg1; - tvc->lheight= sc->lheight; - tvc->sel_start= sc->sel_start; - tvc->sel_end= sc->sel_end; + SpaceConsole *sc = (SpaceConsole *)tvc->arg1; + tvc->lheight = sc->lheight; + tvc->sel_start = sc->sel_start; + tvc->sel_end = sc->sel_end; /* iterator */ - tvc->iter= sc->scrollback.last; + tvc->iter = sc->scrollback.last; return (tvc->iter != NULL); } static void console_textview_end(TextViewContext *tvc) { - SpaceConsole *sc= (SpaceConsole *)tvc->arg1; + SpaceConsole *sc = (SpaceConsole *)tvc->arg1; (void)sc; } static int console_textview_step(TextViewContext *tvc) { - return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); + return ((tvc->iter = (void *)((Link *)tvc->iter)->prev) != NULL); } static int console_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) { - ConsoleLine *cl= (ConsoleLine *)tvc->iter; - *line= cl->line; - *len= cl->len; + ConsoleLine *cl = (ConsoleLine *)tvc->iter; + *line = cl->line; + *len = cl->len; return 1; } static int console_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char UNUSED(bg[3])) { - ConsoleLine *cl_iter= (ConsoleLine *)tvc->iter; + ConsoleLine *cl_iter = (ConsoleLine *)tvc->iter; /* annoying hack, to draw the prompt */ if (tvc->iter_index == 0) { - const SpaceConsole *sc= (SpaceConsole *)tvc->arg1; - const ConsoleLine *cl= (ConsoleLine *)sc->history.last; - const int prompt_len= strlen(sc->prompt); - const int cursor_loc= cl->cursor + prompt_len; + const SpaceConsole *sc = (SpaceConsole *)tvc->arg1; + const ConsoleLine *cl = (ConsoleLine *)sc->history.last; + const int prompt_len = strlen(sc->prompt); + const int cursor_loc = cl->cursor + prompt_len; int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; - xy[1] += tvc->lheight/6; + xy[1] += tvc->lheight / 6; /* account for wrapping */ if (cl->len < tvc->console_width) { /* simple case, no wrapping */ - pen[0]= tvc->cwidth * cursor_loc; - pen[1]= -2; + pen[0] = tvc->cwidth * cursor_loc; + pen[1] = -2; } else { /* wrap */ - pen[0]= tvc->cwidth * (cursor_loc % tvc->console_width); - pen[1]= -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight); + pen[0] = tvc->cwidth * (cursor_loc % tvc->console_width); + pen[1] = -2 + (((cl->len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight); } /* cursor */ UI_GetThemeColor3ubv(TH_CONSOLE_CURSOR, fg); glColor3ubv(fg); - glRecti( (xy[0] + pen[0]) - 1, - (xy[1] + pen[1]), - (xy[0] + pen[0]) + 1, - (xy[1] + pen[1] + tvc->lheight) - ); + glRecti((xy[0] + pen[0]) - 1, + (xy[1] + pen[1]), + (xy[0] + pen[0]) + 1, + (xy[1] + pen[1] + tvc->lheight) + ); } console_line_color(fg, cl_iter->type); @@ -193,33 +193,33 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, int draw, int mval[2], void **mouse_pick, int *pos_pick) { - ConsoleLine cl_dummy= {NULL}; - int ret= 0; + ConsoleLine cl_dummy = {NULL}; + int ret = 0; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; - TextViewContext tvc= {0}; + TextViewContext tvc = {0}; - tvc.begin= console_textview_begin; - tvc.end= console_textview_end; + tvc.begin = console_textview_begin; + tvc.end = console_textview_end; - tvc.step= console_textview_step; - tvc.line_get= console_textview_line_get; - tvc.line_color= console_textview_line_color; + tvc.step = console_textview_step; + tvc.line_get = console_textview_line_get; + tvc.line_color = console_textview_line_color; - tvc.arg1= sc; - tvc.arg2= NULL; + tvc.arg1 = sc; + tvc.arg2 = NULL; /* view */ - tvc.sel_start= sc->sel_start; - tvc.sel_end= sc->sel_end; - tvc.lheight= sc->lheight; + tvc.sel_start = sc->sel_start; + tvc.sel_end = sc->sel_end; + tvc.lheight = sc->lheight; tvc.ymin = v2d->cur.ymin; tvc.ymax = v2d->cur.ymax; - tvc.winx= ar->winx; + tvc.winx = ar->winx; console_scrollback_prompt_begin(sc, &cl_dummy); - ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); + ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); console_scrollback_prompt_end(sc, &cl_dummy); return ret; @@ -240,12 +240,12 @@ int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar) int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, int mval[2]) { - int pos_pick= 0; - void *mouse_pick= NULL; + int pos_pick = 0; + void *mouse_pick = NULL; int mval_clamp[2]; - mval_clamp[0]= CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx-(CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN)); - mval_clamp[1]= CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy-CONSOLE_DRAW_MARGIN); + mval_clamp[0] = CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx - (CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN)); + mval_clamp[1] = CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy - CONSOLE_DRAW_MARGIN); console_textview_main__internal(sc, ar, 0, mval_clamp, &mouse_pick, &pos_pick); return pos_pick; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 425cee38af0..d80b9e2ffb9 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -57,16 +57,16 @@ /* so when we type - the view scrolls to the bottom */ static void console_scroll_bottom(ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; v2d->cur.ymin = 0.0; - v2d->cur.ymax =(float)v2d->winy; + v2d->cur.ymax = (float)v2d->winy; } static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; - UI_view2d_totRect_set(v2d, ar->winx-1, console_textview_height(sc, ar)); + UI_view2d_totRect_set(v2d, ar->winx - 1, console_textview_height(sc, ar)); } static void console_select_offset(SpaceConsole *sc, const int offset) @@ -92,21 +92,21 @@ static void console_scrollback_limit(SpaceConsole *sc) { int tot; - if (U.scrollback < 32) U.scrollback= 256; // XXX - save in user defaults + if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults - for (tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--) + for (tot = BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--) console_scrollback_free(sc, sc->scrollback.first); } -static ConsoleLine * console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore) +static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore) { ConsoleLine *cl; - for (cl= sc->history.last; cl; cl= cl->prev) { - if (cl==cl_ignore) + for (cl = sc->history.last; cl; cl = cl->prev) { + if (cl == cl_ignore) continue; - if (strcmp(str, cl->line)==0) + if (strcmp(str, cl->line) == 0) return cl; } @@ -118,9 +118,9 @@ static int console_line_cursor_set(ConsoleLine *cl, int cursor) { int cursor_new; - if (cursor < 0) cursor_new = 0; - else if (cursor > cl->len) cursor_new = cl->len; - else cursor_new = cursor; + if (cursor < 0) cursor_new = 0; + else if (cursor > cl->len) cursor_new = cl->len; + else cursor_new = cursor; if (cursor_new == cl->cursor) { return FALSE; @@ -136,7 +136,7 @@ static void console_lb_debug__internal(ListBase *lb) ConsoleLine *cl; printf("%d: ", BLI_countlist(lb)); - for (cl= lb->first; cl; cl= cl->next) + for (cl = lb->first; cl; cl = cl->next) printf("<%s> ", cl->line); printf("\n"); @@ -144,7 +144,7 @@ static void console_lb_debug__internal(ListBase *lb) static void console_history_debug(const bContext *C) { - SpaceConsole *sc= CTX_wm_space_console(C); + SpaceConsole *sc = CTX_wm_space_console(C); console_lb_debug__internal(&sc->history); @@ -153,20 +153,20 @@ static void console_history_debug(const bContext *C) static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) { - ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); + ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); if (from) { - ci->line= BLI_strdup(from->line); - ci->len= strlen(ci->line); - ci->len_alloc= ci->len; + ci->line = BLI_strdup(from->line); + ci->len = strlen(ci->line); + ci->len_alloc = ci->len; - ci->cursor= from->cursor; - ci->type= from->type; + ci->cursor = from->cursor; + ci->type = from->type; } else { - ci->line= MEM_callocN(64, "console-in-line"); - ci->len_alloc= 64; - ci->len= 0; + ci->line = MEM_callocN(64, "console-in-line"); + ci->len_alloc = 64; + ci->len = 0; } BLI_addtail(lb, ci); @@ -175,7 +175,7 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from) { - SpaceConsole *sc= CTX_wm_space_console(C); + SpaceConsole *sc = CTX_wm_space_console(C); return console_lb_add__internal(&sc->history, from); } @@ -183,7 +183,7 @@ static ConsoleLine *console_history_add(const bContext *C, ConsoleLine *from) #if 0 /* may use later ? */ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) { - SpaceConsole *sc= CTX_wm_space_console(C); + SpaceConsole *sc = CTX_wm_space_console(C); return console_lb_add__internal(&sc->scrollback, from); } @@ -191,9 +191,9 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, int own) { - ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - if (own) ci->line= str; - else ci->line= BLI_strdup(str); + ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); + if (own) ci->line = str; + else ci->line = BLI_strdup(str); ci->len = ci->len_alloc = strlen(str); @@ -206,17 +206,17 @@ ConsoleLine *console_history_add_str(SpaceConsole *sc, char *str, int own) } ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, int own) { - ConsoleLine *ci= console_lb_add_str__internal(&sc->scrollback, str, own); + ConsoleLine *ci = console_lb_add_str__internal(&sc->scrollback, str, own); console_select_offset(sc, ci->len + 1); return ci; } ConsoleLine *console_history_verify(const bContext *C) { - SpaceConsole *sc= CTX_wm_space_console(C); - ConsoleLine *ci= sc->history.last; - if (ci==NULL) - ci= console_history_add(C, NULL); + SpaceConsole *sc = CTX_wm_space_console(C); + ConsoleLine *ci = sc->history.last; + if (ci == NULL) + ci = console_history_add(C, NULL); return ci; } @@ -226,13 +226,13 @@ static void console_line_verify_length(ConsoleLine *ci, int len) { /* resize the buffer if needed */ if (len >= ci->len_alloc) { - int new_len= len * 2; /* new length */ - char *new_line= MEM_callocN(new_len, "console line"); + int new_len = len * 2; /* new length */ + char *new_line = MEM_callocN(new_len, "console line"); memcpy(new_line, ci->line, ci->len); MEM_freeN(ci->line); - ci->line= new_line; - ci->len_alloc= new_len; + ci->line = new_line; + ci->len_alloc = new_len; } } @@ -240,18 +240,18 @@ static int console_line_insert(ConsoleLine *ci, char *str) { int len = strlen(str); - if (len>0 && str[len-1]=='\n') {/* stop new lines being pasted at the end of lines */ - str[len-1]= '\0'; + if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */ + str[len - 1] = '\0'; len--; } - if (len==0) + if (len == 0) return 0; console_line_verify_length(ci, len + ci->len); - memmove(ci->line+ci->cursor+len, ci->line+ci->cursor, (ci->len - ci->cursor)+1); - memcpy(ci->line+ci->cursor, str, len); + memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1); + memcpy(ci->line + ci->cursor, str, len); ci->len += len; ci->cursor += len; @@ -262,74 +262,75 @@ static int console_line_insert(ConsoleLine *ci, char *str) /* static funcs for text editing */ /* similar to the text editor, with some not used. keep compatible */ -static EnumPropertyItem console_move_type_items[]= { +static EnumPropertyItem console_move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {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", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int console_move_exec(bContext *C, wmOperator *op) { - ConsoleLine *ci= console_history_verify(C); + ConsoleLine *ci = console_history_verify(C); - int type= RNA_enum_get(op->ptr, "type"); - int done= 0; + int type = RNA_enum_get(op->ptr, "type"); + int done = 0; int pos; switch (type) { - case LINE_BEGIN: + case LINE_BEGIN: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, STRCUR_JUMP_ALL); done = console_line_cursor_set(ci, pos); - break; - case LINE_END: + break; + case LINE_END: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, STRCUR_JUMP_ALL); done = console_line_cursor_set(ci, pos); - break; - case PREV_CHAR: + break; + case PREV_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_PREV, STRCUR_JUMP_NONE); done = console_line_cursor_set(ci, pos); - break; - case NEXT_CHAR: + break; + case NEXT_CHAR: pos = ci->cursor; BLI_str_cursor_step_utf8(ci->line, ci->len, &pos, STRCUR_DIR_NEXT, STRCUR_JUMP_NONE); done = console_line_cursor_set(ci, pos); - break; - - /* - if the character is a delimiter then skip delimiters (including white space) - * - when jump over the word */ - case PREV_WORD: - pos = ci->cursor; - BLI_str_cursor_step_utf8(ci->line, ci->len, - &pos, STRCUR_DIR_PREV, - STRCUR_JUMP_DELIM); - done = console_line_cursor_set(ci, pos); - break; - case NEXT_WORD: - pos = ci->cursor; - BLI_str_cursor_step_utf8(ci->line, ci->len, - &pos, STRCUR_DIR_NEXT, - STRCUR_JUMP_DELIM); - done = console_line_cursor_set(ci, pos); - break; + break; + + /* - if the character is a delimiter then skip delimiters (including white space) + * - when jump over the word */ + case PREV_WORD: + pos = ci->cursor; + BLI_str_cursor_step_utf8(ci->line, ci->len, + &pos, STRCUR_DIR_PREV, + STRCUR_JUMP_DELIM); + done = console_line_cursor_set(ci, pos); + break; + case NEXT_WORD: + pos = ci->cursor; + BLI_str_cursor_step_utf8(ci->line, ci->len, + &pos, STRCUR_DIR_NEXT, + STRCUR_JUMP_DELIM); + done = console_line_cursor_set(ci, pos); + break; } if (done) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); ED_area_tag_redraw(sa); console_scroll_bottom(ar); @@ -357,26 +358,26 @@ void CONSOLE_OT_move(wmOperatorType *ot) #define TAB_LENGTH 4 static int console_insert_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ConsoleLine *ci= console_history_verify(C); - char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); + char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); int len; // XXX, alligned tab key hack - if (str[0]=='\t' && str[1]=='\0') { - len= TAB_LENGTH - (ci->cursor % TAB_LENGTH); + if (str[0] == '\t' && str[1] == '\0') { + len = TAB_LENGTH - (ci->cursor % TAB_LENGTH); MEM_freeN(str); - str= MEM_mallocN(len + 1, "insert_exec"); + str = MEM_mallocN(len + 1, "insert_exec"); memset(str, ' ', len); - str[len]= '\0'; + str[len] = '\0'; } - len= console_line_insert(ci, str); + len = console_line_insert(ci, str); MEM_freeN(str); - if (len==0) { + if (len == 0) { return OPERATOR_CANCELLED; } else { @@ -401,8 +402,8 @@ static int console_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) } else { char str[2]; - str[0]= event->ascii; - str[1]= '\0'; + str[0] = event->ascii; + str[1] = '\0'; RNA_string_set(op->ptr, "text", str); } @@ -430,42 +431,43 @@ void CONSOLE_OT_insert(wmOperatorType *ot) } -static EnumPropertyItem console_delete_type_items[]= { +static EnumPropertyItem console_delete_type_items[] = { {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}}; + {0, NULL, 0, NULL, NULL} +}; static int console_delete_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ConsoleLine *ci= console_history_verify(C); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); - const short type= RNA_enum_get(op->ptr, "type"); + const short type = RNA_enum_get(op->ptr, "type"); int done = 0; - if (ci->len==0) { + if (ci->len == 0) { return OPERATOR_CANCELLED; } - switch(type) { - case DEL_NEXT_CHAR: - if (ci->cursor < ci->len) { - memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); - ci->len--; - done= 1; - } - break; - case DEL_PREV_CHAR: - if (ci->cursor > 0) { - ci->cursor--; /* same as above */ - memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); - ci->len--; - done= 1; - } - break; + switch (type) { + case DEL_NEXT_CHAR: + if (ci->cursor < ci->len) { + memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1); + ci->len--; + done = 1; + } + break; + case DEL_PREV_CHAR: + if (ci->cursor > 0) { + ci->cursor--; /* same as above */ + memmove(ci->line + ci->cursor, ci->line + ci->cursor + 1, (ci->len - ci->cursor) + 1); + ci->len--; + done = 1; + } + break; } if (!done) { @@ -503,11 +505,11 @@ void CONSOLE_OT_delete(wmOperatorType *ot) /* the python exec operator uses this */ static int console_clear_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); - short scrollback= RNA_boolean_get(op->ptr, "scrollback"); - short history= RNA_boolean_get(op->ptr, "history"); + short scrollback = RNA_boolean_get(op->ptr, "scrollback"); + short history = RNA_boolean_get(op->ptr, "history"); /*ConsoleLine *ci= */ console_history_verify(C); @@ -548,42 +550,42 @@ void CONSOLE_OT_clear(wmOperatorType *ot) /* the python exec operator uses this */ static int console_history_cycle_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); - ConsoleLine *ci= console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */ - short reverse= RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ - int prev_len= ci->len; + ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */ + short reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ + int prev_len = ci->len; /* keep a copy of the line above so when history is cycled * this is the only function that needs to know about the double-up */ if (ci->prev) { - ConsoleLine *ci_prev= (ConsoleLine *)ci->prev; + ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; - if (strcmp(ci->line, ci_prev->line)==0) + if (strcmp(ci->line, ci_prev->line) == 0) console_history_free(sc, ci_prev); } if (reverse) { /* last item in mistory */ - ci= sc->history.last; + ci = sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); } else { - ci= sc->history.first; + ci = sc->history.first; BLI_remlink(&sc->history, ci); BLI_addtail(&sc->history, ci); } - { /* add a duplicate of the new arg and remove all other instances */ + { /* add a duplicate of the new arg and remove all other instances */ ConsoleLine *cl; - while ((cl= console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); console_history_add(C, (ConsoleLine *)sc->history.last); } - ci= sc->history.last; + ci = sc->history.last; console_select_offset(sc, ci->len - prev_len); /* could be wrapped so update scroll rect */ @@ -614,28 +616,28 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) /* the python exec operator uses this */ static int console_history_append_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ScrArea *sa= CTX_wm_area(C); - ConsoleLine *ci= console_history_verify(C); - char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ - int cursor= RNA_int_get(op->ptr, "current_character"); - short rem_dupes= RNA_boolean_get(op->ptr, "remove_duplicates"); - int prev_len= ci->len; + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); + ConsoleLine *ci = console_history_verify(C); + char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ + int cursor = RNA_int_get(op->ptr, "current_character"); + short rem_dupes = RNA_boolean_get(op->ptr, "remove_duplicates"); + int prev_len = ci->len; if (rem_dupes) { ConsoleLine *cl; - while ((cl= console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); - if (strcmp(str, ci->line)==0) { + if (strcmp(str, ci->line) == 0) { MEM_freeN(str); return OPERATOR_FINISHED; } } - ci= console_history_add_str(sc, str, 1); /* own the string */ + ci = console_history_add_str(sc, str, 1); /* own the string */ console_select_offset(sc, ci->len - prev_len); console_line_cursor_set(ci, cursor); @@ -671,17 +673,17 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) /* the python exec operator uses this */ static int console_scrollback_append_exec(bContext *C, wmOperator *op) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); ConsoleLine *ci; - char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ - int type= RNA_enum_get(op->ptr, "type"); + char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ + int type = RNA_enum_get(op->ptr, "type"); console_history_verify(C); - ci= console_scrollback_add_str(sc, str, 1); /* own the string */ - ci->type= type; + ci = console_scrollback_add_str(sc, str, 1); /* own the string */ + ci->type = type; console_scrollback_limit(sc); @@ -700,10 +702,10 @@ 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", ""}, + {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 */ @@ -723,20 +725,20 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceConsole *sc= CTX_wm_space_console(C); + SpaceConsole *sc = CTX_wm_space_console(C); - DynStr *buf_dyn= BLI_dynstr_new(); + DynStr *buf_dyn = BLI_dynstr_new(); char *buf_str; ConsoleLine *cl; int sel[2]; - int offset= 0; + int offset = 0; - ConsoleLine cl_dummy= {NULL}; + ConsoleLine cl_dummy = {NULL}; #if 0 /* copy whole file */ - for (cl= sc->scrollback.first; cl; cl= cl->next) { + for (cl = sc->scrollback.first; cl; cl = cl->next) { BLI_dynstr_append(buf_dyn, cl->line); BLI_dynstr_append(buf_dyn, "\n"); } @@ -747,23 +749,23 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) console_scrollback_prompt_begin(sc, &cl_dummy); - for (cl= sc->scrollback.first; cl; cl= cl->next) { + for (cl = sc->scrollback.first; cl; cl = cl->next) { offset += cl->len + 1; } - if (offset==0) { + if (offset == 0) { console_scrollback_prompt_end(sc, &cl_dummy); return OPERATOR_CANCELLED; } offset -= 1; - sel[0]= offset - sc->sel_end; - sel[1]= offset - sc->sel_start; + sel[0] = offset - sc->sel_end; + sel[1] = offset - sc->sel_start; - for (cl= sc->scrollback.first; cl; cl= cl->next) { + for (cl = sc->scrollback.first; cl; cl = cl->next) { if (sel[0] <= cl->len && sel[1] >= 0) { - int sta= MAX2(sel[0], 0); - int end= MIN2(sel[1], cl->len); + int sta = MAX2(sel[0], 0); + int end = MIN2(sel[1], cl->len); if (BLI_dynstr_get_len(buf_dyn)) BLI_dynstr_append(buf_dyn, "\n"); @@ -775,7 +777,7 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) sel[1] -= cl->len + 1; } - buf_str= BLI_dynstr_get_cstring(buf_dyn); + buf_str = BLI_dynstr_get_cstring(buf_dyn); BLI_dynstr_free(buf_dyn); WM_clipboard_text_set(buf_str, 0); @@ -803,28 +805,28 @@ void CONSOLE_OT_copy(wmOperatorType *ot) static int console_paste_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ConsoleLine *ci= console_history_verify(C); + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); - char *buf_str= WM_clipboard_text_get(0); + char *buf_str = WM_clipboard_text_get(0); char *buf_step, *buf_next; - if (buf_str==NULL) + if (buf_str == NULL) return OPERATOR_CANCELLED; - buf_step= buf_str; + buf_step = buf_str; - while ((buf_next=buf_step) && buf_next[0] != '\0') { - buf_step= strchr(buf_next, '\n'); + while ((buf_next = buf_step) && buf_next[0] != '\0') { + buf_step = strchr(buf_next, '\n'); if (buf_step) { - *buf_step= '\0'; + *buf_step = '\0'; buf_step++; } if (buf_next != buf_str) { WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); - ci= console_history_verify(C); + ci = console_history_verify(C); } console_select_offset(sc, console_line_insert(ci, buf_next)); @@ -863,10 +865,10 @@ typedef struct SetConsoleCursor { static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleCursor *scu, int mval[2], int UNUSED(sel)) { int pos; - pos= console_char_pick(sc, ar, mval); + pos = console_char_pick(sc, ar, mval); if (scu->sel_init == INT_MAX) { - scu->sel_init= pos; + scu->sel_init = pos; sc->sel_start = sc->sel_end = pos; return; } @@ -886,17 +888,17 @@ static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleC static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *event) { - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - SetConsoleCursor *scu= op->customdata; + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + SetConsoleCursor *scu = op->customdata; int mval[2]; int sel_prev[2]; - mval[0]= event->mval[0]; - mval[1]= event->mval[1]; + mval[0] = event->mval[0]; + mval[1] = event->mval[1]; - sel_prev[0]= sc->sel_start; - sel_prev[1]= sc->sel_end; + sel_prev[0] = sc->sel_start; + sel_prev[1] = sc->sel_end; console_cursor_set_to_pos(sc, ar, scu, mval, TRUE); @@ -909,7 +911,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op) { // SpaceConsole *sc= CTX_wm_space_console(C); - SetConsoleCursor *scu= op->customdata; + SetConsoleCursor *scu = op->customdata; #if 0 if (txt_has_sel(text)) { @@ -924,15 +926,15 @@ static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op) static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { - SpaceConsole *sc= CTX_wm_space_console(C); + SpaceConsole *sc = CTX_wm_space_console(C); // ARegion *ar= CTX_wm_region(C); SetConsoleCursor *scu; - op->customdata= MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor"); - scu= op->customdata; + op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor"); + scu = op->customdata; - scu->sel_old[0]= sc->sel_start; - scu->sel_old[1]= sc->sel_end; + scu->sel_old[0] = sc->sel_start; + scu->sel_old[1] = sc->sel_end; scu->sel_init = INT_MAX; @@ -945,7 +947,7 @@ static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *eve static int console_modal_select(bContext *C, wmOperator *op, wmEvent *event) { - switch(event->type) { + switch (event->type) { case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 1867f93b1ef..0dbd4876a65 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -54,7 +54,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "console_intern.h" // own include +#include "console_intern.h" // own include /* ******************** default callbacks for console space ***************** */ @@ -63,32 +63,32 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) ARegion *ar; SpaceConsole *sconsole; - sconsole= MEM_callocN(sizeof(SpaceConsole), "initconsole"); - sconsole->spacetype= SPACE_CONSOLE; + sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole"); + sconsole->spacetype = SPACE_CONSOLE; - sconsole->lheight= 14; + sconsole->lheight = 14; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for console"); + ar = MEM_callocN(sizeof(ARegion), "header for console"); BLI_addtail(&sconsole->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for text"); + ar = MEM_callocN(sizeof(ARegion), "main area for text"); BLI_addtail(&sconsole->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; /* keep in sync with info */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ + ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */ ar->v2d.keepofs |= V2D_LOCKOFS_X; - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM); @@ -99,7 +99,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void console_free(SpaceLink *sl) { - SpaceConsole *sc= (SpaceConsole*) sl; + SpaceConsole *sc = (SpaceConsole *) sl; while (sc->scrollback.first) console_scrollback_free(sc, sc->scrollback.first); @@ -117,13 +117,13 @@ static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa) static SpaceLink *console_duplicate(SpaceLink *sl) { - SpaceConsole *sconsolen= MEM_dupallocN(sl); + SpaceConsole *sconsolen = MEM_dupallocN(sl); /* clear or remove stuff from old */ /* TODO - duplicate?, then we also need to duplicate the py namespace */ - sconsolen->scrollback.first= sconsolen->scrollback.last= NULL; - sconsolen->history.first= sconsolen->history.last= NULL; + sconsolen->scrollback.first = sconsolen->scrollback.last = NULL; + sconsolen->history.first = sconsolen->history.last = NULL; return (SpaceLink *)sconsolen; } @@ -136,13 +136,13 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ListBase *lb; - const float prev_y_min= ar->v2d.cur.ymin; /* so re-sizing keeps the cursor visible */ + const float prev_y_min = ar->v2d.cur.ymin; /* so re-sizing keeps the cursor visible */ UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* always keep the bottom part of the view aligned, less annoying */ if (prev_y_min != ar->v2d.cur.ymin) { - const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin; + const float cur_y_range = ar->v2d.cur.ymax - ar->v2d.cur.ymin; ar->v2d.cur.ymin = prev_y_min; ar->v2d.cur.ymax = prev_y_min + cur_y_range; } @@ -152,7 +152,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); /* add drop boxes */ - lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); WM_event_add_dropbox_handler(&ar->handlers, lb); } @@ -163,7 +163,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { // SpaceConsole *sc= CTX_wm_space_console(C); - if (drag->type==WM_DRAG_ID) + if (drag->type == WM_DRAG_ID) return 1; return 0; } @@ -171,10 +171,10 @@ static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event static void id_drop_copy(wmDrag *drag, wmDropBox *drop) { char text[64]; - ID *id= drag->poin; + ID *id = drag->poin; char id_esc[(sizeof(id->name) - 2) * 2]; - BLI_strescape(id_esc, id->name+2, sizeof(id_esc)); + BLI_strescape(id_esc, id->name + 2, sizeof(id_esc)); BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc); @@ -185,14 +185,14 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { // SpaceConsole *sc= CTX_wm_space_console(C); - if (drag->type==WM_DRAG_PATH) + if (drag->type == WM_DRAG_PATH) return 1; return 0; } static void path_drop_copy(wmDrag *drag, wmDropBox *drop) { - char pathname[FILE_MAX+2]; + char pathname[FILE_MAX + 2]; BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); RNA_string_set(drop->ptr, "text", pathname); } @@ -201,7 +201,7 @@ static void path_drop_copy(wmDrag *drag, wmDropBox *drop) /* this region dropbox definition */ static void console_dropboxes(void) { - ListBase *lb= WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); + ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy); WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy); @@ -212,11 +212,11 @@ static void console_dropboxes(void) static void console_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceConsole *sc= CTX_wm_space_console(C); - View2D *v2d= &ar->v2d; + SpaceConsole *sc = CTX_wm_space_console(C); + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - if (sc->scrollback.first==NULL) + if (sc->scrollback.first == NULL) WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); /* clear and setup matrix */ @@ -235,7 +235,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -355,7 +355,7 @@ static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) // SpaceInfo *sinfo= sa->spacedata.first; /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_SPACE: if (wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */ ED_region_tag_redraw(ar); @@ -367,41 +367,41 @@ static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_console(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype console"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console"); ARegionType *art; - st->spaceid= SPACE_CONSOLE; + st->spaceid = SPACE_CONSOLE; strncpy(st->name, "Console", BKE_ST_MAXNAME); - st->new= console_new; - st->free= console_free; - st->init= console_init; - st->duplicate= console_duplicate; - st->operatortypes= console_operatortypes; - st->keymap= console_keymap; - st->dropboxes= console_dropboxes; + st->new = console_new; + st->free = console_free; + st->init = console_init; + st->duplicate = console_duplicate; + st->operatortypes = console_operatortypes; + st->keymap = console_keymap; + st->dropboxes = console_dropboxes; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype console region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype console region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= console_main_area_init; - art->draw= console_main_area_draw; - art->listener= console_main_area_listener; + art->init = console_main_area_init; + art->draw = console_main_area_draw; + art->listener = console_main_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype console region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype console region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - art->init= console_header_area_init; - art->draw= console_header_area_draw; + art->init = console_header_area_init; + art->draw = console_header_area_draw; BLI_addhead(&st->regiontypes, art); |