40 inline void RipplePts(
int& ptA,
int& ptB,
int len,
int delta)
42 if (ptA > len - delta)
44 if (ptB > len - delta)
73 int val = 33 * firstTip.
Length() ^ numPages;
74 for (wxString::const_iterator itr = firstTip.
begin();
75 itr != firstTip.
end(); ++itr)
77 val = 33 * val ^
static_cast<int>(*itr);
89 sizes[0] = int(size * 0.75);
90 sizes[1] = int(size * 0.83);
92 sizes[3] = int(size * 1.2);
93 sizes[4] = int(size * 1.44);
94 sizes[5] = int(size * 1.73);
95 sizes[6] = int(size * 2);
111 template<>
CCManager* Mgr<CCManager>::instance =
nullptr;
121 DEFINE_EVENT_TYPE(cbEVT_DEFERRED_CALLTIP_SHOW)
122 DEFINE_EVENT_TYPE(cbEVT_DEFERRED_CALLTIP_CANCEL)
125 #define CALLTIP_REFRESH_DELAY 90 126 #define AUTOCOMP_SELECT_DELAY 35 127 #define SCROLL_REFRESH_DELAY 500 163 #endif // wxUSE_POPUPWIN 186 bool Destroy()
override;
188 void ActivateParent();
190 void DoSetSize(
int x,
int y,
int width,
int height,
int sizeFlags =
wxSIZE_AUTO)
override;
191 bool Show(
bool show =
true)
override;
194 DECLARE_EVENT_TABLE()
207 wxRect r(GetPosition(), GetSize());
209 p->Refresh(
false, &r);
211 if ( !wxPendingDelete.Member(
this) )
212 wxPendingDelete.Append(
this);
219 GetParent()->SetFocus();
234 int width,
int height,
239 GetParent()->ClientToScreen(&x,
NULL);
242 GetParent()->ClientToScreen(
NULL, &y);
244 BaseClass::DoSetSize(x, y, width, height, sizeFlags);
249 bool rv = BaseClass::Show(show);
253 GetParent()->Refresh(
false);
267 m_AutocompPosition(wxSCI_INVALID_POSITION),
268 m_CallTipActive(wxSCI_INVALID_POSITION),
269 m_LastAutocompIndex(wxNOT_FOUND),
270 m_LastTipPos(wxSCI_INVALID_POSITION),
272 m_OwnsAutocomp(true),
273 m_CallTipTimer(this, idCallTipTimer),
274 m_AutoLaunchTimer(this, idAutoLaunchTimer),
275 m_AutocompSelectTimer(this, idAutocompSelectTimer),
277 m_pAutocompPopup(
nullptr),
279 m_pLastEditor(
nullptr),
280 m_pLastCCPlugin(
nullptr)
283 m_CallTipChars[
nullptr] = std::set<wxChar>(ctChars.
begin(), ctChars.
end());
285 m_AutoLaunchChars[
nullptr] = std::set<wxChar>(alChars.begin(), alChars.end());
295 m_pHtml->Connect(wxEVT_COMMAND_HTML_LINK_CLICKED,
306 wxMenuBar* menuBar = mainFrame->GetMenuBar();
311 const wxMenuItemList& itemsList = edMenu->
GetMenuItems();
312 size_t insertPos = itemsList.GetCount();
313 for (
size_t i = 0; i < insertPos; ++i)
315 if (itemsList[i]->GetItemLabel() ==
_(
"Complete code"))
322 edMenu->
Insert(insertPos, idShowTooltip,
_(
"Show tooltip\tShift-Alt-Space"));
323 edMenu->
Insert(insertPos + 1, idCallTipNext,
_(
"Next call tip\tCtrl-N"));
324 edMenu->
Insert(insertPos + 2, idCallTipPrevious,
_(
"Previous call tip\tCtrl-P"));
326 mainFrame->Connect(idShowTooltip, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
327 mainFrame->Connect(idCallTipNext, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
328 mainFrame->Connect(idCallTipPrevious, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
350 m_pHtml->Disconnect(wxEVT_COMMAND_HTML_LINK_CLICKED,
355 mainFrame->Disconnect(idShowTooltip, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
356 mainFrame->Disconnect(idCallTipNext, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
357 mainFrame->Disconnect(idCallTipPrevious, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(
CCManager::OnMenuSelect),
nullptr,
this);
360 Disconnect(idCallTipTimer);
361 Disconnect(idAutoLaunchTimer);
362 Disconnect(idAutocompSelectTimer);
363 Disconnect(cbEVT_DEFERRED_CALLTIP_SHOW);
364 Disconnect(cbEVT_DEFERRED_CALLTIP_CANCEL);
371 if (ed == m_pLastEditor)
372 return m_pLastCCPlugin;
375 m_pLastCCPlugin =
nullptr;
378 for (
size_t i = 0; i < pa.GetCount(); ++i)
389 return m_pLastCCPlugin;
395 m_CallTipChars[registrant] = std::set<wxChar>(chars.
begin(), chars.
end());
401 m_AutoLaunchChars[registrant] = std::set<wxChar>(chars.
begin(), chars.
end());
408 DoShowDocumentation(ed);
413 m_pLastEditor =
nullptr;
414 m_pLastCCPlugin =
nullptr;
423 m_OwnsAutocomp =
false;
424 m_AutocompTokens.clear();
432 if (direction == Next)
435 if (m_CurCallTip == m_CallTips.end())
436 m_CurCallTip = m_CallTips.begin();
440 if (m_CurCallTip == m_CallTips.begin())
442 if (m_CallTips.size() > 1)
443 m_CurCallTip = m_CallTips.begin() + m_CallTips.size() - 1;
452 bool wasProcessed =
false;
457 if (stc->
CallTipActive() && m_CallTipActive != wxSCI_INVALID_POSITION && m_CallTips.size() > 1)
462 AdvanceTip(Previous);
478 TokenSorter(
bool& alphabetical,
bool caseSensitive): m_PureAlphabetical(alphabetical), m_CaseSensitive(caseSensitive)
480 m_PureAlphabetical =
true;
498 m_PureAlphabetical =
false;
521 if (tknEnd == m_LastACLaunchState[
lsCaretStart] && !m_AutocompTokens.empty())
529 ed, tknStart, tknEnd);
530 if (m_AutocompTokens.empty())
533 if (m_AutocompTokens.size() == 1 && cfg->
ReadBool(
wxT(
"/auto_select_single"),
false))
539 m_CallTipActive = wxSCI_INVALID_POSITION;
541 m_OwnsAutocomp =
true;
545 m_LastAutocompIndex = 0;
548 autoCompFinishEvt.
SetText(m_AutocompTokens.front().displayName);
550 OnEditorHook(ed, autoCompFinishEvt);
555 bool isPureAlphabetical =
true;
556 bool isCaseSensitive = cfg->
ReadBool(
wxT(
"/case_sensitive"),
false);
557 TokenSorter sortFunctor(isPureAlphabetical, isCaseSensitive);
558 std::sort(m_AutocompTokens.begin(), m_AutocompTokens.end(), sortFunctor);
559 if (isPureAlphabetical)
565 items.
Alloc(m_AutocompTokens.size() * 20);
566 for (
size_t i = 0; i < m_AutocompTokens.size(); ++i)
568 items += m_AutocompTokens[i].displayName;
569 if (m_AutocompTokens[i].category == -1)
572 items +=
F(
wxT(
"\n%d\r"), m_AutocompTokens[i].category);
577 m_CallTipActive = wxSCI_INVALID_POSITION;
584 m_OwnsAutocomp =
true;
585 if (isPureAlphabetical)
588 std::vector<cbCodeCompletionPlugin::CCToken>::const_iterator tknIt
589 = std::lower_bound(m_AutocompTokens.begin(), m_AutocompTokens.end(),
592 if (tknIt != m_AutocompTokens.end() && tknIt->displayName.StartsWith(contextStr))
612 AddPendingEvent(pendingCancel);
649 stc->Connect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
662 for (
int ii = 0; ii < count; ++ii)
675 if (ed == m_pLastEditor)
676 m_pLastEditor =
nullptr;
680 ed->
GetControl()->Disconnect(wxEVT_COMMAND_LIST_ITEM_SELECTED,
696 bool fromMouseDwell =
event.GetString().IsEmpty();
710 if (!ccPlugin || pos < 0 || pos >= stc->
GetLength())
713 static_cast<wxScintilla*>(stc)->CallTipCancel();
717 int hlStart, hlEnd, argsPos;
719 bool allowCallTip =
true;
720 const std::vector<cbCodeCompletionPlugin::CCToken>& tokens = ccPlugin->
GetTokenAt(pos, ed, allowCallTip);
721 std::set<wxString> uniqueTips;
722 for (
size_t i = 0; i < tokens.size(); ++i)
723 uniqueTips.insert(tokens[i].displayName);
724 wxStringVec tips(uniqueTips.begin(), uniqueTips.end());
726 const int style =
event.GetInt();
731 if (tknEnd - tknStart > 2)
733 for (
size_t i = 0; i < tips[0].Length(); ++i)
735 size_t hlLoc = tips[0].find(stc->
GetTextRange(tknStart, tknEnd), i);
739 hlEnd = hlStart + tknEnd - tknStart;
740 if ( (hlStart > 0 && (tips[0][hlStart - 1] ==
wxT(
'_') ||
wxIsalpha(tips[0][hlStart - 1])))
741 || (hlEnd < static_cast<int>(tips[0].Length()) - 1 && (tips[0][hlEnd] ==
wxT(
'_') ||
wxIsalpha(tips[0][hlEnd]))) )
751 else if ( allowCallTip
761 for (
size_t i = 0; i < cTips.size(); ++i)
762 tips.push_back(cTips[i].tip);
765 hlStart = cTips[0].hlStart;
766 hlEnd = cTips[0].hlEnd;
773 static_cast<wxScintilla*>(stc)->CallTipCancel();
777 DoShowTips(tips, stc, pos, argsPos, hlStart, hlEnd);
778 event.SetExtraLong(1);
786 if (evtType == wxEVT_SCI_CHARADDED)
788 const wxChar ch =
event.GetKey();
789 CCPluginCharMap::const_iterator ctChars = m_CallTipChars.find(GetProviderFor(ed));
790 if (ctChars == m_CallTipChars.end())
791 ctChars = m_CallTipChars.find(
nullptr);
794 if (ctChars->second.find(ch) != ctChars->second.end())
797 if ( tooltipMode != 3
798 || m_CallTipActive != wxSCI_INVALID_POSITION )
801 AddPendingEvent(pendingShow);
809 CCPluginCharMap::const_iterator alChars = m_AutoLaunchChars.find(GetProviderFor(ed));
810 if (alChars == m_AutoLaunchChars.end())
811 alChars = m_AutoLaunchChars.find(
nullptr);
817 if ( (pos - wordStartPos >= autolaunchCt && !stc->
AutoCompActive())
818 || pos - wordStartPos == autolaunchCt + 4 )
823 else if (alChars->second.find(ch) != alChars->second.end())
826 m_AutocompPosition = pos;
830 else if (evtType == wxEVT_SCI_UPDATEUI)
843 else if (m_CallTipTimer.IsRunning())
849 m_CallTipTimer.Stop();
853 if (m_AutoLaunchTimer.IsRunning())
858 m_AutoLaunchTimer.Stop();
869 else if (evtType == wxEVT_SCI_MODIFIED)
874 if (m_CallTipActive != wxSCI_INVALID_POSITION && stc->
GetCurrentPos() >= m_CallTipActive)
880 else if (evtType == wxEVT_SCI_AUTOCOMP_SELECTION)
884 if (ccPlugin && m_OwnsAutocomp)
886 if ( m_LastAutocompIndex != wxNOT_FOUND
887 && m_LastAutocompIndex < (
int)m_AutocompTokens.size() )
889 ccPlugin->
DoAutocomplete(m_AutocompTokens[m_LastAutocompIndex], ed);
895 CallSmartIndentCCDone(ed);
898 else if (evtType == wxEVT_SCI_AUTOCOMP_CANCELLED)
900 else if (evtType == wxEVT_SCI_CALLTIP_CLICK)
905 AdvanceTip(Previous);
962 if (!m_CallTips.empty() && m_CurCallTip != m_CallTips.end())
963 curTip = m_CurCallTip->tip;
968 if (!m_CallTips.empty() && (
event.GetInt() !=
FROM_TIMER || argsPos == m_CallTipActive))
973 if ( m_CallTips.size() > 1
979 for (CallTipVec::const_iterator itr = m_CallTips.begin();
980 itr != m_CallTips.end(); ++itr)
982 if (hlStart == hlEnd && itr->hlStart != itr->hlEnd)
984 hlStart = tip.
Length() + itr->hlStart;
985 hlEnd = tip.
Length() + itr->hlEnd;
987 tip += itr->tip +
wxT(
'\n');
992 m_CurCallTip = m_CallTips.begin();
993 if (m_CallTips.size() > 1)
998 std::map<int, size_t>::const_iterator choiceItr =
1002 if (choiceItr != m_CallTipChoiceDict.end() && choiceItr->second < m_CallTips.size())
1003 m_CurCallTip = m_CallTips.begin() + choiceItr->second;
1005 if (choiceItr == m_CallTipChoiceDict.end() || argsPos == m_CallTipActive)
1007 int prefixEndPos = argsPos;
1014 if (choiceItr != m_CallTipFuzzyChoiceDict.end() && choiceItr->second < m_CallTips.size())
1015 m_CurCallTip = m_CallTips.begin() + choiceItr->second;
1018 for (CallTipVec::const_iterator itr = m_CallTips.begin();
1019 itr != m_CallTips.end(); ++itr)
1021 if (itr->tip == curTip)
1028 m_CallTipActive = argsPos;
1029 DoUpdateCallTip(ed);
1033 if (m_CallTipActive != wxSCI_INVALID_POSITION)
1039 m_CurCallTip = m_CallTips.end();
1047 wxObject* evtObj =
event.GetEventObject();
1051 m_pAutocompPopup =
static_cast<wxListView*
>(evtObj);
1058 m_DocPos = m_pPopup->GetParent()->ScreenToClient(evtWin->GetScreenPosition());
1059 m_DocPos.x += evtWin->GetSize().x;
1061 wxRect edRect = ed->GetRect();
1062 if (!m_pPopup->IsShown())
1067 m_DocSize.x = edRect.
width * 5 / 12;
1068 m_DocSize.y = acMaxHeight * textHeight;
1072 m_WindowBound = m_DocPos.x + m_DocSize.x;
1073 if (idx != wxNOT_FOUND)
1075 const wxPoint& corner = m_pPopup->GetParent()->ScreenToClient(
wxDisplay(idx).GetGeometry().GetBottomRight());
1076 m_DocSize.
y = std::max(9 * textHeight, std::min(m_DocSize.y, corner.
y - m_DocPos.y - 2));
1077 m_DocSize.x = std::max(m_DocSize.y * 2 / 3, std::min(m_DocSize.x, corner.
x - m_DocPos.x - 2));
1078 m_WindowBound = std::min(corner.
x - 2, m_WindowBound);
1081 if ((m_DocPos.x + m_DocSize.x) > m_WindowBound)
1082 m_DocPos.x -= evtWin->GetSize().x + m_DocSize.x;
1084 m_DocSize.x = std::min(m_WindowBound - m_DocPos.x, edRect.
width * 5 / 12);
1092 wxObject* evtObj =
event.GetEventObject();
1095 if (m_CallTipActive != wxSCI_INVALID_POSITION && !m_AutoLaunchTimer.IsRunning())
1106 evt.SetInt(event.GetInt());
1121 const wxPoint& pos = m_pLastEditor->GetControl()->ClientToScreen(event.
GetPosition());
1122 if (m_pPopup->GetScreenRect().Contains(pos))
1123 m_pHtml->GetEventHandler()->ProcessEvent(event);
1124 else if (m_pAutocompPopup && m_pAutocompPopup->GetScreenRect().Contains(pos))
1137 bool dismissPopup =
false;
1142 m_pHtml->SetPage(html);
1152 AddPendingEvent(evt);
1174 DoShowDocumentation(ed);
1197 evt.SetExtraLong(0);
1198 evt.SetString(
wxT(
"evt from menu"));
1209 DoUpdateCallTip(ed);
1213 AdvanceTip(Previous);
1214 DoUpdateCallTip(ed);
1224 items.
Alloc(m_AutocompTokens.size() * 20);
1225 for (
size_t i = 0; i < m_AutocompTokens.size(); ++i)
1227 items += m_AutocompTokens[i].displayName;
1228 if (m_AutocompTokens[i].category == -1)
1231 items +=
F(
wxT(
"\n%d\r"), m_AutocompTokens[i].category);
1235 m_CallTipActive = wxSCI_INVALID_POSITION;
1238 m_OwnsAutocomp =
true;
1243 (m_LastAutocompIndex != wxNOT_FOUND && m_LastAutocompIndex < (int)m_AutocompTokens.size()))
1248 if (sepIdx == wxNOT_FOUND)
1257 if (!m_pPopup->IsShown())
1261 if (m_pLastEditor && m_pLastEditor->GetControl())
1268 if (!
Manager::Get()->GetConfigManager(
wxT(
"ccmanager"))->ReadBool(
wxT(
"/documentation_popup"),
true))
1274 if ( m_LastAutocompIndex == wxNOT_FOUND
1275 || m_LastAutocompIndex >= (
int)m_AutocompTokens.size() )
1287 m_pHtml->SetSize(m_DocSize);
1288 m_pHtml->SetPage(html);
1289 m_pPopup->SetClientSize(m_DocSize);
1290 m_pPopup->SetPosition(m_DocPos);
1292 if (!m_pPopup->IsShown())
1304 int hlStart = m_CurCallTip->hlStart;
1305 int hlEnd = m_CurCallTip->hlEnd;
1307 size_t eRange = m_CurCallTip->tip.find(
wxT(
'\n'));
1310 tips.push_back(m_CurCallTip->tip.Mid(sRange, eRange - sRange));
1312 sRange = eRange + 1;
1313 eRange = m_CurCallTip->tip.find(
wxT(
'\n'), sRange);
1315 if (sRange < m_CurCallTip->tip.Length())
1316 tips.push_back(m_CurCallTip->tip.Mid(sRange));
1321 if (m_CallTips.size() > 1)
1323 tips.front().Prepend(
wxT(
"\001\002"));
1328 tip <<
wxT(
"(") << (m_CurCallTip - m_CallTips.begin() + 1) <<
wxT(
"/") << m_CallTips.size() <<
wxT(
")");
1330 tips.push_back(tip);
1334 int prefixEndPos = m_CallTipActive;
1347 DoShowTips(tips, stc, std::max(pos, lnStart), m_CallTipActive, hlStart + offset, hlEnd + offset);
1355 maxWidth = std::min(std::max(60, maxWidth), 135);
1359 if (!tips.front().IsEmpty() && tips.front()[0] <=
wxT(
'\002'))
1362 lineBreak +=
wxT(
' ');
1363 if (tips.front().Length() > 1 && tips.front()[1] <=
wxT(
'\002'))
1364 lineBreak +=
wxT(
" ");
1367 for (
size_t i = 0; i < tips.size() && lineCount < maxLines; ++i)
1369 if (tips[i].Length() > (size_t)maxWidth + 6)
1375 int index = segment.
Find(
wxT(
' '),
true);
1378 segment = tipLn.
Mid(0, maxWidth * 6 / 5);
1379 index = segment.
Find(
wxT(
' '),
true);
1381 for (
int commaIdx = index - 1; commaIdx > maxWidth / 2; --commaIdx)
1383 if (segment[commaIdx] ==
wxT(
',') && segment[commaIdx + 1] ==
wxT(
' '))
1385 index = commaIdx + 1;
1389 if (index < 20 || segment == tipLn)
1391 tip += tipLn + lineBreak;
1397 tip += segment.
Mid(0, index) + lineBreak +
wxT(
' ');
1400 tipLn = tipLn.
Mid(index);
1407 tip += tips[i] + lineBreak;
1417 if (argsPos == wxSCI_INVALID_POSITION)
1427 if (hlStart >= 0 && hlEnd > hlStart)
1435 event.SetEditor(ed);
wxString F(const wxChar *msg,...)
sprintf-like function
bool CallTipActive()
Is there an active call tip?
virtual std::vector< CCToken > GetTokenAt(int pos, cbEditor *ed, bool &allowCallTip)=0
Supply the definition of the token at the specified location.
virtual std::vector< CCToken > GetAutocompList(bool isAuto, cbEditor *ed, int &tknStart, int &tknEnd)=0
Supply content for the autocompletion list.
void SetText(const wxString &t)
Kept for backwards compatibility, use SetString().
#define wxSCI_MARGIN_NUMBER
int WordEndPosition(int pos, bool onlyWordCharacters)
Get position of end of word.
EVTIMPORT const wxEventType cbEVT_EDITOR_CC_DONE
Base class for code-completion plugins.
PluginManager * GetPluginManager() const
const_iterator begin() const
std::vector< cbCodeCompletionPlugin::CCCallTip > CallTipVec
bool AutoCompActive()
Is there an auto-completion list visible?
void CallTipSetHighlight(int highlightStart, int highlightEnd)
Highlight a segment of the definition.
bool wxIsspace(const wxUniChar &c)
ConfigManager * GetConfigManager(const wxString &name_space) const
CCProviderStatus
Level of functionality a CC plugin is able to provide.
int ReadInt(const wxString &name, int defaultVal=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
#define wxSCI_MARGIN_SYMBOL
void CallTipSetForegroundHighlight(const wxColour &fore)
Set the foreground colour for the highlighted part of the call tip.
int Cmp(const wxString &s) const
#define wxDynamicCast(ptr, classname)
void OnEditorOpen(CodeBlocksEvent &event)
Event handler to avoid tooltips getting stuck active.
void NotifyDocumentation()
Let CCManager know that new results are available from cbCodeCompletionPlugin::GetDocumentation().
void OnAutocompleteSelect(wxListEvent &event)
Event handler to show documentation, when user changes autocomplete selection.
void RegisterColour(const wxString &category, const wxString &name, const wxString &id, const wxColour &defaultColour)
Structure representing an individual calltip with an optional highlighted range.
int GetColumn(int pos) const
Retrieve the column number of a position, taking tab width into account.
void NotifyPluginStatus()
Let CCManager know that a change (e.g.
bool ReadBool(const wxString &name, bool defaultVal=false)
void OnAutocompleteHide(wxShowEvent &event)
Event handler to tear down documentation, when autocomplete closes.
void AutoCompSetOrder(int order)
Set the way autocompletion lists are ordered.
int VisibleFromDocLine(int docLine)
Find the display line of a document line taking hidden lines into account.
void OnDeferredCallTipCancel(wxCommandEvent &event)
Defer canceling the calltip to avoid a crash issue.
void CallTipSetForeground(const wxColour &fore)
Set the foreground colour for the call tip.
const int idAutoLaunchTimer
#define AUTOCOMP_SELECT_DELAY
void OnTimer(wxTimerEvent &event)
Grouped event handler for several timers.
int FindColumn(int line, int column, wxScintilla *stc)
void CallTipShow(int pos, const wxString &definition)
Show a call tip containing a definition near position pos.
std::vector< wxString > wxStringVec
int TextHeight(int line)
Retrieve the height of a particular line of text in pixels.
void OnDeactivateEd(CodeBlocksEvent &event)
Event handler to avoid tooltips getting stuck active.
virtual wxString OnDocumentationLink(wxHtmlLinkEvent &event, bool &dismissPopup)=0
Callback to handle a click on a link in the documentation popup.
void RegisterCallTipChars(const wxString &chars, cbCodeCompletionPlugin *registrant)
Register a new set of characters that, when typed, invoke calltip requests.
EditorBase * GetEditor() const
#define wxFRAME_NO_TASKBAR
wxEventType wxEVT_MOUSEWHEEL
int GetModificationType() const
#define wxSCI_ORDER_PRESORTED
EVTIMPORT const wxEventType cbEVT_SHOW_CALL_TIP
int GetWheelRotation() const
void OnCompleteCode(CodeBlocksEvent &event)
Event handler to list the suggestion, when a user press Ctrl-space (by default).
void RegisterAutoLaunchChars(const wxString &chars, cbCodeCompletionPlugin *registrant)
Register a new set of characters that, when typed, auto-launch codecomplete requests.
A generic Code::Blocks event.
static void setupColours(cbEditor *editor, ColourManager *manager)
wxPoint GetPosition() const
int GetLineEndPosition(int line) const
Get the position after the last visible characters on a line.
static int GetDefaultHTMLFontSize()
const int idCallTipPrevious
int WordStartPosition(int pos, bool onlyWordCharacters)
Get position of start of word.
EditorManager * GetEditorManager() const
bool IsPosVisible(int pos, wxScintilla *stc)
wxUSE_UNICODE_dependent wxChar
#define wxSCI_STYLE_LINENUMBER
CC plugin provides specialized functionality.
int weight
Lower numbers are placed earlier in listing, 5 is default; try to keep 0-10.
PluginsArray GetCodeCompletionOffers()
EVTIMPORT const wxEventType cbEVT_EDITOR_CLOSE
int PositionFromPointClose(int x, int y)
Find the position from a point within the window but return wxSCI_INVALID_POSITION if not close to te...
void DoShowDocumentation(cbEditor *ed)
Show the documentation popup.
int GetCurrentLine()
Manually declared methods.
static int CallTipToInt(const wxString &firstTip, int numPages)
wxString & RemoveLast(size_t n=1)
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
wxColour GetColour(const wxString &id) const
#define wxHW_SCROLLBAR_AUTO
void AutoCompShow(int lengthEntered, const wxString &itemList)
Display a auto-completion list.
virtual wxString GetDocumentation(const CCToken &token)=0
Supply html formatted documentation for the passed token.
void CallTipCancel()
Cancel calltip only if not jumping braces via tab.
wxPoint PointFromPosition(int pos)
Retrieve the point in the window where a position is displayed.
void CallTipSetBackground(const wxColour &back)
Set the background colour for the call tip.
EVTIMPORT const wxEventType cbEVT_APP_DEACTIVATED
cbCodeCompletionPlugin * GetProviderFor(cbEditor *ed=nullptr)
Get the ccPlugin instant for the cbEditor.
wxFrame * GetAppFrame() const
void AutoCompSetMaxHeight(int rowCount)
Set the maximum height, in rows, of auto-completion and user lists.
const wxSize wxDefaultSize
cbEditor * GetBuiltinActiveEditor()
#define CALLTIP_REFRESH_DELAY
const wxPoint wxDefaultPosition
void DoUpdateCallTip(cbEditor *ed)
Update which tip to show next and where to show it.
void AutoCompCancel()
Remove the auto-completion list from the screen.
void RemoveAllEventSinksFor(void *owner)
bool IsCharacter(int style)
Is style classified as character for current language?
Base class that all "editors" should inherit from.
int GetCurrentPos() const
Returns the position of the caret.
void AdvanceTip(Direction direction)
Switch the tip window to the next item.
Structure representing a generic token, passed between CC plugins and CCManager.
bool IsString(int style)
Is style classified as string for current language?
int GetLength() const
Returns the number of bytes in the document.
wxString displayName
Verbose string representing the token.
void AutoCompSetSeparator(int separatorCharacter)
Change the separator character in the string setting up an auto-completion list.
virtual bool IsBuiltinEditor() const
Is this a built-in editor?
#define wxFRAME_FLOAT_ON_PARENT
void OnEditorClose(CodeBlocksEvent &event)
Event handler to avoid tooltips getting stuck active.
EVTIMPORT const wxEventType cbEVT_EDITOR_DEACTIVATED
#define FROM_TIMER
FROM_TIMER means the event is automatically fired from the ccmanager, not explicitly called by the us...
EVTIMPORT const wxEventType cbEVT_COMPLETE_CODE
bool & m_PureAlphabetical
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
Code Completion Plugin Manager.
EditorBase * GetEditor(int index)
cbEditor * GetBuiltinEditor(EditorBase *eb)
void AutoCompSetTypeSeparator(int separatorCharacter)
Change the type-separator character in the string setting up an auto-completion list.
Functor class for use as a editor modification operations hook.
void UpdateEnvSettings()
Called after env settings have changed, so the changes can be applied.
int PositionFromPoint(wxPoint pt) const
Find the position from a point within the window.
int PositionFromLine(int line) const
Retrieve the position at the start of a line.
static int GetFromWindow(const wxWindow *win)
void DoBufferedCC(cbStyledTextCtrl *stc)
CC launched in the same state as last run, display via cached data.
ColourManager * GetColourManager() const
const int idAutocompSelectTimer
int GetCharAt(int pos) const
Returns the character byte at the position.
void SetEditor(EditorBase *editor)
bool wxIsalpha(const wxUniChar &c)
void AutoCompSetIgnoreCase(bool ignoreCase)
Set whether case is significant when performing auto-completion searches.
TokenSorter(bool &alphabetical, bool caseSensitive)
void CallSmartIndentCCDone(cbEditor *ed)
Code completion as just insert some text in the editor, ask the smart indent plugin to adjust the ind...
wxString GetLineIndentString(int line=-1) const
Returns the specified line's (0-based) indentation (whitespace) string.
Direction
User click the next or previous small button of the tip window.
#define wxSCI_INVALID_POSITION
const_iterator end() const
bool ProcessEvent(CodeBlocksEvent &event)
void OnShowCallTip(CodeBlocksEvent &event)
Event handler to show the call tip, when user press Ctrl-Shift-Space.
void OnEditorHook(cbEditor *ed, wxScintillaEvent &event)
Hook to the editor.
void RegisterEventSink(wxEventType eventType, IEventFunctorBase< CodeBlocksEvent > *functor)
virtual int GetPointSize() const
DLLIMPORT HookFunctorBase * UnregisterHook(int id, bool deleteHook=true)
Unregister a previously registered project loading/saving hook.
int GetStyleAt(int pos) const
Returns the style byte at the position.
void SetHeight(int height)
int LineFromPosition(int pos) const
Retrieve the line containing a position.
void InjectAutoCompShow(int lenEntered, const wxString &itemList)
If for some reason you need to use wxScintilla::AutoCompShow(), call this instead so CCManager does n...
static void BuildFontSizes(int *sizes, int size)
int LinesOnScreen() const
Retrieves the number of lines completely visible.
int Find(wxUniChar ch, bool fromEnd=false) const
EVTIMPORT const wxEventType cbEVT_EDITOR_OPEN
int TextWidth(int style, const wxString &text)
Measure the pixel width of some text in a particular style.
int GetMarginWidth(int margin) const
Retrieve the width of a margin in pixels.
void OnHtmlLink(wxHtmlLinkEvent &event)
A link is clicked in the document window.
void OnDeactivateApp(CodeBlocksEvent &event)
Event handler to avoid tooltips getting stuck active.
#define wxSCI_ORDER_CUSTOM
virtual std::vector< CCCallTip > GetCallTips(int pos, int style, cbEditor *ed, int &argsPos)=0
Supply content for the calltip at the specified location.
bool ProcessArrow(int key)
Used by cbStyledTextCtrl to process ArrowUp and ArrowDown key press.
void OnDeferredCallTipShow(wxCommandEvent &event)
Defer showing the calltip to avoid a crash issue.
void AutoCompSelect(const wxString &select)
Select the item in the auto-completion list that starts with a string.
bool wxGetKeyState(wxKeyCode key)
wxString GetText() const
Kept for backwards compatibility, use GetString().
wxString Mid(size_t first, size_t nCount=wxString::npos) const
virtual void DoAutocomplete(const CCToken &token, cbEditor *ed)
Callback for inserting the selected autocomplete entry into the editor.
bool operator()(const cbCodeCompletionPlugin::CCToken &a, const cbCodeCompletionPlugin::CCToken &b)
int AutoCompGetCurrent() const
Get currently selected item position in the auto-completion list.
void RipplePts(int &ptA, int &ptB, int len, int delta)
bool IsPreprocessor(int style)
Is style classified as preprocessor for current language?
int GetFirstVisibleLine() const
Retrieve the display line at the top of the display.
int AutoCompGetMaxHeight() const
Set the maximum height, in rows, of auto-completion and user lists.
wxWindow * wxGetTopLevelParent(wxWindow *window)
void DoShowTips(const wxStringVec &tips, cbStyledTextCtrl *stc, int pos, int argsPos, int hlStart, int hlEnd)
Format tips by breaking long lines at (hopefully) logical places.
DLLIMPORT int RegisterHook(HookFunctorBase *functor)
Register a project loading/saving hook.
CC plugin provides generic functionality.