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_text/text_ops.c')
-rw-r--r--source/blender/editors/space_text/text_ops.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 842570459be..eea3e4d7958 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -143,7 +143,7 @@ static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size)
BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x)
{
/* Add half the char width so mouse cursor selection is in between letters. */
- return (x + (st->cwidth / 2)) / st->cwidth;
+ return (x + (st->runtime.cwidth_px / 2)) / st->runtime.cwidth_px;
}
/** \} */
@@ -270,8 +270,8 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
st->text = text;
st->left = 0;
st->top = 0;
- st->scroll_ofs_px[0] = 0;
- st->scroll_ofs_px[1] = 0;
+ st->runtime.scroll_ofs_px[0] = 0;
+ st->runtime.scroll_ofs_px[1] = 0;
text_drawcache_tag_update(st, 1);
}
@@ -353,8 +353,8 @@ static int text_open_exec(bContext *C, wmOperator *op)
st->text = text;
st->left = 0;
st->top = 0;
- st->scroll_ofs_px[0] = 0;
- st->scroll_ofs_px[1] = 0;
+ st->runtime.scroll_ofs_px[0] = 0;
+ st->runtime.scroll_ofs_px[1] = 0;
}
text_drawcache_tag_update(st, 1);
@@ -2206,7 +2206,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
case PREV_PAGE:
if (st) {
- cursor_skip(st, ar, st->text, -st->viewlines, select);
+ cursor_skip(st, ar, st->text, -st->runtime.viewlines, select);
}
else {
cursor_skip(NULL, NULL, text, -10, select);
@@ -2215,7 +2215,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
case NEXT_PAGE:
if (st) {
- cursor_skip(st, ar, st->text, st->viewlines, select);
+ cursor_skip(st, ar, st->text, st->runtime.viewlines, select);
}
else {
cursor_skip(NULL, NULL, text, 10, select);
@@ -2497,7 +2497,7 @@ static void txt_screen_clamp(SpaceText *st, ARegion *ar)
else {
int last;
last = text_get_total_lines(st, ar);
- last = last - (st->viewlines / 2);
+ last = last - (st->runtime.viewlines / 2);
if (last > 0 && st->top > last) {
st->top = last;
}
@@ -2544,9 +2544,9 @@ static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *ar)
tsc->state.ofs_init[1] = st->top;
tsc->state.ofs_max[0] = INT_MAX;
- tsc->state.ofs_max[1] = text_get_total_lines(st, ar) - (st->viewlines / 2);
+ tsc->state.ofs_max[1] = text_get_total_lines(st, ar) - (st->runtime.viewlines / 2);
- tsc->state.size_px[0] = st->cwidth;
+ tsc->state.size_px[0] = st->runtime.cwidth_px;
tsc->state.size_px[1] = TXT_LINE_HEIGHT(st);
}
@@ -2602,7 +2602,8 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
tsc->ofs_delta_px[1] += tsc->mval_delta[1];
}
else {
- tsc->ofs_delta_px[1] -= (tsc->mval_delta[1] * st->pix_per_line) * tsc->state.size_px[1];
+ tsc->ofs_delta_px[1] -= (tsc->mval_delta[1] * st->runtime.scroll_px_per_line) *
+ tsc->state.size_px[1];
}
for (int i = 0; i < 2; i += 1) {
@@ -2651,12 +2652,12 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
if (scroll_ofs_new[0] != st->left || scroll_ofs_new[1] != st->top ||
/* Horizontal sub-pixel offset currently isn't used. */
/* scroll_ofs_px_new[0] != st->scroll_ofs_px[0] || */
- scroll_ofs_px_new[1] != st->scroll_ofs_px[1]) {
+ scroll_ofs_px_new[1] != st->runtime.scroll_ofs_px[1]) {
st->left = scroll_ofs_new[0];
st->top = scroll_ofs_new[1];
- st->scroll_ofs_px[0] = scroll_ofs_px_new[0];
- st->scroll_ofs_px[1] = scroll_ofs_px_new[1];
+ st->runtime.scroll_ofs_px[0] = scroll_ofs_px_new[0];
+ st->runtime.scroll_ofs_px[1] = scroll_ofs_px_new[1];
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -2671,12 +2672,12 @@ static void scroll_exit(bContext *C, wmOperator *op)
st->flags &= ~ST_SCROLL_SELECT;
- if (st->scroll_ofs_px[1] > tsc->state.size_px[1] / 2) {
+ if (st->runtime.scroll_ofs_px[1] > tsc->state.size_px[1] / 2) {
st->top += 1;
}
- st->scroll_ofs_px[0] = 0;
- st->scroll_ofs_px[1] = 0;
+ st->runtime.scroll_ofs_px[0] = 0;
+ st->runtime.scroll_ofs_px[1] = 0;
ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(op->customdata);
@@ -2700,7 +2701,7 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_RELEASE) {
if (ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
txt_screen_skip(
- st, ar, st->viewlines * (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
+ st, ar, st->runtime.viewlines * (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -2744,8 +2745,8 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
tsc->mval_prev[0] = event->x;
tsc->mval_prev[1] = event->y;
/* Sensitivity of scroll set to 4pix per line/char */
- tsc->mval_delta[0] = (event->x - event->prevx) * st->cwidth / 4;
- tsc->mval_delta[1] = (event->y - event->prevy) * st->lheight_dpi / 4;
+ tsc->mval_delta[0] = (event->x - event->prevx) * st->runtime.cwidth_px / 4;
+ tsc->mval_delta[1] = (event->y - event->prevy) * st->runtime.lheight_px / 4;
tsc->is_first = false;
tsc->is_scrollbar = false;
text_scroll_apply(C, op, event);
@@ -2819,13 +2820,15 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
/* verify we are in the right zone */
- if (mval[0] > st->txtbar.xmin && mval[0] < st->txtbar.xmax) {
- if (mval[1] >= st->txtbar.ymin && mval[1] <= st->txtbar.ymax) {
+ if (mval[0] > st->runtime.scroll_region_handle.xmin &&
+ mval[0] < st->runtime.scroll_region_handle.xmax) {
+ if (mval[1] >= st->runtime.scroll_region_handle.ymin &&
+ mval[1] <= st->runtime.scroll_region_handle.ymax) {
/* mouse inside scroll handle */
zone = SCROLLHANDLE_BAR;
}
else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < ar->winy - TXT_SCROLL_SPACE) {
- if (mval[1] < st->txtbar.ymin) {
+ if (mval[1] < st->runtime.scroll_region_handle.ymin) {
zone = SCROLLHANDLE_MIN_OUTSIDE;
}
else {
@@ -2850,8 +2853,8 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* jump scroll, works in v2d but needs to be added here too :S */
if (event->type == MIDDLEMOUSE) {
- tsc->mval_prev[0] = ar->winrct.xmin + BLI_rcti_cent_x(&st->txtbar);
- tsc->mval_prev[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->txtbar);
+ tsc->mval_prev[0] = ar->winrct.xmin + BLI_rcti_cent_x(&st->runtime.scroll_region_handle);
+ tsc->mval_prev[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->runtime.scroll_region_handle);
tsc->is_first = false;
tsc->zone = SCROLLHANDLE_BAR;
@@ -3228,7 +3231,7 @@ static int text_selection_set_invoke(bContext *C, wmOperator *op, const wmEvent
SpaceText *st = CTX_wm_space_text(C);
SetSelection *ssel;
- if (event->mval[0] >= st->txtbar.xmin) {
+ if (event->mval[0] >= st->runtime.scroll_region_handle.xmin) {
return OPERATOR_PASS_THROUGH;
}
@@ -3309,7 +3312,7 @@ static int text_cursor_set_invoke(bContext *C, wmOperator *op, const wmEvent *ev
{
SpaceText *st = CTX_wm_space_text(C);
- if (event->mval[0] >= st->txtbar.xmin) {
+ if (event->mval[0] >= st->runtime.scroll_region_handle.xmin) {
return OPERATOR_PASS_THROUGH;
}
@@ -3358,7 +3361,8 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
return OPERATOR_PASS_THROUGH;
}
- if (!(mval[0] > 2 && mval[0] < (TXT_NUMCOL_WIDTH(st) + (TXT_BODY_LPAD * st->cwidth)) &&
+ if (!(mval[0] > 2 &&
+ mval[0] < (TXT_NUMCOL_WIDTH(st) + (TXT_BODY_LPAD * st->runtime.cwidth_px)) &&
mval[1] > 2 && mval[1] < ar->winy - 2)) {
return OPERATOR_PASS_THROUGH;
}