MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / Poll

Method Poll

Source/CodeEntry.cpp:73–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void 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;

Callers

nothing calls this directly

Calls 11

ofLogClass · 0.85
ofGetFrameRateFunction · 0.85
ofToStringFunction · 0.85
StringClass · 0.85
ofStringReplaceFunction · 0.85
emptyMethod · 0.80
sizeMethod · 0.80
resizeMethod · 0.80
PathMethod · 0.80
OnCodeUpdatedMethod · 0.45
GetAllModulesMethod · 0.45

Tested by

no test coverage detected