| 71 | } |
| 72 | |
| 73 | void CodeEntry::Poll() |
| 74 | { |
| 75 | if (mCodeUpdated) |
| 76 | { |
| 77 | if (mDoSyntaxHighlighting && sDoSyntaxHighlighting) |
| 78 | { |
| 79 | try |
| 80 | { |
| 81 | py::globals()["syntax_highlight_code"] = GetVisibleCode(); |
| 82 | py::object ret = py::eval("syntax_highlight_basic()", py::globals()); |
| 83 | mSyntaxHighlightMapping = ret.cast<std::vector<int> >(); |
| 84 | } |
| 85 | catch (const std::exception& e) |
| 86 | { |
| 87 | ofLog() << "syntax highlight execution exception: " << e.what(); |
| 88 | } |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | mSyntaxHighlightMapping.clear(); |
| 93 | } |
| 94 | |
| 95 | if (mListener) |
| 96 | mListener->OnCodeUpdated(); |
| 97 | |
| 98 | mCodeUpdated = false; |
| 99 | } |
| 100 | |
| 101 | if (mAutocompleteUpdateTimer > 0) |
| 102 | { |
| 103 | mAutocompleteUpdateTimer -= 1.0 / ofGetFrameRate(); |
| 104 | if (mAutocompleteUpdateTimer <= 0) |
| 105 | { |
| 106 | if (sDoPythonAutocomplete) |
| 107 | { |
| 108 | mAutocompleteCaretCoords = GetCaretCoords(mCaretPosition); |
| 109 | |
| 110 | if (!GetVisibleCode().empty()) |
| 111 | { |
| 112 | try |
| 113 | { |
| 114 | std::string prefix = ScriptModule::GetBootstrapImportString() + "; import me\n"; |
| 115 | py::exec("jediScript = jedi.Script('''" + prefix + GetVisibleCode() + "''', project=jediProject)", py::globals()); |
| 116 | //py::exec("jediScript = jedi.Script('''" + prefix + GetVisibleCode() + "''')", py::globals()); |
| 117 | //py::exec("jediScript = jedi.Interpreter('''" + prefix + GetVisibleCode() + "''', [locals(), globals()])", py::globals()); |
| 118 | auto coords = GetCaretCoords(mCaretPosition); |
| 119 | |
| 120 | { |
| 121 | py::object ret = py::eval("jediScript.get_signatures(" + ofToString(coords.y + 2) + "," + ofToString(coords.x) + ")", py::globals()); |
| 122 | auto signatures = ret.cast<std::list<py::object> >(); |
| 123 | |
| 124 | size_t i = 0; |
| 125 | for (auto signature : signatures) |
| 126 | { |
| 127 | mWantToShowAutocomplete = true; |
| 128 | if (i < mAutocompleteSignatures.size()) |
| 129 | { |
| 130 | mAutocompleteSignatures[i].valid = true; |
nothing calls this directly
no test coverage detected