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')
-rw-r--r--source/blender/editors/space_text/space_text.c76
-rw-r--r--source/blender/editors/space_text/text_autocomplete.c10
-rw-r--r--source/blender/editors/space_text/text_draw.c158
-rw-r--r--source/blender/editors/space_text/text_header.c26
-rw-r--r--source/blender/editors/space_text/text_intern.h18
-rw-r--r--source/blender/editors/space_text/text_ops.c175
6 files changed, 234 insertions, 229 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 09a2b83d909..437b118a69c 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -55,7 +55,7 @@
static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
- ARegion *ar;
+ ARegion *region;
SpaceText *stext;
stext = MEM_callocN(sizeof(SpaceText), "inittext");
@@ -68,31 +68,31 @@ static SpaceLink *text_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scen
stext->showlinenrs = true;
/* header */
- ar = MEM_callocN(sizeof(ARegion), "header for text");
+ region = MEM_callocN(sizeof(ARegion), "header for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_HEADER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ BLI_addtail(&stext->regionbase, region);
+ region->regiontype = RGN_TYPE_HEADER;
+ region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
/* footer */
- ar = MEM_callocN(sizeof(ARegion), "footer for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_FOOTER;
- ar->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
+ region = MEM_callocN(sizeof(ARegion), "footer for text");
+ BLI_addtail(&stext->regionbase, region);
+ region->regiontype = RGN_TYPE_FOOTER;
+ region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM;
/* properties region */
- ar = MEM_callocN(sizeof(ARegion), "properties region for text");
+ region = MEM_callocN(sizeof(ARegion), "properties region for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_UI;
- ar->alignment = RGN_ALIGN_RIGHT;
- ar->flag = RGN_FLAG_HIDDEN;
+ BLI_addtail(&stext->regionbase, region);
+ region->regiontype = RGN_TYPE_UI;
+ region->alignment = RGN_ALIGN_RIGHT;
+ region->flag = RGN_FLAG_HIDDEN;
/* main region */
- ar = MEM_callocN(sizeof(ARegion), "main region for text");
+ region = MEM_callocN(sizeof(ARegion), "main region for text");
- BLI_addtail(&stext->regionbase, ar);
- ar->regiontype = RGN_TYPE_WINDOW;
+ BLI_addtail(&stext->regionbase, region);
+ region->regiontype = RGN_TYPE_WINDOW;
return (SpaceLink *)stext;
}
@@ -269,30 +269,30 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
/********************* main region ********************/
/* add handlers, stuff you only do once or on area/region changes */
-static void text_main_region_init(wmWindowManager *wm, ARegion *ar)
+static void text_main_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
ListBase *lb;
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
+ UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_STANDARD, region->winx, region->winy);
/* own keymap */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
+ WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
keymap = WM_keymap_ensure(wm->defaultconf, "Text", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
+ WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
/* add drop boxes */
lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW);
- WM_event_add_dropbox_handler(&ar->handlers, lb);
+ WM_event_add_dropbox_handler(&region->handlers, lb);
}
-static void text_main_region_draw(const bContext *C, ARegion *ar)
+static void text_main_region_draw(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
SpaceText *st = CTX_wm_space_text(C);
- // View2D *v2d = &ar->v2d;
+ // View2D *v2d = &region->v2d;
/* clear and setup matrix */
UI_ThemeClearColor(TH_BACK);
@@ -301,7 +301,7 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
// UI_view2d_view_ortho(v2d);
/* data... */
- draw_text_main(st, ar);
+ draw_text_main(st, region);
/* reset view matrix */
// UI_view2d_view_restore(C);
@@ -309,13 +309,13 @@ static void text_main_region_draw(const bContext *C, ARegion *ar)
/* scrollers? */
}
-static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
+static void text_cursor(wmWindow *win, ScrArea *sa, ARegion *region)
{
SpaceText *st = sa->spacedata.first;
int wmcursor = WM_CURSOR_TEXT_EDIT;
if (st->text && BLI_rcti_isect_pt(&st->runtime.scroll_region_handle,
- win->eventstate->x - ar->winrct.xmin,
+ win->eventstate->x - region->winrct.xmin,
st->runtime.scroll_region_handle.ymin)) {
wmcursor = WM_CURSOR_DEFAULT;
}
@@ -378,40 +378,40 @@ static void text_dropboxes(void)
/****************** header region ******************/
/* add handlers, stuff you only do once or on area/region changes */
-static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *ar)
+static void text_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
{
- ED_region_header_init(ar);
+ ED_region_header_init(region);
}
-static void text_header_region_draw(const bContext *C, ARegion *ar)
+static void text_header_region_draw(const bContext *C, ARegion *region)
{
- ED_region_header(C, ar);
+ ED_region_header(C, region);
}
/****************** properties region ******************/
/* add handlers, stuff you only do once or on area/region changes */
-static void text_properties_region_init(wmWindowManager *wm, ARegion *ar)
+static void text_properties_region_init(wmWindowManager *wm, ARegion *region)
{
wmKeyMap *keymap;
- ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
- ED_region_panels_init(wm, ar);
+ region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE;
+ ED_region_panels_init(wm, region);
/* own keymaps */
keymap = WM_keymap_ensure(wm->defaultconf, "Text Generic", SPACE_TEXT, 0);
- WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
+ WM_event_add_keymap_handler_v2d_mask(&region->handlers, keymap);
}
-static void text_properties_region_draw(const bContext *C, ARegion *ar)
+static void text_properties_region_draw(const bContext *C, ARegion *region)
{
SpaceText *st = CTX_wm_space_text(C);
- ED_region_panels(C, ar);
+ ED_region_panels(C, region);
/* this flag trick is make sure buttons have been added already */
if (st->flags & ST_FIND_ACTIVATE) {
- if (UI_textbutton_activate_rna(C, ar, st, "find_text")) {
+ if (UI_textbutton_activate_rna(C, region, st, "find_text")) {
/* if the panel was already open we need to do another redraw */
ScrArea *sa = CTX_wm_area(C);
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_TEXT, sa);
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index a560b8af70f..97ce7035222 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -49,7 +49,7 @@
/** \name Public API
* \{ */
-int text_do_suggest_select(SpaceText *st, ARegion *ar)
+int text_do_suggest_select(SpaceText *st, ARegion *region)
{
SuggItem *item, *first, *last /* , *sel */ /* UNUSED */;
TextLine *tmp;
@@ -84,7 +84,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
text_update_character_width(st);
x = TXT_BODY_LEFT(st) + (st->runtime.cwidth_px * (st->text->curc - st->left));
- y = ar->winy - st->runtime.lheight_px * l - 2;
+ y = region->winy - st->runtime.lheight_px * l - 2;
w = SUGG_LIST_WIDTH * st->runtime.cwidth_px + U.widget_unit;
h = SUGG_LIST_SIZE * st->runtime.lheight_px + 0.4f * U.widget_unit;
@@ -336,7 +336,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
{
SpaceText *st = CTX_wm_space_text(C);
ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ ARegion *region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
int draw = 0, tools = 0, swallow = 0, scroll = 1;
Text *text = CTX_data_edit_text(C);
@@ -356,7 +356,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
switch (event->type) {
case LEFTMOUSE:
if (event->val == KM_PRESS) {
- if (text_do_suggest_select(st, ar)) {
+ if (text_do_suggest_select(st, region)) {
swallow = 1;
}
else {
@@ -374,7 +374,7 @@ static int text_autocomplete_modal(bContext *C, wmOperator *op, const wmEvent *e
break;
case MIDDLEMOUSE:
if (event->val == KM_PRESS) {
- if (text_do_suggest_select(st, ar)) {
+ if (text_do_suggest_select(st, region)) {
ED_text_undo_push_init(C);
confirm_suggestion(st->text);
text_update_line_edited(st->text->curl);
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 02914737229..b03c3ca68cb 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -187,9 +187,9 @@ static void format_draw_color(const TextDrawContext *tdc, char formatchar)
* \encode
*/
-int wrap_width(const SpaceText *st, ARegion *ar)
+int wrap_width(const SpaceText *st, ARegion *region)
{
- int winx = ar->winx - TXT_SCROLL_WIDTH;
+ int winx = region->winx - TXT_SCROLL_WIDTH;
int x, max;
x = TXT_BODY_LEFT(st);
@@ -199,7 +199,7 @@ int wrap_width(const SpaceText *st, ARegion *ar)
/* Sets (offl, offc) for transforming (line, curs) to its wrapped position */
void wrap_offset(
- const SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int *offl, int *offc)
+ const SpaceText *st, ARegion *region, TextLine *linein, int cursin, int *offl, int *offc)
{
Text *text;
TextLine *linep;
@@ -221,7 +221,7 @@ void wrap_offset(
linep = text->lines.first;
i = st->top;
while (i > 0 && linep) {
- int lines = text_get_visible_lines(st, ar, linep->line);
+ int lines = text_get_visible_lines(st, region, linep->line);
/* Line before top */
if (linep == linein) {
@@ -241,7 +241,7 @@ void wrap_offset(
}
}
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
cursin = BLI_str_utf8_offset_to_column(linein->line, cursin);
while (linep) {
@@ -305,7 +305,7 @@ void wrap_offset(
/* cursin - mem, offc - view */
void wrap_offset_in_line(
- const SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int *offl, int *offc)
+ const SpaceText *st, ARegion *region, TextLine *linein, int cursin, int *offl, int *offc)
{
int i, j, start, end, chars, max, chop;
char ch;
@@ -319,7 +319,7 @@ void wrap_offset_in_line(
return;
}
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
start = 0;
end = max;
@@ -598,7 +598,7 @@ static void text_drawcache_init(SpaceText *st)
st->runtime.drawcache = drawcache;
}
-static void text_update_drawcache(SpaceText *st, ARegion *ar)
+static void text_update_drawcache(SpaceText *st, ARegion *region)
{
DrawCache *drawcache;
int full_update = 0, nlines = 0;
@@ -616,7 +616,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
/* check if full cache update is needed */
/* area was resized */
- full_update |= drawcache->winx != ar->winx;
+ full_update |= drawcache->winx != region->winx;
/* word-wrapping option was toggled */
full_update |= drawcache->wordwrap != st->wordwrap;
/* word-wrapping option was toggled */
@@ -673,7 +673,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
lines_count = fp[lineno];
}
else {
- lines_count = text_get_visible_lines(st, ar, line->line);
+ lines_count = text_get_visible_lines(st, region, line->line);
}
fp[lineno] = lines_count;
@@ -706,7 +706,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
drawcache->nlines = nlines;
/* store settings */
- drawcache->winx = ar->winx;
+ drawcache->winx = region->winx;
drawcache->wordwrap = st->wordwrap;
drawcache->lheight = st->runtime.lheight_px;
drawcache->cwidth_px = st->runtime.cwidth_px;
@@ -793,12 +793,12 @@ static int text_get_visible_lines_no(const SpaceText *st, int lineno)
return drawcache->line_height[lineno];
}
-int text_get_visible_lines(const SpaceText *st, ARegion *ar, const char *str)
+int text_get_visible_lines(const SpaceText *st, ARegion *region, const char *str)
{
int i, j, start, end, max, lines, chars;
char ch;
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
lines = 1;
start = 0;
end = max;
@@ -832,7 +832,7 @@ int text_get_visible_lines(const SpaceText *st, ARegion *ar, const char *str)
return lines;
}
-int text_get_span_wrap(const SpaceText *st, ARegion *ar, TextLine *from, TextLine *to)
+int text_get_span_wrap(const SpaceText *st, ARegion *region, TextLine *from, TextLine *to)
{
if (st->wordwrap) {
int ret = 0;
@@ -843,7 +843,7 @@ int text_get_span_wrap(const SpaceText *st, ARegion *ar, TextLine *from, TextLin
if (tmp == to) {
return ret;
}
- ret += text_get_visible_lines(st, ar, tmp->line);
+ ret += text_get_visible_lines(st, region, tmp->line);
tmp = tmp->next;
}
@@ -854,11 +854,11 @@ int text_get_span_wrap(const SpaceText *st, ARegion *ar, TextLine *from, TextLin
}
}
-int text_get_total_lines(SpaceText *st, ARegion *ar)
+int text_get_total_lines(SpaceText *st, ARegion *region)
{
DrawCache *drawcache;
- text_update_drawcache(st, ar);
+ text_update_drawcache(st, region);
drawcache = st->runtime.drawcache;
return drawcache->total_lines;
@@ -866,7 +866,7 @@ int text_get_total_lines(SpaceText *st, ARegion *ar)
/************************ draw scrollbar *****************************/
-static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
+static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *back)
{
int lhlstart, lhlend, ltexth, sell_off, curl_off;
short barheight, barstart, hlstart, hlend, blank_lines;
@@ -874,17 +874,17 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
pix_top_margin = (0.4 * U.widget_unit);
pix_bottom_margin = (0.4 * U.widget_unit);
- pix_available = ar->winy - pix_top_margin - pix_bottom_margin;
- ltexth = text_get_total_lines(st, ar);
+ pix_available = region->winy - pix_top_margin - pix_bottom_margin;
+ ltexth = text_get_total_lines(st, region);
blank_lines = st->runtime.viewlines / 2;
/* nicer code: use scroll rect for entire bar */
- back->xmin = ar->winx - (0.6 * U.widget_unit);
- back->xmax = ar->winx;
+ back->xmin = region->winx - (0.6 * U.widget_unit);
+ back->xmax = region->winx;
back->ymin = 0;
- back->ymax = ar->winy;
+ back->ymax = region->winy;
- scroll->xmax = ar->winx - (0.2 * U.widget_unit);
+ scroll->xmax = region->winx - (0.2 * U.widget_unit);
scroll->xmin = scroll->xmax - (0.4 * U.widget_unit);
scroll->ymin = pix_top_margin;
scroll->ymax = pix_available;
@@ -909,16 +909,16 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
st->runtime.scroll_region_handle.ymax -= barstart;
st->runtime.scroll_region_handle.ymin = st->runtime.scroll_region_handle.ymax - barheight;
- CLAMP(st->runtime.scroll_region_handle.ymin, pix_bottom_margin, ar->winy - pix_top_margin);
- CLAMP(st->runtime.scroll_region_handle.ymax, pix_bottom_margin, ar->winy - pix_top_margin);
+ CLAMP(st->runtime.scroll_region_handle.ymin, pix_bottom_margin, region->winy - pix_top_margin);
+ CLAMP(st->runtime.scroll_region_handle.ymax, pix_bottom_margin, region->winy - pix_top_margin);
st->runtime.scroll_px_per_line = (pix_available > 0) ? (float)ltexth / pix_available : 0;
if (st->runtime.scroll_px_per_line < 0.1f) {
st->runtime.scroll_px_per_line = 0.1f;
}
- curl_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->curl);
- sell_off = text_get_span_wrap(st, ar, st->text->lines.first, st->text->sell);
+ curl_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->curl);
+ sell_off = text_get_span_wrap(st, region, st->text->lines.first, st->text->sell);
lhlstart = MIN2(curl_off, sell_off);
lhlend = MAX2(curl_off, sell_off);
@@ -981,11 +981,11 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back)
}
st->runtime.scroll_region_select = *scroll;
- st->runtime.scroll_region_select.ymax = ar->winy - pix_top_margin - hlstart;
- st->runtime.scroll_region_select.ymin = ar->winy - pix_top_margin - hlend;
+ st->runtime.scroll_region_select.ymax = region->winy - pix_top_margin - hlstart;
+ st->runtime.scroll_region_select.ymin = region->winy - pix_top_margin - hlend;
- CLAMP(st->runtime.scroll_region_select.ymin, pix_bottom_margin, ar->winy - pix_top_margin);
- CLAMP(st->runtime.scroll_region_select.ymax, pix_bottom_margin, ar->winy - pix_top_margin);
+ CLAMP(st->runtime.scroll_region_select.ymin, pix_bottom_margin, region->winy - pix_top_margin);
+ CLAMP(st->runtime.scroll_region_select.ymax, pix_bottom_margin, region->winy - pix_top_margin);
}
static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
@@ -1025,7 +1025,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back)
/*********************** draw documentation *******************************/
#if 0
-static void draw_documentation(const SpaceText *st, ARegion *ar)
+static void draw_documentation(const SpaceText *st, ARegion *region)
{
TextDrawContext tdc = {0};
TextLine *tmp;
@@ -1062,7 +1062,7 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
x += SUGG_LIST_WIDTH * st->runtime.cwidth_px + 50;
}
- /* top = */ /* UNUSED */ y = ar->winy - st->runtime.lheight_px * l - 2;
+ /* top = */ /* UNUSED */ y = region->winy - st->runtime.lheight_px * l - 2;
boxw = DOC_WIDTH * st->runtime.cwidth_px + 20;
boxh = (DOC_HEIGHT + 1) * TXT_LINE_HEIGHT(st);
@@ -1136,7 +1136,7 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
/*********************** draw suggestion list *******************************/
-static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc, ARegion *ar)
+static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc, ARegion *region)
{
SuggItem *item, *first, *last, *sel;
char str[SUGG_LIST_WIDTH * BLI_UTF8_MAX + 1];
@@ -1163,12 +1163,12 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
sel = texttool_suggest_selected();
top = texttool_suggest_top();
- wrap_offset(st, ar, st->text->curl, st->text->curc, &offl, &offc);
+ wrap_offset(st, region, st->text->curl, st->text->curc, &offl, &offc);
vcurl = txt_get_span(st->text->lines.first, st->text->curl) - st->top + offl;
vcurc = text_get_char_pos(st, st->text->curl->line, st->text->curc) - st->left + offc;
x = TXT_BODY_LEFT(st) + (vcurc * st->runtime.cwidth_px);
- y = ar->winy - (vcurl + 1) * lheight - 2;
+ y = region->winy - (vcurl + 1) * lheight - 2;
/* offset back so the start of the text lines up with the suggestions,
* not essential but makes suggestions easier to follow */
@@ -1178,8 +1178,8 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
boxw = SUGG_LIST_WIDTH * st->runtime.cwidth_px + 20;
boxh = SUGG_LIST_SIZE * lheight + 8;
- if (x + boxw > ar->winx) {
- x = MAX2(0, ar->winx - boxw);
+ if (x + boxw > region->winx) {
+ x = MAX2(0, region->winx - boxw);
}
/* not needed but stands out nicer */
@@ -1232,7 +1232,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
/*********************** draw cursor ************************/
-static void draw_text_decoration(SpaceText *st, ARegion *ar)
+static void draw_text_decoration(SpaceText *st, ARegion *region)
{
Text *text = st->text;
int vcurl, vcurc, vsell, vselc, hidden = 0;
@@ -1241,7 +1241,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
const int lheight = TXT_LINE_HEIGHT(st);
/* Convert to view space character coordinates to determine if cursor is hidden */
- wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
+ wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
vsell = txt_get_span(text->lines.first, text->sell) - st->top + offl;
vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc;
@@ -1262,7 +1262,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
/* Draw the selection */
if (text->curl != text->sell || text->curc != text->selc) {
/* Convert all to view space character coordinates */
- wrap_offset(st, ar, text->curl, text->curc, &offl, &offc);
+ wrap_offset(st, region, text->curl, text->curc, &offl, &offc);
vcurl = txt_get_span(text->lines.first, text->curl) - st->top + offl;
vcurc = text_get_char_pos(st, text->curl->line, text->curc) - st->left + offc;
@@ -1273,7 +1273,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
immUniformThemeColor(TH_SHADE2);
x = TXT_BODY_LEFT(st);
- y = ar->winy;
+ y = region->winy;
if (st->flags & ST_SCROLL_SELECT) {
y += st->runtime.scroll_ofs_px[1];
}
@@ -1314,11 +1314,11 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
y -= froml * lheight;
- immRecti(pos, x + fromc * st->runtime.cwidth_px - U.pixelsize, y, ar->winx, y - lheight);
+ immRecti(pos, x + fromc * st->runtime.cwidth_px - U.pixelsize, y, region->winx, y - lheight);
y -= lheight;
for (i = froml + 1; i < tol; i++) {
- immRecti(pos, x - U.pixelsize, y, ar->winx, y - lheight);
+ immRecti(pos, x - U.pixelsize, y, region->winx, y - lheight);
y -= lheight;
}
@@ -1333,25 +1333,25 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
int y1, y2;
if (st->wordwrap) {
- int visible_lines = text_get_visible_lines(st, ar, text->sell->line);
+ int visible_lines = text_get_visible_lines(st, region, text->sell->line);
- wrap_offset_in_line(st, ar, text->sell, text->selc, &offl, &offc);
+ wrap_offset_in_line(st, region, text->sell, text->selc, &offl, &offc);
- y1 = ar->winy - (vsell - offl) * lheight;
+ y1 = region->winy - (vsell - offl) * lheight;
if (st->flags & ST_SCROLL_SELECT) {
y1 += st->runtime.scroll_ofs_px[1];
}
y2 = y1 - (lheight * visible_lines);
}
else {
- y1 = ar->winy - vsell * lheight;
+ y1 = region->winy - vsell * lheight;
if (st->flags & ST_SCROLL_SELECT) {
y1 += st->runtime.scroll_ofs_px[1];
}
y2 = y1 - (lheight);
}
- if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */
+ if (!(y1 < 0 || y2 > region->winy)) { /* check we need to draw */
float highlight_color[4];
UI_GetThemeColor4fv(TH_TEXT, highlight_color);
highlight_color[3] = 0.1f;
@@ -1359,7 +1359,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
GPU_blend_set_func_separate(
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
GPU_blend(true);
- immRecti(pos, 0, y1, ar->winx, y2);
+ immRecti(pos, 0, y1, region->winx, y2);
GPU_blend(false);
}
}
@@ -1367,7 +1367,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
if (!hidden) {
/* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */
x = TXT_BODY_LEFT(st) + (vselc * st->runtime.cwidth_px);
- y = ar->winy - vsell * lheight;
+ y = region->winy - vsell * lheight;
if (st->flags & ST_SCROLL_SELECT) {
y += st->runtime.scroll_ofs_px[1];
}
@@ -1396,7 +1396,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
/******************* draw matching brackets *********************/
-static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegion *ar)
+static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegion *region)
{
TextLine *startl, *endl, *linep;
Text *text = st->text;
@@ -1521,14 +1521,14 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
UI_FontThemeColor(tdc->font_id, TH_HILITE);
x = TXT_BODY_LEFT(st);
- y = ar->winy - st->runtime.lheight_px;
+ y = region->winy - st->runtime.lheight_px;
if (st->flags & ST_SCROLL_SELECT) {
y += st->runtime.scroll_ofs_px[1];
}
/* draw opening bracket */
ch = startl->line[startc];
- wrap_offset(st, ar, startl, startc, &offl, &offc);
+ wrap_offset(st, region, startl, startc, &offl, &offc);
viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc;
if (viewc >= 0) {
@@ -1542,7 +1542,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
/* draw closing bracket */
ch = endl->line[endc];
- wrap_offset(st, ar, endl, endc, &offl, &offc);
+ wrap_offset(st, region, endl, endc, &offl, &offc);
viewc = text_get_char_pos(st, endl->line, endc) - st->left + offc;
if (viewc >= 0) {
@@ -1557,7 +1557,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
/*********************** main region drawing *************************/
-void draw_text_main(SpaceText *st, ARegion *ar)
+void draw_text_main(SpaceText *st, ARegion *region)
{
TextDrawContext tdc = {0};
Text *text = st->text;
@@ -1581,12 +1581,12 @@ void draw_text_main(SpaceText *st, ARegion *ar)
const int clip_min_y = -(int)(st->runtime.lheight_px - 1);
st->runtime.viewlines = (st->runtime.lheight_px) ?
- (int)(ar->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
+ (int)(region->winy - clip_min_y) / TXT_LINE_HEIGHT(st) :
0;
text_draw_context_init(st, &tdc);
- text_update_drawcache(st, ar);
+ text_update_drawcache(st, region);
/* make sure all the positional pointers exist */
if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) {
@@ -1594,7 +1594,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
}
/* update rects for scroll */
- calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */
+ calc_text_rcts(st, region, &scroll, &back); /* scroll will hold the entire bar size */
/* update syntax formatting if needed */
tft = ED_text_format_get(text);
@@ -1637,7 +1637,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformThemeColor(TH_GRID);
- immRecti(pos, 0, 0, TXT_NUMCOL_WIDTH(st), ar->winy);
+ immRecti(pos, 0, 0, TXT_NUMCOL_WIDTH(st), region->winy);
immUnbindProgram();
}
else {
@@ -1645,17 +1645,17 @@ void draw_text_main(SpaceText *st, ARegion *ar)
}
x = TXT_BODY_LEFT(st);
- y = ar->winy - st->runtime.lheight_px;
+ y = region->winy - st->runtime.lheight_px;
int viewlines = st->runtime.viewlines;
if (st->flags & ST_SCROLL_SELECT) {
y += st->runtime.scroll_ofs_px[1];
viewlines += 1;
}
- winx = ar->winx - TXT_SCROLL_WIDTH;
+ winx = region->winx - TXT_SCROLL_WIDTH;
/* draw cursor, margin, selection and highlight */
- draw_text_decoration(st, ar);
+ draw_text_decoration(st, region);
/* draw the text */
UI_FontThemeColor(tdc.font_id, TH_TEXT);
@@ -1695,7 +1695,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
else {
/* draw unwrapped text */
text_draw(
- st, &tdc, tmp->line, st->left, ar->winx / st->runtime.cwidth_px, x, y, tmp->format);
+ st, &tdc, tmp->line, st->left, region->winx / st->runtime.cwidth_px, x, y, tmp->format);
y -= TXT_LINE_HEIGHT(st);
}
@@ -1713,17 +1713,17 @@ void draw_text_main(SpaceText *st, ARegion *ar)
margin_color[3] = 0.2f;
immUniformColor4fv(margin_color);
GPU_blend(true);
- immRecti(pos, margin_column_x, 0, margin_column_x + U.pixelsize, ar->winy);
+ immRecti(pos, margin_column_x, 0, margin_column_x + U.pixelsize, region->winy);
GPU_blend(false);
immUnbindProgram();
}
}
/* draw other stuff */
- draw_brackets(st, &tdc, ar);
+ draw_brackets(st, &tdc, region);
draw_textscroll(st, &scroll, &back);
- /* draw_documentation(st, ar); - No longer supported */
- draw_suggestion_list(st, &tdc, ar);
+ /* draw_documentation(st, region); - No longer supported */
+ draw_suggestion_list(st, &tdc, region);
text_font_end(&tdc);
}
@@ -1744,10 +1744,10 @@ void text_update_character_width(SpaceText *st)
/* Moves the view to the cursor location,
* also used to make sure the view isn't outside the file */
-void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
+void text_scroll_to_cursor(SpaceText *st, ARegion *region, const bool center)
{
Text *text;
- int i, x, winx = ar->winx;
+ int i, x, winx = region->winx;
if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
@@ -1760,7 +1760,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
i = txt_get_span(text->lines.first, text->sell);
if (st->wordwrap) {
int offl, offc;
- wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
+ wrap_offset(st, region, text->sell, text->selc, &offl, &offc);
i += offl;
}
@@ -1814,16 +1814,16 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
/* takes an area instead of a region, use for listeners */
void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center)
{
- ARegion *ar;
+ ARegion *region;
if (ELEM(NULL, st, st->text, st->text->curl)) {
return;
}
- ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ region = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- if (ar) {
- text_scroll_to_cursor(st, ar, center);
+ if (region) {
+ text_scroll_to_cursor(st, region, center);
}
}
@@ -1839,7 +1839,7 @@ void text_update_cursor_moved(bContext *C)
* Takes a cursor (row, character) and returns x,y pixel coords.
*/
bool ED_text_region_location_from_cursor(SpaceText *st,
- ARegion *ar,
+ ARegion *region,
const int cursor_co[2],
int r_pixel_co[2])
{
@@ -1859,10 +1859,10 @@ bool ED_text_region_location_from_cursor(SpaceText *st,
/* handle tabs as well! */
int char_pos = text_get_char_pos(st, line->line, cursor_co[1]);
- wrap_offset(st, ar, line, cursor_co[1], &offl, &offc);
+ wrap_offset(st, region, line, cursor_co[1], &offl, &offc);
r_pixel_co[0] = (char_pos + offc - st->left) * st->runtime.cwidth_px + linenr_offset;
r_pixel_co[1] = (cursor_co[0] + offl - st->top) * TXT_LINE_HEIGHT(st);
- r_pixel_co[1] = (ar->winy - (r_pixel_co[1] + (TXT_BODY_LPAD * st->runtime.cwidth_px))) -
+ r_pixel_co[1] = (region->winy - (r_pixel_co[1] + (TXT_BODY_LPAD * st->runtime.cwidth_px))) -
st->runtime.lheight_px;
}
return true;
diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c
index 846220b95ba..da39ba3c5ad 100644
--- a/source/blender/editors/space_text/text_header.c
+++ b/source/blender/editors/space_text/text_header.c
@@ -44,24 +44,24 @@
static ARegion *text_has_properties_region(ScrArea *sa)
{
- ARegion *ar, *arnew;
+ ARegion *region, *arnew;
- ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
- if (ar) {
- return ar;
+ region = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+ if (region) {
+ return region;
}
/* add subdiv level; after header */
- ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
+ region = BKE_area_find_region_type(sa, RGN_TYPE_HEADER);
/* is error! */
- if (ar == NULL) {
+ if (region == NULL) {
return NULL;
}
arnew = MEM_callocN(sizeof(ARegion), "properties region");
- BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+ BLI_insertlinkafter(&sa->regionbase, region, arnew);
arnew->regiontype = RGN_TYPE_UI;
arnew->alignment = RGN_ALIGN_LEFT;
@@ -78,21 +78,21 @@ static bool text_properties_poll(bContext *C)
static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = text_has_properties_region(sa);
+ ARegion *region = text_has_properties_region(sa);
SpaceText *st = CTX_wm_space_text(C);
- if (ar) {
- if (ar->flag & RGN_FLAG_HIDDEN) {
- ED_region_toggle_hidden(C, ar);
+ if (region) {
+ if (region->flag & RGN_FLAG_HIDDEN) {
+ ED_region_toggle_hidden(C, region);
}
- UI_panel_category_active_set(ar, "Text");
+ UI_panel_category_active_set(region, "Text");
/* cannot send a button activate yet for case when region wasn't visible yet */
/* flag gets checked and cleared in main draw callback */
st->flags |= ST_FIND_ACTIVATE;
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw(region);
}
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index 1a36b21952b..5ad6a554188 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -35,12 +35,12 @@ struct bContext;
struct wmOperatorType;
/* text_draw.c */
-void draw_text_main(struct SpaceText *st, struct ARegion *ar);
+void draw_text_main(struct SpaceText *st, struct ARegion *region);
void text_update_line_edited(struct TextLine *line);
void text_update_edited(struct Text *text);
void text_update_character_width(struct SpaceText *st);
-void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *ar, const bool center);
+void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *region, const bool center);
void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *sa, const bool center);
void text_update_cursor_moved(struct bContext *C);
@@ -74,15 +74,15 @@ void text_update_cursor_moved(struct bContext *C);
#define TOOL_SUGG_LIST 0x01
#define TOOL_DOCUMENT 0x02
-int wrap_width(const struct SpaceText *st, struct ARegion *ar);
+int wrap_width(const struct SpaceText *st, struct ARegion *region);
void wrap_offset(const struct SpaceText *st,
- struct ARegion *ar,
+ struct ARegion *region,
struct TextLine *linein,
int cursin,
int *offl,
int *offc);
void wrap_offset_in_line(const struct SpaceText *st,
- struct ARegion *ar,
+ struct ARegion *region,
struct TextLine *linep,
int cursin,
int *offl,
@@ -92,15 +92,15 @@ int text_get_char_pos(const struct SpaceText *st, const char *line, int cur);
void text_drawcache_tag_update(struct SpaceText *st, int full);
void text_free_caches(struct SpaceText *st);
-int text_do_suggest_select(struct SpaceText *st, struct ARegion *ar);
+int text_do_suggest_select(struct SpaceText *st, struct ARegion *region);
void text_pop_suggest_list(void);
-int text_get_visible_lines(const struct SpaceText *st, struct ARegion *ar, const char *str);
+int text_get_visible_lines(const struct SpaceText *st, struct ARegion *region, const char *str);
int text_get_span_wrap(const struct SpaceText *st,
- struct ARegion *ar,
+ struct ARegion *region,
struct TextLine *from,
struct TextLine *to);
-int text_get_total_lines(struct SpaceText *st, struct ARegion *ar);
+int text_get_total_lines(struct SpaceText *st, struct ARegion *region);
/* text_ops.c */
enum {
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index ab1f5f53e7b..43010829bdf 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -60,7 +60,7 @@
#include "text_intern.h"
#include "text_format.h"
-static void txt_screen_clamp(SpaceText *st, ARegion *ar);
+static void txt_screen_clamp(SpaceText *st, ARegion *region);
/* -------------------------------------------------------------------- */
/** \name Util
@@ -195,13 +195,13 @@ static bool text_region_edit_poll(bContext *C)
{
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
if (!st || !text) {
return 0;
}
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
+ if (!region || region->regiontype != RGN_TYPE_WINDOW) {
return 0;
}
@@ -421,7 +421,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
{
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
/* store view & cursor state */
const int orig_top = st->top;
@@ -448,7 +448,7 @@ static int text_reload_exec(bContext *C, wmOperator *op)
/* return to scroll position */
st->top = orig_top;
- txt_screen_clamp(st, ar);
+ txt_screen_clamp(st, region);
/* return cursor */
txt_move_to(text, orig_curl, orig_curc, false);
@@ -1633,12 +1633,13 @@ static const EnumPropertyItem move_type_items[] = {
};
/* get cursor position in line by relative wrapped line and column positions */
-static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int rell, int relc)
+static int text_get_cursor_rel(
+ SpaceText *st, ARegion *region, TextLine *linein, int rell, int relc)
{
int i, j, start, end, max, chop, curs, loop, endj, found, selc;
char ch;
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
selc = start = endj = curs = found = 0;
end = max;
@@ -1726,17 +1727,17 @@ static int text_get_cursor_rel(SpaceText *st, ARegion *ar, TextLine *linein, int
}
static int cursor_skip_find_line(
- SpaceText *st, ARegion *ar, int lines, TextLine **linep, int *charp, int *rell, int *relc)
+ SpaceText *st, ARegion *region, int lines, TextLine **linep, int *charp, int *rell, int *relc)
{
int offl, offc, visible_lines;
- wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc);
+ wrap_offset_in_line(st, region, *linep, *charp, &offl, &offc);
*relc = text_get_char_pos(st, (*linep)->line, *charp) + offc;
*rell = lines;
/* handle current line */
if (lines > 0) {
- visible_lines = text_get_visible_lines(st, ar, (*linep)->line);
+ visible_lines = text_get_visible_lines(st, region, (*linep)->line);
if (*rell - visible_lines + offl >= 0) {
if (!(*linep)->next) {
@@ -1780,7 +1781,7 @@ static int cursor_skip_find_line(
/* skip lines and find destination line and offsets */
while (*linep) {
- visible_lines = text_get_visible_lines(st, ar, (*linep)->line);
+ visible_lines = text_get_visible_lines(st, region, (*linep)->line);
if (lines < 0) { /* moving top */
if (*rell + visible_lines >= 0) {
@@ -1814,7 +1815,7 @@ static int cursor_skip_find_line(
return 1;
}
-static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
+static void txt_wrap_move_bol(SpaceText *st, ARegion *region, const bool sel)
{
Text *text = st->text;
TextLine **linep;
@@ -1835,7 +1836,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
oldc = *charp;
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
start = endj = 0;
end = max;
@@ -1898,7 +1899,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, const bool sel)
}
}
-static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
+static void txt_wrap_move_eol(SpaceText *st, ARegion *region, const bool sel)
{
Text *text = st->text;
TextLine **linep;
@@ -1919,7 +1920,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
oldc = *charp;
- max = wrap_width(st, ar);
+ max = wrap_width(st, region);
start = endj = 0;
end = max;
@@ -1982,7 +1983,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, const bool sel)
}
}
-static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
+static void txt_wrap_move_up(SpaceText *st, ARegion *region, const bool sel)
{
Text *text = st->text;
TextLine **linep;
@@ -2000,18 +2001,18 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
charp = &text->curc;
}
- wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc);
+ wrap_offset_in_line(st, region, *linep, *charp, &offl, &offc);
col = text_get_char_pos(st, (*linep)->line, *charp) + offc;
if (offl) {
- *charp = text_get_cursor_rel(st, ar, *linep, offl - 1, col);
+ *charp = text_get_cursor_rel(st, region, *linep, offl - 1, col);
}
else {
if ((*linep)->prev) {
int visible_lines;
*linep = (*linep)->prev;
- visible_lines = text_get_visible_lines(st, ar, (*linep)->line);
- *charp = text_get_cursor_rel(st, ar, *linep, visible_lines - 1, col);
+ visible_lines = text_get_visible_lines(st, region, (*linep)->line);
+ *charp = text_get_cursor_rel(st, region, *linep, visible_lines - 1, col);
}
else {
*charp = 0;
@@ -2023,7 +2024,7 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, const bool sel)
}
}
-static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
+static void txt_wrap_move_down(SpaceText *st, ARegion *region, const bool sel)
{
Text *text = st->text;
TextLine **linep;
@@ -2041,16 +2042,16 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
charp = &text->curc;
}
- wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc);
+ wrap_offset_in_line(st, region, *linep, *charp, &offl, &offc);
col = text_get_char_pos(st, (*linep)->line, *charp) + offc;
- visible_lines = text_get_visible_lines(st, ar, (*linep)->line);
+ visible_lines = text_get_visible_lines(st, region, (*linep)->line);
if (offl < visible_lines - 1) {
- *charp = text_get_cursor_rel(st, ar, *linep, offl + 1, col);
+ *charp = text_get_cursor_rel(st, region, *linep, offl + 1, col);
}
else {
if ((*linep)->next) {
*linep = (*linep)->next;
- *charp = text_get_cursor_rel(st, ar, *linep, 0, col);
+ *charp = text_get_cursor_rel(st, region, *linep, 0, col);
}
else {
*charp = (*linep)->len;
@@ -2068,7 +2069,7 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, const bool sel)
*
* This is to replace screen_skip for PageUp/Down operations.
*/
-static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const bool sel)
+static void cursor_skip(SpaceText *st, ARegion *region, Text *text, int lines, const bool sel)
{
TextLine **linep;
int *charp;
@@ -2082,12 +2083,12 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const
charp = &text->curc;
}
- if (st && ar && st->wordwrap) {
+ if (st && region && st->wordwrap) {
int rell, relc;
/* find line and offsets inside it needed to set cursor position */
- if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc)) {
- *charp = text_get_cursor_rel(st, ar, *linep, rell, relc);
+ if (cursor_skip_find_line(st, region, lines, linep, charp, &rell, &relc)) {
+ *charp = text_get_cursor_rel(st, region, *linep, rell, relc);
}
}
else {
@@ -2114,11 +2115,11 @@ static int text_move_cursor(bContext *C, int type, bool select)
{
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
/* ensure we have the right region, it's optional */
- if (ar && ar->regiontype != RGN_TYPE_WINDOW) {
- ar = NULL;
+ if (region && region->regiontype != RGN_TYPE_WINDOW) {
+ region = NULL;
}
switch (type) {
@@ -2126,8 +2127,8 @@ static int text_move_cursor(bContext *C, int type, bool select)
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar) {
- txt_wrap_move_bol(st, ar, select);
+ if (st && st->wordwrap && region) {
+ txt_wrap_move_bol(st, region, select);
}
else {
txt_move_bol(text, select);
@@ -2138,8 +2139,8 @@ static int text_move_cursor(bContext *C, int type, bool select)
if (!select) {
txt_sel_clear(text);
}
- if (st && st->wordwrap && ar) {
- txt_wrap_move_eol(st, ar, select);
+ if (st && st->wordwrap && region) {
+ txt_wrap_move_eol(st, region, select);
}
else {
txt_move_eol(text, select);
@@ -2189,8 +2190,8 @@ static int text_move_cursor(bContext *C, int type, bool select)
break;
case PREV_LINE:
- if (st && st->wordwrap && ar) {
- txt_wrap_move_up(st, ar, select);
+ if (st && st->wordwrap && region) {
+ txt_wrap_move_up(st, region, select);
}
else {
txt_move_up(text, select);
@@ -2198,8 +2199,8 @@ static int text_move_cursor(bContext *C, int type, bool select)
break;
case NEXT_LINE:
- if (st && st->wordwrap && ar) {
- txt_wrap_move_down(st, ar, select);
+ if (st && st->wordwrap && region) {
+ txt_wrap_move_down(st, region, select);
}
else {
txt_move_down(text, select);
@@ -2208,7 +2209,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
case PREV_PAGE:
if (st) {
- cursor_skip(st, ar, st->text, -st->runtime.viewlines, select);
+ cursor_skip(st, region, st->text, -st->runtime.viewlines, select);
}
else {
cursor_skip(NULL, NULL, text, -10, select);
@@ -2217,7 +2218,7 @@ static int text_move_cursor(bContext *C, int type, bool select)
case NEXT_PAGE:
if (st) {
- cursor_skip(st, ar, st->text, st->runtime.viewlines, select);
+ cursor_skip(st, region, st->text, st->runtime.viewlines, select);
}
else {
cursor_skip(NULL, NULL, text, 10, select);
@@ -2491,14 +2492,14 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
/** \name Scroll Operator
* \{ */
-static void txt_screen_clamp(SpaceText *st, ARegion *ar)
+static void txt_screen_clamp(SpaceText *st, ARegion *region)
{
if (st->top <= 0) {
st->top = 0;
}
else {
int last;
- last = text_get_total_lines(st, ar);
+ last = text_get_total_lines(st, region);
last = last - (st->runtime.viewlines / 2);
if (last > 0 && st->top > last) {
st->top = last;
@@ -2507,10 +2508,10 @@ static void txt_screen_clamp(SpaceText *st, ARegion *ar)
}
/* Moves the view vertically by the specified number of lines */
-static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines)
+static void txt_screen_skip(SpaceText *st, ARegion *region, int lines)
{
st->top += lines;
- txt_screen_clamp(st, ar);
+ txt_screen_clamp(st, region);
}
/* quick enum for tsc->zone (scroller handles) */
@@ -2540,13 +2541,14 @@ typedef struct TextScroll {
int ofs_delta_px[2];
} TextScroll;
-static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *ar)
+static void text_scroll_state_init(TextScroll *tsc, SpaceText *st, ARegion *region)
{
tsc->state.ofs_init[0] = st->left;
tsc->state.ofs_init[1] = st->top;
tsc->state.ofs_max[0] = INT_MAX;
- tsc->state.ofs_max[1] = max_ii(0, text_get_total_lines(st, ar) - (st->runtime.viewlines / 2));
+ tsc->state.ofs_max[1] = max_ii(0,
+ text_get_total_lines(st, region) - (st->runtime.viewlines / 2));
tsc->state.size_px[0] = st->runtime.cwidth_px;
tsc->state.size_px[1] = TXT_LINE_HEIGHT(st);
@@ -2562,7 +2564,7 @@ static bool text_scroll_poll(bContext *C)
static int text_scroll_exec(bContext *C, wmOperator *op)
{
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
int lines = RNA_int_get(op->ptr, "lines");
@@ -2570,7 +2572,7 @@ static int text_scroll_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- txt_screen_skip(st, ar, lines * U.wheellinescroll);
+ txt_screen_skip(st, region, lines * U.wheellinescroll);
ED_area_tag_redraw(CTX_wm_area(C));
@@ -2689,7 +2691,7 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
TextScroll *tsc = op->customdata;
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
switch (event->type) {
case MOUSEMOVE:
@@ -2702,8 +2704,10 @@ static int text_scroll_modal(bContext *C, wmOperator *op, const wmEvent *event)
case MIDDLEMOUSE:
if (event->val == KM_RELEASE) {
if (ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
- txt_screen_skip(
- st, ar, st->runtime.viewlines * (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
+ txt_screen_skip(st,
+ region,
+ st->runtime.viewlines *
+ (tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -2723,7 +2727,7 @@ static void text_scroll_cancel(bContext *C, wmOperator *op)
static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
TextScroll *tsc;
@@ -2735,7 +2739,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event)
tsc->is_first = true;
tsc->zone = SCROLLHANDLE_BAR;
- text_scroll_state_init(tsc, st, ar);
+ text_scroll_state_init(tsc, st, region);
op->customdata = tsc;
@@ -2796,13 +2800,13 @@ static bool text_region_scroll_poll(bContext *C)
/* same as text_region_edit_poll except it works on libdata too */
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
if (!st || !text) {
return 0;
}
- if (!ar || ar->regiontype != RGN_TYPE_WINDOW) {
+ if (!region || region->regiontype != RGN_TYPE_WINDOW) {
return 0;
}
@@ -2812,7 +2816,7 @@ static bool text_region_scroll_poll(bContext *C)
static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
TextScroll *tsc;
const int *mval = event->mval;
enum eScrollZone zone = SCROLLHANDLE_INVALID_OUTSIDE;
@@ -2829,7 +2833,7 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
/* mouse inside scroll handle */
zone = SCROLLHANDLE_BAR;
}
- else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < ar->winy - TXT_SCROLL_SPACE) {
+ else if (mval[1] > TXT_SCROLL_SPACE && mval[1] < region->winy - TXT_SCROLL_SPACE) {
if (mval[1] < st->runtime.scroll_region_handle.ymin) {
zone = SCROLLHANDLE_MIN_OUTSIDE;
}
@@ -2851,12 +2855,12 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev
op->customdata = tsc;
st->flags |= ST_SCROLL_SELECT;
- text_scroll_state_init(tsc, st, ar);
+ text_scroll_state_init(tsc, st, region);
/* 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->runtime.scroll_region_handle);
- tsc->mval_prev[1] = ar->winrct.ymin + BLI_rcti_cent_y(&st->runtime.scroll_region_handle);
+ tsc->mval_prev[0] = region->winrct.xmin + BLI_rcti_cent_x(&st->runtime.scroll_region_handle);
+ tsc->mval_prev[1] = region->winrct.ymin + BLI_rcti_cent_y(&st->runtime.scroll_region_handle);
tsc->is_first = false;
tsc->zone = SCROLLHANDLE_BAR;
@@ -2943,7 +2947,7 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index)
return j;
}
-static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *ar, int *y)
+static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *region, int *y)
{
TextLine *linep = st->text->lines.first;
int i, lines;
@@ -2953,7 +2957,7 @@ static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *ar, int *y)
}
for (i = -st->top; i <= *y && linep; linep = linep->next, i += lines) {
- lines = text_get_visible_lines(st, ar, linep->line);
+ lines = text_get_visible_lines(st, region, linep->line);
if (i + lines > *y) {
/* We found the line matching given vertical 'coordinate',
@@ -2966,15 +2970,15 @@ static TextLine *get_line_pos_wrapped(SpaceText *st, ARegion *ar, int *y)
}
static void text_cursor_set_to_pos_wrapped(
- SpaceText *st, ARegion *ar, int x, int y, const bool sel)
+ SpaceText *st, ARegion *region, int x, int y, const bool sel)
{
Text *text = st->text;
- int max = wrap_width(st, ar); /* column */
- int charp = -1; /* mem */
- bool found = false; /* flags */
+ int max = wrap_width(st, region); /* column */
+ int charp = -1; /* mem */
+ bool found = false; /* flags */
/* Point to line matching given y position, if any. */
- TextLine *linep = get_line_pos_wrapped(st, ar, &y);
+ TextLine *linep = get_line_pos_wrapped(st, region, &y);
if (linep) {
int i = 0, start = 0, end = max; /* column */
@@ -3090,11 +3094,11 @@ static void text_cursor_set_to_pos_wrapped(
}
}
-static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, const bool sel)
+static void text_cursor_set_to_pos(SpaceText *st, ARegion *region, int x, int y, const bool sel)
{
Text *text = st->text;
text_update_character_width(st);
- y = (ar->winy - 2 - y) / TXT_LINE_HEIGHT(st);
+ y = (region->winy - 2 - y) / TXT_LINE_HEIGHT(st);
x -= TXT_BODY_LEFT(st);
if (x < 0) {
@@ -3103,7 +3107,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
x = text_pixel_x_to_column(st, x) + st->left;
if (st->wordwrap) {
- text_cursor_set_to_pos_wrapped(st, ar, x, y, sel);
+ text_cursor_set_to_pos_wrapped(st, region, x, y, sel);
}
else {
TextLine **linep;
@@ -3173,24 +3177,25 @@ static void text_cursor_timer_remove(bContext *C, SetSelection *ssel)
static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
SetSelection *ssel = op->customdata;
- if (event->mval[1] < 0 || event->mval[1] > ar->winy) {
+ if (event->mval[1] < 0 || event->mval[1] > region->winy) {
text_cursor_timer_ensure(C, ssel);
if (event->type == TIMER) {
- text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1], 1);
- text_scroll_to_cursor(st, ar, false);
+ text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
+ text_scroll_to_cursor(st, region, false);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
}
}
- else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > ar->winx)) {
+ else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > region->winx)) {
text_cursor_timer_ensure(C, ssel);
if (event->type == TIMER) {
- text_cursor_set_to_pos(st, ar, CLAMPIS(event->mval[0], 0, ar->winx), event->mval[1], 1);
- text_scroll_to_cursor(st, ar, false);
+ text_cursor_set_to_pos(
+ st, region, CLAMPIS(event->mval[0], 0, region->winx), event->mval[1], 1);
+ text_scroll_to_cursor(st, region, false);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
}
}
@@ -3198,8 +3203,8 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev
text_cursor_timer_remove(C, ssel);
if (event->type != TIMER) {
- text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1], 1);
- text_scroll_to_cursor(st, ar, false);
+ text_cursor_set_to_pos(st, region, event->mval[0], event->mval[1], 1);
+ text_scroll_to_cursor(st, region, false);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
ssel->mval_prev[0] = event->mval[0];
@@ -3298,11 +3303,11 @@ void TEXT_OT_selection_set(wmOperatorType *ot)
static int text_cursor_set_exec(bContext *C, wmOperator *op)
{
SpaceText *st = CTX_wm_space_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
int x = RNA_int_get(op->ptr, "x");
int y = RNA_int_get(op->ptr, "y");
- text_cursor_set_to_pos(st, ar, x, y, 0);
+ text_cursor_set_to_pos(st, region, x, y, 0);
text_update_cursor_moved(C);
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text);
@@ -3351,7 +3356,7 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
{
SpaceText *st = CTX_wm_space_text(C);
Text *text = CTX_data_edit_text(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
const int *mval = event->mval;
double time;
static int jump_to = 0;
@@ -3365,7 +3370,7 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
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)) {
+ mval[1] > 2 && mval[1] < region->winy - 2)) {
return OPERATOR_PASS_THROUGH;
}