1 |
schoenebeck |
2604 |
/* |
2 |
schoenebeck |
2886 |
Copyright (c) 2014-2016 Christian Schoenebeck |
3 |
schoenebeck |
2604 |
|
4 |
|
|
This file is part of "gigedit" and released under the terms of the |
5 |
|
|
GNU General Public License version 2. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef GIGEDIT_SCRIPTEDITOR_H |
9 |
|
|
#define GIGEDIT_SCRIPTEDITOR_H |
10 |
|
|
|
11 |
|
|
#include <gig.h> |
12 |
|
|
#include <gtkmm.h> |
13 |
schoenebeck |
2886 |
#include <config.h> |
14 |
schoenebeck |
2604 |
#include "compat.h" |
15 |
schoenebeck |
2893 |
#include "ManagedWindow.h" |
16 |
schoenebeck |
2604 |
|
17 |
schoenebeck |
2886 |
// Should we use a very simple (and buggy) local NKSP syntax parser, or should |
18 |
|
|
// we rather use the full features NKSP syntax highlighting backend from |
19 |
|
|
// liblinuxsampler for syntax highlighting of this text editor? |
20 |
|
|
#if HAVE_LINUXSAMPLER |
21 |
|
|
# define USE_LS_SCRIPTVM 1 |
22 |
|
|
#endif |
23 |
|
|
|
24 |
|
|
#if USE_LS_SCRIPTVM |
25 |
schoenebeck |
2896 |
# include <linuxsampler/scriptvm/ScriptVM.h> |
26 |
|
|
# include <linuxsampler/scriptvm/ScriptVMFactory.h> |
27 |
schoenebeck |
2886 |
#endif |
28 |
|
|
|
29 |
schoenebeck |
2893 |
class ScriptEditor : public ManagedWindow { |
30 |
schoenebeck |
2604 |
public: |
31 |
|
|
ScriptEditor(); |
32 |
|
|
~ScriptEditor(); |
33 |
|
|
void setScript(gig::Script* script); |
34 |
schoenebeck |
2893 |
|
35 |
|
|
// implementation for abstract methods of interface class "ManagedWindow" |
36 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->scriptEditorWindowX; } |
37 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->scriptEditorWindowY; } |
38 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->scriptEditorWindowW; } |
39 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->scriptEditorWindowH; } |
40 |
|
|
|
41 |
schoenebeck |
2604 |
protected: |
42 |
|
|
Gtk::VBox m_vbox; |
43 |
|
|
Gtk::HButtonBox m_buttonBox; |
44 |
|
|
Gtk::ScrolledWindow m_scrolledWindow; |
45 |
|
|
Glib::RefPtr<Gtk::TextBuffer> m_textBuffer; |
46 |
|
|
Glib::RefPtr<Gtk::TextBuffer::TagTable> m_tagTable; |
47 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_keywordTag; |
48 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_eventTag; |
49 |
schoenebeck |
2886 |
Glib::RefPtr<Gtk::TextBuffer::Tag> m_variableTag; |
50 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_functionTag; |
51 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_numberTag; |
52 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_stringTag; |
53 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_commentTag; |
54 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_preprocTag; |
55 |
schoenebeck |
2890 |
Glib::RefPtr<Gtk::TextBuffer::Tag> m_errorTag; |
56 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_warningTag; |
57 |
schoenebeck |
2896 |
Glib::RefPtr<Gtk::TextBuffer::Tag> m_readOnlyTag; |
58 |
schoenebeck |
2604 |
Gtk::TextView m_textView; |
59 |
|
|
Gtk::Button m_applyButton; |
60 |
|
|
Gtk::Button m_cancelButton; |
61 |
|
|
|
62 |
|
|
gig::Script* m_script; |
63 |
schoenebeck |
2886 |
#if USE_LS_SCRIPTVM |
64 |
|
|
LinuxSampler::ScriptVM* m_vm; |
65 |
schoenebeck |
2896 |
std::vector<LinuxSampler::ParserIssue> m_issues; |
66 |
schoenebeck |
2886 |
#endif |
67 |
|
|
|
68 |
schoenebeck |
2896 |
bool m_ignoreEraseEvents; |
69 |
|
|
|
70 |
schoenebeck |
2604 |
void onButtonCancel(); |
71 |
|
|
void onButtonApply(); |
72 |
|
|
void onWindowHide(); |
73 |
|
|
void onTextInserted(const Gtk::TextBuffer::iterator& it, const Glib::ustring& txt, int length); |
74 |
|
|
void onTextErased(const Gtk::TextBuffer::iterator& itStart, const Gtk::TextBuffer::iterator& itEnd); |
75 |
|
|
void onModifiedChanged(); |
76 |
schoenebeck |
2886 |
#if USE_LS_SCRIPTVM |
77 |
schoenebeck |
2896 |
void removeIssueAnchors(); |
78 |
schoenebeck |
2886 |
void updateSyntaxHighlightingByVM(); |
79 |
schoenebeck |
2890 |
void updateParserIssuesByVM(); |
80 |
|
|
LinuxSampler::ScriptVM* GetScriptVM(); |
81 |
schoenebeck |
2886 |
#endif |
82 |
schoenebeck |
2604 |
}; |
83 |
|
|
|
84 |
|
|
#endif // GIGEDIT_SCRIPTEDITOR_H |