diff options
author | reduz <reduzio@gmail.com> | 2014-05-06 08:59:34 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2014-05-06 08:59:34 -0300 |
commit | 5044bead5f344a24f971f0bb0c8d282f1785f06a (patch) | |
tree | 554effb91a3c96ae28017bb1ee60d0ef17fc5691 /scene | |
parent | e27bc784ddb71423792f58e88266680d63f4d237 (diff) | |
parent | 6c0f3f8d0ca9e30951f0e6e643af07ca7ed695a9 (diff) |
Merge pull request #373 from marynate/PR-contextual-help
Contextual help for Script Editor
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/text_edit.cpp | 22 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 87900306d4..bd15e14ccd 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2485,6 +2485,27 @@ String TextEdit::get_selection_text() const { } +String TextEdit::get_word_under_cursor() const { + + int prev_cc = cursor.column; + while(prev_cc >0) { + bool is_char = _is_text_char(text[cursor.line][prev_cc-1]); + if (!is_char) + break; + --prev_cc; + } + + int next_cc = cursor.column; + while(next_cc<text[cursor.line].length()) { + bool is_char = _is_text_char(text[cursor.line][next_cc]); + if(!is_char) + break; + ++ next_cc; + } + if (prev_cc == cursor.column || next_cc == cursor.column) + return ""; + return text[cursor.line].substr(prev_cc, next_cc-prev_cc); +} DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const { @@ -3037,6 +3058,7 @@ void TextEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line); ObjectTypeDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column); ObjectTypeDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text); + ObjectTypeDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor); ObjectTypeDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind); ObjectTypeDB::bind_method(_MD("undo"),&TextEdit::undo); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 58d62dea48..7700bfd4d3 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -341,6 +341,8 @@ public: int get_selection_to_column() const; String get_selection_text() const; + String get_word_under_cursor() const; + bool search(const String &p_key,uint32_t p_search_flags, int p_from_line, int p_from_column,int &r_line,int &r_column) const; void undo(); |