<glimmer-definition>
   <settings>
      <language>Fortran</language>
      <compiler>glimmerout g77 -g %2 -o %3 2&gt;&amp;1</compiler>
      <debugger>%term% gdb %3</debugger>
      <execution>%term% %1/%3</execution>
      <auto-indent>1</auto-indent>
      <use-spaces>0</use-spaces>
      <tab-stop>6</tab-stop>
   </settings>

   <mime-types>
      <extension>f</extension>
      <extension>for</extension>
      <extension>F</extension>
      <extension>FOR</extension>
      <extension>fpp</extension>
   </mime-types>

   <syntax-items>
      <syntax-item>
         <name>string</name>
         <start-regex>&quot;</start-regex>
         <end-regex>\(&quot;\|\n\)</end-regex>
         <style>string</style>
      </syntax-item>
      <syntax-item>
         <name>singlestring</name>
         <start-regex>&apos;</start-regex>
         <end-regex>\(&apos;\|\n\)</end-regex>
         <style>string</style>
      </syntax-item>
      <syntax-item>
         <name>comment</name>
         <start-regex>\(^[Cc*]\|!\)</start-regex>
         <end-regex>\n</end-regex>
         <style>comment</style>
      </syntax-item>
      <syntax-item>
         <name>preprocessor</name>
         <start-regex>^#</start-regex>
         <end-regex>\n</end-regex>
         <style>preprocessor</style>
      </syntax-item>
      <syntax-item>
         <name>define_comment</name>
         <start-regex>^#if 0</start-regex>
         <end-regex>^#endif</end-regex>
         <style>comment</style>
      </syntax-item>
   </syntax-items>

   <pattern-items>
      <pattern-item>
         <name>function1</name>
         <regex>\(FUNCTION\|SUBROUTINE\|BLOCK\|BLOCKDATA\|PROGRAM\)</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>function2</name>
         <regex>\(function\|subroutine\|block\|blockdata\|program\)</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>types1</name>
         <regex>\(CHARACTER\|COMMON\|COMPLEX\|DIMENSION\|DOUBLE\|EQUIVALENCE\|EXTERNAL\|IMPLICIT\|INTEGER\|INTRINSIC\|KIND\|LOGICAL\|NAMELIST\|NONE\|PARAMETER\|PRECISION\|REAL\)</regex>
         <style>data_type</style>
      </pattern-item>
      <pattern-item>
         <name>types2</name>
         <regex>\(character\|common\|complex\|dimension\|double\|equivalence\|external\|implicit\|integer\|intrinsic\|kind\|logical\|namelist\|none\|parameter\|precision\|real\)</regex>
         <style>data_type</style>
      </pattern-item>
      <pattern-item>
         <name>keywords1</name>
         <regex>\b\(ASSIGN\|BACKSPACE\|CALL\|CASE\|CLOSE\|CYCLE\|DATA\|DO\|ELSE\|ELSEIF\|ENDFILE\|ENDDO\|ENDIF\|END\|EXIT\|FORMAT\|GOTO\|GO\|IF\|INCLUDE\|OPEN\|PAUSE\|READ\|RETURN\|REWIND\|SELECT\|SELECTCASE\|STOP\|THEN\|TO\|WHILE\|WRITE\|CONTINUE\|PRINT\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>keywords2</name>
         <regex>\b\(assign\|backspace\|call\|case\|close\|cycle\|data\|do\|else\|elseif\|endfile\|enddo\|endif\|end\|exit\|format\|goto\|go\|if\|include\|open\|pause\|read\|return\|rewind\|select\|selectcase\|stop\|then\|to\|while\|write\|continue\|print\)\b</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>intrinsic_functions1</name>
         <regex>\b\(ABS\|ACOS\|AIMAG\|AINT\|ASIN\|ATAN\|ATAN2\|BESJ0\|BESJ1\|BESJN\|BESY0\|BESY1\|BESYN\|CHAR\|CMPLX\|CONJG\|COS\|COSH\|DBLE\|DIM\|DPROD\|ERF\|ERFC\|EXP\|GETARG\|IACHAR\|IARGC\|ICHAR\|IMAG\|INDEX\|LEN\|LENTRIM\|LGE\|LGT\|LLE\|LLT\|LOC\|LOG\|LOG10\|MAX\|MIN\|MOD\|NINT\|RAND\|SIGN\|SIN\|SINH\|SQRT\|TAN\|TANH\|TIME\|XOR\)\b</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>intrinsic_functions2</name>
         <regex>\b\(abs\|acos\|aimag\|aint\|asin\|atan\|atan2\|besj0\|besj1\|besjn\|besy0\|besy1\|besyn\|char\|cmplx\|conjg\|cos\|cosh\|dble\|dim\|dprod\|erf\|erfc\|exp\|getarg\|iachar\|iargc\|ichar\|imag\|index\|len\|lentrim\|lge\|lgt\|lle\|llt\|loc\|log\|log10\|max\|min\|mod\|nint\|rand\|sign\|sin\|sinh\|sqrt\|tan\|tanh\|time\|xor\)\b</regex>
         <style>function</style>
      </pattern-item>
      <pattern-item>
         <name>chars</name>
         <regex>\((\|)\|=\)</regex>
         <style>keyword</style>
      </pattern-item>
      <pattern-item>
         <name>operators</name>
         <regex>\(\*\|\/\|&lt;\|&gt;\|==\|/=\|&lt;=\|&gt;=\|%\|+\|-\|,\|\:\)</regex>
         <style>operator</style>
      </pattern-item>
      <pattern-item>
         <name>operators1</name>
         <regex>\(\.AND\.\|\.NOT\.\|\.OR\.\|\.GT\.\|\.LT\.\|\.GE\.\|\.LE\.\|\.EQ\.\|\.NE\.\|\.FALSE\.\|\.TRUE\.\)</regex>
         <style>operator</style>
      </pattern-item>
      <pattern-item>
         <name>operators2</name>
         <regex>\(\.and\.\|\.not\.\|\.or\.\|\.gt\.\|\.lt\.\|\.ge\.\|\.le\.\|\.eq\.\|\.ne\.\)</regex>
         <style>operator</style>
      </pattern-item>
      <pattern-item>
         <name>labels</name>
         <regex>\(^[0-9]+\b\|^ [0-9]+\b\)</regex>
         <style>macro</style>
      </pattern-item>
      <pattern-item>
         <name>hex_numbers</name>
         <regex>#\([0-9A-Fa-f]\)+\b</regex>
         <style>hexidecimal</style>
      </pattern-item>
   </pattern-items>
</glimmer-definition>

<python-definition>
import glimmer

def insert_fortran_comment():
    glimmer.freeze()
    if glimmer.has_selection():
        start = glimmer.selection_start()
        end = glimmer.selection_end()
        file = glimmer.get_file_number()
        glimmer.move(0)
        line1 = glimmer.line_by_pos(start)
        line2 = glimmer.line_by_pos(end)
        cur = line1
        print start
        print end
        while cur <= line2:
           glimmer.move_to_col(0)
           glimmer.move_to_line(cur)
           glimmer.insert("C")
           cur = cur+1
        glimmer.move_to(end+((line2-line1)+1)*2)
    else:
        glimmer.move_to_col(0)
        glimmer.insert("C")
    glimmer.thaw()

glimmer.add_sub_to_menu("_Insert/", "FORTRAN", -1)
glimmer.add_item_to_menu("_Insert/FORTRAN/", "Comment line", "", "", -1, insert_fortran_comment)
glimmer.add_item_to_popup_menu("Comment line", -1, insert_fortran_comment)
</python-definition>
