forked from bartvdbraak/blender
fix for copy in the console (wasnt taking the prompt into account)
This commit is contained in:
parent
e568ea668e
commit
c76d339b6c
@ -286,6 +286,24 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
|
||||
#undef STEP_SEL
|
||||
}
|
||||
|
||||
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");
|
||||
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);
|
||||
}
|
||||
void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy)
|
||||
{
|
||||
MEM_freeN(cl_dummy->line);
|
||||
BLI_remlink(&sc->scrollback, cl_dummy);
|
||||
}
|
||||
|
||||
#define CONSOLE_DRAW_MARGIN 4
|
||||
#define CONSOLE_DRAW_SCROLL 16
|
||||
|
||||
@ -349,15 +367,7 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
|
||||
xy[0]= x_orig; /* remove prompt offset */
|
||||
}
|
||||
|
||||
/* fake the edit line being in the scroll buffer */
|
||||
cl_dummy.type= CONSOLE_LINE_INPUT;
|
||||
cl_dummy.len= cl_dummy.len_alloc= 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);
|
||||
BLI_addtail(&sc->scrollback, &cl_dummy);
|
||||
|
||||
console_scrollback_prompt_begin(sc, &cl_dummy);
|
||||
|
||||
for(cl= sc->scrollback.last; cl; cl= cl->prev) {
|
||||
y_prev= xy[1];
|
||||
@ -378,9 +388,7 @@ static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *
|
||||
}
|
||||
}
|
||||
|
||||
/* temp line end */
|
||||
MEM_freeN(cl_dummy.line);
|
||||
BLI_remlink(&sc->scrollback, &cl_dummy);
|
||||
console_scrollback_prompt_end(sc, &cl_dummy);
|
||||
}
|
||||
else {
|
||||
Report *report;
|
||||
|
@ -41,6 +41,9 @@ int console_text_height(struct SpaceConsole *sc, struct ARegion *ar, struct Repo
|
||||
void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports, int mouse_y); /* needed for selection */
|
||||
int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mval[2]);
|
||||
|
||||
void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
|
||||
void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy);
|
||||
|
||||
/* console_ops.c */
|
||||
void console_history_free(SpaceConsole *sc, ConsoleLine *cl);
|
||||
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl);
|
||||
|
@ -705,6 +705,8 @@ static int copy_exec(bContext *C, wmOperator *op)
|
||||
int sel[2];
|
||||
int offset= 0;
|
||||
|
||||
ConsoleLine cl_dummy= {0};
|
||||
|
||||
#if 0
|
||||
/* copy whole file */
|
||||
for(cl= sc->scrollback.first; cl; cl= cl->next) {
|
||||
@ -716,14 +718,16 @@ static int copy_exec(bContext *C, wmOperator *op)
|
||||
if(sc->sel_start == sc->sel_end)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
console_scrollback_prompt_begin(sc, &cl_dummy);
|
||||
|
||||
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;
|
||||
@ -750,6 +754,9 @@ static int copy_exec(bContext *C, wmOperator *op)
|
||||
WM_clipboard_text_set(buf_str, 0);
|
||||
|
||||
MEM_freeN(buf_str);
|
||||
|
||||
console_scrollback_prompt_end(sc, &cl_dummy);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user