UBUNTU: highlighting in Gedit

Kirk
2010-03-15
2013-05-30
  • Kirk

    Kirk - 2010-03-15

    I was inspired by a previous post. Unfortunately I wasnt able to find the file and so I had to create my own. To enable highliting of great cow basic files in gedit copy the following file to $HOME/.local/share/gtksourceview-2.0/cow.lang

    <?xml version="1.0" encoding="UTF-8"?>
    <!-

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the
    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.

    ->
    <language id="cow" _name="Cow" version="2.0" _section="Sources">
      <metadata>
        <property name="mimetypes">text/x-gcbsrc</property>
        <property name="globs">*.gcb</property>
        <property name="line-comment-start">'</property>
      </metadata>

      <styles>
        <style id="keyword" _name="Keyword" map-to="def:keyword"/>
        <style id="type" _name="Data Type" map-to="def:type"/>
        <style id="preprocessor" _name="CompilerDirective" map-to="def:preprocessor"/>
        <style id="storage-class" _name="TimeUnits" map-to="def:type"/>
        <style id="string" _name="String" map-to="def:string"/>
    <style id="decimal" _name="Decimal" map-to="def:decimal"/>
    <style id="comment" _name="Comment" map-to="def:comment"/>

      </styles>

      <default-regex-options case-sensitive="false"/>

      <definitions>

    <context id="cow">
          <include>
    <context ref="keyword"/>
    <context ref="type"/>
    <context ref="preprocessor-keyword"/>
    <context ref="storage-class"/>
    <context ref="string"/>
    <context ref="number"/>
    <context ref="comment"/>

          </include>
        </context>

    <context id="keyword" style-ref="keyword">
          <keyword>ReadAD</keyword>
          <keyword>ADoff</keyword>
          <keyword>EEPROM</keyword>
          <keyword>EPRead</keyword>
          <keyword>EPWrite</keyword>
          <keyword>ProgramErase</keyword>
          <keyword>ProgramWrite</keyword>
          <keyword>ProgramRead</keyword>
          <keyword>CALL EVRY</keyword>
          <keyword>DO</keyword>
          <keyword>END</keyword>
          <keyword>EXIT SUB</keyword>
          <keyword>For</keyword>
    <keyword>to</keyword>
    <keyword>Next</keyword>
          <keyword>Gosub</keyword>
    <keyword>Sub</keyword>

    <keyword>Return</keyword>
          <keyword>Goto</keyword>
          <keyword>If</keyword>
    <keyword>then</keyword>

          <keyword>Repeat</keyword>
          <keyword>Select</keyword>
          <keyword>Wait</keyword>
          <keyword>Print</keyword>
          <keyword>Locate</keyword>
          <keyword>Put</keyword>
          <keyword>Get</keyword>
          <keyword>cls</keyword>
          <keyword>LCDInt</keyword>
          <keyword>LCDHex</keyword>
          <keyword>LCDWord</keyword>
          <keyword>KeypadData</keyword>
          <keyword>KeypadRaw</keyword>
          <keyword>PWMOff</keyword>
          <keyword>PWMOn</keyword>
          <keyword>PWMout</keyword>
          <keyword>HPWM</keyword>
          <keyword>DisplayValue</keyword>
          <keyword>DiusplayChar</keyword>
          <keyword>InitSer</keyword>
          <keyword>SerSend</keyword>
          <keyword>SerReceive</keyword>
          <keyword>SPIMode</keyword>
          <keyword>SPITransfer</keyword>
          <keyword>Tone</keyword>
          <keyword>ShortTone</keyword>
          <keyword>Rotate</keyword>
          <keyword>Set</keyword>
          <keyword>Dim</keyword>
    <keyword>As</keyword>
          <keyword>Dir</keyword>
    <keyword>In</keyword>
    <keyword>Out</keyword>
          <keyword>Pot</keyword>
          <keyword>PULSEOUT</keyword>
          <keyword>PEEK</keyword>
    <keyword>POKE</keyword>
    <keyword>ReadTable</keyword>
    <keyword>InitTimer</keyword>
    <keyword>InitTimer1</keyword>
    <keyword>StartTimer</keyword>
    <keyword>ClearTimer</keyword>
    <keyword>StopTimer</keyword>
        </context>

      <context id="type" style-ref="type">
          <keyword>Bit</keyword>
          <keyword>Byte</keyword>
          <keyword>Word</keyword>
          <keyword>String</keyword>
         </context>

    <define-regex id="preproc-start">^\s*#\s*</define-regex>

    <context id="preprocessor-keyword" style-ref="preprocessor" end-at-line-end="true">
         <start extended="true">
            \%{preproc-start}
            (chip|config|define|def|include|script|int|startup|mem)
            \b
          </start>
        </context>

      <context id="storage-class" style-ref="storage-class">
          <keyword>us</keyword>
          <keyword>10us</keyword>
          <keyword>ms</keyword>
          <keyword>10ms</keyword>
          <keyword>S</keyword>
          <keyword>M</keyword>
          <keyword>H</keyword>
          </context>

    <context id="string" style-ref="string" end-at-line-end="true">
          <start>"</start>
          <end>"</end>
          <!- no escapes possible except for "" = literal "   ->
        <include>
             <context id="string-esc" style-ref="escaped-character" extend-parent="true">
                <match>""</match>
             </context>
           </include>
        </context>

      <context id="number" style-ref="decimal">
          <match extended="true">
            (?&lt;!)
            *(E?*)?
            (?!)
          </match>
        </context>

       <context id="comment" style-ref="comment" end-at-line-end="true">
          <start>'</start>
       </context>

      </definitions>
    </language>

     
  • Nobody/Anonymous

    Thanks!!

    I had one, but this is much better, very complete.

    Best regards.

     

Log in to post a comment.