User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Code colorisation

  1. #1
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code colorisation

    Hello,
    I search how to color code (text) every X seconds, while the user enter text. I know it's possible to color the code when pressing a button, but the problem is that to color text, a selection is made and the carret is moved. This means that it's impossible to color text while the user enter it...
    But maybe somebody have a solution <img src="/center/images/graemlins/wink.gif" alt="" />

  2. #2
    No Products Registered

    Join Date
    Jun 2006
    Location
    here
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    I don't think "colorisation" is a word, lol

    Also, you don't seem to have uploaded a file, did you mean to?

    but anyway, I think the common method used in MMF apps is to check for syntax as the user types it, so when the text changes, the current carret position / selection is stored, the text nearby is checked and if it matches certain syntax (i.e. is a ( / * Pow etc.) it is selected and recoloured. Then the selection is restored. Most of the time, no action is needed, as the text entered doesn't match a syntax, or is in speach marks, so the user sees nothing, and when some text has to change, the user may see a brief flicker but nothing more.

    I think a version of iPublish was released as open source on the old forums, so try searching there for an example. (I think it used this menthod)

  3. #3
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    Thanks, it seems to be a good approach. I'll search it.

    (Sorry for the word "colorisation", its a French word <img src="/center/images/graemlins/tongue.gif" alt="" />)

    EDIT: I don't find an example but I've just realised a test and it could be possible. I'll post an example when it will be fine. Do you know if it's possible to make selection invisible/visible ?

  4. #4
    No Products Registered

    Join Date
    Jun 2006
    Location
    here
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    Possible methods to make the selection invisible (Note that I haven't tested these, so they probably won't work :P )

    1) Disable the object temporarily. This may result in some graying out though
    2) Put the selection changes in a fastloop (which runs only once) where the actions are to set the selection, then change the colour, then restore the selection. I'm not sure if this will remove the flicker if you use the inbuilt fastloops, but I think cellosoft's fastloop object had some extra actions to change when the screen is redrawn....

    I couldn't find the iPublish example either. Maybe Gizmo can help (I think he's the creator of iPublish) I also recall him saying he was working on a better method than the one in the released version. Maybe you can persuade him to post an example of that.

  5. #5
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    Your method works well. It's ok, I'll post my result soon. i use Regex object. It's a very useful object.
    But their is 3 issues :
    - The selection can be seen some times (but it's really fast)
    - Sometimes, some lines are moved up/down by 1pixel, I don't know why.
    - It could be better to color the line where caret is instead of color a range of caracter around the caret but I don't find how to get the current caret line (I can get carte line number and caret position but not caret line string...)

    Thanks for your Help <img src="/center/images/graemlins/wink.gif" alt="" />

  6. #6
    No Products Registered

    Join Date
    Jun 2006
    Location
    here
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    I'd say the first problem may not have a solution, and the second problem is probably a bug with the component, or may be due to a change in font / style (i.e. I think fonts change height when italic).

    As for the third, I think that's a limitation of the rich edit object. A workaround would be to take a very large string and search for a new line ($newline) using the Regex object and use it as a cut off point.

  7. #7
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    Ok, I'll try to see how to get the caret line with RegEx but I think it's impossible because the selection can contain two or more lines...

    I've found another bug: I parse a string around caret every second but when I scroll down or up, every second, the view return at the caret position. Do you know how to set a non automatic scrolling ?

    thanks again <img src="/center/images/graemlins/wink.gif" alt="" />

  8. #8
    No Products Registered

    Join Date
    Jun 2006
    Location
    here
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    hmm, I would say only apply the checks when the text is modified, not every second.

    Use the condition "Has the text been modified" then the action Control-&gt;Modified-&gt;No to stop it staying true forever.

    I don't think there's a way to stop it scrolling though.

  9. #9
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    You're wonderful. I think it was impossible to reset the modified state. This thing resolve scrollbar problem and selection wich is visible shortly (because it appears only after a modification, so it's not very important).
    Thanks ! I'll post my result soon. <img src="/center/images/graemlins/smile.gif" alt="" />

  10. #10
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Sphax's Avatar
    Join Date
    Jun 2006
    Location
    Paris, France
    Posts
    4,454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Code colorisation

    My example is posted. There is a bug when loading a file, I don't know why... If somebody find why, repost it please <img src="/center/images/graemlins/wink.gif" alt="" />. This example is able to color LUA syntax. <img src="/center/images/graemlins/smile.gif" alt="" />
    It could be improved by interpret the current line only but I don't find how to do that.
    Attached files Attached files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Is there any way to see the code?
    By Valerio in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 25th February 2010, 08:59 PM
  2. RGB into Hex code?
    By Game_Master in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 4th October 2009, 09:37 AM
  3. Using DLL or Code
    By Pegasus_Seiya in forum Extension Development
    Replies: 0
    Last Post: 12th June 2009, 04:43 PM
  4. V-Code Generator Source Code
    By LB in forum File Archive
    Replies: 1
    Last Post: 10th March 2008, 08:52 PM
  5. Colorisation de code temps réel (MMF2 Dev)
    By Sphax in forum File Archive
    Replies: 13
    Last Post: 18th February 2007, 09:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •