Added breakpoint markers, issue 4750
(cherry picked from commit 72fda444d1
)
This commit is contained in:
parent
211a6d01bc
commit
99c948ba56
|
@ -314,6 +314,10 @@ void TextEdit::_update_scrollbars() {
|
||||||
if (line_numbers)
|
if (line_numbers)
|
||||||
total_width += cache.line_number_w;
|
total_width += cache.line_number_w;
|
||||||
|
|
||||||
|
if (draw_breakpoint_gutter) {
|
||||||
|
total_width += cache.breakpoint_gutter_width;
|
||||||
|
}
|
||||||
|
|
||||||
bool use_hscroll=true;
|
bool use_hscroll=true;
|
||||||
bool use_vscroll=true;
|
bool use_vscroll=true;
|
||||||
|
|
||||||
|
@ -415,6 +419,12 @@ void TextEdit::_notification(int p_what) {
|
||||||
};
|
};
|
||||||
case NOTIFICATION_DRAW: {
|
case NOTIFICATION_DRAW: {
|
||||||
|
|
||||||
|
if (draw_breakpoint_gutter) {
|
||||||
|
cache.breakpoint_gutter_width = breakpoint_gutter_width;
|
||||||
|
} else {
|
||||||
|
cache.breakpoint_gutter_width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int line_number_char_count=0;
|
int line_number_char_count=0;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -439,7 +449,7 @@ void TextEdit::_notification(int p_what) {
|
||||||
|
|
||||||
|
|
||||||
RID ci = get_canvas_item();
|
RID ci = get_canvas_item();
|
||||||
int xmargin_beg=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w;
|
int xmargin_beg=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width;
|
||||||
int xmargin_end=cache.size.width-cache.style_normal->get_margin(MARGIN_RIGHT);
|
int xmargin_end=cache.size.width-cache.style_normal->get_margin(MARGIN_RIGHT);
|
||||||
//let's do it easy for now:
|
//let's do it easy for now:
|
||||||
cache.style_normal->draw(ci,Rect2(Point2(),cache.size));
|
cache.style_normal->draw(ci,Rect2(Point2(),cache.size));
|
||||||
|
@ -692,7 +702,7 @@ void TextEdit::_notification(int p_what) {
|
||||||
fc="0"+fc;
|
fc="0"+fc;
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT),ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
|
cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT)+cache.breakpoint_gutter_width,ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Map<int,Text::ColorRegionInfo>& cri_map=text.get_color_region_info(line);
|
const Map<int,Text::ColorRegionInfo>& cri_map=text.get_color_region_info(line);
|
||||||
|
@ -706,6 +716,14 @@ void TextEdit::_notification(int p_what) {
|
||||||
if (text.is_breakpoint(line)) {
|
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);
|
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(xmargin_beg, ofs_y,xmargin_end-xmargin_beg,get_row_height()),cache.breakpoint_color);
|
||||||
|
|
||||||
|
// draw breakpoint marker
|
||||||
|
if (draw_breakpoint_gutter) {
|
||||||
|
int vertical_gap = cache.breakpoint_gutter_width / 2;
|
||||||
|
int marker_size = cache.breakpoint_gutter_width - vertical_gap;
|
||||||
|
// no transparency on marker
|
||||||
|
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cache.style_normal->get_margin(MARGIN_LEFT) + 1, ofs_y + vertical_gap ,marker_size, marker_size),Color(cache.breakpoint_color.r, cache.breakpoint_color.g, cache.breakpoint_color.b));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1347,7 +1365,7 @@ void TextEdit::_get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) co
|
||||||
col=text[row].size();
|
col=text[row].size();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
col=p_mouse.x-(cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w);
|
col=p_mouse.x-(cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width);
|
||||||
col+=cursor.x_ofs;
|
col+=cursor.x_ofs;
|
||||||
col=get_char_pos_for( col, get_line(row) );
|
col=get_char_pos_for( col, get_line(row) );
|
||||||
}
|
}
|
||||||
|
@ -1421,6 +1439,15 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
||||||
int row,col;
|
int row,col;
|
||||||
_get_mouse_pos(Point2i(mb.x,mb.y), row,col);
|
_get_mouse_pos(Point2i(mb.x,mb.y), row,col);
|
||||||
|
|
||||||
|
// toggle breakpoint on gutter click
|
||||||
|
if (draw_breakpoint_gutter) {
|
||||||
|
int gutter=cache.style_normal->get_margin(MARGIN_LEFT);
|
||||||
|
if (mb.x > gutter && mb.x <= gutter + cache.breakpoint_gutter_width + 3) {
|
||||||
|
set_line_as_breakpoint(row, !is_line_set_as_breakpoint(row));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int prev_col=cursor.column;
|
int prev_col=cursor.column;
|
||||||
int prev_line=cursor.line;
|
int prev_line=cursor.line;
|
||||||
|
|
||||||
|
@ -2816,7 +2843,7 @@ void TextEdit::adjust_viewport_to_cursor() {
|
||||||
if (cursor.line_ofs>cursor.line)
|
if (cursor.line_ofs>cursor.line)
|
||||||
cursor.line_ofs=cursor.line;
|
cursor.line_ofs=cursor.line;
|
||||||
|
|
||||||
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w;
|
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
|
||||||
if (v_scroll->is_visible())
|
if (v_scroll->is_visible())
|
||||||
visible_width-=v_scroll->get_combined_minimum_size().width;
|
visible_width-=v_scroll->get_combined_minimum_size().width;
|
||||||
visible_width-=20; // give it a little more space
|
visible_width-=20; // give it a little more space
|
||||||
|
@ -3045,7 +3072,8 @@ void TextEdit::insert_text_at_cursor(const String& p_text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Control::CursorShape TextEdit::get_cursor_shape(const Point2& p_pos) const {
|
Control::CursorShape TextEdit::get_cursor_shape(const Point2& p_pos) const {
|
||||||
if(completion_active && completion_rect.has_point(p_pos)) {
|
int gutter=cache.style_normal->get_margin(MARGIN_LEFT)+cache.line_number_w+cache.breakpoint_gutter_width;
|
||||||
|
if((completion_active && completion_rect.has_point(p_pos)) || p_pos.x < gutter) {
|
||||||
return CURSOR_ARROW;
|
return CURSOR_ARROW;
|
||||||
}
|
}
|
||||||
return CURSOR_IBEAM;
|
return CURSOR_IBEAM;
|
||||||
|
@ -4137,6 +4165,24 @@ void TextEdit::set_show_line_numbers(bool p_show) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEdit::set_draw_breakpoint_gutter(bool p_draw) {
|
||||||
|
draw_breakpoint_gutter = p_draw;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TextEdit::is_drawing_breakpoint_gutter() const {
|
||||||
|
return draw_breakpoint_gutter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextEdit::set_breakpoint_gutter_width(int p_gutter_width) {
|
||||||
|
breakpoint_gutter_width = p_gutter_width;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
int TextEdit::get_breakpoint_gutter_width() const {
|
||||||
|
return cache.breakpoint_gutter_width;
|
||||||
|
}
|
||||||
|
|
||||||
bool TextEdit::is_text_field() const {
|
bool TextEdit::is_text_field() const {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -4235,6 +4281,8 @@ TextEdit::TextEdit() {
|
||||||
cache.row_height=1;
|
cache.row_height=1;
|
||||||
cache.line_spacing=1;
|
cache.line_spacing=1;
|
||||||
cache.line_number_w=1;
|
cache.line_number_w=1;
|
||||||
|
cache.breakpoint_gutter_width=0;
|
||||||
|
breakpoint_gutter_width = 0;
|
||||||
|
|
||||||
tab_size=4;
|
tab_size=4;
|
||||||
text.set_tab_size(tab_size);
|
text.set_tab_size(tab_size);
|
||||||
|
@ -4316,6 +4364,7 @@ TextEdit::TextEdit() {
|
||||||
completion_line_ofs=0;
|
completion_line_ofs=0;
|
||||||
tooltip_obj=NULL;
|
tooltip_obj=NULL;
|
||||||
line_numbers=false;
|
line_numbers=false;
|
||||||
|
draw_breakpoint_gutter=false;
|
||||||
next_operation_is_complex=false;
|
next_operation_is_complex=false;
|
||||||
scroll_past_end_of_file_enabled=false;
|
scroll_past_end_of_file_enabled=false;
|
||||||
auto_brace_completion_enabled=false;
|
auto_brace_completion_enabled=false;
|
||||||
|
|
|
@ -91,6 +91,7 @@ class TextEdit : public Control {
|
||||||
int row_height;
|
int row_height;
|
||||||
int line_spacing;
|
int line_spacing;
|
||||||
int line_number_w;
|
int line_number_w;
|
||||||
|
int breakpoint_gutter_width;
|
||||||
Size2 size;
|
Size2 size;
|
||||||
} cache;
|
} cache;
|
||||||
|
|
||||||
|
@ -221,6 +222,8 @@ class TextEdit : public Control {
|
||||||
bool text_changed_dirty;
|
bool text_changed_dirty;
|
||||||
bool undo_enabled;
|
bool undo_enabled;
|
||||||
bool line_numbers;
|
bool line_numbers;
|
||||||
|
bool draw_breakpoint_gutter;
|
||||||
|
int breakpoint_gutter_width;
|
||||||
|
|
||||||
bool highlight_all_occurrences;
|
bool highlight_all_occurrences;
|
||||||
bool scroll_past_end_of_file_enabled;
|
bool scroll_past_end_of_file_enabled;
|
||||||
|
@ -435,6 +438,12 @@ public:
|
||||||
|
|
||||||
void set_show_line_numbers(bool p_show);
|
void set_show_line_numbers(bool p_show);
|
||||||
|
|
||||||
|
void set_draw_breakpoint_gutter(bool p_draw);
|
||||||
|
bool is_drawing_breakpoint_gutter() const;
|
||||||
|
|
||||||
|
void set_breakpoint_gutter_width(int p_gutter_width);
|
||||||
|
int get_breakpoint_gutter_width() const;
|
||||||
|
|
||||||
void set_tooltip_request_func(Object *p_obj, const StringName& p_function, const Variant& p_udata);
|
void set_tooltip_request_func(Object *p_obj, const StringName& p_function, const Variant& p_udata);
|
||||||
|
|
||||||
void set_completion(bool p_enabled,const Vector<String>& p_prefixes);
|
void set_completion(bool p_enabled,const Vector<String>& p_prefixes);
|
||||||
|
|
|
@ -498,6 +498,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
set("text_editor/draw_tabs", true);
|
set("text_editor/draw_tabs", true);
|
||||||
|
|
||||||
set("text_editor/show_line_numbers", true);
|
set("text_editor/show_line_numbers", true);
|
||||||
|
set("text_editor/show_breakpoint_gutter", true);
|
||||||
|
|
||||||
set("text_editor/trim_trailing_whitespace_on_save", false);
|
set("text_editor/trim_trailing_whitespace_on_save", false);
|
||||||
set("text_editor/idle_parse_delay",2);
|
set("text_editor/idle_parse_delay",2);
|
||||||
|
|
|
@ -584,7 +584,7 @@ void ScriptTextEditor::_bind_methods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptTextEditor::ScriptTextEditor() {
|
ScriptTextEditor::ScriptTextEditor() {
|
||||||
|
get_text_edit()->set_breakpoint_gutter_width(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** SCRIPT EDITOR ******/
|
/*** SCRIPT EDITOR ******/
|
||||||
|
@ -1987,6 +1987,7 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
|
||||||
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
|
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
|
||||||
ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink"));
|
ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink"));
|
||||||
ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed"));
|
ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed"));
|
||||||
|
ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter"));
|
||||||
ste->get_text_edit()->set_callhint_settings(
|
ste->get_text_edit()->set_callhint_settings(
|
||||||
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
|
EditorSettings::get_singleton()->get("text_editor/put_callhint_tooltip_below_current_line"),
|
||||||
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
|
EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset"));
|
||||||
|
@ -2136,6 +2137,7 @@ void ScriptEditor::_editor_settings_changed() {
|
||||||
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
|
ste->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlight_all_occurrences"));
|
||||||
ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink"));
|
ste->get_text_edit()->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/caret_blink"));
|
||||||
ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed"));
|
ste->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/caret_blink_speed"));
|
||||||
|
ste->get_text_edit()->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/show_breakpoint_gutter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue