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:
Diffstat (limited to 'source/blender/editors/space_console')
-rw-r--r--source/blender/editors/space_console/console_draw.c40
-rw-r--r--source/blender/editors/space_console/console_intern.h7
-rw-r--r--source/blender/editors/space_console/console_ops.c45
-rw-r--r--source/blender/editors/space_console/console_report.c10
-rw-r--r--source/blender/editors/space_console/space_console.c12
5 files changed, 69 insertions, 45 deletions
diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c
index d1fa4e17e6f..edbb539e836 100644
--- a/source/blender/editors/space_console/console_draw.c
+++ b/source/blender/editors/space_console/console_draw.c
@@ -133,7 +133,7 @@ typedef struct ConsoleDrawContext {
int draw;
} ConsoleDrawContext;
-static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int console_width, int lheight)
+static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight)
{
if(sel[0] <= str_len_draw && sel[1] >= 0) {
int sta = MAX2(sel[0], 0);
@@ -222,7 +222,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
if(cdc->sel[0] != cdc->sel[1]) {
STEP_SEL(-initial_offset);
// glColor4ub(255, 0, 0, 96); // debug
- console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->console_width, cdc->lheight);
+ console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight);
STEP_SEL(cdc->console_width);
glColor3ubv(fg);
}
@@ -240,7 +240,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
if(cdc->sel[0] != cdc->sel[1]) {
// glColor4ub(0, 255, 0, 96); // debug
- console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->console_width, cdc->lheight);
+ console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight);
STEP_SEL(cdc->console_width);
glColor3ubv(fg);
}
@@ -272,7 +272,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, char *str, int str_len,
if(cdc->sel[0] != cdc->sel[1]) {
int isel[2]= {str_len - cdc->sel[1], str_len - cdc->sel[0]};
// glColor4ub(255, 255, 0, 96); // debug
- console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->console_width, cdc->lheight);
+ console_draw_sel(isel, cdc->xy, str_len, cdc->cwidth, cdc->lheight);
STEP_SEL(-(str_len + 1));
}
@@ -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;
diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h
index c74d39f25e3..1a48dd408bd 100644
--- a/source/blender/editors/space_console/console_intern.h
+++ b/source/blender/editors/space_console/console_intern.h
@@ -41,11 +41,14 @@ 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);
-ConsoleLine *console_history_add_str(const struct bContext *C, char *str, int own);
-ConsoleLine *console_scrollback_add_str(const struct bContext *C, char *str, int own);
+ConsoleLine *console_history_add_str(struct SpaceConsole *sc, char *str, int own);
+ConsoleLine *console_scrollback_add_str(struct SpaceConsole *sc, char *str, int own);
ConsoleLine *console_history_verify(const struct bContext *C);
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c
index a49581cb417..2b419b0a833 100644
--- a/source/blender/editors/space_console/console_ops.c
+++ b/source/blender/editors/space_console/console_ops.c
@@ -194,7 +194,7 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from)
}
#endif
-static ConsoleLine *console_lb_add_str__internal(ListBase *lb, const bContext *C, char *str, int own)
+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;
@@ -205,14 +205,13 @@ static ConsoleLine *console_lb_add_str__internal(ListBase *lb, const bContext *C
BLI_addtail(lb, ci);
return ci;
}
-ConsoleLine *console_history_add_str(const bContext *C, char *str, int own)
+ConsoleLine *console_history_add_str(SpaceConsole *sc, char *str, int own)
{
- return console_lb_add_str__internal(&CTX_wm_space_console(C)->history, C, str, own);
+ return console_lb_add_str__internal(&sc->history, str, own);
}
-ConsoleLine *console_scrollback_add_str(const bContext *C, char *str, int own)
+ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, int own)
{
- SpaceConsole *sc= CTX_wm_space_console(C);
- ConsoleLine *ci= console_lb_add_str__internal(&sc->scrollback, C, str, own);
+ ConsoleLine *ci= console_lb_add_str__internal(&sc->scrollback, str, own);
console_select_offset(sc, ci->len + 1);
return ci;
}
@@ -403,8 +402,13 @@ static int insert_exec(bContext *C, wmOperator *op)
static int insert_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- if(!RNA_property_is_set(op->ptr, "text")) {
+ // if(!RNA_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */
+ if(!RNA_string_length(op->ptr, "text")) {
char str[2] = {event->ascii, '\0'};
+ /* if alt/ctrl/super are pressed pass through */
+ if(event->ctrl || event->oskey)
+ return OPERATOR_PASS_THROUGH;
+
RNA_string_set(op->ptr, "text", str);
}
return insert_exec(C, op);
@@ -622,7 +626,7 @@ static int history_append_exec(bContext *C, wmOperator *op)
}
}
- ci= console_history_add_str(C, 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);
@@ -658,7 +662,7 @@ static int scrollback_append_exec(bContext *C, wmOperator *op)
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
int type= RNA_enum_get(op->ptr, "type");
- ci= console_scrollback_add_str(C, str, 1); /* own the string */
+ ci= console_scrollback_add_str(sc, str, 1); /* own the string */
ci->type= type;
console_scrollback_limit(sc);
@@ -693,7 +697,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
}
-static int copy_exec(bContext *C, wmOperator *op)
+static int copy_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
int buf_len;
@@ -705,6 +709,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 +722,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 +758,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;
}
@@ -767,8 +778,9 @@ void CONSOLE_OT_copy(wmOperatorType *ot)
/* properties */
}
-static int paste_exec(bContext *C, wmOperator *op)
+static int paste_exec(bContext *C, wmOperator *UNUSED(op))
{
+ SpaceConsole *sc= CTX_wm_space_console(C);
ConsoleLine *ci= console_history_verify(C);
char *buf_str= WM_clipboard_text_get(0);
@@ -792,7 +804,7 @@ static int paste_exec(bContext *C, wmOperator *op)
ci= console_history_verify(C);
}
- console_line_insert(ci, buf_next);
+ console_select_offset(sc, console_line_insert(ci, buf_next));
}
MEM_freeN(buf_str);
@@ -821,7 +833,8 @@ typedef struct SetConsoleCursor {
int sel_init;
} SetConsoleCursor;
-static void set_cursor_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleCursor *scu, int mval[2], int sel)
+// TODO, cursor placement without selection
+static void set_cursor_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleCursor *scu, int mval[2], int UNUSED(sel))
{
int pos;
pos= console_char_pick(sc, ar, NULL, mval);
@@ -856,7 +869,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve
ED_area_tag_redraw(CTX_wm_area(C));
}
-static void set_cursor_exit(bContext *C, wmOperator *op)
+static void set_cursor_exit(bContext *UNUSED(C), wmOperator *op)
{
// SpaceConsole *sc= CTX_wm_space_console(C);
SetConsoleCursor *scu= op->customdata;
diff --git a/source/blender/editors/space_console/console_report.c b/source/blender/editors/space_console/console_report.c
index 51bffa5b981..6483177a045 100644
--- a/source/blender/editors/space_console/console_report.c
+++ b/source/blender/editors/space_console/console_report.c
@@ -72,7 +72,7 @@ static int console_report_poll(bContext *C)
return 1;
}
-static int report_replay_exec(bContext *C, wmOperator *op)
+static int report_replay_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
ReportList *reports= CTX_wm_reports(C);
@@ -83,7 +83,7 @@ static int report_replay_exec(bContext *C, wmOperator *op)
for(report=reports->list.last; report; report=report->prev) {
if((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) {
- console_history_add_str(C, report->message, 0);
+ console_history_add_str(sc, report->message, 0);
WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -165,7 +165,7 @@ void CONSOLE_OT_select_pick(wmOperatorType *ot)
-static int report_select_all_toggle_exec(bContext *C, wmOperator *op)
+static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
ReportList *reports= CTX_wm_reports(C);
@@ -314,7 +314,7 @@ void CONSOLE_OT_select_border(wmOperatorType *ot)
-static int report_delete_exec(bContext *C, wmOperator *op)
+static int report_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
ReportList *reports= CTX_wm_reports(C);
@@ -359,7 +359,7 @@ void CONSOLE_OT_report_delete(wmOperatorType *ot)
}
-static int report_copy_exec(bContext *C, wmOperator *op)
+static int report_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
SpaceConsole *sc= CTX_wm_space_console(C);
ReportList *reports= CTX_wm_reports(C);
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index c30897bbb87..70263788b13 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -67,7 +67,7 @@ static void console_update_rect(const bContext *C, ARegion *ar)
/* ******************** default callbacks for console space ***************** */
-static SpaceLink *console_new(const bContext *C)
+static SpaceLink *console_new(const bContext *UNUSED(C))
{
ARegion *ar;
SpaceConsole *sconsole;
@@ -121,7 +121,7 @@ static void console_free(SpaceLink *sl)
/* spacetype; init callback */
-static void console_init(struct wmWindowManager *wm, ScrArea *sa)
+static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
{
}
@@ -162,7 +162,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
/* ************* dropboxes ************* */
-static int id_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+static int id_drop_poll(bContext *C, wmDrag *drag, wmEvent *UNUSED(event))
{
SpaceConsole *sc= CTX_wm_space_console(C);
if(sc->type==CONSOLE_TYPE_PYTHON)
@@ -182,7 +182,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
RNA_string_set(drop->ptr, "text", text);
}
-static int path_drop_poll(bContext *C, wmDrag *drag, wmEvent *event)
+static int path_drop_poll(bContext *C, wmDrag *drag, wmEvent *UNUSED(event))
{
SpaceConsole *sc= CTX_wm_space_console(C);
if(sc->type==CONSOLE_TYPE_PYTHON)
@@ -227,7 +227,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar)
console_update_rect(C, ar);
/* worlks best with no view2d matrix set */
- UI_view2d_view_ortho(C, v2d);
+ UI_view2d_view_ortho(v2d);
/* data... */
@@ -361,7 +361,7 @@ void console_keymap(struct wmKeyConfig *keyconf)
/****************** header region ******************/
/* add handlers, stuff you only do once or on area/region changes */
-static void console_header_area_init(wmWindowManager *wm, ARegion *ar)
+static void console_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
{
ED_region_header_init(ar);
}