1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Copyright : (C) 2015 Eran Ifrah
// File name : wxCodeCompletionBoxManager.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef WXCODECOMPLETIONBOXMANAGER_H
#define WXCODECOMPLETIONBOXMANAGER_H
#include "codelite_exports.h"
#include "wxCodeCompletionBox.h"
#include <wx/event.h>
class wxStyledTextCtrl;
class WXDLLIMPEXP_SDK wxCodeCompletionBoxManager : public wxEvtHandler
{
friend class wxCodeCompletionBox;
protected:
wxCodeCompletionBox* m_box;
wxStyledTextCtrl* m_stc;
private:
wxCodeCompletionBoxManager();
~wxCodeCompletionBoxManager();
protected:
void DestroyCurrent();
void InsertSelection(wxCodeCompletionBoxEntry::Ptr_t match, bool userTriggered);
void InsertSelectionTemplateFunction(const wxString& selection);
void ShowAddIncludeDialog(const wxString& include);
// Handle the current editor events
void OnStcModified(wxStyledTextEvent& event);
void OnStcCharAdded(wxStyledTextEvent& event);
void OnStcKeyDown(wxKeyEvent& event);
void OnStcLeftDown(wxMouseEvent& event);
void OnDismissBox(wxCommandEvent& event);
void OnAppActivate(wxActivateEvent& event);
void DoShowCCBoxTags(const TagEntryPtrVector_t& tags);
void DoShowCCBoxLSPItems(const LSP::CompletionItem::Vec_t& items);
void DoShowCCBoxEntries(const wxCodeCompletionBoxEntry::Vec_t& entries);
void DoConnectStcEventHandlers(wxStyledTextCtrl* ctrl);
public:
static wxCodeCompletionBoxManager& Get();
/**
* @brief uninitialize all event handlers and destroy the CC box manager
*/
static void Free();
/**
* @brief destroy the current CC box
*/
void DestroyCCBox();
/**
* @brief show the completion box
* @param ctrl the wxSTC control requesting the completion box
* @param entries list of entries to display
* @param flags code completion box options. See wxCodeCompletionBox::eOptions
* for possible values
* @param eventObject all events fired by the cc box will have eventObject
* as the event object (wxEvent::GetEventObject())
*/
void ShowCompletionBox(wxStyledTextCtrl* ctrl, const wxCodeCompletionBoxEntry::Vec_t& entries, size_t flags,
int startPos, wxEvtHandler* eventObject = NULL);
/**
* @brief show the completion box
* @param ctrl the wxSTC control requesting the completion box
* @param entries list of entries to display
* @param bitmaps alternative bitmap list to use
* @param flags code completion box options. See wxCodeCompletionBox::eOptions
* for possible values
* @param eventObject all events fired by the cc box will have eventObject
* as the event object (wxEvent::GetEventObject())
*/
void ShowCompletionBox(wxStyledTextCtrl* ctrl, const wxCodeCompletionBoxEntry::Vec_t& entries,
const wxCodeCompletionBox::BmpVec_t& bitmaps, size_t flags, int startPos,
wxEvtHandler* eventObject = NULL);
/**
* @brief show the completion box
* @param ctrl the wxSTC control requesting the completion box
* @param tags list of entries to display
* @param flags code completion box options. See wxCodeCompletionBox::eOptions
* for possible values
* @param eventObject all events fired by the cc box will have eventObject
* as the event object (wxEvent::GetEventObject())
*/
void ShowCompletionBox(wxStyledTextCtrl* ctrl, const TagEntryPtrVector_t& tags, size_t flags, int startPos,
wxEvtHandler* eventObject = NULL);
/**
* @brief show the completion box. Language Server Protocol version
*/
void ShowCompletionBox(wxStyledTextCtrl* ctrl, const LSP::CompletionItem::Vec_t& completions, size_t flags = 0,
int startPos = wxNOT_FOUND, wxEvtHandler* eventObject = NULL);
/**
* @brief do we have a completion box shown?
*/
bool IsShown() const { return m_box != NULL; }
/**
* @brief return the code completion box
*/
wxCodeCompletionBox* GetCCWindow() { return m_box; }
};
#endif // WXCODECOMPLETIONBOXMANAGER_H
|