<settings>
language=Javascript
compiler=
debugger=
execution=
auto_indent=1
use_spaces=0
tab_stop=4
</settings>

<extensions> 
 <item name="javascript file" ext="js">
</extensions> 

<syntax>
 <item name="string" start="\"" end="\(\"\|\n\)" color="string">
 <item name="chars" start="'" end="\(\'\|\n\)" color="char_string">
 <item name="cpps_comment" start="//" end="\n" color="comment">
 <item name="cs_comment" start="/\*" end="\*/" color="comment">
</syntax>

<pattern>
 <item name="numeric_constant" words="<(?i0[X][\\dA-F]+|\\d+(\\.\\d*)?(?:E[+-]?[\\d]+)?F?|\\.\\d+(?:E[+-]?[\\d]+)?F?|[\\d]+[LF]?))" color="character">
 <item name="string_escape" words="(?:\\\\u[\\dA-Faf]{4}|\\\\[0-7]{1,3}|\\\\[btnfr'\"\"\\\\])" color="character">
 <item name="primitive" words="\b\(var\)\b" color="keyword">
 <item name="flow" words="\b\(break\|case\|catch\|continue\|default\|do\|else\|for\|if\|return\|for\|goto\|if\|return\|switch\|switch\|while\)\b" color="keyword">
 <item name="modifiers" words="\b\(finally\|private\|protected\|public\|static\)\b" color="keyword">
 <item name="memory" words="\b\(new\|null\|super\this\|void\)\b" color="keyword">
 <item name="unused" words="\b\(const\|gotol\|transient\)\b" color="keyword">
 <item name="operators" words="\(\*\|-)\|::\|<<\|<\|=\|==\|!=\|<=\|)=\|++\|--\|%\|+\|-\|||\|&&\|!\|+=\|-=\|\*=\|/=\|%=\)" color="operator">
</pattern>

<python>
import glimmer
import string

def js_enter_callback():
    insert = "\n"
    extralen = 0
    slen = 0
    file = glimmer.get_file_number()
    tstart = glimmer.line_start()
    tend = glimmer.current_position()
    if (tend-tstart) > 0:
        chars = glimmer.get_text(tstart, tend)
        slen = len(chars)
        if slen > 0:
            index = 0
            while index < slen:
                c = chars[index]
                if c == '\t' or c == ' ':
                    insert = insert + chars[index]
                    index = index+1
                else:
                    break
            c = chars[slen-1]
            if c == '{':
                extralen = glimmer.get_file_tab_width(file)
                if glimmer.get_file_use_spaces(file):
                    while extralen > 0:
                        insert = insert + " "
                        extralen = extralen-1
                else:
                    insert = insert + '\t'
    glimmer.insert(insert)

glimmer.register_signal_hook("enter-pressed", js_enter_callback)

def js_tab_callback():
   tablen = 0
   insertchars = ""
   file = glimmer.get_file_number()
   if glimmer.get_file_use_spaces(file):
      tablen = glimmer.get_file_tab_width(file)
      pos = glimmer.current_position()
      lstart = glimmer.line_start()
      if pos - lstart > 0:
         str1 = glimmer.get_text(lstart, pos)
      else:
         str1 = ""
      if glimmer.get_tab_stops():
         str1 = string.expandtabs(str1, tablen)
         len1 = len(str1)
         del str1
         tablen = tablen - (len1 % tablen)
      while tablen > 0:
         insertchars = insertchars + " "
         tablen = tablen-1
   else:
      insertchars = insertchars + "\t"
   glimmer.insert(insertchars)

glimmer.register_signal_hook("tab-pressed", js_tab_callback)
</python>
