当前位置: 首页>>代码示例>>C++>>正文


C++ TextEdit::cursor_get_line方法代码示例

本文整理汇总了C++中TextEdit::cursor_get_line方法的典型用法代码示例。如果您正苦于以下问题:C++ TextEdit::cursor_get_line方法的具体用法?C++ TextEdit::cursor_get_line怎么用?C++ TextEdit::cursor_get_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextEdit的用法示例。


在下文中一共展示了TextEdit::cursor_get_line方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reload_text

void TextEditor::reload_text() {

	ERR_FAIL_COND(text_file.is_null());

	TextEdit *te = code_editor->get_text_edit();
	int column = te->cursor_get_column();
	int row = te->cursor_get_line();
	int h = te->get_h_scroll();
	int v = te->get_v_scroll();

	te->set_text(text_file->get_text());
	te->clear_undo_history();
	te->cursor_set_line(row);
	te->cursor_set_column(column);
	te->set_h_scroll(h);
	te->set_v_scroll(v);

	te->tag_saved_version();

	code_editor->update_line_and_column();
}
开发者ID:Valentactive,项目名称:godot,代码行数:21,代码来源:text_editor.cpp

示例2: _edit_option

void ScriptTextEditor::_edit_option(int p_op) {

	switch(p_op) {
		case EDIT_UNDO: {
			code_editor->get_text_edit()->undo();
			code_editor->get_text_edit()->call_deferred("grab_focus");
		} break;
		case EDIT_REDO: {
			code_editor->get_text_edit()->redo();
			code_editor->get_text_edit()->call_deferred("grab_focus");
		} break;
		case EDIT_CUT: {

			code_editor->get_text_edit()->cut();
			code_editor->get_text_edit()->call_deferred("grab_focus");
		} break;
		case EDIT_COPY: {
			code_editor->get_text_edit()->copy();
			code_editor->get_text_edit()->call_deferred("grab_focus");

		} break;
		case EDIT_PASTE: {
			code_editor->get_text_edit()->paste();
			code_editor->get_text_edit()->call_deferred("grab_focus");

		} break;
		case EDIT_SELECT_ALL: {

			code_editor->get_text_edit()->select_all();
			code_editor->get_text_edit()->call_deferred("grab_focus");

		} break;
		case EDIT_MOVE_LINE_UP: {

			TextEdit *tx = code_editor->get_text_edit();
			Ref<Script> scr = script;
			if (scr.is_null())
				return;

			tx->begin_complex_operation();
			if (tx->is_selection_active())
			{
				int from_line = tx->get_selection_from_line();
				int from_col  = tx->get_selection_from_column();
				int to_line   = tx->get_selection_to_line();
				int to_column = tx->get_selection_to_column();

				for (int i = from_line; i <= to_line; i++)
				{
					int line_id = i;
					int next_id = i - 1;

					if (line_id == 0 || next_id < 0)
						return;

					swap_lines(tx, line_id, next_id);
				}
				int from_line_up = from_line > 0 ? from_line-1 : from_line;
				int to_line_up   = to_line   > 0 ? to_line-1   : to_line;
				tx->select(from_line_up, from_col, to_line_up, to_column);
			}
			else
			{
				int line_id = tx->cursor_get_line();
				int next_id = line_id - 1;

				if (line_id == 0 || next_id < 0)
					return;

				swap_lines(tx, line_id, next_id);
			}
			tx->end_complex_operation();
			tx->update();

		} break;
		case EDIT_MOVE_LINE_DOWN: {

			TextEdit *tx = code_editor->get_text_edit();
			Ref<Script> scr = get_edited_script();
			if (scr.is_null())
				return;

			tx->begin_complex_operation();
			if (tx->is_selection_active())
			{
				int from_line = tx->get_selection_from_line();
				int from_col  = tx->get_selection_from_column();
				int to_line   = tx->get_selection_to_line();
				int to_column = tx->get_selection_to_column();

				for (int i = to_line; i >= from_line; i--)
				{
					int line_id = i;
					int next_id = i + 1;

					if (line_id == tx->get_line_count()-1 || next_id > tx->get_line_count())
						return;

					swap_lines(tx, line_id, next_id);
				}
//.........这里部分代码省略.........
开发者ID:Blake-Hudson,项目名称:godot,代码行数:101,代码来源:script_text_editor.cpp

示例3: _menu_option

void ShaderEditor::_menu_option(int p_option) {

	switch (p_option) {
		case EDIT_UNDO: {
			shader_editor->get_text_edit()->undo();
		} break;
		case EDIT_REDO: {
			shader_editor->get_text_edit()->redo();
		} break;
		case EDIT_CUT: {
			shader_editor->get_text_edit()->cut();
		} break;
		case EDIT_COPY: {
			shader_editor->get_text_edit()->copy();
		} break;
		case EDIT_PASTE: {
			shader_editor->get_text_edit()->paste();
		} break;
		case EDIT_SELECT_ALL: {
			shader_editor->get_text_edit()->select_all();
		} break;
		case EDIT_MOVE_LINE_UP: {
			shader_editor->move_lines_up();
		} break;
		case EDIT_MOVE_LINE_DOWN: {
			shader_editor->move_lines_down();
		} break;
		case EDIT_INDENT_LEFT: {

			TextEdit *tx = shader_editor->get_text_edit();
			if (shader.is_null())
				return;

			tx->indent_left();

		} break;
		case EDIT_INDENT_RIGHT: {

			TextEdit *tx = shader_editor->get_text_edit();
			if (shader.is_null())
				return;

			tx->indent_right();

		} break;
		case EDIT_DELETE_LINE: {
			shader_editor->delete_lines();
		} break;
		case EDIT_CLONE_DOWN: {
			shader_editor->clone_lines_down();
		} break;
		case EDIT_TOGGLE_COMMENT: {

			TextEdit *tx = shader_editor->get_text_edit();
			if (shader.is_null())
				return;

			tx->begin_complex_operation();
			if (tx->is_selection_active()) {
				int begin = tx->get_selection_from_line();
				int end = tx->get_selection_to_line();

				// End of selection ends on the first column of the last line, ignore it.
				if (tx->get_selection_to_column() == 0)
					end -= 1;

				// Check if all lines in the selected block are commented
				bool is_commented = true;
				for (int i = begin; i <= end; i++) {
					if (!tx->get_line(i).begins_with("//")) {
						is_commented = false;
						break;
					}
				}
				for (int i = begin; i <= end; i++) {
					String line_text = tx->get_line(i);

					if (line_text.strip_edges().empty()) {
						line_text = "//";
					} else {
						if (is_commented) {
							line_text = line_text.substr(2, line_text.length());
						} else {
							line_text = "//" + line_text;
						}
					}
					tx->set_line(i, line_text);
				}
			} else {
				int begin = tx->cursor_get_line();
				String line_text = tx->get_line(begin);

				if (line_text.begins_with("//"))
					line_text = line_text.substr(2, line_text.length());
				else
					line_text = "//" + line_text;
				tx->set_line(begin, line_text);
			}
			tx->end_complex_operation();
			tx->update();
//.........这里部分代码省略.........
开发者ID:timoschwarzer,项目名称:godot,代码行数:101,代码来源:shader_editor_plugin.cpp

示例4: _edit_option

void TextEditor::_edit_option(int p_op) {
	TextEdit *tx = code_editor->get_text_edit();

	switch (p_op) {
		case EDIT_UNDO: {

			tx->undo();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_REDO: {

			tx->redo();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_CUT: {

			tx->cut();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_COPY: {

			tx->copy();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_PASTE: {

			tx->paste();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_SELECT_ALL: {

			tx->select_all();
			tx->call_deferred("grab_focus");
		} break;
		case EDIT_MOVE_LINE_UP: {

			code_editor->move_lines_up();
		} break;
		case EDIT_MOVE_LINE_DOWN: {

			code_editor->move_lines_down();
		} break;
		case EDIT_INDENT_LEFT: {

			tx->indent_left();
		} break;
		case EDIT_INDENT_RIGHT: {

			tx->indent_right();
		} break;
		case EDIT_DELETE_LINE: {

			code_editor->delete_lines();
		} break;
		case EDIT_CLONE_DOWN: {

			code_editor->clone_lines_down();
		} break;
		case EDIT_TOGGLE_FOLD_LINE: {

			tx->toggle_fold_line(tx->cursor_get_line());
			tx->update();
		} break;
		case EDIT_FOLD_ALL_LINES: {

			tx->fold_all_lines();
			tx->update();
		} break;
		case EDIT_UNFOLD_ALL_LINES: {

			tx->unhide_all_lines();
			tx->update();
		} break;
		case EDIT_TRIM_TRAILING_WHITESAPCE: {

			trim_trailing_whitespace();
		} break;
		case EDIT_CONVERT_INDENT_TO_SPACES: {

			convert_indent_to_spaces();
		} break;
		case EDIT_CONVERT_INDENT_TO_TABS: {

			convert_indent_to_tabs();
		} break;
		case EDIT_TO_UPPERCASE: {

			_convert_case(CodeTextEditor::UPPER);
		} break;
		case EDIT_TO_LOWERCASE: {

			_convert_case(CodeTextEditor::LOWER);
		} break;
		case EDIT_CAPITALIZE: {

			_convert_case(CodeTextEditor::CAPITALIZE);
		} break;
		case SEARCH_FIND: {

			code_editor->get_find_replace_bar()->popup_search();
//.........这里部分代码省略.........
开发者ID:Valentactive,项目名称:godot,代码行数:101,代码来源:text_editor.cpp


注:本文中的TextEdit::cursor_get_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。