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 |
2901 |
#include <gtkmm/uimanager.h> |
16 |
|
|
#include <gtkmm/actiongroup.h> |
17 |
schoenebeck |
2893 |
#include "ManagedWindow.h" |
18 |
schoenebeck |
2604 |
|
19 |
schoenebeck |
2886 |
// Should we use a very simple (and buggy) local NKSP syntax parser, or should |
20 |
schoenebeck |
2899 |
// we rather use the full featured NKSP syntax highlighting backend from |
21 |
schoenebeck |
2886 |
// liblinuxsampler for syntax highlighting of this text editor? |
22 |
|
|
#if HAVE_LINUXSAMPLER |
23 |
|
|
# define USE_LS_SCRIPTVM 1 |
24 |
|
|
#endif |
25 |
|
|
|
26 |
|
|
#if USE_LS_SCRIPTVM |
27 |
schoenebeck |
2896 |
# include <linuxsampler/scriptvm/ScriptVM.h> |
28 |
|
|
# include <linuxsampler/scriptvm/ScriptVMFactory.h> |
29 |
schoenebeck |
2886 |
#endif |
30 |
|
|
|
31 |
schoenebeck |
2893 |
class ScriptEditor : public ManagedWindow { |
32 |
schoenebeck |
2604 |
public: |
33 |
|
|
ScriptEditor(); |
34 |
|
|
~ScriptEditor(); |
35 |
|
|
void setScript(gig::Script* script); |
36 |
schoenebeck |
2893 |
|
37 |
schoenebeck |
2903 |
sigc::signal<void, gig::Script*> signal_script_to_be_changed; |
38 |
|
|
sigc::signal<void, gig::Script*> signal_script_changed; |
39 |
|
|
|
40 |
schoenebeck |
2893 |
// implementation for abstract methods of interface class "ManagedWindow" |
41 |
|
|
virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->scriptEditorWindowX; } |
42 |
|
|
virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->scriptEditorWindowY; } |
43 |
|
|
virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->scriptEditorWindowW; } |
44 |
|
|
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->scriptEditorWindowH; } |
45 |
|
|
|
46 |
schoenebeck |
2604 |
protected: |
47 |
|
|
Gtk::VBox m_vbox; |
48 |
schoenebeck |
2899 |
Gtk::HBox m_footerHBox; |
49 |
|
|
Gtk::HBox m_statusHBox; |
50 |
schoenebeck |
2604 |
Gtk::HButtonBox m_buttonBox; |
51 |
|
|
Gtk::ScrolledWindow m_scrolledWindow; |
52 |
|
|
Glib::RefPtr<Gtk::TextBuffer> m_textBuffer; |
53 |
|
|
Glib::RefPtr<Gtk::TextBuffer::TagTable> m_tagTable; |
54 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_keywordTag; |
55 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_eventTag; |
56 |
schoenebeck |
2886 |
Glib::RefPtr<Gtk::TextBuffer::Tag> m_variableTag; |
57 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_functionTag; |
58 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_numberTag; |
59 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_stringTag; |
60 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_commentTag; |
61 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_preprocTag; |
62 |
schoenebeck |
2890 |
Glib::RefPtr<Gtk::TextBuffer::Tag> m_errorTag; |
63 |
|
|
Glib::RefPtr<Gtk::TextBuffer::Tag> m_warningTag; |
64 |
schoenebeck |
2604 |
Gtk::TextView m_textView; |
65 |
schoenebeck |
2899 |
Gtk::Image m_statusImage; |
66 |
|
|
Gtk::Label m_statusLabel; |
67 |
schoenebeck |
2604 |
Gtk::Button m_applyButton; |
68 |
|
|
Gtk::Button m_cancelButton; |
69 |
|
|
|
70 |
schoenebeck |
2899 |
Glib::RefPtr<Gdk::Pixbuf> m_warningIcon; |
71 |
|
|
Glib::RefPtr<Gdk::Pixbuf> m_errorIcon; |
72 |
|
|
Glib::RefPtr<Gdk::Pixbuf> m_successIcon; |
73 |
|
|
|
74 |
schoenebeck |
2901 |
Glib::RefPtr<Gtk::ActionGroup> m_actionGroup; |
75 |
|
|
Glib::RefPtr<Gtk::UIManager> m_uiManager; |
76 |
|
|
|
77 |
schoenebeck |
2604 |
gig::Script* m_script; |
78 |
schoenebeck |
2886 |
#if USE_LS_SCRIPTVM |
79 |
|
|
LinuxSampler::ScriptVM* m_vm; |
80 |
schoenebeck |
2896 |
std::vector<LinuxSampler::ParserIssue> m_issues; |
81 |
schoenebeck |
2899 |
std::vector<LinuxSampler::ParserIssue> m_errors; |
82 |
|
|
std::vector<LinuxSampler::ParserIssue> m_warnings; |
83 |
schoenebeck |
2886 |
#endif |
84 |
|
|
|
85 |
schoenebeck |
2898 |
bool isModified() const; |
86 |
schoenebeck |
2604 |
void onButtonCancel(); |
87 |
|
|
void onButtonApply(); |
88 |
|
|
void onWindowHide(); |
89 |
|
|
void onTextInserted(const Gtk::TextBuffer::iterator& it, const Glib::ustring& txt, int length); |
90 |
|
|
void onTextErased(const Gtk::TextBuffer::iterator& itStart, const Gtk::TextBuffer::iterator& itEnd); |
91 |
|
|
void onModifiedChanged(); |
92 |
schoenebeck |
2886 |
#if USE_LS_SCRIPTVM |
93 |
|
|
void updateSyntaxHighlightingByVM(); |
94 |
schoenebeck |
2890 |
void updateParserIssuesByVM(); |
95 |
|
|
LinuxSampler::ScriptVM* GetScriptVM(); |
96 |
schoenebeck |
2897 |
void updateIssueTooltip(GdkEventMotion* e); |
97 |
schoenebeck |
2899 |
void updateStatusBar(); |
98 |
schoenebeck |
2886 |
#endif |
99 |
schoenebeck |
2897 |
bool on_motion_notify_event(GdkEventMotion* e); |
100 |
schoenebeck |
2898 |
bool onWindowDelete(GdkEventAny* e); |
101 |
schoenebeck |
2956 |
void onMenuChangeFontSize(); |
102 |
|
|
int currentFontSize() const; |
103 |
|
|
void setFontSize(int size, bool save); |
104 |
schoenebeck |
2604 |
}; |
105 |
|
|
|
106 |
|
|
#endif // GIGEDIT_SCRIPTEDITOR_H |