void TE_View::make_visible(const boolean scroll_page) { int index = text_editor_->Dot(); int line = te_buffer_->line(index); if (line < start_row_) scroll_to_line(line); else if (line > end_row_) { if (scroll_page) scroll_to_line(line); else scroll_to_line(first_visible_line() + 1); } }
static void draw_markers(SpaceText *st, ARegion *ar) { Text *text= st->text; TextMarker *marker, *next; TextLine *top, *line; int offl, offc, i, x1, x2, y1, y2, x, y; int topi, topy; /* Move pointer to first visible line (top) */ top= first_visible_line(st, ar, NULL); topi= BLI_findindex(&text->lines, top); topy= txt_get_span(text->lines.first, top); for(marker= text->markers.first; marker; marker= next) { next= marker->next; /* invisible line (before top) */ if(marker->lineno<topi) continue; line= BLI_findlink(&text->lines, marker->lineno); /* Remove broken markers */ if(marker->end>line->len || marker->start>marker->end) { BLI_freelinkN(&text->markers, marker); continue; } wrap_offset(st, ar, line, marker->start, &offl, &offc); y1 = txt_get_span(top, line) - st->top + offl + topy; x1 = text_get_char_pos(st, line->line, marker->start) - st->left + offc; wrap_offset(st, ar, line, marker->end, &offl, &offc); y2 = txt_get_span(top, line) - st->top + offl + topy; x2 = text_get_char_pos(st, line->line, marker->end) - st->left + offc; /* invisible part of line (before top, after last visible line) */ if(y2 < 0 || y1 > st->top+st->viewlines) continue; glColor3ubv(marker->color); x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; y= ar->winy-3; if(y1==y2) { y -= y1*st->lheight; glBegin(GL_LINE_LOOP); glVertex2i(x+x2*st->cwidth+1, y); glVertex2i(x+x1*st->cwidth-2, y); glVertex2i(x+x1*st->cwidth-2, y-st->lheight); glVertex2i(x+x2*st->cwidth+1, y-st->lheight); glEnd(); } else { y -= y1*st->lheight; glBegin(GL_LINE_STRIP); glVertex2i(ar->winx, y); glVertex2i(x+x1*st->cwidth-2, y); glVertex2i(x+x1*st->cwidth-2, y-st->lheight); glVertex2i(ar->winx, y-st->lheight); glEnd(); y-=st->lheight; for(i=y1+1; i<y2; i++) { glBegin(GL_LINES); glVertex2i(x, y); glVertex2i(ar->winx, y); glVertex2i(x, y-st->lheight); glVertex2i(ar->winx, y-st->lheight); glEnd(); y-=st->lheight; } glBegin(GL_LINE_STRIP); glVertex2i(x, y); glVertex2i(x+x2*st->cwidth+1, y); glVertex2i(x+x2*st->cwidth+1, y-st->lheight); glVertex2i(x, y-st->lheight); glEnd(); } } }