Merge pull request #14973 from poke1024/docs-word-selection
Double-click word selection for RichTextLabel (i.e. docs)
This commit is contained in:
@ -56,6 +56,40 @@
|
||||
#define IS_DIGIT(m_d) ((m_d) >= '0' && (m_d) <= '9')
|
||||
#define IS_HEX_DIGIT(m_d) (((m_d) >= '0' && (m_d) <= '9') || ((m_d) >= 'a' && (m_d) <= 'f') || ((m_d) >= 'A' && (m_d) <= 'F'))
|
||||
|
||||
bool is_symbol(CharType c) {
|
||||
return c != '_' && ((c >= '!' && c <= '/') || (c >= ':' && c <= '@') || (c >= '[' && c <= '`') || (c >= '{' && c <= '~') || c == '\t' || c == ' ');
|
||||
}
|
||||
|
||||
bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end) {
|
||||
|
||||
const String &s = p_s;
|
||||
int beg = CLAMP(p_col, 0, s.length());
|
||||
int end = beg;
|
||||
|
||||
if (s[beg] > 32 || beg == s.length()) {
|
||||
|
||||
bool symbol = beg < s.length() && is_symbol(s[beg]);
|
||||
|
||||
while (beg > 0 && s[beg - 1] > 32 && (symbol == is_symbol(s[beg - 1]))) {
|
||||
beg--;
|
||||
}
|
||||
while (end < s.length() && s[end + 1] > 32 && (symbol == is_symbol(s[end + 1]))) {
|
||||
end++;
|
||||
}
|
||||
|
||||
if (end < s.length())
|
||||
end += 1;
|
||||
|
||||
r_beg = beg;
|
||||
r_end = end;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** STRING **/
|
||||
|
||||
bool CharString::operator<(const CharString &p_right) const {
|
||||
|
||||
Reference in New Issue
Block a user