summaryrefslogtreecommitdiff
path: root/scene/gui/text_edit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r--scene/gui/text_edit.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1738e303aa..d79ce25344 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -36,6 +36,10 @@
#include "project_settings.h"
#include "scene/main/viewport.h"
+#ifdef TOOLS_ENABLED
+#include "editor/editor_scale.h"
+#endif
+
#define TAB_PIXELS
static bool _is_text_char(CharType c) {
@@ -729,15 +733,18 @@ void TextEdit::_notification(int p_what) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color);
}
- if (text.is_breakpoint(line)) {
-
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
- }
-
if (line == cursor.line) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color);
}
+ if (text.is_breakpoint(line) && !draw_breakpoint_gutter) {
+#ifdef TOOLS_ENABLED
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color);
+#else
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color);
+#endif
+ }
+
// draw breakpoint marker
if (text.is_breakpoint(line)) {
if (draw_breakpoint_gutter) {
@@ -1766,7 +1773,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
- menu->set_position(get_global_transform().xform(get_local_mouse_pos()));
+ menu->set_position(get_global_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
menu->popup();
grab_focus();
@@ -1837,7 +1844,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->is_pressed()) {
- highlighted_word = get_word_at_pos(get_local_mouse_pos());
+ highlighted_word = get_word_at_pos(get_local_mouse_position());
update();
} else {
@@ -2793,12 +2800,16 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int ini = selection.from_line;
int end = selection.to_line;
for (int i = ini; i <= end; i++) {
- if (text[i][0] == '#')
+ if (get_line(i).begins_with("#"))
_remove_text(i, 0, i, 1);
}
} else {
- if (text[cursor.line][0] == '#')
+ if (get_line(cursor.line).begins_with("#")) {
_remove_text(cursor.line, 0, cursor.line, 1);
+ if (cursor.column >= get_line(cursor.line).length()) {
+ cursor.column = MAX(0, get_line(cursor.line).length() - 1);
+ }
+ }
}
update();
}
@@ -3488,7 +3499,7 @@ String TextEdit::get_text() {
String TextEdit::get_text_for_lookup_completion() {
int row, col;
- _get_mouse_pos(get_local_mouse_pos(), row, col);
+ _get_mouse_pos(get_local_mouse_position(), row, col);
String longthing;
int len = text.size();
@@ -4255,6 +4266,10 @@ bool TextEdit::is_insert_mode() const {
return insert_mode;
}
+bool TextEdit::is_insert_text_operation() {
+ return (current_op.type == TextOperation::TYPE_INSERT);
+}
+
uint32_t TextEdit::get_version() const {
return current_op.version;
}