Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_draw.c
| Show First 20 Lines • Show All 1,101 Lines • ▼ Show 20 Lines | for (i = 0; i < SUGG_LIST_SIZE && item; i++, item = item->next) { | ||||
| text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL); | text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL); | ||||
| if (item == last) break; | if (item == last) break; | ||||
| } | } | ||||
| } | } | ||||
| /*********************** draw cursor ************************/ | /*********************** draw cursor ************************/ | ||||
| static void draw_text_decoration(SpaceText *st, ARegion *ar) | static void draw_text_decoration(SpaceText *st, ARegion *ar, int cursor_xy[2]) | ||||
| { | { | ||||
| Text *text = st->text; | Text *text = st->text; | ||||
| int vcurl, vcurc, vsell, vselc, hidden = 0; | int vcurl, vcurc, vsell, vselc, hidden = 0; | ||||
| int x, y, w, i; | int x, y, w, i; | ||||
| int offl, offc; | int offl, offc; | ||||
| const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | ||||
| /* Convert to view space character coordinates to determine if cursor is hidden */ | /* Convert to view space character coordinates to determine if cursor is hidden */ | ||||
| ▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ | ||||
| GPU_blend(false); | GPU_blend(false); | ||||
| } | } | ||||
| } | } | ||||
| if (!hidden) { | if (!hidden) { | ||||
| /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ | /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ | ||||
| x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | ||||
| x += vselc * st->cwidth; | x += vselc * st->cwidth; | ||||
| y = ar->winy - vsell * lheight; | y = ar->winy - vsell * lheight - lheight; | ||||
| immUniformThemeColor(TH_HILITE); | immUniformThemeColor(TH_HILITE); | ||||
| /* return pixel coordinates of bottom-left of the character */ | |||||
| cursor_xy[0] = x; | |||||
| cursor_xy[1] = y; | |||||
| if (st->overwrite) { | if (st->overwrite) { | ||||
| char ch = text->sell->line[text->selc]; | char ch = text->sell->line[text->selc]; | ||||
| y += TXT_LINE_SPACING; | y += TXT_LINE_SPACING; | ||||
| w = st->cwidth; | w = st->cwidth; | ||||
| if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; | if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; | ||||
| immRecti(pos, x, y - lheight - 1, x + w, y - lheight + 1); | immRecti(pos, x, y - 1, x + w, y + 1); | ||||
| } | } | ||||
| else { | else { | ||||
| immRecti(pos, x - 1, y, x + 1, y - lheight); | immRecti(pos, x - 1, y + lheight, x + 1, y); | ||||
| } | } | ||||
| } | } | ||||
| else | |||||
| cursor_xy[0] = cursor_xy[1] = -1; | |||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| /******************* draw matching brackets *********************/ | /******************* 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 *ar) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | if (viewc >= 0) { | ||||
| text_font_draw_character(tdc, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch); | text_font_draw_character(tdc, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch); | ||||
| text_font_draw_character(tdc, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch); | text_font_draw_character(tdc, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch); | ||||
| } | } | ||||
| } | } | ||||
| /*********************** main region drawing *************************/ | /*********************** main region drawing *************************/ | ||||
| void draw_text_main(SpaceText *st, ARegion *ar) | void draw_text_main(SpaceText *st, ARegion *ar, int cursor_xy[2]) | ||||
| { | { | ||||
| TextDrawContext tdc = {0}; | TextDrawContext tdc = {0}; | ||||
| Text *text = st->text; | Text *text = st->text; | ||||
| TextFormatType *tft; | TextFormatType *tft; | ||||
| TextLine *tmp; | TextLine *tmp; | ||||
| rcti scroll, back; | rcti scroll, back; | ||||
| char linenr[12]; | char linenr[12]; | ||||
| int i, x, y, winx, linecount = 0, lineno = 0; | int i, x, y, winx, linecount = 0, lineno = 0; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | void draw_text_main(SpaceText *st, ARegion *ar, int cursor_xy[2]) | ||||
| else { | else { | ||||
| st->linenrs_tot = 0; /* not used */ | st->linenrs_tot = 0; /* not used */ | ||||
| x = TXT_OFFSET; | x = TXT_OFFSET; | ||||
| } | } | ||||
| y = ar->winy - st->lheight_dpi; | y = ar->winy - st->lheight_dpi; | ||||
| winx = ar->winx - TXT_SCROLL_WIDTH; | winx = ar->winx - TXT_SCROLL_WIDTH; | ||||
| /* draw cursor, margin, selection and highlight */ | /* draw cursor, margin, selection and highlight */ | ||||
| draw_text_decoration(st, ar); | draw_text_decoration(st, ar, cursor_xy); | ||||
| /* draw the text */ | /* draw the text */ | ||||
| UI_FontThemeColor(tdc.font_id, TH_TEXT); | UI_FontThemeColor(tdc.font_id, TH_TEXT); | ||||
| for (i = 0; y > clip_min_y && i < st->viewlines && tmp; i++, tmp = tmp->next) { | for (i = 0; y > clip_min_y && i < st->viewlines && tmp; i++, tmp = tmp->next) { | ||||
| if (st->showsyntax && !tmp->format) | if (st->showsyntax && !tmp->format) | ||||
| tft->format_line(st, tmp, false); | tft->format_line(st, tmp, false); | ||||
| ▲ Show 20 Lines • Show All 198 Lines • Show Last 20 Lines | |||||