New Language, start from existing one? (Import to user defined language)

jwka
2014-01-26
2014-02-08
  • jwka

    jwka - 2014-01-26

    Hi,

    I am trying to "modify" an existing color scheme for a language (PHP). I want to have certain keywords being highlighted differently to the "built in" set, also I want to have some more "enrichments".

    Seems that one cannot overwrite or combine a personal set and a standard set.

    Therefor, I would like to simply start on the existing set for PHP and "import" it to the user language definition including my changes to the PHP set).

    Is that possible? If so, how can I do it?

    Thanks for any help in advance.

     
    Last edit: jwka 2014-01-26
  • Loreia2

    Loreia2 - 2014-01-27

    Hi jwka,

    this is not possible and never can be because UDL does not match keyword groups of built-in Scintilla languages. You need to create your language from scratch.

    BR,
    Loreia

     
  • mzvarik

    mzvarik - 2014-01-28

    Hey Loreia,
    do you think it's possible to change comment start/end syntax?
    I know it is stored in langs.xml like this:
    <Language name="php" ext="php php3 phtml" commentLine="//" commentStart="/*" commentEnd="*/">

    I tryed changing it, but it doesn't reflect anything... perhaps it's also within the built-in Scintilla?

    Thanks,
    Martin

     
  • mzvarik

    mzvarik - 2014-01-28

    Btw. there are plugins like "Quick Color Picker" which highlight content that was already highlighted using built-in parser... so it is possible to add new highlighting within current one, just don't know how.

     
    • Loreia2

      Loreia2 - 2014-01-29

      Well, that requires writing a plugin, which is a non trivial task.

      BR,
      Loreia

       
  • Loreia2

    Loreia2 - 2014-01-29

    Hi Martin,

    I know Scintilla supports custom strings for comments, but Notepad++ does not expose this functionality to user. You will have to scan Scintilla documentation (http://www.scintilla.org/ScintillaDoc.html), and then find a way to send Scintilla messages to Notepad++ through Python plugin.

    There are simple examples on Notepad++ wiki but I can't find it right now (tried 10 minutes of Google-ing with no luck). I hope cchris will see this and provide the link.

    BR,
    Loreia

     
  • cchris

    cchris - 2014-02-08

    Some lexers for built-in languages provide properties that you can set for this purpose. For instance, C++ provides the following, excerpted from https://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Built-in_Languages#C.2B.2B:

    fold.cpp.comment.explicit
    Set to 1 (default) to fold on explicit foldable comments, else 0.
    fold.cpp.comment.multiline
    Set to 1 (default) to fold on multiline comments, else 0.
    fold.cpp.explicit.anywhere
    Set to 1 to enable explicit fold points anywhere, else 0 (default).
    fold.cpp.explicit.end
    Alternate end string for explicit fold points, defaults to "".
    fold.cpp.explicit.start
    Alternate start string for explicit folding points, defaults to "".

    N++ ignores these properties, but you can set them by sending the proper SCI_SETPROPERTY messages to the current Scintilla. Python Script can do that indeed.

    Since you send to a specific Scintilla, you'll need to send the message to both views.

    Since these properties have specific language based names, changing the current language b going to another document shouldn't reset them. Not tested.

    CChris