Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Orion (Archived) » Hi(about a good tutorial)
Hi [message #1266775] Fri, 07 March 2014 23:54 Go to next message
duke vah is currently offline duke vahFriend
Messages: 33
Registered: December 2013
Member
Hi,

I am fascinated by Orion so I want to provide a plugin for my own language.
I could use content assistance and it worked well. However, I could not provide a highlighter. I used documentation but it didn't work for me.
I wonder if there is a good step by step guide with a sample which shows how to highlight some specified keywords.
thanks in advance.
This is my plugin:

<!DOCTYPE html>
<html>
<head>
<script src="plugin.js"></script>
<script type="text/javascript">
/*global window eclipse*/

var provider = new eclipse.PluginProvider();
provider.registerServiceProvider("orion.edit.highlighter",
{
// no service methods
}, {
id: "orion.ump",
contentTypes: { id: "application/ump", extension: ["ump"], "extends": "text/plain"},
patterns: [
{
include: "orion.lib"
}, {
match: "\b(if|while|for|return)\b",
name: "keyword.ump"
}
]
});
provider.connect();
//--------------------------------------------------------
</script>
</head>
<body>
</body>
</html>

[Updated on: Sat, 08 March 2014 00:04]

Report message to a moderator

Re: Hi [message #1268732 is a reply to message #1266775] Mon, 10 March 2014 23:16 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi, you need to change a couple of things (these changes are shown at the bottom):

1. The grammar's contentTypes needs to be an array of strings, a content type cannot be declared in-line here. The snippet below first registers an orion.core.contenttype for the type, and orion.edit.highlighter's contentType then just refers to it as "application/ump".

2. Your \b's need double-escaping (the first '\' escapes the second '\' in the JS string, resulting in one '\' in the string).

provider.registerService("orion.core.contenttype", {}, {
    contentTypes: [
        {
            id: "application/ump",
            "extends": "text/plain",
            name: "ump",
            extension: ["ump"]
        }
    ]
});

provider.registerServiceProvider("orion.edit.highlighter",
    {
        // no service methods
    }, {
        id: "orion.ump",
        contentTypes: ["application/ump"],
        patterns: [
            {
                include: "orion.lib"
            }, {
                match: "\\b(if|while|for|return)\\b",
                name: "keyword.ump"
            }
        ]
    }
);


Grant
Previous Topic:Seeking editor customization advise
Next Topic:Orion editor didn't support Korean language
Goto Forum:
  


Current Time: Sat Apr 27 00:08:10 GMT 2024

Powered by FUDForum. Page generated in 0.03132 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top