TextEdit word wrap

This commit is contained in:
Ian 2018-01-25 20:41:17 -05:00 committed by ianb96
parent 92f1debf08
commit e1fff4bc09
4 changed files with 1028 additions and 618 deletions

View file

@ -779,6 +779,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/word_wrap"));
text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));

View file

@ -371,6 +371,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/line_numbers/line_numbers_zero_padded", false);
_initial_set("text_editor/line_numbers/show_breakpoint_gutter", true);
_initial_set("text_editor/line_numbers/code_folding", true);
_initial_set("text_editor/line_numbers/word_wrap", false);
_initial_set("text_editor/line_numbers/show_line_length_guideline", false);
_initial_set("text_editor/line_numbers/line_length_guideline_column", 80);
hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");

File diff suppressed because it is too large Load diff

View file

@ -76,6 +76,7 @@ public:
bool marked : 1;
bool breakpoint : 1;
bool hidden : 1;
int wrap_amount_cache : 24;
Map<int, ColorRegionInfo> region_info;
String data;
};
@ -94,6 +95,9 @@ public:
void set_color_regions(const Vector<ColorRegion> *p_regions) { color_regions = p_regions; }
int get_line_width(int p_line) const;
int get_max_width(bool p_exclude_hidden = false) const;
int get_char_width(char c, char next_c, int px) const;
void set_line_wrap_amount(int p_line, int p_wrap_amount) const;
int get_line_wrap_amount(int p_line) const;
const Map<int, ColorRegionInfo> &get_color_region_info(int p_line) const;
void set(int p_line, const String &p_text);
void set_marked(int p_line, bool p_marked) { text[p_line].marked = p_marked; }
@ -106,7 +110,8 @@ public:
void remove(int p_at);
int size() const { return text.size(); }
void clear();
void clear_caches();
void clear_width_cache();
void clear_wrap_cache();
_FORCE_INLINE_ const String &operator[](int p_line) const { return text[p_line].data; }
Text() { indent_size = 4; }
};
@ -115,7 +120,7 @@ private:
struct Cursor {
int last_fit_x;
int line, column; ///< cursor
int x_ofs, line_ofs;
int x_ofs, line_ofs, wrap_ofs;
} cursor;
struct Selection {
@ -263,8 +268,11 @@ private:
bool block_caret;
bool right_click_moves_caret;
bool wrap_enabled;
int wrap_at;
int wrap_right_offset;
bool setting_row;
bool wrap;
bool draw_tabs;
bool override_selected_font_color;
bool cursor_changed_dirty;
@ -321,19 +329,34 @@ private:
int search_result_line;
int search_result_col;
double line_scroll_pos;
bool context_menu_enabled;
int get_visible_rows() const;
int get_total_unhidden_rows() const;
double get_line_scroll_pos(bool p_recalculate = false) const;
void update_line_scroll_pos();
int get_total_visible_rows() const;
void update_cursor_wrap_offset();
void update_wrap_at();
bool line_wraps(int line) const;
int times_line_wraps(int line) const;
Vector<String> get_wrap_rows_text(int p_line) const;
int get_cursor_wrap_index() const;
int get_line_wrap_index_at_col(int p_line, int p_column) const;
int get_char_count();
double get_scroll_pos_for_line(int p_line, int p_wrap_index = 0) const;
void set_line_as_first_visible(int p_line, int p_wrap_index = 0);
void set_line_as_center_visible(int p_line, int p_wrap_index = 0);
void set_line_as_last_visible(int p_line, int p_wrap_index = 0);
int get_first_visible_line() const;
int get_last_visible_line() const;
int get_last_visible_line_wrap_index() const;
double get_visible_rows_offset() const;
double get_v_scroll_offset() const;
int get_char_pos_for_line(int p_px, int p_line, int p_wrap_index = 0) const;
int get_column_x_offset_for_line(int p_char, int p_line) const;
int get_char_pos_for(int p_px, String p_str) const;
int get_column_x_offset(int p_char, String p_str);
int get_column_x_offset(int p_char, String p_str) const;
void adjust_viewport_to_cursor();
double get_scroll_line_diff() const;
@ -455,8 +478,10 @@ public:
bool is_line_hidden(int p_line) const;
void fold_all_lines();
void unhide_all_lines();
int num_lines_from(int p_line_from, int unhidden_amount) const;
bool is_last_visible_line(int p_line) const;
int num_lines_from(int p_line_from, int visible_amount) const;
int num_lines_from_rows(int p_line_from, int p_wrap_index_from, int visible_amount, int &wrap_index) const;
int get_last_unhidden_line() const;
bool can_fold(int p_line) const;
bool is_folded(int p_line) const;
void fold_line(int p_line);
@ -493,7 +518,7 @@ public:
void center_viewport_to_cursor();
void cursor_set_column(int p_col, bool p_adjust_viewport = true);
void cursor_set_line(int p_row, bool p_adjust_viewport = true, bool p_can_be_hidden = true);
void cursor_set_line(int p_row, bool p_adjust_viewport = true, bool p_can_be_hidden = true, int p_wrap_index = 0);
int cursor_get_column() const;
int cursor_get_line() const;
@ -516,8 +541,8 @@ public:
void set_max_chars(int p_max_chars);
int get_max_chars() const;
void set_wrap(bool p_wrap);
bool is_wrapping() const;
void set_wrap_enabled(bool p_wrap_enabled);
bool is_wrap_enabled() const;
void clear();
@ -578,8 +603,8 @@ public:
Color get_member_color(String p_member) const;
void clear_member_keywords();
int get_v_scroll() const;
void set_v_scroll(int p_scroll);
double get_v_scroll() const;
void set_v_scroll(double p_scroll);
int get_h_scroll() const;
void set_h_scroll(int p_scroll);