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); } }
bool RichTextLabel::search(const String& p_string,bool p_from_selection) { ERR_FAIL_COND_V(!selection.enabled,false); Item *it=main; int charidx=0; if (p_from_selection && selection.active && selection.enabled) { it=selection.to; charidx=selection.to_char+1; } int line=-1; while(it) { if (it->type==ITEM_TEXT) { ItemText *t = static_cast<ItemText*>(it); int sp = t->text.find(p_string,charidx); if (sp!=-1) { selection.from=it; selection.from_char=sp; selection.to=it; selection.to_char=sp+p_string.length()-1; selection.active=true; update(); if (line==-1) { while(it) { if (it->type==ITEM_NEWLINE) { line=static_cast<ItemNewline*>(it)->line; break; } it=_get_next_item(it); } } line-=2; scroll_to_line(line<0?0:line); return true; } } it=_get_next_item(it); charidx=0; } return false; }
void TE_View::do_scroll(GlyphIndex new_start) { scroll_to_line((int)new_start); // notify(); }
void cmd_scroll_bottom_nonempty(CmdContext *c, CmdParams *p) { scroll_to_line(p, - p->line_visible_num + 1, TRUE); }
void cmd_scroll_top_nonempty(CmdContext *c, CmdParams *p) { scroll_to_line(p, 0, TRUE); }
void cmd_scroll_center_nonempty(CmdContext *c, CmdParams *p) { scroll_to_line(p, - p->line_visible_num / 2, TRUE); }
void cmd_scroll_bottom(CmdContext *c, CmdParams *p) { scroll_to_line(p, - p->line_visible_num + 1, FALSE); }
void cmd_scroll_top(CmdContext *c, CmdParams *p) { scroll_to_line(p, 0, FALSE); }
void cmd_scroll_center(CmdContext *c, CmdParams *p) { scroll_to_line(p, - p->line_visible_num / 2, FALSE); }