forked from bartvdbraak/blender
Console Scrolling - reset while typing.
patch from Damir Prebeg with some edits. Also made it so resizing the console view keeps the lower part of the text in view (could be annoying when you needed to scroll because of a resized view).
This commit is contained in:
parent
198295e9ca
commit
5db33d11bd
@ -54,6 +54,14 @@
|
||||
|
||||
#include "console_intern.h"
|
||||
|
||||
/* so when we type - the view scrolls to the bottom */
|
||||
static void console_scroll_bottom(ARegion *ar)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
v2d->cur.ymin = 0.0;
|
||||
v2d->cur.ymax =(float)v2d->winy;
|
||||
}
|
||||
|
||||
static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
@ -339,9 +347,14 @@ static int move_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
if(done) {
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
|
||||
ED_area_tag_redraw(sa);
|
||||
console_scroll_bottom(ar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -391,7 +404,9 @@ static int insert_exec(bContext *C, wmOperator *op)
|
||||
|
||||
console_textview_update_rect(sc, ar);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
|
||||
console_scroll_bottom(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -478,6 +493,8 @@ static int delete_exec(bContext *C, wmOperator *op)
|
||||
|
||||
console_textview_update_rect(sc, ar);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
console_scroll_bottom(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -589,6 +606,8 @@ static int history_cycle_exec(bContext *C, wmOperator *op)
|
||||
console_textview_update_rect(sc, ar);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
console_scroll_bottom(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -612,6 +631,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot)
|
||||
static int history_append_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceConsole *sc= CTX_wm_space_console(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ConsoleLine *ci= console_history_verify(C);
|
||||
char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
|
||||
@ -637,6 +657,8 @@ static int history_append_exec(bContext *C, wmOperator *op)
|
||||
|
||||
ED_area_tag_redraw(sa);
|
||||
|
||||
console_scroll_bottom(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -825,6 +847,8 @@ static int paste_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
console_textview_update_rect(sc, ar);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
console_scroll_bottom(ar);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
|
@ -138,8 +138,17 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
wmKeyMap *keymap;
|
||||
ListBase *lb;
|
||||
|
||||
const int prev_y_min= ar->v2d.cur.ymin; /* so resizing keeps the cursor visible */
|
||||
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
||||
|
||||
/* always keep the bottom part of the view aligned, less annoying */
|
||||
if(prev_y_min != ar->v2d.cur.ymin) {
|
||||
const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin;
|
||||
ar->v2d.cur.ymin= prev_y_min;
|
||||
ar->v2d.cur.ymax= prev_y_min + cur_y_range;
|
||||
}
|
||||
|
||||
/* own keymap */
|
||||
keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
|
Loading…
Reference in New Issue
Block a user