Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 88 lines (72 sloc) 2.28 KB
* Copyright (C) 2009, Alexander Stigsen,
* This software is licensed under the Open Company License as described
* in the file license.txt, which you should have received as part of this
* distribution. The terms are also available at
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
#ifndef __SNIPPETLIST_H__
#define __SNIPPETLIST_H__
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include "SearchListBox.h"
#include "EditorFrame.h"
#include "tmAction.h"
#include "EditorChangeState.h"
#include <vector>
#include <deque>
class SnippetList : public wxPanel {
SnippetList(EditorFrame& services);
bool Destroy();
bool ScopeChanged(const deque<const wxString*> scope);
void GetCurrentActions();
bool FilterAction(const tmAction*);
void OnIdle(wxIdleEvent& event);
class ActionList : public SearchListBox {
ActionList(wxWindow* parent, wxWindowID id, const wxArrayString& actions);
void SetAllItems();
void Find(const wxString& text, bool refresh=true);
void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
class aItem {
aItem() : id(0), action(NULL), rank(0) {};
aItem(unsigned int id, const wxString* a, const vector<unsigned int>& hl)
: id(id), action(a), hlChars(hl), rank(SearchListBox::CalcRank(hl)) {};
bool operator<(const aItem& ai) const {
if (rank < ai.rank) return true;
else if (rank > ai.rank) return false;
else if (action && ai.action) return *action < *ai.action;
else return false;
unsigned int id;
const wxString* action;
vector<unsigned int> hlChars;
unsigned int rank;
const wxArrayString& m_actions;
vector<aItem> m_items;
wxString m_searchText;
// Member variables
EditorFrame& m_editorFrame;
EditorCtrl* m_editorCtrl;
TmSyntaxHandler& m_syntaxHandler;
// Widgets
ActionList* m_listBox;
deque<const wxString*> m_previousScope;
EditorChangeState m_editorState;
wxArrayString m_bundleStrings;
#endif // __SNIPPETLIST_H__