32 |
} |
} |
33 |
|
|
34 |
ScriptEditor::ScriptEditor() : |
ScriptEditor::ScriptEditor() : |
35 |
m_applyButton(Gtk::Stock::APPLY), m_cancelButton(Gtk::Stock::CANCEL) |
m_applyButton(_("_Apply"), true), |
36 |
|
m_cancelButton(_("_Cancel"), true) |
37 |
{ |
{ |
38 |
m_script = NULL; |
m_script = NULL; |
39 |
|
|
45 |
m_tagTable->add(m_keywordTag); |
m_tagTable->add(m_keywordTag); |
46 |
m_eventTag = Gtk::TextBuffer::Tag::create(); |
m_eventTag = Gtk::TextBuffer::Tag::create(); |
47 |
m_eventTag->property_foreground() = "blue"; |
m_eventTag->property_foreground() = "blue"; |
48 |
|
m_eventTag->property_weight() = PANGO_WEIGHT_BOLD; |
49 |
m_tagTable->add(m_eventTag); |
m_tagTable->add(m_eventTag); |
50 |
m_textBuffer = Gtk::TextBuffer::create(m_tagTable); |
m_textBuffer = Gtk::TextBuffer::create(m_tagTable); |
51 |
m_textView.set_buffer(m_textBuffer); |
m_textView.set_buffer(m_textBuffer); |
52 |
{ |
{ |
53 |
Pango::FontDescription fdesc; |
Pango::FontDescription fdesc; |
54 |
fdesc.set_family("monospace"); |
fdesc.set_family("monospace"); |
55 |
|
#if defined(__APPLE__) |
56 |
|
fdesc.set_size(12 * PANGO_SCALE); |
57 |
|
#else |
58 |
fdesc.set_size(10 * PANGO_SCALE); |
fdesc.set_size(10 * PANGO_SCALE); |
59 |
|
#endif |
60 |
#if GTKMM_MAJOR_VERSION < 3 |
#if GTKMM_MAJOR_VERSION < 3 |
61 |
m_textView.modify_font(fdesc); |
m_textView.modify_font(fdesc); |
62 |
#else |
#else |
124 |
} |
} |
125 |
|
|
126 |
void ScriptEditor::onTextInserted(const Gtk::TextBuffer::iterator& itEnd, const Glib::ustring& txt, int length) { |
void ScriptEditor::onTextInserted(const Gtk::TextBuffer::iterator& itEnd, const Glib::ustring& txt, int length) { |
127 |
printf("inserted %d\n", length); |
//printf("inserted %d\n", length); |
128 |
Gtk::TextBuffer::iterator itStart = itEnd; |
Gtk::TextBuffer::iterator itStart = itEnd; |
129 |
itStart.backward_chars(length); |
itStart.backward_chars(length); |
130 |
|
|
140 |
} |
} |
141 |
|
|
142 |
Glib::ustring s = m_textBuffer->get_text(itWordStart, it, false); |
Glib::ustring s = m_textBuffer->get_text(itWordStart, it, false); |
143 |
printf("{%s}\n", s.c_str()); |
//printf("{%s}\n", s.c_str()); |
144 |
if (isKeyword(s)) |
if (isKeyword(s)) |
145 |
m_textBuffer->apply_tag(m_keywordTag, itWordStart, it); |
m_textBuffer->apply_tag(m_keywordTag, itWordStart, it); |
146 |
else if (isEvent(s)) { |
else if (isEvent(s)) { |
167 |
} |
} |
168 |
|
|
169 |
void ScriptEditor::onTextErased(const Gtk::TextBuffer::iterator& itStart, const Gtk::TextBuffer::iterator& itEnd) { |
void ScriptEditor::onTextErased(const Gtk::TextBuffer::iterator& itStart, const Gtk::TextBuffer::iterator& itEnd) { |
170 |
printf("erased\n"); |
//printf("erased\n"); |
171 |
Gtk::TextBuffer::iterator itStart2 = itStart; |
Gtk::TextBuffer::iterator itStart2 = itStart; |
172 |
if (itStart2.inside_word() || itStart2.ends_word()) |
if (itStart2.inside_word() || itStart2.ends_word()) |
173 |
itStart2.backward_word_start(); |
itStart2.backward_word_start(); |