mirror of
https://github.com/godotengine/godot.git
synced 2025-01-12 20:22:49 +08:00
EDITOR_DEF in the right place
This commit is contained in:
parent
2c683b0f99
commit
bb853d121e
@ -44,8 +44,6 @@
|
||||
#include "globals.h"
|
||||
#include "message_queue.h"
|
||||
|
||||
#include "tools/editor/editor_settings.h"
|
||||
|
||||
#define TAB_PIXELS
|
||||
|
||||
static bool _is_text_char(CharType c) {
|
||||
@ -64,7 +62,7 @@ static bool _is_pair_right_symbol(CharType c) {
|
||||
c == '\'' ||
|
||||
c == ')' ||
|
||||
c == ']' ||
|
||||
c == '}';
|
||||
c == '}';
|
||||
}
|
||||
|
||||
static bool _is_pair_left_symbol(CharType c) {
|
||||
@ -839,8 +837,7 @@ void TextEdit::backspace_at_cursor() {
|
||||
|
||||
int prev_line = cursor.column?cursor.line:cursor.line-1;
|
||||
int prev_column = cursor.column?(cursor.column-1):(text[cursor.line-1].length());
|
||||
bool auto_brace_complete = EDITOR_DEF("text_editor/auto_brace_complete", false);
|
||||
if(auto_brace_complete &&
|
||||
if(auto_brace_completion_enabled &&
|
||||
cursor.column > 0 &&
|
||||
_is_pair_left_symbol(text[cursor.line][cursor.column - 1])) {
|
||||
_consume_backspace_for_pair_symbol(prev_line, prev_column);
|
||||
@ -1246,8 +1243,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||
default:
|
||||
if (k.unicode>=32 && !k.mod.command && !k.mod.alt && !k.mod.meta)
|
||||
clear=true;
|
||||
bool auto_brace_complete=EDITOR_DEF("text_editor/auto_brace_complete", false);
|
||||
if (auto_brace_complete && _is_pair_left_symbol(k.unicode))
|
||||
if (auto_brace_completion_enabled && _is_pair_left_symbol(k.unicode))
|
||||
clear=false;
|
||||
}
|
||||
|
||||
@ -1671,12 +1667,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||
if (readonly)
|
||||
break;
|
||||
|
||||
|
||||
|
||||
const CharType chr[2] = {k.unicode, 0};
|
||||
bool auto_brace_complete = EDITOR_DEF("text_editor/auto_brace_complete", false);
|
||||
|
||||
if(auto_brace_complete && _is_pair_symbol(chr[0])) {
|
||||
if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
|
||||
_consume_pair_symbol(chr[0]);
|
||||
} else {
|
||||
_insert_text_at_cursor(chr);
|
||||
@ -2025,7 +2018,6 @@ void TextEdit::adjust_viewport_to_cursor() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TextEdit::cursor_set_column(int p_col) {
|
||||
|
||||
if (p_col<0)
|
||||
@ -3148,6 +3140,7 @@ TextEdit::TextEdit() {
|
||||
tooltip_obj=NULL;
|
||||
line_numbers=false;
|
||||
next_operation_is_complex=false;
|
||||
auto_brace_completion_enabled=false;
|
||||
}
|
||||
|
||||
TextEdit::~TextEdit(){
|
||||
|
@ -206,6 +206,8 @@ class TextEdit : public Control {
|
||||
bool text_changed_dirty;
|
||||
bool undo_enabled;
|
||||
bool line_numbers;
|
||||
|
||||
bool auto_brace_completion_enabled;
|
||||
|
||||
uint64_t last_dblclk;
|
||||
|
||||
@ -304,8 +306,11 @@ public:
|
||||
String get_text();
|
||||
String get_line(int line) const;
|
||||
void backspace_at_cursor();
|
||||
|
||||
|
||||
|
||||
inline void set_auto_brace_completion(bool p_enabled) {
|
||||
auto_brace_completion_enabled = p_enabled;
|
||||
}
|
||||
|
||||
void cursor_set_column(int p_col);
|
||||
void cursor_set_line(int p_row);
|
||||
|
||||
|
@ -510,7 +510,7 @@ void CodeTextEditor::set_error(const String& p_error) {
|
||||
|
||||
}
|
||||
|
||||
void CodeTextEditor::_update_font() {
|
||||
void CodeTextEditor::_on_settings_change() {
|
||||
|
||||
String editor_font = EditorSettings::get_singleton()->get("text_editor/font");
|
||||
if (editor_font!="") {
|
||||
@ -522,6 +522,10 @@ void CodeTextEditor::_update_font() {
|
||||
}
|
||||
|
||||
text_editor->add_font_override("font",get_font("source","Fonts"));
|
||||
|
||||
text_editor->set_auto_brace_completion(
|
||||
EDITOR_DEF("text_editor/auto_brace_complete", false)
|
||||
);
|
||||
}
|
||||
|
||||
void CodeTextEditor::_text_changed_idle_timeout() {
|
||||
@ -541,7 +545,7 @@ void CodeTextEditor::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed);
|
||||
ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed);
|
||||
ObjectTypeDB::bind_method("_update_font",&CodeTextEditor::_update_font);
|
||||
ObjectTypeDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change);
|
||||
ObjectTypeDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout);
|
||||
ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request);
|
||||
}
|
||||
@ -586,5 +590,5 @@ CodeTextEditor::CodeTextEditor() {
|
||||
text_editor->set_completion(true,cs);
|
||||
idle->connect("timeout", this,"_text_changed_idle_timeout");
|
||||
|
||||
EditorSettings::get_singleton()->connect("settings_changed",this,"_update_font");
|
||||
EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change");
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
|
||||
void set_text_editor(TextEdit *p_text_editor);
|
||||
GotoLineDialog();
|
||||
GotoLineDialog();
|
||||
};
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ class CodeTextEditor : public Control {
|
||||
|
||||
Label *error;
|
||||
|
||||
void _update_font();
|
||||
void _on_settings_change();
|
||||
|
||||
void _complete_request(const String& p_request,int p_line);
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user