summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorLeonardo Christino <leomilho@gmail.com>2021-04-03 12:17:51 -0300
committerLeonardo Christino <leomilho@gmail.com>2021-07-13 10:03:26 -0300
commit8b91828e4ff73fb3783b5fefcf9d150ce242907f (patch)
treea30843231851d637de9c5247b3d2e4c33e10ea9a /servers
parent9e0e74e58e84374050a35ad33f60855bab6e9bdd (diff)
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.cpp4
-rw-r--r--servers/text_server.h6
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;