Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_draw.c
| Show First 20 Lines • Show All 1,086 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_cursor(SpaceText *st, ARegion *ar) | static void draw_cursor(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; | ||||
| const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | ||||
| /* Draw the selection */ | /* Draw the selection */ | ||||
| if (text->curl != text->sell || text->curc != text->selc) { | if (text->curl != text->sell || text->curc != text->selc) { | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| } | } | ||||
| 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; | ||||
| /* 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; | ||||
| UI_ThemeColor(TH_HILITE); | UI_ThemeColor(TH_HILITE); | ||||
| glRecti(x, y - lheight - 1, x + w, y - lheight + 1); | glRecti(x, y - 1, x + w, y + 1); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_ThemeColor(TH_HILITE); | UI_ThemeColor(TH_HILITE); | ||||
| glRecti(x - 1, y, x + 1, y - lheight); | glRecti(x - 1, y + lheight, x + 1, y); | ||||
| } | } | ||||
| } | } | ||||
| else | |||||
| cursor_xy[0] = cursor_xy[1] = -1; | |||||
| } | } | ||||
| /******************* 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) | ||||
| { | { | ||||
| TextLine *startl, *endl, *linep; | TextLine *startl, *endl, *linep; | ||||
| Text *text = st->text; | Text *text = st->text; | ||||
| ▲ Show 20 Lines • Show All 115 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 68 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 */ | /* draw cursor */ | ||||
| draw_cursor(st, ar); | draw_cursor(st, ar, cursor_xy); | ||||
| /* draw the text */ | /* draw the text */ | ||||
| UI_ThemeColor(TH_TEXT); | UI_ThemeColor(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 185 Lines • Show Last 20 Lines | |||||