locked
Custom coloring using MPF RRS feed

  • Question

  • The documentation mentions the following for creating custom colorable items:

    - Set RequestStockColors to 0 or leave it untouched (Left it untouched)
    - Define your own ColorableItems in the constructor of LanguageService
    - Override GetItemCount and GetColorableItem methods of LanguageService

    I followed the above steps and still the custom colorable items do not show up in Fonts and Colors property page on Options dialog box. I made sure that the names of the colorable items are different from the existing ones.

    I am using October RTM version of SDK.

    What else needs to be done?

    Thanks in advance.

     

    Tuesday, December 6, 2005 9:23 PM

Answers

  • Vinay,

    How many colors are you adding?  There are six default colorable items (Text, Keyword, Comment, Identifier, String, Number).  If you are setting less than six, can you try adding the default six to the beginning of your list? 

    Also, did you try running the reset tool mentioned in the documentation? vsregex.exe GetOrig 8.0 Exp

    As for your second question, you do not need to implement a Colorizer to colorize your code, but you do need to implement a Scanner.  The documentation you mentioned talks about this in the section: The Colorizer class and the Scanner

    Let me know if you still have problems.

    Thanks,

    Dylan
    Friday, December 9, 2005 6:59 PM

All replies

  • Vinay,

    Have you tried setting a break point in your code to see if the GetColorableItem method is being called?

    Also, have you tried running devenv /setup?

    Thanks,

    Dylan
    Wednesday, December 7, 2005 10:18 PM
  • Dylan,

    Thanks for your reply. I am sorry I could not reply yesterday, I was out of office.
    The GetColorableItem's break point does not hit. However, I have noticed couple of times that GetItemCount method was hit.

    I ran devenv/setup and then ran the program again. However, the custom color items still don't show up.

    It seems I have missed something. Do we need to write our own Colorizer and override ColorizeLine method in this case? I noticed that in one of the places in documentation it mentions that.
     
    I am running the VSPackage in debug mode.

    I followed the procedure mentioned in this documentation item to create my sample. I am not sure, if it would be accessible via link. The title of the help item is Syntax Highlighting (Managed Package Framework).

    ms-help://MS.VSIPCC.v80/MS.VSSDK.v80/dv_search/html/1ca1736a-f554-42e4-a9c7-fe8c3c1717df.htm

    Thanks for your help.

    Best Regards,
    Vinay Ahuja

    Friday, December 9, 2005 4:55 PM
  • Vinay,

    How many colors are you adding?  There are six default colorable items (Text, Keyword, Comment, Identifier, String, Number).  If you are setting less than six, can you try adding the default six to the beginning of your list? 

    Also, did you try running the reset tool mentioned in the documentation? vsregex.exe GetOrig 8.0 Exp

    As for your second question, you do not need to implement a Colorizer to colorize your code, but you do need to implement a Scanner.  The documentation you mentioned talks about this in the section: The Colorizer class and the Scanner

    Let me know if you still have problems.

    Thanks,

    Dylan
    Friday, December 9, 2005 6:59 PM
  • Dylan,

    Thanks for your response.

    I added the default 6 colors in the ColorableItem array in the beginning and it worked. Is that mandatory?

    Vinay


    Tuesday, December 13, 2005 8:16 PM
  • Yes it is.  Feel free to file a suggestion if you think that should change.  You can file a suggestion here:

    http://lab.msdn.microsoft.com/productfeedback/Default.aspx

    Glad that is working for you.

    Dylan
    Wednesday, December 14, 2005 4:07 PM
  • Thank you Dylan.

    Regards,

    Vinay
    Wednesday, December 14, 2005 7:22 PM
  • You've probably figured this by now, but the color index supplied by GetColorableItem() is 1-based i.e. you'll never get asked for item 0. 

     

     

    Thursday, December 15, 2005 6:37 PM
  • To continue with the custom coloring discussion, I thought it would be appropriate to ask this question on this thread itself.

    As mentioned in the previous post, I have defined ColorableItems for the custom colors. One of the parameters in ColorableItem constructor is FONTFLAGS. Now,  FONTFLAGS has only got flags for BOLD, DEFAULT, and STRIKETHROUGH.

     Is there a way to underline a token? Is there a possibility to extend the flag options?

    Thanks,

    Vinay

    Friday, December 16, 2005 3:28 PM
  • Vinay,

    This is just from my experience and isn't a definitive answer. Although you can set STRIKETHROUGH and it works, there is no UI option to allow users to configure this, so if they try to change the color, then you'll lose the strike thru.

    There isn't anyway to do underline as far as I'm aware, which is an odd omission, but you could try all the other flag combinations and see if anything shows up. However, you'll have the same problem when users customize the colors

     

     

    Friday, December 16, 2005 3:37 PM
  • Mark,

    You are right. I have observed this as well, that strikethrough option is available through the SDK but not in the Options dialog, which is kind of inconsistent.

    What I am trying to find out is - If there is a way to implement Underline (or custom formatting options for fonts) ourselves by extending any class.

    Thanks anyways.

    Regards,

    Vinay

    Friday, December 16, 2005 3:50 PM
  • You can add an underline some text by creating a text marker and setting the appropriate attributes.  Currently there is no way to always underline text.  Please let me know if you have trouble doing this.  Also, feel free to log a bug about the strikethrough not being available in the fonts and colors dialog.

    Thanks,

    Dylan

    Friday, December 16, 2005 4:45 PM
  • Dylan,

    Can you point me to the procedure or a sample for implementing a text marker. I could not find anything in the documentation.

    Thanks in advance.

    Regards,

    Vinay

    Friday, December 16, 2005 10:05 PM
  • To get custom colors you also have to also tell the LanguageService you support custom colors by setting the RequestStockColors to 0 under HKLM\Software\Microsoft\VisualStudio\8.0\Languages\Language Services\YourLanguage.

     

    Wednesday, December 21, 2005 6:28 AM
  • We have added the 6 default colorable items to be our first six items that are returned as well.. but our added ones are still not showing up in Tools->Options... Do we have to use specific names for the first 6 for this to work??
    Thursday, January 18, 2007 7:38 PM