Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Issues with QSyntaxHighlighter (Or Regular Expressions?)
Forum Updated to NodeBB v4.3 + New Features

Issues with QSyntaxHighlighter (Or Regular Expressions?)

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dimbreath
    wrote on last edited by
    #1

    Well, so i've made my syntax highlighter with the regular expressions from the Qt site. (Did i say regular expressions don't want to be my friends?)

    Whatever, it works fine. But i keep having those issues:

    !http://i.imgur.com/PSrgU.png()!

    As you can see, single line comment works fine. (I haven't done multi-line. Seems a big more challenging.) But whatever, it has some "issues". (Which are strange!)

    For example, i have some keywords like goto, break, new, they show fine, in the single line comment color. But what about if? It's showing on blue! Something is wrong there.

    @ QStringList m_keywordList;
    m_keywordList << "\bgoto\b" << "\bbreak\b" << "\bnew\b" << "\bif\b";
    foreach(const QString &m_keyword, m_keywordList) {
    m_highlightData.insert(m_keyword, m_keywordFormat);
    }@

    Second issue, on #define. Yes, works fine. If you see the last quote after Hello, it's on the quotation color instead of the green text.

    @ QStringList m_preprocessorList;
    m_preprocessorList << "#define";
    foreach(const QString &m_preprocessor, m_preprocessorList) {
    m_highlightData.insert("" + m_preprocessor + "[^\n]*\b", m_preprocessorFormat);
    }@

    Third issue. Here, we're looking at quotation format. Displays fine, except for the numbers. Different color.

    @m_highlightData.insert("[0-9]", m_numberFormat);
    m_highlightData.insert("".*"", m_quotesFormat);@

    Did i mention regular expressions doesn't like me? Well. What's the issue? I suppose the regular expressions, but why?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dimbreath
      wrote on last edited by
      #2

      The first issue was because of the \n, it should be \n.
      The second issue was because of the \n, it should be \n and the \b, doesn't have to be there. (Though it has the same issue as the quotation, but only with keywords)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved