예제 #1
0
bool FindReplaceBar::search_next() {

	uint32_t flags = 0;
	String text = get_search_text();

	if (is_whole_words())
		flags |= TextEdit::SEARCH_WHOLE_WORDS;
	if (is_case_sensitive())
		flags |= TextEdit::SEARCH_MATCH_CASE;

	int line, col;
	_get_search_from(line, col);

	if (line == result_line && col == result_col) {
		col += text.length();
		if (col > text_edit->get_line(line).length()) {
			line += 1;
			if (line >= text_edit->get_line_count())
				line = 0;
			col = 0;
		}
	}

	return _search(flags, line, col);
}
예제 #2
0
bool FindReplaceBar::search_prev() {

	uint32_t flags = 0;
	String text = get_search_text();

	if (is_whole_words())
		flags |= TextEdit::SEARCH_WHOLE_WORDS;
	if (is_case_sensitive())
		flags |= TextEdit::SEARCH_MATCH_CASE;

	flags |= TextEdit::SEARCH_BACKWARDS;

	int line, col;
	_get_search_from(line, col);

	col -= text.length();
	if (col < 0) {
		line -= 1;
		if (line < 0)
			line = text_edit->get_line_count() - 1;
		col = text_edit->get_line(line).length();
	}

	return _search(flags, line, col);
}
예제 #3
0
bool FindReplaceDialog::_search() {


	String text=get_search_text();
	uint32_t flags=0;

	if (is_whole_words())
		flags|=TextEdit::SEARCH_WHOLE_WORDS;
	if (is_case_sensitive())
		flags|=TextEdit::SEARCH_MATCH_CASE;
	if (is_backwards())
		flags|=TextEdit::SEARCH_BACKWARDS;

	int line,col;
	bool found = text_edit->search(text,flags,text_edit->cursor_get_line(),text_edit->cursor_get_column(),line,col);


	if (found) {
		print_line("found");
		text_edit->cursor_set_line(line);
		text_edit->cursor_set_column(col+text.length());
		text_edit->select(line,col,line,col+text.length());
		set_error("");
		return true;
	} else {

		set_error("Not Found!");
		return false;
	}

}
예제 #4
0
bool FindReplaceBar::search_current() {

	uint32_t flags = 0;

	if (is_whole_words())
		flags |= TextEdit::SEARCH_WHOLE_WORDS;
	if (is_case_sensitive())
		flags |= TextEdit::SEARCH_MATCH_CASE;

	int line, col;
	_get_search_from(line, col);

	return _search(flags, line, col);
}
예제 #5
0
bool FindReplaceDialog::_search() {

	String text = get_search_text();
	uint32_t flags = 0;

	if (is_whole_words())
		flags |= TextEdit::SEARCH_WHOLE_WORDS;
	if (is_case_sensitive())
		flags |= TextEdit::SEARCH_MATCH_CASE;
	if (is_backwards())
		flags |= TextEdit::SEARCH_BACKWARDS;

	int line = text_edit->cursor_get_line(), col = text_edit->cursor_get_column();

	if (is_backwards()) {
		col -= 1;
		if (col < 0) {
			line -= 1;
			if (line < 0) {
				line = text_edit->get_line_count() - 1;
			}
			col = text_edit->get_line(line).length();
		}
	}
	bool found = text_edit->search(text, flags, line, col, line, col);

	if (found) {
		// print_line("found");
		text_edit->unfold_line(line);
		text_edit->cursor_set_line(line);
		if (is_backwards())
			text_edit->cursor_set_column(col);
		else
			text_edit->cursor_set_column(col + text.length());
		text_edit->select(line, col, line, col + text.length());
		set_error("");
		return true;
	} else {

		set_error(TTR("Not found!"));
		return false;
	}
}