Logo Search packages:      
Sourcecode: ktikz version File versions  Download package

QVector< HighlightingRule > TikzCommandInserter::getHighlightingRules (  )

Returns a vector with the highlighting rules derived from the TikZ commands which are available in the menu/dock widget. These rules are used by TikzHighlighter to highlight the commands in the text.

Returns:
a vector containing the highlighting rules

Definition at line 428 of file tikzcommandinserter.cpp.

References HighlightingRule::pattern.

{
      QVector<HighlightingRule> highlightingRules;
      HighlightingRule rule;

      for (int i = 0; i < m_tikzCommandsList.size(); ++i)
      {
            QString command = m_tikzCommandsList.at(i).command;
            const int type = m_tikzCommandsList.at(i).type;
            int end;
            switch (type)
            {
                  case 1:
                        {
                              const int end1 = command.indexOf(' ', 0);
                              const int end2 = command.indexOf('[', 0);
                              const int end3 = command.indexOf('{', 0);
                              end = end1;
                              if (end < 0 || (end2 >= 0 && end2 < end))
                                    end = end2;
                              if (end < 0 || (end3 >= 0 && end3 < end))
                                    end = end3;
                        }
                        command = command.left(end);
                        command = command.replace('\\', QLatin1String("\\\\"));
                        rule.type = highlightTypeNames.at(0);
                        rule.pattern = QRegExp(command);
                        highlightingRules.append(rule);
                        break;
                  case 2:
//                      command = command.replace("()", "\\([^\\)]*\\)");
//                      command = command.replace("(,)", "\\([^\\)]*\\)");
//                      command = command.replace("(:::)", "\\([^\\)]*\\)");
                        command = command.remove('+');
                        command = command.remove(" ()");
                        command = command.remove(" (,)");
                        command = command.remove(" (:::)");
                        command = command.remove(" {} ");
                        rule.type = highlightTypeNames.at(1);
                        rule.pattern = QRegExp(command);
                        highlightingRules.append(rule);
                        break;
                  case 3:
                        command = command.replace('|', QLatin1String("\\|"));
                        end = command.indexOf('=', 0) + 1;
                        if (end > 0)
                              command = command.left(end);
                        rule.type = highlightTypeNames.at(2);
                        rule.pattern = QRegExp(command);
                        highlightingRules.append(rule);
                        break;
            }
      }

      return highlightingRules;
}

Generated by  Doxygen 1.6.0   Back to index