Results 1 to 6 of 6

Thread: two questions

  1. #1
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default two questions

    I'm using QSyntaxHighlighter (surprise surprise), and i am having two problems (so far..)

    1. i want to differentiate a function call from a function declaration . i used the example in the documentation and it doesn't differ the two (since it function as letter/digits followed by (). i need to set it to also require a set of letters/digits before the first set). what would be the RegExp for that?

    2. i want to insert a tab character (for instance) in the beginning of the line on certain occasions from the highlightBlock. i tried to append a string to currentBlock.text but it didn't really do anything..

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: two questions

    Quote Originally Posted by jajdoo View Post
    i want to differentiate a function call from a function declaration . i used the example in the documentation and it doesn't differ the two (since it function as letter/digits followed by (). i need to set it to also require a set of letters/digits before the first set). what would be the RegExp for that?
    Why would you want to do that? Anyway, you should probably come up with the regexp yourself...
    Last edited by franz; 18th July 2010 at 19:23.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: two questions

    err.. right...

    so can someone help with appending some text at the beginning/end of a text block?

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: two questions

    A function declaration contains a return type and, if there are arguments, it contains types as arguments. A function call returns an instance of a type, and is passed instances of types as its arguments, if any.

    You need to build an actual parser with a symbol table to differentiate between these effectively. There is no bulletproof way to accomplish this with regular expressions, since C++ allows the user to declare their own types.

    This assumes you're trying to highlight C++. Other languages may differ in various ways.

  5. #5
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: two questions

    Quote Originally Posted by jajdoo View Post
    so can someone help with appending some text at the beginning/end of a text block?
    Sure. What did you try before?
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  6. #6
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: two questions

    i decided to try and +1 BlockState per '{' and -1 it per '}' in order to indent the code appropriately(much like the multi-line comment in the code editor example), but couldn't find how/where to insert the tabs in the beginning of the block..

    tried append a string to currentBlock.text but couldn't find where to "put it back in" (as it isn't a reference it seems)
    Last edited by jajdoo; 18th July 2010 at 21:23.

Similar Threads

  1. 2 Questions
    By kingfinn in forum Qt Programming
    Replies: 4
    Last Post: 12th March 2010, 17:00
  2. Some questions for Qt?
    By tszzp in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2009, 09:46
  3. Several questions
    By zlatko in forum Qt Tools
    Replies: 3
    Last Post: 25th May 2007, 08:47

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.