本文整理汇总了C++中TextEdit::begin_complex_operation方法的典型用法代码示例。如果您正苦于以下问题:C++ TextEdit::begin_complex_operation方法的具体用法?C++ TextEdit::begin_complex_operation怎么用?C++ TextEdit::begin_complex_operation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEdit
的用法示例。
在下文中一共展示了TextEdit::begin_complex_operation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trim_trailing_whitespace
void ScriptTextEditor::trim_trailing_whitespace() {
TextEdit *tx = code_editor->get_text_edit();
bool trimed_whitespace = false;
for (int i = 0; i < tx->get_line_count(); i++) {
String line = tx->get_line(i);
if (line.ends_with(" ") || line.ends_with("\t")) {
if (!trimed_whitespace) {
tx->begin_complex_operation();
trimed_whitespace = true;
}
int end = 0;
for (int j = line.length() - 1; j > -1; j--) {
if (line[j] != ' ' && line[j] != '\t') {
end = j+1;
break;
}
}
tx->set_line(i, line.substr(0, end));
}
}
if (trimed_whitespace) {
tx->end_complex_operation();
tx->update();
}
}
示例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);
}
//.........这里部分代码省略.........
示例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();
//.........这里部分代码省略.........