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:
authorSv. Lockal <lockalsash@gmail.com>2012-10-14 23:57:49 +0400
committerSv. Lockal <lockalsash@gmail.com>2012-10-14 23:57:49 +0400
commit1086069fb32acab7267192b1a2995440e6f4697f (patch)
treea8cbcb230f2172f570e3cb1784472615f80a5a2d /source/blender/editors/space_console
parent36c53ec9c3450f250fe8ab9e351a53455792498c (diff)
Fix for misplaced cursor in wrapped console prompt, also fixes newline for single wrap when input line width equals console width
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_draw.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index 4c2f0ac73d4..c4a5c2a0154 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -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 */