diff options
author | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2012-11-12 16:30:02 +0400 |
---|---|---|
committer | Jason Wilkins <Jason.A.Wilkins@gmail.com> | 2012-11-12 16:30:02 +0400 |
commit | 6b65102c20e9bdafd90f55f60c2a2084d873e809 (patch) | |
tree | a0f5554702501d2da1073b22ff55f740aff135f9 /source/blender/editors/space_console | |
parent | 053710fcbc78ff83b9617be87558876e381f85a6 (diff) | |
parent | 83de5cb30831328548502126dff84ffdb72544f2 (diff) |
Merge w/ trunk: r51141-52085 (Important Note: gameengine and blenderplayer were not merged due to complex differences)
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r-- | source/blender/editors/space_console/console_draw.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 8 |
3 files changed, 28 insertions, 19 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 08a0ad8672c..93c6ce472f8 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -84,7 +84,7 @@ typedef struct ConsoleDrawContext { #if 0 /* used by textview, may use later */ int *xy; // [2] int *sel; // [2] - int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. + int *pos_pick; /* bottom of view == 0, top of file == combine chars, end of line is lower then start. */ int *mval; // [2] int draw; #endif @@ -94,12 +94,14 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du { /* fake the edit line being in the scroll buffer */ ConsoleLine *cl = sc->history.last; + int prompt_len = strlen(sc->prompt); + cl_dummy->type = CONSOLE_LINE_INPUT; - cl_dummy->len = cl_dummy->len_alloc = strlen(sc->prompt) + cl->len; + cl_dummy->len = prompt_len + 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); + memcpy(cl_dummy->line, sc->prompt, prompt_len); + memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1); BLI_addtail(&sc->scrollback, cl_dummy); } void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy) @@ -158,12 +160,13 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha const ConsoleLine *cl = (ConsoleLine *)sc->history.last; const int prompt_len = strlen(sc->prompt); const int cursor_loc = cl->cursor + prompt_len; + const int line_len = cl->len + prompt_len; int xy[2] = {CONSOLE_DRAW_MARGIN, CONSOLE_DRAW_MARGIN}; int pen[2]; xy[1] += tvc->lheight / 6; /* account for wrapping */ - if (cl->len < tvc->console_width) { + if (line_len < tvc->console_width) { /* simple case, no wrapping */ pen[0] = tvc->cwidth * cursor_loc; pen[1] = -2; @@ -171,7 +174,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha 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[1] = -2 + (((line_len / tvc->console_width) - (cursor_loc / tvc->console_width)) * tvc->lheight); } /* cursor */ diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 7efcbcceb3c..d3ae5373a18 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -39,6 +39,7 @@ #include "BLI_string.h" #include "BLI_dynstr.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_text.h" /* only for character utility funcs */ @@ -449,7 +450,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op)) memmove(ci->line + len, ci->line, ci->len); memset(ci->line, ' ', len); ci->len += len; + BLI_assert(ci->len >= 0); console_line_cursor_set(ci, ci->cursor + len); + console_select_offset(sc, len); console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); @@ -495,9 +498,10 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op)) memmove(ci->line, ci->line + len, (ci->len - len) + 1); ci->len -= len; - console_line_cursor_set(ci, ci->cursor - len); + BLI_assert(ci->len >= 0); - //console_select_offset(sc, -4); + console_line_cursor_set(ci, ci->cursor - len); + console_select_offset(sc, -len); console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); @@ -554,6 +558,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) if (stride) { memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); ci->len -= stride; + BLI_assert(ci->len >= 0); done = TRUE; } } @@ -570,6 +575,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) ci->cursor -= stride; /* same as above */ memmove(ci->line + ci->cursor, ci->line + ci->cursor + stride, (ci->len - ci->cursor) + 1); ci->len -= stride; + BLI_assert(ci->len >= 0); done = TRUE; } } @@ -580,7 +586,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - console_select_offset(sc, -1); + console_select_offset(sc, -stride); } console_textview_update_rect(sc, ar); @@ -650,7 +656,7 @@ static int console_clear_exec(bContext *C, wmOperator *op) short scrollback = RNA_boolean_get(op->ptr, "scrollback"); short history = RNA_boolean_get(op->ptr, "history"); - /*ConsoleLine *ci= */ console_history_verify(C); + /*ConsoleLine *ci = */ console_history_verify(C); if (scrollback) { /* last item in mistory */ while (sc->scrollback.first) @@ -803,7 +809,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) ot->poll = ED_operator_console_active; /* properties */ - RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); + RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000); RNA_def_boolean(ot->srna, "remove_duplicates", 0, "Remove Duplicates", "Remove duplicate items in the history"); } @@ -904,8 +910,8 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) 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 = max_ii(sel[0], 0); + int end = min_ii(sel[1], cl->len); if (BLI_dynstr_get_len(buf_dyn)) BLI_dynstr_append(buf_dyn, "\n"); @@ -1050,7 +1056,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); +// SpaceConsole *sc = CTX_wm_space_console(C); SetConsoleCursor *scu = op->customdata; #if 0 @@ -1067,7 +1073,7 @@ 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); -// ARegion *ar= CTX_wm_region(C); +// ARegion *ar = CTX_wm_region(C); SetConsoleCursor *scu; op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor"); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index d8d71d72382..4fc9b281854 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -91,7 +91,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) 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); + //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); return (SpaceLink *)sconsole; } @@ -162,7 +162,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); +// SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_ID) return 1; return 0; @@ -184,7 +184,7 @@ 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); + // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_PATH) return 1; return 0; @@ -359,7 +359,7 @@ static void console_header_area_draw(const bContext *C, ARegion *ar) static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) { - // SpaceInfo *sinfo= sa->spacedata.first; + // SpaceInfo *sinfo = sa->spacedata.first; /* context changes */ switch (wmn->category) { |