diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-07-13 19:09:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-13 19:09:11 +0200 |
commit | 4e4bcbc98678ae6dc4e6878dd8c9ac2127671d55 (patch) | |
tree | 56cdc6c0e9925304863d5bd7868a24cc877a1108 /servers | |
parent | 79137a02608d65fd5f664a5210919c2e71ea6c5f (diff) | |
parent | 8b91828e4ff73fb3783b5fefcf9d150ce242907f (diff) |
Merge pull request #47604 from christinoleo/master
Separate underscore from grapheme punctuation to enable doubleclick and caret jump over snakecase variables in editor
Diffstat (limited to 'servers')
-rw-r--r-- | servers/text_server.cpp | 4 | ||||
-rw-r--r-- | servers/text_server.h | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/servers/text_server.cpp b/servers/text_server.cpp index 97cfe828f0..1491368109 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -712,7 +712,7 @@ Vector<Vector2i> TextServer::shaped_text_get_line_breaks(RID p_shaped, float p_w return lines; } -Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped) const { +Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const { Vector<Vector2i> words; const_cast<TextServer *>(this)->shaped_text_update_justification_ops(p_shaped); @@ -726,7 +726,7 @@ Vector<Vector2i> TextServer::shaped_text_get_word_breaks(RID p_shaped) const { for (int i = 0; i < l_size; i++) { if (l_gl[i].count > 0) { - if (((l_gl[i].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE) || ((l_gl[i].flags & GRAPHEME_IS_PUNCTUATION) == GRAPHEME_IS_PUNCTUATION)) { + if ((l_gl[i].flags & p_grapheme_flags) != 0) { words.push_back(Vector2i(word_start, l_gl[i].start)); word_start = l_gl[i].end; } diff --git a/servers/text_server.h b/servers/text_server.h index 06020d3ffd..4c2ada7fc9 100644 --- a/servers/text_server.h +++ b/servers/text_server.h @@ -87,7 +87,8 @@ public: GRAPHEME_IS_BREAK_SOFT = 1 << 5, // Is line break (optional break, e.g. space). GRAPHEME_IS_TAB = 1 << 6, // Is tab or vertical tab. GRAPHEME_IS_ELONGATION = 1 << 7, // Elongation (e.g. kashida), glyph can be duplicated or truncated to fit line to width. - GRAPHEME_IS_PUNCTUATION = 1 << 8 // Punctuation (can be used as word break, but not line break or justifiction). + GRAPHEME_IS_PUNCTUATION = 1 << 8, // Punctuation, except underscore (can be used as word break, but not line break or justifiction). + GRAPHEME_IS_UNDERSCORE = 1 << 9, // Underscore (can be used as word break). }; enum Hinting { @@ -354,10 +355,9 @@ public: virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<float> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const; - virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped) const; + virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const; virtual void shaped_text_overrun_trim_to_width(RID p_shaped, float p_width, uint8_t p_clip_flags) = 0; - virtual Array shaped_text_get_objects(RID p_shaped) const = 0; virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const = 0; |