/[svn]/gigedit/trunk/src/gigedit/scripteditor.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/scripteditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3261 by schoenebeck, Wed May 31 21:11:56 2017 UTC revision 3286 by schoenebeck, Thu Jun 22 10:54:10 2017 UTC
# Line 132  ScriptEditor::ScriptEditor() : Line 132  ScriptEditor::ScriptEditor() :
132      m_commentTag->property_foreground() = "#9c9c9c"; // gray      m_commentTag->property_foreground() = "#9c9c9c"; // gray
133      m_tagTable->add(m_commentTag);      m_tagTable->add(m_commentTag);
134    
135        #define PREPROC_TOKEN_COLOR  "#2f8a33" // green
136    
137      m_preprocTag = Gtk::TextBuffer::Tag::create();      m_preprocTag = Gtk::TextBuffer::Tag::create();
138      m_preprocTag->property_foreground() = "#2f8a33"; // green      m_preprocTag->property_foreground() = PREPROC_TOKEN_COLOR;
139      m_tagTable->add(m_preprocTag);      m_tagTable->add(m_preprocTag);
140    
141        m_preprocCommentTag = Gtk::TextBuffer::Tag::create();
142        m_preprocCommentTag->property_strikethrough() = true;
143        m_preprocCommentTag->property_background() = "#e5e5e5";
144        m_tagTable->add(m_preprocCommentTag);
145    
146      m_errorTag = Gtk::TextBuffer::Tag::create();      m_errorTag = Gtk::TextBuffer::Tag::create();
147      m_errorTag->property_background() = "#ff9393"; // red      m_errorTag->property_background() = "#ff9393"; // red
148      m_tagTable->add(m_errorTag);      m_tagTable->add(m_errorTag);
# Line 343  LinuxSampler::ScriptVM* ScriptEditor::Ge Line 350  LinuxSampler::ScriptVM* ScriptEditor::Ge
350      return m_vm;      return m_vm;
351  }  }
352    
353  static void getIteratorsForIssue(Glib::RefPtr<Gtk::TextBuffer>& txtbuf, const LinuxSampler::ParserIssue& issue, Gtk::TextBuffer::iterator& start, Gtk::TextBuffer::iterator& end) {  template<class T>
354    static void getIteratorsForIssue(Glib::RefPtr<Gtk::TextBuffer>& txtbuf, const T& issue, Gtk::TextBuffer::iterator& start, Gtk::TextBuffer::iterator& end) {
355      Gtk::TextBuffer::iterator itLine =      Gtk::TextBuffer::iterator itLine =
356          txtbuf->get_iter_at_line_index(issue.firstLine - 1, 0);          txtbuf->get_iter_at_line_index(issue.firstLine - 1, 0);
357      const int charsInLine = itLine.get_bytes_in_line();      const int charsInLine = itLine.get_bytes_in_line();
# Line 382  static void applyCodeTag(Glib::RefPtr<Gt Line 390  static void applyCodeTag(Glib::RefPtr<Gt
390      txtbuf->apply_tag(tag, itStart, itEnd);      txtbuf->apply_tag(tag, itStart, itEnd);
391  }  }
392    
393    static void applyPreprocessorComment(Glib::RefPtr<Gtk::TextBuffer>& txtbuf, const LinuxSampler::CodeBlock& block, Glib::RefPtr<Gtk::TextBuffer::Tag>& tag) {
394        Gtk::TextBuffer::iterator itStart, itEnd;
395        getIteratorsForIssue(txtbuf, block, itStart, itEnd);
396        txtbuf->apply_tag(tag, itStart, itEnd);
397    }
398    
399  void ScriptEditor::updateSyntaxHighlightingByVM() {  void ScriptEditor::updateSyntaxHighlightingByVM() {
400      GetScriptVM();      GetScriptVM();
401      const std::string s = m_textBuffer->get_text();      const std::string s = m_textBuffer->get_text();
# Line 421  void ScriptEditor::updateParserIssuesByV Line 435  void ScriptEditor::updateParserIssuesByV
435      m_issues = parserContext->issues();      m_issues = parserContext->issues();
436      m_errors = parserContext->errors();      m_errors = parserContext->errors();
437      m_warnings = parserContext->warnings();      m_warnings = parserContext->warnings();
438        m_preprocComments = parserContext->preprocessorComments();
439    
440      if (!s.empty()) {      if (!s.empty()) {
441          for (int i = 0; i < m_issues.size(); ++i) {          for (int i = 0; i < m_issues.size(); ++i) {
# Line 434  void ScriptEditor::updateParserIssuesByV Line 449  void ScriptEditor::updateParserIssuesByV
449          }          }
450      }      }
451    
452        for (int i = 0; i < m_preprocComments.size(); ++i) {
453            applyPreprocessorComment(m_textBuffer, m_preprocComments[i],
454                                     m_preprocCommentTag);
455        }
456    
457      delete parserContext;      delete parserContext;
458  }  }
459    
# Line 465  void ScriptEditor::updateIssueTooltip(Gd Line 485  void ScriptEditor::updateIssueTooltip(Gd
485              );              );
486              return;              return;
487          }          }
488        }
489    
490        for (int i = 0; i < m_preprocComments.size(); ++i) {
491            const LinuxSampler::CodeBlock& block = m_preprocComments[i];
492            const int firstLine   = block.firstLine - 1;
493            const int firstColumn = block.firstColumn - 1;
494            const int lastLine    = block.lastLine - 1;
495            const int lastColumn  = block.lastColumn - 1;
496            if (firstLine  <= line && line <= lastLine &&
497                (firstLine != line || firstColumn <= column) &&
498                (lastLine  != line || lastColumn  >= column))
499            {
500                m_textView.set_tooltip_markup(
501                    "Code block filtered out by preceding <span foreground=\"" PREPROC_TOKEN_COLOR "\">preprocessor</span> statement."
502                );
503                return;
504            }
505      }      }
506    
507      m_textView.set_tooltip_markup("");      m_textView.set_tooltip_markup("");

Legend:
Removed from v.3261  
changed lines
  Added in v.3286

  ViewVC Help
Powered by ViewVC