Преглед на файлове

Added Line numbers to CodeEdit

Paulb23 преди 5 години
родител
ревизия
1353ed5e44

+ 2 - 2
editor/code_editor.cpp

@@ -932,7 +932,7 @@ void CodeTextEditor::update_editor_settings() {
 	text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
 	text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
 	text_editor->set_minimap_width((int)EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width") * EDSCALE);
-	text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
+	text_editor->set_draw_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
 	text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/appearance/line_numbers_zero_padded"));
 	text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_bookmark_gutter"));
 	text_editor->set_breakpoint_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_breakpoint_gutter"));
@@ -1693,7 +1693,7 @@ CodeTextEditor::CodeTextEditor() {
 
 	find_replace_bar->set_text_edit(text_editor);
 
-	text_editor->set_show_line_numbers(true);
+	text_editor->set_draw_line_numbers(true);
 	text_editor->set_brace_matching(true);
 	text_editor->set_auto_indent(true);
 

+ 1 - 1
editor/plugins/shader_editor_plugin.cpp

@@ -365,7 +365,7 @@ void ShaderEditor::_editor_settings_changed() {
 	shader_editor->get_text_editor()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
 	shader_editor->get_text_editor()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
 	shader_editor->get_text_editor()->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces"));
-	shader_editor->get_text_editor()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
+	shader_editor->get_text_editor()->set_draw_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
 	shader_editor->get_text_editor()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
 	shader_editor->get_text_editor()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
 	shader_editor->get_text_editor()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));

+ 2 - 2
editor/plugins/visual_shader_editor_plugin.cpp

@@ -968,7 +968,7 @@ void VisualShaderEditor::_update_graph() {
 
 			expression_box->set_text(expression);
 			expression_box->set_context_menu_enabled(false);
-			expression_box->set_show_line_numbers(true);
+			expression_box->set_draw_line_numbers(true);
 
 			expression_box->connect("focus_exited", callable_mp(this, &VisualShaderEditor::_expression_focus_out), varray(expression_box, nodes[n_i]));
 		}
@@ -2557,7 +2557,7 @@ VisualShaderEditor::VisualShaderEditor() {
 	preview_text->set_v_size_flags(SIZE_EXPAND_FILL);
 	preview_text->set_custom_minimum_size(Size2(400 * EDSCALE, 0));
 	preview_text->set_syntax_highlighter(syntax_highlighter);
-	preview_text->set_show_line_numbers(true);
+	preview_text->set_draw_line_numbers(true);
 	preview_text->set_readonly(true);
 
 	error_text = memnew(Label);

+ 85 - 1
scene/gui/code_edit.cpp

@@ -32,15 +32,99 @@
 
 void CodeEdit::_notification(int p_what) {
 	switch (p_what) {
+		case NOTIFICATION_THEME_CHANGED:
+		case NOTIFICATION_ENTER_TREE: {
+			set_gutter_width(line_number_gutter, (line_number_digits + 1) * cache.font->get_char_size('0').width);
+
+			line_number_color = get_theme_color("line_number_color");
+		} break;
 		case NOTIFICATION_DRAW: {
-		}
+		} break;
 	}
 }
 
+/* Line numbers */
+void CodeEdit::set_draw_line_numbers(bool p_draw) {
+	set_gutter_draw(line_number_gutter, p_draw);
+}
+
+bool CodeEdit::is_draw_line_numbers_enabled() const {
+	return is_gutter_drawn(line_number_gutter);
+}
+
+void CodeEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
+	p_zero_padded ? line_number_padding = "0" : line_number_padding = " ";
+	update();
+}
+
+bool CodeEdit::is_line_numbers_zero_padded() const {
+	return line_number_padding == "0";
+}
+
+void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
+	String fc = String::num(p_line + 1).lpad(line_number_digits, line_number_padding);
+
+	int yofs = region.position.y + (cache.row_height - cache.font->get_height()) / 2;
+	cache.font->draw(get_canvas_item(), Point2(region.position.x, yofs + cache.font->get_ascent()), fc, line_number_color);
+}
+
 void CodeEdit::_bind_methods() {
+	/* Line numbers */
+	ClassDB::bind_method(D_METHOD("_line_number_draw_callback"), &CodeEdit::_line_number_draw_callback);
+
+	ClassDB::bind_method(D_METHOD("set_draw_line_numbers", "enable"), &CodeEdit::set_draw_line_numbers);
+	ClassDB::bind_method(D_METHOD("is_draw_line_numbers_enabled"), &CodeEdit::is_draw_line_numbers_enabled);
+	ClassDB::bind_method(D_METHOD("set_line_numbers_zero_padded", "enable"), &CodeEdit::set_line_numbers_zero_padded);
+	ClassDB::bind_method(D_METHOD("is_line_numbers_zero_padded"), &CodeEdit::is_line_numbers_zero_padded);
+
+	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_line_numbers"), "set_draw_line_numbers", "is_draw_line_numbers_enabled");
+	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "zero_pad_line_numbers"), "set_line_numbers_zero_padded", "is_line_numbers_zero_padded");
+}
+
+void CodeEdit::_gutter_clicked(int p_line, int p_gutter) {
+	if (p_gutter == line_number_gutter) {
+		cursor_set_line(p_line);
+		return;
+	}
+}
+
+void CodeEdit::_line_edited_from(int p_line) {
+	int line_count = get_line_count();
+	if (line_count != cached_line_count) {
+		int lc = line_count;
+		line_number_digits = 1;
+		while (lc /= 10) {
+			line_number_digits++;
+		}
+		set_gutter_width(line_number_gutter, (line_number_digits + 1) * cache.font->get_char_size('0').width);
+
+		cached_line_count = line_count;
+	}
+}
+
+void CodeEdit::_update_gutter_indexes() {
+	for (int i = 0; i < get_gutter_count(); i++) {
+		if (get_gutter_name(i) == "line_numbers") {
+			line_number_gutter = i;
+			continue;
+		}
+	}
 }
 
 CodeEdit::CodeEdit() {
+	/* Line numbers */
+	add_gutter();
+	set_gutter_name(0, "line_numbers");
+	set_gutter_draw(0, false);
+	set_gutter_type(0, GUTTER_TPYE_CUSTOM);
+	set_gutter_custom_draw(0, this, "_line_number_draw_callback");
+
+	connect("line_edited_from", callable_mp(this, &CodeEdit::_line_edited_from));
+	connect("gutter_clicked", callable_mp(this, &CodeEdit::_gutter_clicked));
+
+	connect("gutter_added", callable_mp(this, &CodeEdit::_update_gutter_indexes));
+	connect("gutter_removed", callable_mp(this, &CodeEdit::_update_gutter_indexes));
+	_update_gutter_indexes();
 }
 
 CodeEdit::~CodeEdit() {

+ 20 - 0
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();
 };

