Results 1 to 4 of 4

Thread: highlighting text between the same symbols

  1. #1
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default highlighting text between the same symbols

    Hi,

    Untill now, it was rather easy to find my way highlighting things like C++ comments in QTextEdit, or whatever text inside different symbols, i.e between "<" and ">" on sereral lines with the states mechanism.

    Now, I wanted to highlight things between the same symbol, i.e ''' and ''' (like trible simple strings in Python). The problem is that the 2 regexps matches the same symbol and so the same positions. The end and start symbols may or not be on the same line.

    Does someone have any idea on how to solve such things ?
    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: highlighting text between the same symbols

    don't use regexps, but a normal state machine...?

  3. #3
    Join Date
    May 2007
    Posts
    22
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: highlighting text between the same symbols

    I'm sorry about my ignorance on the subject Edulco, but I initially though QSyntaxHighlighter was a state machine. Am I wrong ? If so, where can I find some "simple" articles on the this ?

    Thanks.

  4. #4
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: highlighting text between the same symbols

    no, it helps you to maintain a state machine.

    Look at the implementation of "/*" in the examples, and assign the state 2, to the state found between "<>". This means that if you find "<", set the state to "2" and when you see ">" set the state to "0", since "1" is comment... well, you know how the rest goes.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. KDE 3.5.0 crash while opening project
    By MarkoSan in forum KDE Forum
    Replies: 2
    Last Post: 19th October 2007, 16:21
  4. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.