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>2019-03-26 13:16:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-26 13:16:47 +0300
commitce3b78c73a7ccc16fdccf7decedb5d1578dfdf0a (patch)
tree87f1a9c41ebe6f74806f1ae76206f1d328c85700 /source/blender/editors/space_console
parent5279d118c2ddee0e6fef66aaf78452c1b302dd42 (diff)
Cleanup: style, use braces for editor/spaces
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_draw.c3
-rw-r--r--source/blender/editors/space_console/console_ops.c75
-rw-r--r--source/blender/editors/space_console/space_console.c9
3 files changed, 60 insertions, 27 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index b7e4133e073..042fb366224 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -132,8 +132,9 @@ static void console_cursor_wrap_offset(const char *str, int width, int *row, int
*column = 0;
}
- if (end && str >= end)
+ if (end && str >= end) {
break;
+ }
*column += col;
}
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index 46d22df2609..d4489337847 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -87,10 +87,13 @@ 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_listbase_count(&sc->scrollback); tot > U.scrollback; tot--)
+ for (tot = BLI_listbase_count(&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)
@@ -98,11 +101,13 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons
ConsoleLine *cl;
for (cl = sc->history.last; cl; cl = cl->prev) {
- if (cl == cl_ignore)
+ if (cl == cl_ignore) {
continue;
+ }
- if (STREQ(str, cl->line))
+ if (STREQ(str, cl->line)) {
return cl;
+ }
}
return NULL;
@@ -113,9 +118,15 @@ static bool 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;
@@ -184,8 +195,12 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own)
{
ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add");
- if (own) ci->line = str;
- else ci->line = BLI_strdup(str);
+ if (own) {
+ ci->line = str;
+ }
+ else {
+ ci->line = BLI_strdup(str);
+ }
ci->len = ci->len_alloc = strlen(str);
@@ -207,8 +222,9 @@ ConsoleLine *console_history_verify(const bContext *C)
{
SpaceConsole *sc = CTX_wm_space_console(C);
ConsoleLine *ci = sc->history.last;
- if (ci == NULL)
+ if (ci == NULL) {
ci = console_history_add(sc, NULL);
+ }
return ci;
}
@@ -242,8 +258,9 @@ static int console_line_insert(ConsoleLine *ci, char *str)
len--;
}
- if (len == 0)
+ if (len == 0) {
return 0;
+ }
console_line_verify_length(ci, len + ci->len);
@@ -480,8 +497,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op))
int len;
for (spaces = 0; spaces < ci->len; spaces++) {
- if (ci->line[spaces] != ' ')
+ if (ci->line[spaces] != ' ') {
break;
+ }
}
len = TAB_LENGTH - spaces % TAB_LENGTH;
@@ -524,16 +542,19 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op))
int len;
for (spaces = 0; spaces < ci->len; spaces++) {
- if (ci->line[spaces] != ' ')
+ if (ci->line[spaces] != ' ') {
break;
+ }
}
- if (spaces == 0)
+ if (spaces == 0) {
return OPERATOR_CANCELLED;
+ }
len = spaces % TAB_LENGTH;
- if (len == 0)
+ if (len == 0) {
len = TAB_LENGTH;
+ }
console_line_verify_length(ci, ci->len - len);
@@ -701,13 +722,15 @@ static int console_clear_exec(bContext *C, wmOperator *op)
/*ConsoleLine *ci = */ console_history_verify(C);
if (scrollback) { /* last item in mistory */
- while (sc->scrollback.first)
+ while (sc->scrollback.first) {
console_scrollback_free(sc, sc->scrollback.first);
+ }
}
if (history) {
- while (sc->history.first)
+ while (sc->history.first) {
console_history_free(sc, sc->history.first);
+ }
console_history_verify(C);
}
@@ -751,8 +774,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
if (ci->prev) {
ConsoleLine *ci_prev = (ConsoleLine *)ci->prev;
- if (STREQ(ci->line, ci_prev->line))
+ if (STREQ(ci->line, ci_prev->line)) {
console_history_free(sc, ci_prev);
+ }
}
if (reverse) { /* last item in history */
@@ -768,8 +792,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op)
{ /* 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(sc, (ConsoleLine *)sc->history.last);
}
@@ -818,8 +843,9 @@ static int console_history_append_exec(bContext *C, wmOperator *op)
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 (STREQ(str, ci->line)) {
MEM_freeN(str);
@@ -928,8 +954,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
ConsoleLine cl_dummy = {NULL};
- if (sc->sel_start == sc->sel_end)
+ if (sc->sel_start == sc->sel_end) {
return OPERATOR_CANCELLED;
+ }
console_scrollback_prompt_begin(sc, &cl_dummy);
@@ -952,8 +979,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op))
int sta = max_ii(sel[0], 0);
int end = min_ii(sel[1], cl->len);
- if (BLI_dynstr_get_len(buf_dyn))
+ if (BLI_dynstr_get_len(buf_dyn)) {
BLI_dynstr_append(buf_dyn, "\n");
+ }
BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta);
}
@@ -998,8 +1026,9 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op))
char *buf_str = WM_clipboard_text_get(false, &buf_len);
char *buf_step, *buf_next;
- if (buf_str == NULL)
+ if (buf_str == NULL) {
return OPERATOR_CANCELLED;
+ }
buf_step = buf_str;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 65f1fe36fec..5d4623e6fe6 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -88,11 +88,13 @@ static void console_free(SpaceLink *sl)
{
SpaceConsole *sc = (SpaceConsole *) sl;
- while (sc->scrollback.first)
+ while (sc->scrollback.first) {
console_scrollback_free(sc, sc->scrollback.first);
+ }
- while (sc->history.first)
+ while (sc->history.first) {
console_history_free(sc, sc->history.first);
+ }
}
@@ -208,8 +210,9 @@ static void console_main_region_draw(const bContext *C, ARegion *ar)
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- if (BLI_listbase_is_empty(&sc->scrollback))
+ if (BLI_listbase_is_empty(&sc->scrollback)) {
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
+ }
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);