+ 12 - 67
scene/gui/text_edit.cpp

@@ -280,10 +280,6 @@ void TextEdit::_update_scrollbars() {
 	int visible_width = size.width - cache.style_normal->get_minimum_size().width;
 	int total_width = text.get_max_width(true) + vmin.x + gutters_width + gutter_padding;
 
-	if (line_numbers) {
-		total_width += cache.line_number_w;
-	}
-
 	if (draw_breakpoint_gutter || draw_bookmark_gutter) {
 		total_width += cache.breakpoint_gutter_width;
 	}
@@ -612,28 +608,11 @@ void TextEdit::_notification(int p_what) {
 				cache.minimap_width = minimap_width;
 			}
 
-			int line_number_char_count = 0;
-
-			{
-				int lc = text.size();
-				cache.line_number_w = 0;
-				while (lc) {
-					cache.line_number_w += 1;
-					lc /= 10;
-				};
-
-				if (line_numbers) {
-					line_number_char_count = cache.line_number_w;
-					cache.line_number_w = (cache.line_number_w + 1) * cache.font->get_char_size('0').width;
-				} else {
-					cache.line_number_w = 0;
-				}
-			}
 			_update_scrollbars();
 
 			RID ci = get_canvas_item();
 			RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
-			int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
+			int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
 
 			int xmargin_end = size.width - cache.style_normal->get_margin(MARGIN_RIGHT) - cache.minimap_width;
 			// Let's do it easy for now.
@@ -824,8 +803,6 @@ void TextEdit::_notification(int p_what) {
 			// Check if highlighted words contains only whitespaces (tabs or spaces).
 			bool only_whitespaces_highlighted = highlighted_text.strip_edges() == String();
 
-			String line_num_padding = line_numbers_zero_padded ? "0" : " ";
-
 			int cursor_wrap_index = get_cursor_wrap_index();
 
 			FontDrawer drawer(cache.font, Color(1, 1, 1));
@@ -1206,7 +1183,7 @@ void TextEdit::_notification(int p_what) {
 						// Draw fold markers.
 						if (draw_fold_gutter) {
 							int horizontal_gap = (cache.fold_gutter_width * 30) / 100;
-							int gutter_left = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + cache.breakpoint_gutter_width + cache.line_number_w + cache.info_gutter_width;
+							int gutter_left = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + cache.breakpoint_gutter_width + cache.info_gutter_width;
 							if (is_folded(line)) {
 								int xofs = horizontal_gap - (cache.can_fold_icon->get_width()) / 2;
 								int yofs = (get_row_height() - cache.folded_icon->get_height()) / 2;
@@ -1217,17 +1194,6 @@ void TextEdit::_notification(int p_what) {
 								cache.can_fold_icon->draw(ci, Point2(gutter_left + xofs + ofs_x, ofs_y + yofs), cache.code_folding_color);
 							}
 						}
-
-						// Draw line numbers.
-						if (cache.line_number_w) {
-							int yofs = ofs_y + (get_row_height() - cache.font->get_height()) / 2;
-							String fc = String::num(line + 1);
-							while (fc.length() < line_number_char_count) {
-								fc = line_num_padding + fc;
-							}
-
-							cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + cache.breakpoint_gutter_width + cache.info_gutter_width + ofs_x, yofs + cache.font->get_ascent()), fc, text.is_safe(line) ? cache.safe_line_number_color : cache.line_number_color);
-						}
 					}
 
 					// Loop through characters in one line.
@@ -2101,7 +2067,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
 		row = text.size() - 1;
 		col = text[row].size();
 	} else {
-		int colx = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width);
+		int colx = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width);
 		colx += cursor.x_ofs;
 		col = get_char_pos_for_line(colx, row, wrap_index);
 		if (is_wrap_enabled() && wrap_index < times_line_wraps(row)) {
@@ -2146,7 +2112,7 @@ Vector2i TextEdit::_get_cursor_pixel_pos() {
 
 	// Calculate final pixel position
 	int y = (row - get_v_scroll_offset() + 1 /*Bottom of line*/) * get_row_height();
-	int x = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs;
+	int x = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs;
 	int ix = 0;
 	while (ix < rows2[0].size() && ix < cursor.column) {
 		if (cache.font != nullptr) {
@@ -2318,7 +2284,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
 				// Toggle fold on gutter click if can.
 				if (draw_fold_gutter) {
 					left_margin = cache.style_normal->get_margin(MARGIN_LEFT);
-					int gutter_left = left_margin + gutters_width + cache.breakpoint_gutter_width + cache.line_number_w + cache.info_gutter_width;
+					int gutter_left = left_margin + gutters_width + cache.breakpoint_gutter_width + cache.info_gutter_width;
 					if (mb->get_position().x > gutter_left - 6 && mb->get_position().x <= gutter_left + cache.fold_gutter_width - 3) {
 						if (is_folded(row)) {
 							unfold_line(row);
@@ -2332,7 +2298,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
 				// Unfold on folded icon click.
 				if (is_folded(row)) {
 					int line_width = text.get_line_width(row);
-					line_width += cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.line_number_w + cache.breakpoint_gutter_width + cache.info_gutter_width + cache.fold_gutter_width - cursor.x_ofs;
+					line_width += cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.breakpoint_gutter_width + cache.info_gutter_width + cache.fold_gutter_width - cursor.x_ofs;
 					if (mb->get_position().x > line_width - 3 && mb->get_position().x <= line_width + cache.folded_eol_icon->get_width() + 3) {
 						unfold_line(row);
 						return;
@@ -4215,7 +4181,7 @@ int TextEdit::get_total_visible_rows() const {
 }
 
 void TextEdit::_update_wrap_at() {
-	wrap_at = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width - wrap_right_offset;
+	wrap_at = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width - wrap_right_offset;
 	update_cursor_wrap_offset();
 	text.clear_wrap_cache();
 
@@ -4250,7 +4216,7 @@ void TextEdit::adjust_viewport_to_cursor() {
 		set_line_as_last_visible(cur_line, cur_wrap);
 	}
 
-	int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
+	int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
 	if (v_scroll->is_visible_in_tree()) {
 		visible_width -= v_scroll->get_combined_minimum_size().width;
 	}
@@ -4285,7 +4251,7 @@ void TextEdit::center_viewport_to_cursor() {
 	}
 
 	set_line_as_center_visible(cursor.line, get_cursor_wrap_index());
-	int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
+	int visible_width = get_size().width - cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding - cache.breakpoint_gutter_width - cache.fold_gutter_width - cache.info_gutter_width - cache.minimap_width;
 	if (v_scroll->is_visible_in_tree()) {
 		visible_width -= v_scroll->get_combined_minimum_size().width;
 	}
@@ -4732,7 +4698,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
 		return CURSOR_POINTING_HAND;
 	}
 
-	int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
+	int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width;
 	if ((completion_active && completion_rect.has_point(p_pos))) {
 		return CURSOR_ARROW;
 	}
@@ -4771,7 +4737,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
 		}
 
 		// Fold icon.
-		if (draw_fold_gutter && p_pos.x > gutter_left + cache.line_number_w - 6 && p_pos.x <= gutter_left + cache.line_number_w + cache.fold_gutter_width - 3) {
+		if (draw_fold_gutter && p_pos.x > gutter_left - 6 && p_pos.x <= gutter_left + cache.fold_gutter_width - 3) {
 			if (is_folded(row) || can_fold(row)) {
 				return CURSOR_POINTING_HAND;
 			} else {
@@ -4791,7 +4757,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
 		// EOL fold icon.
 		if (is_folded(row)) {
 			int line_width = text.get_line_width(row);
-			line_width += cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs;
+			line_width += cache.style_normal->get_margin(MARGIN_LEFT) + gutters_width + gutter_padding + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs;
 			if (p_pos.x > line_width - 3 && p_pos.x <= line_width + cache.folded_eol_icon->get_width() + 3) {
 				return CURSOR_POINTING_HAND;
 			}
@@ -4994,7 +4960,6 @@ void TextEdit::_update_caches() {
 	cache.font = get_theme_font("font");
 	cache.caret_color = get_theme_color("caret_color");
 	cache.caret_background_color = get_theme_color("caret_background_color");
-	cache.line_number_color = get_theme_color("line_number_color");
 	cache.safe_line_number_color = get_theme_color("safe_line_number_color");
 	cache.font_color = get_theme_color("font_color");
 	cache.font_color_selected = get_theme_color("font_color_selected");
@@ -6817,20 +6782,6 @@ void TextEdit::insert_at(const String &p_text, int at) {
 	}
 }
 
-void TextEdit::set_show_line_numbers(bool p_show) {
-	line_numbers = p_show;
-	update();
-}
-
-void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
-	line_numbers_zero_padded = p_zero_padded;
-	update();
-}
-
-bool TextEdit::is_show_line_numbers_enabled() const {
-	return line_numbers;
-}
-
 void TextEdit::set_show_line_length_guidelines(bool p_show) {
 	line_length_guidelines = p_show;
 	update();
@@ -7115,8 +7066,6 @@ void TextEdit::_bind_methods() {
 	ClassDB::bind_method(D_METHOD("redo"), &TextEdit::redo);
 	ClassDB::bind_method(D_METHOD("clear_undo_history"), &TextEdit::clear_undo_history);
 
-	ClassDB::bind_method(D_METHOD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
-	ClassDB::bind_method(D_METHOD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
 	ClassDB::bind_method(D_METHOD("set_draw_tabs"), &TextEdit::set_draw_tabs);
 	ClassDB::bind_method(D_METHOD("is_drawing_tabs"), &TextEdit::is_drawing_tabs);
 	ClassDB::bind_method(D_METHOD("set_draw_spaces"), &TextEdit::set_draw_spaces);
@@ -7207,7 +7156,6 @@ void TextEdit::_bind_methods() {
 	ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled");
-	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_tabs"), "set_draw_tabs", "is_drawing_tabs");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "draw_spaces"), "set_draw_spaces", "is_drawing_spaces");
 	ADD_PROPERTY(PropertyInfo(Variant::BOOL, "breakpoint_gutter"), "set_breakpoint_gutter_enabled", "is_breakpoint_gutter_enabled");
@@ -7279,7 +7227,6 @@ TextEdit::TextEdit() {
 	_update_caches();
 	cache.row_height = 1;
 	cache.line_spacing = 1;
-	cache.line_number_w = 1;
 	cache.breakpoint_gutter_width = 0;
 	breakpoint_gutter_width = 0;
 	cache.fold_gutter_width = 0;
@@ -7349,8 +7296,6 @@ TextEdit::TextEdit() {
 	completion_active = false;
 	completion_line_ofs = 0;
 	tooltip_obj = nullptr;
-	line_numbers = false;
-	line_numbers_zero_padded = false;
 	line_length_guidelines = false;
 	line_length_guideline_soft_col = 80;
 	line_length_guideline_hard_col = 100;

+ 51 - 61
scene/gui/text_edit.h

@@ -223,60 +223,6 @@ private:
 		}
 	} selection;
 
-	struct Cache {
-		Ref<Texture2D> tab_icon;
-		Ref<Texture2D> space_icon;
-		Ref<Texture2D> can_fold_icon;
-		Ref<Texture2D> folded_icon;
-		Ref<Texture2D> folded_eol_icon;
-		Ref<Texture2D> executing_icon;
-		Ref<StyleBox> style_normal;
-		Ref<StyleBox> style_focus;
-		Ref<StyleBox> style_readonly;
-		Ref<Font> font;
-		Color completion_background_color;
-		Color completion_selected_color;
-		Color completion_existing_color;
-		Color completion_font_color;
-		Color caret_color;
-		Color caret_background_color;
-		Color line_number_color;
-		Color safe_line_number_color;
-		Color font_color;
-		Color font_color_selected;
-		Color font_color_readonly;
-		Color selection_color;
-		Color mark_color;
-		Color bookmark_color;
-		Color breakpoint_color;
-		Color executing_line_color;
-		Color code_folding_color;
-		Color current_line_color;
-		Color line_length_guideline_color;
-		Color brace_mismatch_color;
-		Color word_highlighted_color;
-		Color search_result_color;
-		Color search_result_border_color;
-		Color background_color;
-
-		int row_height;
-		int line_spacing;
-		int line_number_w;
-		int breakpoint_gutter_width;
-		int fold_gutter_width;
-		int info_gutter_width;
-		int minimap_width;
-		Cache() {
-			row_height = 0;
-			line_spacing = 0;
-			line_number_w = 0;
-			breakpoint_gutter_width = 0;
-			fold_gutter_width = 0;
-			info_gutter_width = 0;
-			minimap_width = 0;
-		}
-	} cache;
-
 	Map<int, Dictionary> syntax_highlighting_cache;
 
 	struct TextOperation {
@@ -372,8 +318,6 @@ private:
 	bool cursor_changed_dirty;
 	bool text_changed_dirty;
 	bool undo_enabled;
-	bool line_numbers;
-	bool line_numbers_zero_padded;
 	bool line_length_guidelines;
 	int line_length_guideline_soft_col;
 	int line_length_guideline_hard_col;
@@ -534,6 +478,57 @@ private:
 	int _calculate_spaces_till_next_right_indent(int column);
 
 protected:
+	struct Cache {
+		Ref<Texture2D> tab_icon;
+		Ref<Texture2D> space_icon;
+		Ref<Texture2D> can_fold_icon;
+		Ref<Texture2D> folded_icon;
+		Ref<Texture2D> folded_eol_icon;
+		Ref<Texture2D> executing_icon;
+		Ref<StyleBox> style_normal;
+		Ref<StyleBox> style_focus;
+		Ref<StyleBox> style_readonly;
+		Ref<Font> font;
+		Color completion_background_color;
+		Color completion_selected_color;
+		Color completion_existing_color;
+		Color completion_font_color;
+		Color caret_color;
+		Color caret_background_color;
+		Color safe_line_number_color;
+		Color font_color;
+		Color font_color_selected;
+		Color font_color_readonly;
+		Color selection_color;
+		Color mark_color;
+		Color bookmark_color;
+		Color breakpoint_color;
+		Color executing_line_color;
+		Color code_folding_color;
+		Color current_line_color;
+		Color line_length_guideline_color;
+		Color brace_mismatch_color;
+		Color word_highlighted_color;
+		Color search_result_color;
+		Color search_result_border_color;
+		Color background_color;
+
+		int row_height;
+		int line_spacing;
+		int breakpoint_gutter_width;
+		int fold_gutter_width;
+		int info_gutter_width;
+		int minimap_width;
+		Cache() {
+			row_height = 0;
+			line_spacing = 0;
+			breakpoint_gutter_width = 0;
+			fold_gutter_width = 0;
+			info_gutter_width = 0;
+			minimap_width = 0;
+		}
+	} cache;
+
 	virtual String get_tooltip(const Point2 &p_pos) const override;
 
 	void _insert_text(int p_line, int p_char, const String &p_text, int *r_end_line = nullptr, int *r_end_char = nullptr);
@@ -786,14 +781,9 @@ public:
 
 	void menu_option(int p_option);
 
-	void set_show_line_numbers(bool p_show);
-	bool is_show_line_numbers_enabled() const;
-
 	void set_highlight_current_line(bool p_enabled);
 	bool is_highlight_current_line_enabled() const;
 
-	void set_line_numbers_zero_padded(bool p_zero_padded);
-
 	void set_show_line_length_guidelines(bool p_show);
 	void set_line_length_guideline_soft_column(int p_column);
 	void set_line_length_guideline_hard_column(int p_column);

+ 0 - 1
scene/resources/default_theme/default_theme.cpp

@@ -406,7 +406,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
 	theme->set_color("caret_color", "TextEdit", control_font_color);
 	theme->set_color("caret_background_color", "TextEdit", Color(0, 0, 0));
 	theme->set_color("brace_mismatch_color", "TextEdit", Color(1, 0.2, 0.2));
-	theme->set_color("line_number_color", "TextEdit", Color(0.67, 0.67, 0.67, 0.4));
 	theme->set_color("safe_line_number_color", "TextEdit", Color(0.67, 0.78, 0.67, 0.6));
 	theme->set_color("word_highlighted_color", "TextEdit", Color(0.8, 0.9, 0.9, 0.15));