| 374 | } |
| 375 | |
| 376 | void ScriptTextEditor::add_callback(const String &p_function, const PackedStringArray &p_args) { |
| 377 | ScriptLanguage *language = script->get_language(); |
| 378 | if (!language->can_make_function()) { |
| 379 | return; |
| 380 | } |
| 381 | code_editor->get_text_editor()->begin_complex_operation(); |
| 382 | code_editor->get_text_editor()->remove_secondary_carets(); |
| 383 | code_editor->get_text_editor()->deselect(); |
| 384 | String code = code_editor->get_text_editor()->get_text(); |
| 385 | int pos = language->find_function(p_function, code); |
| 386 | if (pos == -1) { |
| 387 | // Function does not exist, create it at the end of the file. |
| 388 | int last_line = code_editor->get_text_editor()->get_line_count() - 1; |
| 389 | String func = language->make_function("", p_function, p_args); |
| 390 | code_editor->get_text_editor()->insert_text("\n\n" + func, last_line, code_editor->get_text_editor()->get_line(last_line).length()); |
| 391 | pos = last_line + 3; |
| 392 | } |
| 393 | // Put caret on the line after the function, after the indent. |
| 394 | int indent_column = 1; |
| 395 | if (EDITOR_GET("text_editor/behavior/indent/type")) { |
| 396 | indent_column = EDITOR_GET("text_editor/behavior/indent/size"); |
| 397 | } |
| 398 | code_editor->get_text_editor()->set_caret_line(pos, true, true, -1); |
| 399 | code_editor->get_text_editor()->set_caret_column(indent_column); |
| 400 | code_editor->get_text_editor()->end_complex_operation(); |
| 401 | } |
| 402 | |
| 403 | bool ScriptTextEditor::show_members_overview() { |
| 404 | return true; |
nothing calls this directly
no test coverage detected