extend javascript highlighting with a few extra keywords.

804 views
Skip to first unread message

Pedro Bakster

unread,
Apr 2, 2015, 6:41:46 PM4/2/15
to ace-d...@googlegroups.com
Is it possible to add a few keywords on the fly  the mode.javascript.js information on the fly.

My program allows the user to add different objects to the world say a cow or a catapult.
I would like those to light up with some color it doesn't matter which one really.

I was using editArea previously and to do this I simply had to get access to the keywords array and add a few items to the array.
it was something like editAreaLoader.load_syntax.js.keywords.push("cow","catapult");
so it was pretty simple.

Is there a way to do something like that in ACE?

Thank you,

Harutyun Amirjanyan

unread,
Apr 3, 2015, 6:20:53 PM4/3/15
to ace-d...@googlegroups.com

Pedro Bakster

unread,
Apr 4, 2015, 2:32:14 AM4/4/15
to ace-d...@googlegroups.com
Sorry I left out two lines in the code above. I hav the ace-builds-master on my desktop with my html file also on the desktop

<script src="ace-builds-master/src/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace-builds-master/src/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>

I'm using the code from the src folder and not the no-conflict folder.
I'm not sure what you mean by using ace.require

What is the proper way to setup ace for running this code below that you suggested?

I'm getting require errors and $ not being recognized errors when trying to add the code from this post
http://stackoverflow.com/questions/22166784/dynamically-update-syntax-highlighting-mode-rules-for-the-ace-editor

Thank you,

Pedro Bakster

unread,
Apr 4, 2015, 3:02:56 PM4/4/15
to ace-d...@googlegroups.com
Sorry somehow my posts got mixed up.  I'm trying to run the code you suggested but do not know how to setup ace properly to use require.
Reply all
Reply to author
Forward
0 new messages