Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_draw.c
| Show All 26 Lines | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "DNA_text_types.h" | #include "DNA_text_types.h" | ||||
| #include "DNA_space_types.h" | #include "DNA_space_types.h" | ||||
| #include "DNA_screen_types.h" | #include "DNA_screen_types.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_suggestions.h" | |||||
| #include "BKE_text.h" | #include "BKE_text.h" | ||||
| #include "BKE_text_suggestions.h" | |||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "ED_text.h" | #include "ED_text.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_state.h" | #include "GPU_state.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| ▲ Show 20 Lines • Show All 1,219 Lines • ▼ Show 20 Lines | if (text->curl != text->sell || text->curc != text->selc) { | ||||
| if (vcurc < 0) { | if (vcurc < 0) { | ||||
| vcurc = 0; | vcurc = 0; | ||||
| } | } | ||||
| immUniformThemeColor(TH_SHADE2); | immUniformThemeColor(TH_SHADE2); | ||||
| x = TXT_BODY_LEFT(st); | x = TXT_BODY_LEFT(st); | ||||
| y = ar->winy; | y = ar->winy; | ||||
| if (st->flags & ST_SCROLL_SELECT) { | |||||
| y += st->scroll_ofs_px[1]; | |||||
| } | |||||
| if (vcurl == vsell) { | if (vcurl == vsell) { | ||||
| y -= vcurl * lheight; | y -= vcurl * lheight; | ||||
| if (vcurc < vselc) { | if (vcurc < vselc) { | ||||
| immRecti(pos, x + vcurc * st->cwidth, y, x + vselc * st->cwidth, y - lheight); | immRecti(pos, x + vcurc * st->cwidth, y, x + vselc * st->cwidth, y - lheight); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */ | ||||
| GPU_blend(true); | GPU_blend(true); | ||||
| immRecti(pos, 0, y1, ar->winx, y2); | immRecti(pos, 0, y1, ar->winx, y2); | ||||
| 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 = TXT_BODY_LEFT(st); | x = TXT_BODY_LEFT(st) + (vselc * st->cwidth); | ||||
| x += vselc * st->cwidth; | |||||
| y = ar->winy - vsell * lheight; | y = ar->winy - vsell * lheight; | ||||
| if (st->flags & ST_SCROLL_SELECT) { | |||||
| y += st->scroll_ofs_px[1]; | |||||
| } | |||||
| immUniformThemeColor(TH_HILITE); | immUniformThemeColor(TH_HILITE); | ||||
| if (st->overwrite) { | if (st->overwrite) { | ||||
| char ch = text->sell->line[text->selc]; | char ch = text->sell->line[text->selc]; | ||||
| y += TXT_LINE_SPACING(st); | y += TXT_LINE_SPACING(st); | ||||
| w = st->cwidth; | w = st->cwidth; | ||||
| ▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegion *ar) | ||||
| if (!endl || endc == -1) { | if (!endl || endc == -1) { | ||||
| return; | return; | ||||
| } | } | ||||
| UI_FontThemeColor(tdc->font_id, TH_HILITE); | UI_FontThemeColor(tdc->font_id, TH_HILITE); | ||||
| x = TXT_BODY_LEFT(st); | x = TXT_BODY_LEFT(st); | ||||
| y = ar->winy - st->lheight_dpi; | y = ar->winy - st->lheight_dpi; | ||||
| if (st->flags & ST_SCROLL_SELECT) { | |||||
| y += st->scroll_ofs_px[1]; | |||||
| } | |||||
| /* draw opening bracket */ | /* draw opening bracket */ | ||||
| ch = startl->line[startc]; | ch = startl->line[startc]; | ||||
| wrap_offset(st, ar, startl, startc, &offl, &offc); | wrap_offset(st, ar, startl, startc, &offl, &offc); | ||||
| viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc; | viewc = text_get_char_pos(st, startl->line, startc) - st->left + offc; | ||||
| if (viewc >= 0) { | if (viewc >= 0) { | ||||
| viewl = txt_get_span(text->lines.first, startl) - st->top + offl; | viewl = txt_get_span(text->lines.first, startl) - st->top + offl; | ||||
| ▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | if (st->showlinenrs) { | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| else { | else { | ||||
| st->linenrs_tot = 0; /* not used */ | st->linenrs_tot = 0; /* not used */ | ||||
| } | } | ||||
| x = TXT_BODY_LEFT(st); | x = TXT_BODY_LEFT(st); | ||||
| y = ar->winy - st->lheight_dpi; | y = ar->winy - st->lheight_dpi; | ||||
| int viewlines = st->viewlines; | |||||
| if (st->flags & ST_SCROLL_SELECT) { | |||||
| y += st->scroll_ofs_px[1]; | |||||
| viewlines += 1; | |||||
| } | |||||
| 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); | ||||
| /* 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 < viewlines && tmp; i++, tmp = tmp->next) { | ||||
| if (tdc.syntax_highlight && !tmp->format) { | if (tdc.syntax_highlight && !tmp->format) { | ||||
| tft->format_line(st, tmp, false); | tft->format_line(st, tmp, false); | ||||
| } | } | ||||
| if (st->showlinenrs && !wrap_skip) { | if (st->showlinenrs && !wrap_skip) { | ||||
| /* draw line number */ | /* draw line number */ | ||||
| if (tmp == text->curl) { | if (tmp == text->curl) { | ||||
| UI_FontThemeColor(tdc.font_id, TH_HILITE); | UI_FontThemeColor(tdc.font_id, TH_HILITE); | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center) | ||||
| if (st->top < 0) { | if (st->top < 0) { | ||||
| st->top = 0; | st->top = 0; | ||||
| } | } | ||||
| if (st->left < 0) { | if (st->left < 0) { | ||||
| st->left = 0; | st->left = 0; | ||||
| } | } | ||||
| st->scroll_accum[0] = 0.0f; | st->scroll_ofs_px[0] = 0; | ||||
| st->scroll_accum[1] = 0.0f; | st->scroll_ofs_px[1] = 0; | ||||
| } | } | ||||
| /* takes an area instead of a region, use for listeners */ | /* takes an area instead of a region, use for listeners */ | ||||
| void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center) | void text_scroll_to_cursor__area(SpaceText *st, ScrArea *sa, const bool center) | ||||
| { | { | ||||
| ARegion *ar; | ARegion *ar; | ||||
| if (ELEM(NULL, st, st->text, st->text->curl)) { | if (ELEM(NULL, st, st->text, st->text->curl)) { | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||