From a0b409cb14df984e1926e4039b0d03bb221b73ba Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Fri, 24 Jul 2020 15:50:35 +0100 Subject: Add and convert editor to use CodeEdit --- scene/gui/code_edit.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 scene/gui/code_edit.h (limited to 'scene/gui/code_edit.h') diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h new file mode 100644 index 0000000000..ce3c6f91f8 --- /dev/null +++ b/scene/gui/code_edit.h @@ -0,0 +1,50 @@ +/*************************************************************************/ +/* code_edit.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef CODEEDIT_H +#define CODEEDIT_H + +#include "scene/gui/text_edit.h" + +class CodeEdit : public TextEdit { + GDCLASS(CodeEdit, TextEdit) + +private: +protected: + void _notification(int p_what); + + static void _bind_methods(); + +public: + CodeEdit(); + ~CodeEdit(); +}; + +#endif // CODEEDIT_H -- cgit v1.2.3 From 1353ed5e44a725308292ce44d24d7cf76b0af272 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Sat, 25 Jul 2020 18:27:35 +0100 Subject: Added Line numbers to CodeEdit --- scene/gui/code_edit.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'scene/gui/code_edit.h') diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index ce3c6f91f8..990d3212c0 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -37,12 +37,32 @@ class CodeEdit : public TextEdit { GDCLASS(CodeEdit, TextEdit) private: + int cached_line_count = 0; + + /* Line numbers */ + int line_number_gutter = -1; + int line_number_digits = 0; + String line_number_padding = " "; + Color line_number_color = Color(1, 1, 1); + void _line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region); + + void _gutter_clicked(int p_line, int p_gutter); + void _line_edited_from(int p_line); + + void _update_gutter_indexes(); + protected: void _notification(int p_what); static void _bind_methods(); public: + /* Line numbers */ + void set_draw_line_numbers(bool p_draw); + bool is_draw_line_numbers_enabled() const; + void set_line_numbers_zero_padded(bool p_zero_padded); + bool is_line_numbers_zero_padded() const; + CodeEdit(); ~CodeEdit(); }; -- cgit v1.2.3 From 907f9f2a8444be195d489ae614f88018a10cf6ce Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Tue, 28 Jul 2020 14:33:46 +0100 Subject: Changed line_edited_from(from) to lines_edit_from(from, to) --- scene/gui/code_edit.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scene/gui/code_edit.h') diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index 990d3212c0..66cae82437 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -47,7 +47,7 @@ private: void _line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region); void _gutter_clicked(int p_line, int p_gutter); - void _line_edited_from(int p_line); + void _lines_edited_from(int p_from_line, int p_to_line); void _update_gutter_indexes(); -- cgit v1.2.3 From 4d7df24d46f931839247a9886c485ed244d1c8ee Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Sun, 26 Jul 2020 15:57:23 +0100 Subject: Add main_gutter (breakpoints, bookmarks, execution lines) to code_edit --- scene/gui/code_edit.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'scene/gui/code_edit.h') diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index 66cae82437..d27536786e 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -37,7 +37,32 @@ class CodeEdit : public TextEdit { GDCLASS(CodeEdit, TextEdit) private: - int cached_line_count = 0; + /* Main Gutter */ + enum MainGutterType { + MAIN_GUTTER_BREAKPOINT = 0x01, + MAIN_GUTTER_BOOKMARK = 0x02, + MAIN_GUTTER_EXECUTING = 0x04 + }; + + int main_gutter = -1; + void _update_draw_main_gutter(); + void _main_gutter_draw_callback(int p_line, int p_gutter, const Rect2 &p_region); + + // breakpoints + HashMap breakpointed_lines; + bool draw_breakpoints = false; + Color breakpoint_color = Color(1, 1, 1); + Ref breakpoint_icon = Ref(); + + // bookmarks + bool draw_bookmarks = false; + Color bookmark_color = Color(1, 1, 1); + Ref bookmark_icon = Ref(); + + // executing lines + bool draw_executing_lines = false; + Color executing_line_color = Color(1, 1, 1); + Ref executing_line_icon = Ref(); /* Line numbers */ int line_number_gutter = -1; @@ -57,6 +82,34 @@ protected: static void _bind_methods(); public: + /* Main Gutter */ + void set_draw_breakpoints_gutter(bool p_draw); + bool is_drawing_breakpoints_gutter() const; + + void set_draw_bookmarks_gutter(bool p_draw); + bool is_drawing_bookmarks_gutter() const; + + void set_draw_executing_lines_gutter(bool p_draw); + bool is_drawing_executing_lines_gutter() const; + + // breakpoints + void set_line_as_breakpoint(int p_line, bool p_breakpointed); + bool is_line_breakpointed(int p_line) const; + void clear_breakpointed_lines(); + Array get_breakpointed_lines() const; + + // bookmarks + void set_line_as_bookmarked(int p_line, bool p_bookmarked); + bool is_line_bookmarked(int p_line) const; + void clear_bookmarked_lines(); + Array get_bookmarked_lines() const; + + // executing lines + void set_line_as_executing(int p_line, bool p_executing); + bool is_line_executing(int p_line) const; + void clear_executing_lines(); + Array get_executing_lines() const; + /* Line numbers */ void set_draw_line_numbers(bool p_draw); bool is_draw_line_numbers_enabled() const; -- cgit v1.2.3 From 7829fdc1d0d4e78e24aa902219f54b0edfb6cd3c Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Mon, 27 Jul 2020 13:54:12 +0100 Subject: Add folding gutter to code_edit --- scene/gui/code_edit.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'scene/gui/code_edit.h') diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index d27536786e..c989e5ed79 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -71,6 +71,14 @@ private: Color line_number_color = Color(1, 1, 1); void _line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region); + /* Fold Gutter */ + int fold_gutter = -1; + bool draw_fold_gutter = false; + Color folding_color = Color(1, 1, 1); + Ref can_fold_icon = Ref(); + Ref folded_icon = Ref(); + void _fold_gutter_draw_callback(int p_line, int p_gutter, Rect2 p_region); + void _gutter_clicked(int p_line, int p_gutter); void _lines_edited_from(int p_from_line, int p_to_line); @@ -116,6 +124,10 @@ public: void set_line_numbers_zero_padded(bool p_zero_padded); bool is_line_numbers_zero_padded() const; + /* Fold gutter */ + void set_draw_fold_gutter(bool p_draw); + bool is_drawing_fold_gutter() const; + CodeEdit(); ~CodeEdit(); }; -- cgit v1.2.3