Board index FlightGear Development Nasal

Nasal highlighter for Gedit

Nasal is the scripting language of FlightGear.

Nasal highlighter for Gedit

Postby Philosopher » Mon Aug 13, 2012 3:55 pm

Hello all,

Here is a highlighter for Nasal and Gedit, just drop it into gtksourceview-2.0/lanugage-specs, wherever you may happen to have that, in a file called "nasal.lang" (the name can be anything, really).

On mac the folder is Applications/gedit/Contents/Resources/share/gtksourceview-X.X/language specs (usually, it's the newest version - should be 3.0 for now). To go there, open up gedit and in the file browser go to "File System." From there go to Applications, find gedit in the list (hit "g" to highlight it) and double-click on that. From there, double-click on Contents, then Resources, then share, gtksourceview-2.0, and finally language-specs. Then create a new file called "nasal.lang" and paste the code into there. Done! (Make sure you restart gedit to allow the changes to take effect) On Linux the path is /usr/share/gtksourceview-X.X/language-specs/

Please tell me where the folders are for other OS's, as I don't use that.... that.... that <mu>soft product anymore. Also, please tell me what I can improve! I love feedback :)!

Note: due to a phpBB bug, the follow code blocks are indented by about four spaces (with 2-space tabulations), and this will cause an XML error. Set tab with to 4 in preferences and use shift+tab to remove the indenting, once the whole file is pasted into gedit and selected.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!--

 Copyright (C) 2013 Philosopher
 Author: Philosopher (Flightgear forums)

 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="nasal" _name="Nasal" version="2.0" _section="Scripts">
  <metadata>
    <property name="globs">*.nas</property>
    <property name="line-comment-start">#</property>
  </metadata>

  <styles>
    <style id="module-handler"    _name="Module Handler"        map-to="def:preprocessor"/>
    <style id="keyword"           _name="Keyword"               map-to="def:keyword"/>
    <style id="blockoid"          _name="Blockoid"              map-to="def:keyword"/>
    <style id="operator"          _name="Operator"              map-to="def:operator"/>

    <style id="builtin-constant"  _name="Builtin Constant"      map-to="def:special-constant"/>
    <style id="builtin-object"    _name="Builtin Object"        map-to="def:type"/>
    <style id="node-object"       _name="Flightgear Node"       map-to="def:type"/>
    <style id="builtin-function"  _name="Builtin Function"      map-to="def:builtin"/>

    <style id="boolean"           _name="Boolean"               map-to="def:boolean"/>
    <style id="floating-point"    _name="Floating point number" map-to="def:floating-point"/>
    <style id="decimal"           _name="Decimal number"        map-to="def:decimal"/>
    <style id="base-n-integer"    _name="Base-N number"         map-to="def:base-n-integer"/>
    <style id="special-variable"  _name="Special Variable"      map-to="def:preprocessor"/><!-- def:identifier -->
    <style id="string-conversion" _name="String conversion numeric"/>

    <style id="string"            _name="String"                map-to="def:string"/>
    <style id="escaped-char"      _name="Escaped Character"     map-to="def:special-char"/>
    <style id="format"            _name="Format"                map-to="def:special-char"/>
    <style id="path"              _name="Path"                  map-to="def:type"/>
    <style id="types"             _name="Type Object"           map-to="def:type"/>
  </styles>

  <definitions>
    <!-- Basic lexing constructs: -->
    <define-regex id="identifier">[_a-zA-Z][_a-zA-Z0-9]*</define-regex>
    <define-regex id="number">[1-9][0-9]*</define-regex>
    <context id="number" style-ref="decimal">
      <match>(?&lt;![0-9a-zA-Z])(0x[0-9a-fA-F]+|([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?)</match>
    </context>

    <!-- Builtin Nasal keyword-operators -->
    <context id="keyword" style-ref="keyword">
      <keyword>and</keyword>
      <keyword>or</keyword>
      <keyword>var</keyword>
      <keyword>return</keyword>
      <keyword>break(\s+[_a-zA-Z]\w*)?</keyword>
      <keyword>continue(\s+[_a-zA-Z]\w*)?</keyword>
    </context>

    <!-- Builtin Nasal blockoids -->
    <context id="blockoid" style-ref="blockoid">
      <keyword>while</keyword>
      <keyword>for</keyword>
      <keyword>foreach</keyword>
      <keyword>forindex</keyword>
      <keyword>if</keyword>
      <keyword>elsif</keyword>
      <keyword>else</keyword>
      <keyword>func</keyword>
    </context>

    <context id="builtin-constants" style-ref="builtin-constant">
      <prefix>(?&lt;![\w\.])</prefix> <!-- look behind for anything but a word or period as a prefix, e.g. a space or tab -->
      <keyword>nil</keyword>
      <keyword>math\.e</keyword>
      <keyword>math\.pi</keyword>
      <!-- Flightgear global constants from globals.nas -->
      <keyword>D2R</keyword>
      <keyword>R2D</keyword>
      <keyword>FT2M</keyword>
      <keyword>M2FT</keyword>
      <keyword>IN2M</keyword>
      <keyword>M2IN</keyword>
      <keyword>NM2M</keyword>
      <keyword>M2NM</keyword>
      <keyword>KT2MPS</keyword>
      <keyword>MPS2KT</keyword>
      <keyword>LB2KG</keyword>
      <keyword>KG2LB</keyword>
      <keyword>GAL2L</keyword>
      <keyword>L2GAL</keyword>
      <!-- Non-official -->
      <keyword>FG_ROOT</keyword>
      <keyword>FG_HOME</keyword>
      <keyword>MODEL_PATH</keyword>
    </context>

    <!-- Other operators -->
    <context id="operators" style-ref="operator" extend-parent="false">
      <match>[-~+*/!=?&lt;&gt;]</match>
    </context>


    <!-- Strings: -->

    <context id="format" style-ref="format" extend-parent="false">
      <match extended="true">
        %                       # leading % sign
        [#0\-\ \+]*             # conversion flags
        (\-?\%{number})?        # minimum field width
        (\.(\-?\%{number}))?    # precision
        [%sdicouxXeEfFgG]       # conversion type
      </match>
    </context>
    <context id="escaped-char" style-ref="escaped-char" extend-parent="true">
      <match extended="true">
        \\(                 # leading backslash
        [\\"abfnrtv]      | # single escaped char
        N\{[A-Z\ ]+\}     | # named unicode character
        u[0-9A-Fa-f]{4}   | # xxxx - character with 16-bit hex value xxxx
        U[0-9A-Fa-f]{8}   | # xxxxxxxx - character with 32-bit hex value xxxxxxxx
        x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh
        [0-7]{1,3}          # \ooo - character with octal value ooo
        )
      </match>
    </context>
    <context id="double-escaped-char" style-ref="escaped-char" extend-parent="true">
      <match extended="true">
        \\\\(               # double leading backslash
        \\"               | # escaped quote (needs an extra backslash)
        [\\abfnrtv]       | # single escaped char
        N\{[A-Z\ ]+\}     | # named unicode character
        u[0-9A-Fa-f]{4}   | # xxxx - character with 16-bit hex value xxxx
        U[0-9A-Fa-f]{8}   | # xxxxxxxx - character with 32-bit hex value xxxxxxxx
        x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh
        [0-7]{1,3}          # \ooo - character with octal value ooo
        )
      </match>
    </context>

    <context id="object-types" style-ref="builtin-object">
      <prefix>(?&lt;=['"])</prefix> <!-- look behind for ' or " as a prefix -->
      <suffix>(?=['"])</suffix> <!-- look ahead for ' or " as a suffix -->
      <keyword>func</keyword>
      <keyword>code</keyword><!-- not official -->
      <keyword>hash</keyword>
      <keyword>scalar</keyword>
      <keyword>vector</keyword>
      <keyword>nil</keyword>
      <keyword>ghost</keyword>
      <!-- GitHub/AndyRoss/Nasal or Gitorious/nasal-standalone -->
      <keyword>iofile</keyword>
      <keyword>cairo</keyword>
      <keyword>cairo_surface</keyword>
      <keyword>GObject</keyword>
      <keyword>regex</keyword>
      <keyword>sqlite_db</keyword>
      <keyword>sqlite_statement</keyword>
      <keyword>dir</keyword>
      <!-- SimGear -->
      <keyword>prop</keyword>
      <!-- FlightGear -->
      <keyword>positioned</keyword>
      <keyword>airport</keyword>
      <keyword>aircraft</keyword>
      <keyword>helipad</keyword>
    </context>

    <define-regex id="property-path" extended="true">
      ( # optional first (root) node
        [a-zA-Z] # first character has to be an alpha
        [-a-zA-Z0-9_]* # now it can be alpha, hyphen, or number, repeat this
        (?:\[ # optional index specifier like this: [90]
            (?:[0-9]+)
         \])?
      )?
      / # require a slash
      ( # middle node(s)
        [a-zA-Z] # first character has to be an alpha
        [-a-zA-Z0-9_]* # now it can be alpha, hyphen, or number, repeat this
        (?:\[ # optional index specifier like this: [90]
            (?:[0-9]+)
         \])?
         / # slash to separate nodes
      )* # repeat or none
      ( # last element, doesn't require a slash at the end
        [a-zA-Z] # first character has to be an alpha
        [-a-zA-Z0-9_]* # now it can be alpha, hyphen, or number, repeat this
        (?:\[ # optional index specifier like this: [90]
            (?:[0-9]+)
         \])?
        /?
      )
    </define-regex>
    <define-regex id="system-path" extended="true">
      [-a-zA-Z0-9_]* # valid characters, repeat this
      / # require a slash
      [-a-zA-Z0-9/_]+ # more valid characters, repeat this once or more
      (.[a-zA-Z0-9]+)? # optional extension
    </define-regex>

    <context id="string-path" style-ref="path" once-only="true">
      <match extended="true">
        (?&lt;=")
        (?:
          (\]/)?\%{property-path}\[? # a recognizeable property path
          |((?:\]/)? # or a "simple" path that isn't covered by above
            [a-zA-Z] # first character has to be an alpha
            [-a-zA-Z0-9_]* # now it can be alpha, hyphen, or number, repeat this
            (\[ # optional index specifier like this: [90]
               (?:[0-9]+\]/?)? # this is the rest after the opening; optional, "node/foo[" is valid
            |/ # or a slash if no opening: sim/
            )
           )
          |\[|\]/? # or a single bracket (closing can have slash): "]", "[", or "]/"
          |(?&lt;=prop\(")            [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[? # or a word like in setprop("foo-bar");
          |(?&lt;=\.getNode\(")       [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[? # or a word like in props.globals.getNode("foo-bar["~index~"]");
          |(?&lt;=\.alias\(")         [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[? # etc.
          |(?&lt;=\.initNode\(")      [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.getValue\(")      [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.getBoolValue\(")  [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.setValue\(")      [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.setBoolValue\(")  [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.setIntValue\(")   [-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.setDoubleValue\(")[-a-zA-Z0-9_]+(?:\[([0-9]+)\])?\[?
          |(?&lt;=\.getChild\(")      [-a-zA-Z0-9_]+    # while these are simple names
          |(?&lt;=\.getChildren\(")   [-a-zA-Z0-9_]+
          |(?&lt;=\.removeChild\(")   [-a-zA-Z0-9_]+
          |(?&lt;=\.removeChildren\(")[-a-zA-Z0-9_]+
        )
        (?=")
      </match>
    </context>

    <context id="double-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
      <start>"</start>
      <end>"</end>
      <include>
        <context ref="format"/>
        <context ref="escaped-char"/>
        <context ref="string-path"/>
      </include>
    </context>

    <context id="single-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
      <start>'</start>
      <end>'</end>
      <include>
        <context ref="format"/>
        <context id="escaped-single-quote" style-ref="escaped-char" extend-parent="true">
          <match>\\'</match>
        </context>
        <context ref="object-types"/>
      </include>
    </context>

    <context id="escaped-double-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
      <start>\\"</start>
      <end>\\"</end>
      <include>
        <context ref="format"/>
        <context ref="double-escaped-char"/>
        <context ref="string-path"/>
      </include>
    </context>

    <context id="escaped-single-quoted-string" style-ref="string" class="string" class-disabled="no-spell-check">
      <start>\\'</start>
      <end>\\'</end>
      <include>
        <context ref="format"/>
        <context id="double-escaped-single-quote" style-ref="escaped-char" extend-parent="true">
          <match>\\\\'</match>
        </context>
        <context ref="object-types"/>
      </include>
    </context>

    <context id="string-conversion" style-ref="string-conversion">
      <match extended="true">
        `
        (
          [^`\\] # any single character except for backqote or backslash
        | # or:
          \\(                 # leading backslash
            [\\`abfnrtv]      | # single escaped char
            N\{[A-Z\ ]+\}     | # named unicode character
            u[0-9A-Fa-f]{4}   | # xxxx - character with 16-bit hex value xxxx
            U[0-9A-Fa-f]{8}   | # xxxxxxxx - character with 32-bit hex value xxxxxxxx
            x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh
            [0-7]{1,3}          # \ooo - character with octal value ooo
          )
        )
        `
      </match>
    </context>

    <!-- Variables (special, chosen between FlightGear/Nasal-Standalone) -->

    <context id="special-variables" style-ref="special-variable">
      <prefix>(?&lt;![\w\.])</prefix>
      <keyword>_?cmdarg</keyword>
      <keyword>arg</keyword>
      <keyword>me</keyword>
      <keyword>parents</keyword>
      <keyword>globals</keyword>
    </context>
    <context id="module-handler" style-ref="module-handler">
      <prefix>(?&lt;![\w\.])</prefix>
      <!-- Nasal-standalone/lib/driver.nas -->
      <keyword>import</keyword>
      <!-- $FG_ROOT/nasal_boostrap.nas -->
      <keyword>require</keyword>
    </context>

    <context id="builtin-function" style-ref="builtin-function">
      <prefix>((?&lt;![\w\.])|(?&lt;=globals\.))</prefix> <!-- look behind for anything but a word or period as a prefix, e.g. a space or tab, or lookbehind for globals. (since it will result in the same path) -->

      <!-- Builtin to Nasal -->
      <keyword>append</keyword>
      <keyword>setsize</keyword>
      <keyword>subvec</keyword>
      <keyword>contains</keyword>
      <keyword>delete</keyword>
      <keyword>num</keyword>
      <keyword>keys</keyword>
      <keyword>pop</keyword>
      <keyword>size</keyword>
      <keyword>streq</keyword>
      <keyword>cmp</keyword>
      <keyword>abs</keyword>
      <keyword>chr</keyword>
      <keyword>sort</keyword>
      <keyword>substr</keyword>
      <keyword>sprintf</keyword>
      <keyword>find</keyword>
      <keyword>split</keyword>
      <keyword>rand</keyword>
      <keyword>typeof</keyword>
      <keyword>die</keyword>
      <keyword>call</keyword>
      <keyword>compile</keyword>
      <keyword>closure</keyword>
      <keyword>caller</keyword>
      <keyword>bind</keyword>
      <keyword>print</keyword>
      <keyword>bits\.fld</keyword>
      <keyword>bits\.sfld</keyword>
      <keyword>bits\.setfld</keyword>
      <keyword>bits\.buf</keyword>
      <keyword>math\.sin</keyword>
      <keyword>math\.cos</keyword>
      <keyword>math\.exp</keyword>
      <keyword>math\.ln</keyword>
      <keyword>math\.sqrt</keyword>
      <keyword>math\.atan2</keyword>
      <keyword>io\.open</keyword>
      <keyword>io\.close</keyword>
      <keyword>io\.read</keyword>
      <keyword>io\.write</keyword>
      <keyword>io\.seek</keyword>
      <keyword>io\.tell</keyword>
      <keyword>io\.readln</keyword>
      <keyword>io\.stat</keyword>
      <keyword>utf8\.chstr</keyword>
      <keyword>utf8\.strc</keyword>
      <keyword>utf8\.substr</keyword>
      <keyword>utf8\.size</keyword>
      <keyword>utf8\.validate</keyword>
      <keyword>thread\.newthread</keyword>
      <keyword>thread\.newlock</keyword>
      <keyword>thread\.lock</keyword>
      <keyword>thread\.unlock</keyword>
      <keyword>thread\.newsem</keyword>
      <keyword>thread\.semdown</keyword>
      <keyword>thread\.semup</keyword>
      <keyword>unix\.pipe</keyword>
      <keyword>unix\.fork</keyword>
      <keyword>unix\.dup2</keyword>
      <keyword>unix\.exec</keyword>
      <keyword>unix\.waitpid</keyword>
      <keyword>unix\.opendir</keyword>
      <keyword>unix\.readdir</keyword>
      <keyword>unix\.closedir</keyword>
      <keyword>unix\.time</keyword>
      <keyword>unix\.chdir</keyword>
      <keyword>unix\.environ</keyword>
      <keyword>regex\.comp</keyword>
      <keyword>regex\.exec</keyword>
      <keyword>sqlite\.open</keyword>
      <keyword>sqlite\.close</keyword>
      <keyword>sqlite\.prepare</keyword>
      <keyword>sqlite\.finalize</keyword>
      <keyword>readline</keyword>

      <!-- Flightgear-specific -->
      <!-- $FG_SRC/NasalSys.cxx -->
      <keyword>getprop</keyword>
      <keyword>setprop</keyword>
      <keyword>print</keyword>
      <keyword>logprint</keyword>
      <keyword>_fgcommand</keyword>
      <keyword>settimer</keyword>
      <keyword>maketimer</keyword>
      <keyword>_setlistener</keyword>
      <keyword>removelistener</keyword>
      <keyword>addcommand</keyword>
      <keyword>removecommand</keyword>
      <keyword>_interpolate</keyword>
      <keyword>rand</keyword>
      <keyword>srand</keyword>
      <keyword>abort</keyword>
      <keyword>directory</keyword>
      <keyword>resolvepath</keyword>
      <keyword>parsexml</keyword>
      <keyword>systime</keyword>
      <!-- globals.nas -->
      <keyword>setlistener</keyword>
      <keyword>fgcommand</keyword>
      <keyword>interpolate</keyword>
      <keyword>isa</keyword>
      <keyword>abs</keyword>
      <keyword>defined</keyword>
      <keyword>thisfunc</keyword>
      <keyword>printf</keyword>
      <keyword>sprintf</keyword>
      <keyword>values</keyword>
      <keyword>printlog</keyword>
      <!-- io.nas -->
      <keyword>io\.readfile</keyword>
      <keyword>io\.load_nasal</keyword>
      <keyword>io\.read_properties</keyword>
      <keyword>io\.read_airport_properties</keyword>
      <keyword>io\.write_properties</keyword>
      <keyword>io\.readxml</keyword>
      <keyword>io\.writexml</keyword>
      <!-- string.nas -->
      <keyword>string\.match</keyword>
      <keyword>string\.normpath</keyword>
      <keyword>string\.join</keyword>
      <keyword>string\.replace</keyword>
      <keyword>string\.iscntrl</keyword>
      <keyword>string\.isascii</keyword>
      <keyword>string\.isupper</keyword>
      <keyword>string\.islower</keyword>
      <keyword>string\.isdigit</keyword>
      <keyword>string\.isblank</keyword>
      <keyword>string\.ispunct</keyword>
      <keyword>string\.isxdigit</keyword>
      <keyword>string\.isspace</keyword>
      <keyword>string\.isalpha</keyword>
      <keyword>string\.isalnum</keyword>
      <keyword>string\.isgraph</keyword>
      <keyword>string\.isprint</keyword>
      <keyword>string\.toupper</keyword>
      <keyword>string\.tolower</keyword>
      <keyword>string\.isxspace</keyword>
      <keyword>string\.trim</keyword>
      <keyword>string\.uc</keyword>
      <keyword>string\.lc</keyword>
      <keyword>string\.icmp</keyword>
      <keyword>string\.imatch</keyword>
      <keyword>string\.scanf</keyword>
      <keyword>string\.setcolors</keyword>
      <keyword>string\.color</keyword>
      <!-- gui.nas -->
      <keyword>gui\.Dialog\.new</keyword>
      <keyword>gui\.OverlaySelector\.new</keyword>
      <keyword>gui\.FileSelector\.new</keyword>
      <keyword>gui\.DirSelector\.new</keyword>
      <keyword>gui\.findElementByName</keyword>
      <keyword>gui\.popupTip</keyword>
      <keyword>gui\.showDialog</keyword>
      <keyword>gui\.showHelpDialog</keyword>
      <keyword>gui\.menuEnable</keyword>
      <keyword>gui\.menuBind</keyword>
      <keyword>gui\.setCursor</keyword>
      <keyword>gui\.save_flight</keyword>
      <keyword>gui\.load_flight</keyword>
      <keyword>gui\.set_screenshotdir</keyword>
      <keyword>gui\.property_browser</keyword>
      <keyword>gui\.dialog_apply</keyword>
      <keyword>gui\.dialog_update</keyword>
      <keyword>gui\.enable_widgets</keyword>
      <!-- props.nas -->
      <keyword>props\.Node\.new</keyword>
      <keyword>props\.Node</keyword>
      <keyword>props\.globals</keyword>
      <keyword>props\.setAll</keyword>
      <keyword>props\.wrap</keyword>
      <keyword>props\.wrapNode</keyword>
      <keyword>props\.copy</keyword>
      <keyword>props\.dump</keyword>
      <keyword>props\.nodeList</keyword>
      <keyword>props\.condition</keyword>
      <keyword>props\.runBinding</keyword>
      <!-- nasal-props.cxx -->
      <keyword>props\._new</keyword>
      <keyword>props\._globals</keyword>
      <keyword>props\._getNode</keyword>
      <keyword>props\._getParent</keyword>
      <keyword>props\._getChild</keyword>
      <keyword>props\._getChildren</keyword>
      <keyword>props\._removeChild</keyword>
      <keyword>props\._removeChildren</keyword>
      <keyword>props\._getAliasTarget</keyword>
      <keyword>props\._getName</keyword>
      <keyword>props\._getIndex</keyword>
      <keyword>props\._getType</keyword>
      <keyword>props\._getAttribute</keyword>
      <keyword>props\._setAttribute</keyword>
      <keyword>props\._getValue</keyword>
      <keyword>props\._setValue</keyword>
      <keyword>props\._setIntValue</keyword>
      <keyword>props\._setBoolValue</keyword>
      <keyword>props\._setDoubleValue</keyword>
      <keyword>props\._unalias</keyword>
      <keyword>props\._alias</keyword>
      <!-- debug.nas -->
      <keyword>debug\.dump</keyword>
      <keyword>debug\.local</keyword>
      <keyword>debug\.backtrace</keyword>
      <keyword>debug\.bt</keyword>
      <keyword>debug\.proptrace</keyword>
      <keyword>debug\.tree</keyword>
      <keyword>debug\.string</keyword>
      <keyword>debug\.attributes</keyword>
      <keyword>debug\.isnan</keyword>
      <keyword>debug\.benchmark</keyword>
      <keyword>debug\.printerror</keyword>
      <keyword>debug\.warn</keyword>
      <keyword>debug\.propify</keyword>
      <!-- math.nas -->
      <keyword>math\.abs</keyword>
      <keyword>math\.sgn</keyword>
      <keyword>math\.max</keyword>
      <keyword>math\.min</keyword>
      <keyword>math\.avg</keyword>
      <keyword>math\.pow</keyword>
      <keyword>math\.mod</keyword>
      <keyword>math\.asin</keyword>
      <keyword>math\.acos</keyword>
      <keyword>math\.tan</keyword>
      <keyword>math\.log10</keyword>
      <keyword>math\.to_base</keyword>
      <keyword>math\.print_base</keyword>
      <!-- view.nas -->
      <keyword>view\.panViewDir</keyword>
      <keyword>view\.panViewPitch</keyword>
      <keyword>view\.resetView</keyword>
      <keyword>view\.manager\.register</keyword>
      <!-- screen.nas -->
      <keyword>screen\.log\.write</keyword>
      <!-- controls.nas -->
      <keyword>controls\.startEngine</keyword>
      <keyword>controls\.selectEngine</keyword>
      <keyword>controls\.stepMagnetos</keyword>
      <keyword>controls\.centerFlightControls</keyword>
      <keyword>controls\.throttleAxis</keyword>
      <keyword>controls\.propellerAxis</keyword>
      <keyword>controls\.mixtureAxis</keyword>
      <keyword>controls\.carbHeatAxis</keyword>
      <keyword>controls\.flapsDown</keyword>
      <keyword>controls\.wingSweep</keyword>
      <keyword>controls\.wingsDown</keyword>
      <keyword>controls\.stepSpoilers</keyword>
      <keyword>controls\.stepSlats</keyword>
      <keyword>controls\.elevatorTrim</keyword>
      <keyword>controls\.aileronTrim</keyword>
      <keyword>controls\.rudderTrim</keyword>
      <keyword>controls\.adjThrottle</keyword>
      <keyword>controls\.adjMixture</keyword>
      <keyword>controls\.adjCondition</keyword>
      <keyword>controls\.adjPropeller</keyword>
      <keyword>controls\.incThrottle</keyword>
      <keyword>controls\.incAileron</keyword>
      <keyword>controls\.incElevator</keyword>
      <keyword>controls\.elevatorTrimAxis</keyword>
      <keyword>controls\.aileronTrimAxis</keyword>
      <keyword>controls\.rudderTrimAxis</keyword>
      <keyword>controls\.gearDown</keyword>
      <keyword>controls\.gearToggle</keyword>
      <keyword>controls\.applyBrakes</keyword>
      <keyword>controls\.applyParkingBrake</keyword>
      <keyword>controls\.deployChute</keyword>
      <keyword>controls\.trigger</keyword>
      <keyword>controls\.ptt</keyword>
      <keyword>controls\.toggleLights</keyword>
      <!-- aircraft.nas -->
      <keyword>aircraft\.door\.new</keyword>
      <keyword>aircraft\.light\.new</keyword>
      <keyword>aircraft\.lowpass\.new</keyword>
      <keyword>aircraft\.angular_lowpass\.new</keyword>
      <keyword>aircraft\.data\.init</keyword>
      <keyword>aircraft\.data\.load</keyword>
      <keyword>aircraft\.data\.save</keyword>
      <keyword>aircraft\.data\.add</keyword>
      <keyword>aircraft\.timer\.new</keyword>
      <keyword>aircraft\.livery\.new</keyword>
      <keyword>aircraft\.livery_update\.new</keyword>
      <keyword>aircraft\.overlay_update\.new</keyword>
      <keyword>aircraft\.steering\.init</keyword>
      <keyword>aircraft\.steering\.setbrakes</keyword>
      <keyword>aircraft\.autotrim\.init</keyword>
      <keyword>aircraft\.autotrim\.start</keyword>
      <keyword>aircraft\.autotrim\.stop</keyword>
      <keyword>aircraft\.tyresmoke\.new</keyword>
      <keyword>aircraft\.tyresmoke_system\.new</keyword>
      <keyword>aircraft\.rain\.init</keyword>
      <keyword>aircraft\.rain\.update</keyword>
      <keyword>aircraft\.teleport</keyword>
      <keyword>aircraft\.wind_speed_from</keyword>
      <keyword>aircraft\.kias_to_ktas</keyword>
      <keyword>aircraft\.HUD\.init</keyword>
      <keyword>aircraft\.HUD\.cycle_color</keyword>
      <keyword>aircraft\.HUD\.cycle_brightness</keyword>
      <keyword>aircraft\.HUD\.normal_type</keyword>
      <keyword>aircraft\.HUD\.cycle_type</keyword>
      <keyword>aircraft\.HUD\.is_active</keyword>
      <keyword>aircraft\.crossfeed_valve\.new</keyword>
      <!-- screen.nas -->
      <keyword>screen\.window\.new</keyword>
      <keyword>screen\.display\.new</keyword>
      <keyword>screen\.msg_repeat</keyword>
      <!-- geo.nas -->
      <keyword>geo\.Coord\.new</keyword>
      <keyword>geo\.normdeg</keyword>
      <keyword>geo\.tile_index</keyword>
      <keyword>geo\.format</keyword>
      <keyword>geo\.tile_path</keyword>
      <keyword>geo\.put_model</keyword>
      <keyword>geo\.click_position</keyword>
      <keyword>geo\.aircraft_position</keyword>
      <keyword>geo\.viewer_position</keyword>

      <!-- Mine (ignore) -->
      <keyword>setlocalprop</keyword>
      <keyword>getlocalprop</keyword>
    </context>

    <!-- Flightgear props.Node methods -->
    <context id="node-object" style-ref="builtin-function">
      <prefix>(?&lt;=\.)</prefix> <!-- look behind for . as a prefix-->
      <keyword>initNode</keyword>
      <keyword>getNode</keyword>
      <keyword>getType</keyword>
      <keyword>getName</keyword>
      <keyword>getPath</keyword>
      <keyword>getIndex</keyword>
      <keyword>getValue</keyword>
      <keyword>getBoolValue</keyword>
      <keyword>getValues</keyword>
      <keyword>getParent</keyword>
      <keyword>getChildren</keyword>
      <keyword>getChild</keyword>
      <keyword>getAttribute</keyword>
      <keyword>setIntValue</keyword>
      <keyword>setBoolValue</keyword>
      <keyword>setDoubleValue</keyword>
      <keyword>setValues</keyword>
      <keyword>setValue</keyword>
      <keyword>setAttribute</keyword>
      <keyword>addChildren</keyword>
      <keyword>addChild</keyword>
      <keyword>removeAllChildren</keyword>
      <keyword>removeChildren</keyword>
      <keyword>removeChild</keyword>
      <keyword>remove</keyword>
      <keyword>clearValue</keyword>
      <keyword>unalias</keyword>
      <keyword>alias</keyword>
    </context>

    <context id="nasal" class="no-spell-check">
      <include>
        <context ref="def:shebang"/>
        <context ref="def:shell-like-comment"/>
        <context ref="nasal-code-string-double"/>
        <context ref="nasal-code-string-single"/>
        <context ref="double-quoted-string"/>
        <context ref="single-quoted-string"/>
        <context ref="string-conversion"/>
        <context ref="number"/>
        <context ref="operators"/>
        <context ref="keyword"/>
        <context ref="blockoid"/>
        <context ref="builtin-constants"/>
        <context ref="builtin-function"/>
        <context ref="node-object"/>
        <context ref="special-variables"/>
        <context ref="module-handler"/>
        <context ref="escaped-char"/>
      </include>
    </context>
    <context id="nasal-noextend" class="no-spell-check" extend-parent="false">
      <start>.</start>
      <end>.</end>
      <include>
        <context ref="def:shebang"/>
        <context ref="def:shell-like-comment"/>
        <context ref="nasal-code-string-double"/>
        <context ref="nasal-code-string-single"/>
        <context ref="double-quoted-string"/>
        <context ref="single-quoted-string"/>
        <context ref="string-conversion"/>
        <context ref="number"/>
        <context ref="operators"/>
        <context ref="keyword"/>
        <context ref="blockoid"/>
        <context ref="builtin-constants"/>
        <context ref="builtin-function"/>
        <context ref="node-object"/>
        <context ref="special-variables"/>
        <context ref="module-handler"/>
        <context ref="escaped-char"/>
      </include>
    </context>

    <context id="nasal-code-string-double">
      <start>"""</start>
      <end>"""</end>
      <include>
        <!-- Highlight our delimiters -->
        <context sub-pattern="0" where="start" style-ref="string"/>
        <context sub-pattern="0" where="end" style-ref="string"/>
        <context ref="def:shebang"/>
        <context ref="def:shell-like-comment"/>
        <context ref="escaped-double-quoted-string"/>
        <context ref="single-quoted-string"/>
        <context id="double-quote-error" style-ref="def:error">
          <match>"(?! *~|"")</match>
        </context>
        <context id="non-string-double" extend-parent="false">
          <start>"</start>
          <end>"</end>
          <include><context ref="nasal-noextend"/></include>
        </context>
        <context ref="string-conversion"/>
        <context ref="number"/>
        <context ref="operators"/>
        <context ref="keyword"/>
        <context ref="blockoid"/>
        <context ref="builtin-constants"/>
        <context ref="builtin-function"/>
        <context ref="node-object"/>
        <context ref="special-variables"/>
        <context ref="module-handler"/>
      </include>
    </context>
    <context id="nasal-code-string-single">
      <start>'''</start>
      <end>'''</end>
      <include>
        <!-- Highlight our delimiters -->
        <context sub-pattern="0" where="start" style-ref="string"/>
        <context sub-pattern="0" where="end" style-ref="string"/>
        <context ref="def:shebang"/>
        <context ref="def:shell-like-comment"/>
        <context ref="double-quoted-string"/>
        <context ref="escaped-single-quoted-string"/>
        <context id="single-quote-error" style-ref="def:error">
          <match>'(?! *~|'')</match>
        </context>
        <context id="non-string-single" extend-parent="false">
          <start>'</start>
          <end>'</end>
          <include><context ref="nasal-noextend"/></include>
        </context>
        <context ref="string-conversion"/>
        <context ref="number"/>
        <context ref="operators"/>
        <context ref="keyword"/>
        <context ref="blockoid"/>
        <context ref="builtin-constants"/>
        <context ref="builtin-function"/>
        <context ref="node-object"/>
        <context ref="special-variables"/>
        <context ref="module-handler"/>
      </include>
    </context>

    <context id="xml-extras">
        <include>
            <context ref="xml:comment"/>
            <context id="cdata">
                <start>&lt;!\[CDATA\[</start>
                <end>\]\]&gt;</end>
                <include>
                    <!-- Highlight our delimiters -->
                    <context sub-pattern="0" where="start" style-ref="xml:cdata-delim" class="no-spell-check"/>
                    <context sub-pattern="0" where="end" style-ref="xml:cdata-delim"/>
                    <!-- And include regular Nasal (no XML extensions) -->
                    <context ref="nasal"/>
                </include>
            </context>
            <context id="character-reference" style-ref="xml:entity">
                <match>&amp;(#([0-9]+|x[a-fA-F0-9]+)|lt|gt|amp|quot|apos);</match>
            </context>
            <context id="unallowed-chars" style-ref="xml:error" extend-parent="false">
                <match>[&amp;&lt;&gt;]</match>
            </context>
        </include>
    </context>

    <!-- For use when embedded in XML, e.g. in a <script> tag. -->
    <context id="xml">
        <include>
            <context id="script">
                <start>(?&lt;=&lt;script&gt;)</start><!-- look behind for <script> as a start -->
                <end>(?=&lt;/script&gt;)</end><!-- look ahead for </script> as an end -->
                <include>
                    <context ref="xml-extras"/>
                    <context ref="nasal"/>
                </include>
            </context>
            <context id="dialog-open">
                <start>(?&lt;=&lt;open&gt;)</start><!-- look behind for <open> as a start -->
                <end>(?=&lt;/open&gt;)</end><!-- look ahead for </open> as an end -->
                <include>
                    <context ref="xml-extras"/>
                    <context ref="nasal"/>
                </include>
            </context>
            <context id="dialog-close">
                <start>(?&lt;=&lt;close&gt;)</start><!-- look behind for <close> as a start -->
                <end>(?=&lt;/close&gt;)</end><!-- look ahead for </close> as an end -->
                <include>
                    <context ref="xml-extras"/>
                    <context ref="nasal"/>
                </include>
            </context>
            <context id="model-load">
                <start>(?&lt;=&lt;load&gt;)</start><!-- look behind for <load> as a start -->
                <end>(?=&lt;/load&gt;)</end><!-- look ahead for </load> as an end -->
                <include>
                    <context ref="xml-extras"/>
                    <context ref="nasal"/>
                </include>
            </context>
            <context id="model-unload">
                <start>(?&lt;=&lt;unload&gt;)</start><!-- look behind for <unload> as a start -->
                <end>(?=&lt;/unload&gt;)</end><!-- look ahead for </unload> as an end -->
                <include>
                    <context ref="xml-extras"/>
                    <context ref="nasal"/>
                </include>
            </context>
        </include>
    </context>
  </definitions>
</language>


Support for the snippet add-on. See the wiki page for installation instructions: http://wiki.flightgear.org/Howto:Syntax ... asal#gedit.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<snippets language="Nasal">
  <snippet id="else">
    <text><![CDATA[else {
   ${0:# body...}
}]]></text>
    <description>else statement</description>
    <tag>else</tag>
  </snippet>
  <snippet id="elsif">
    <text><![CDATA[elsif (${0:condition}) {
   ${0:# body...}
}]]></text>
    <description>conditional elsif statement</description>
    <tag>elsif</tag>
  </snippet>
  <snippet id="}">
    <text><![CDATA[} elsif (${1:variable} == ${2:constant}) {
   ${0:# body...}
}]]></text>
    <description>equality elsif statement</description>
    <tag>}</tag>
  </snippet>
  <snippet id="if">
    <text><![CDATA[if (${0:condition}) {
   ${0:# body...}
}]]></text>
    <description>conditional if statement</description>
    <tag>if</tag>
  </snippet>
  <snippet id="=">
    <text><![CDATA[if (${1:variable} == ${2:constant}) {
   ${0:# body...}
}]]></text>
    <description>equality if statement</description>
    <tag>=</tag>
  </snippet>
  <snippet id="typeif">
      <text><![CDATA[if (typeof(${1:variable}) == "${2:type}") {
   ${0:# body...}
}]]></text>
      <description>typeof if statement</description>
      <tag>typeif</tag>
    </snippet>
</snippets>


For embedding in .xml files, open up xml.lang and find near the end these lines:
Code: Select all
        <context id="xml">
            <include>
                <context ref="comment"/>

Right after the <context ref="comment"/> add this line:
Code: Select all
                <context ref="nasal:xml"/>

Restart gedit and you should be set!

Changelog:
  • Sixth revision: mostly pedantry, nothing major. Support for relative path getValue/setValue(), more pedantic escapes & sprintf formatting, use a character class for operators, and change the "format" style (i.e. for sprintf) to "def:special-char" like character escapes.
  • Fifth revision: Reordered the file (<context>s & <style>s), fixed up things (XML embedding, path recognition) & added a new feature, triple-quoted strings: essentially embedded snippets of Nasal code, e.g. as passed to compile(), with special syntax to support being inside of a string. Note that triple-quoted strings aren't actually a feature of Nasal, but rather are formed by the implicit concatenation of empty string, actual string, and empty string literals (like in C, where Andy probably got the idea from).
  • Fourth revision: Not really sure what I fixed or if I fixed anything. Added a couple more types, these are ghosttypes for different variants of Nasal (AndyRoss/Nasal on GitHub, FlightGear, and SimGear -- all of those overlapping). Fixed a horrible case of shortsightedness: all periods in <keyword>s need to be escaped! And it could be that I fixed some instances of the property string highlighting, I know I have a couple more to correct.
  • Third revision: Lots of updates, too spread out to remember them all :P. Major thing is that paths are now highlighted like types ('vector') were before. They are "broken out" to their own color definition, do you can redefine them in your highlighting file (what good gedit-er hasn't modified their colors?). I found a couple keywords that I had missed, etc., and it should work better now!
  • Second revision: Added some more keywords (mostly in props) and supported embedding in .xml files. Made sure I remembered the parenthesis after cmdarg so that it only highlighted if I got cmdarg() not cmdarg as I had been (mis)typing for a while :P.
  • First revision: cleaned it up some, added support for some of the files in $FG_ROOT/Nasal (gui.nas, screens.nas, debug.nas, aircraft.nas, controls.nas, geo.nas), organized and commented a bit more now that I understand the gist of regex. Added some snippets, requests welcome!
Last edited by Philosopher on Wed Nov 06, 2013 1:12 am, edited 13 times in total.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby islandmonkey » Mon Aug 13, 2012 4:02 pm

To all Linux users: This goes in the same path as Mac but with /usr/share. Also at least on Ubuntu the folder is called gtksourceview-3.0.
User avatar
islandmonkey
 
Posts: 798
Joined: Mon Jan 30, 2012 8:51 pm
Location: EGCN (uni), EGHI (home)
Callsign: G-MNKY
OS: Ubuntu 20.04

Re: Nasal highlighter for Gedit

Postby Philosopher » Mon Aug 13, 2012 5:28 pm

islandmonkey wrote in Mon Aug 13, 2012 4:02 pm:To all Linux users: This goes in the same path as Mac but with /usr/share. Also at least on Ubuntu the folder is called gtksourceview-3.0.


Yeah, sorry, it's really gtksourceview-X.0 depending on the version of gedit. Should range from 1.0 to 3.0.

Thanks for the clarification
--Have a life, have a name, need a signature :D
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby Hooray » Mon Aug 13, 2012 9:44 pm

Hi,

thanks for your contribution, could you please add it here: http://wiki.flightgear.org/Howto:Syntax ... _for_Nasal ?

Thank you!
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Nasal highlighter for Gedit

Postby Philosopher » Tue Aug 14, 2012 11:35 pm

I would, but my mom hasn't rgr'd a wiki account yet, and with her mood this morning (kicking me off the computer) I don't think I want to ask right now. It would be very helpful and much appreciated if someone could add it to the wiki.

Thanks in advance,
Philosopher
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby omega95 » Thu Aug 16, 2012 7:52 am

Philosopher wrote in Tue Aug 14, 2012 11:35 pm:I would, but my mom hasn't rgr'd a wiki account yet, and with her mood this morning (kicking me off the computer) I don't think I want to ask right now. It would be very helpful and much appreciated if someone could add it to the wiki.

Thanks in advance,
Philosopher


Hey, I've added it to the wiki for you... :D

http://wiki.flightgear.org/Howto:Syntax_highlighting_for_Nasal#gEdit

Cheers!
Merlion Virtual Airlines - the experience of a flight time...
Get high quality aircraft, airports, video tutorials or development tools from my hangar.
omega95
 
Posts: 1223
Joined: Sat Jul 30, 2011 12:59 am
Location: -unknown-
Callsign: MIA0001, OM-EGA
IRC name: omega95
Version: 2.12 git
OS: Ubuntu 13.04

Re: Nasal highlighter for Gedit

Postby Philosopher » Thu Aug 16, 2012 11:59 am

Thanks so much! Now you just need to remove it from the others section ;).
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby Hooray » Thu Aug 16, 2012 12:04 pm

done
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Nasal highlighter for Gedit

Postby Philosopher » Fri Oct 05, 2012 8:48 pm

Thanks omega95 for hosting my file and thanks Hooray for making wiki edits for me :).

I've made some changes, it should work better and highlight more, see the first post. I also added snippets and I hope to add more. Note that typeif[tab] makes an if statement like this:
Code: Select all
if (typeof($var) == "$type") {
    $body
}


See the gEdit "Manage Code Snippets" for more information on the snippets (if you have them enabled).

If I learn some more about this gEdit/GTK SourceView stuff, I hope to have another file that recognizes Nasal embedded in XML files... If...
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby Hooray » Sat Oct 06, 2012 3:50 pm

Philosopher wrote in Fri Oct 05, 2012 8:48 pm:I've made some changes, it should work better and highlight more, see the first post. I also added snippets and I hope to add more. Note that typeif[tab] makes an if statement See the gEdit "Manage Code Snippets" for more information on the snippets (if you have them enabled).


Snippet support and "auto-completion" (often called "intellisense") are actually great ideas, which should lower the entry barrier for new programmers significantly.
I was actually hoping to turn the built-in "Nasal Console" into a little "Nasal IDE" (or at least full Nasal editor with load/save support) once we have fully adopted the canvas system - some ideas are collected here: http://wiki.flightgear.org/Nasal_Consol ... hancements
Many of these will only be supported once we use the canvas for creating the GUI widget (text area), and once we have full support for keyboard/mouse events. Also, syntax highlighting in particular will require some modifications of the the C++ code, so that hooks can be registered to change the color/style of certain strings.

If I learn some more about this gEdit/GTK SourceView stuff, I hope to have another file that recognizes Nasal embedded in XML files... If...

The vi/m mode has already supported for nested XML/Nasal code.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Nasal highlighter for Gedit

Postby Philosopher » Sat Oct 06, 2012 8:24 pm

Hooray wrote in Sat Oct 06, 2012 3:50 pm:The vi/m mode has already supported for nested XML/Nasal code.

Shoot! late to the game! ;). I just need to figure out <context> tags and regexes a bit more, then I could do it. I had the genius idea of diagramming regexes, I just need to see if it works in practice :D. More grammar!

And it isn't too much of auto-completion and even less of intellisense, it just has support for hitting tab after a keyword, e.g. else, and it could fill out some text for you and have fields for stuff. So like you could just say "else" then hit tab and it would fill out to:
Code: Select all
else {
    $body
}


Where $body is a field (except it wouldn't have the leading $ sign) and the cursor would automatically select that, then you would hit tab to go to the next field, if it exists. Unfortunately, you can only have one non-alpha character at a time, so }> wouldn't work for example but = would. A slight limitation of the snippet script, but it still works nicely.

I like the idea of a built-in Nasal coder, but it couldn't be a replacement for a separate IDE (or even gEdit) in my mind, because the sim would still have to be running, and you would have to make the changes in-sim, then exit, and couldn't make any changes until you started it up, and if you did something wrong and it crashed, you wouldn't be able to code in-sim anymore. But having a bit more in-sim would be nice, especially since beginners could do little things in there and could see if they're doing it correctly (with proper support for highlighting, etc.).

I do wonder how flexible gEdit is. It seems the answer is very (the snippet window has a separate gEdit file/text editor in it with full highlighting support), but could it make a semi-complete IDE with intellisense? It just might be possible..... ~wanders off, dreaming~ ;). Looks like I need to brush up on python again, after regexes.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby xiii » Sat Oct 06, 2012 8:36 pm

Any kdevelop-4 support ?

I'm just wondering if I stwitch from gedit to this one.

Anyway, thanks a lot ! It's a pleasure to use a correct syntax hilighting in gedit.

Alexis
If the engines are Pratt and Whitney, the seats best be Martin Baker
xiii
 
Posts: 472
Joined: Tue Jan 08, 2008 10:04 pm

Re: Nasal highlighter for Gedit

Postby Hooray » Sat Oct 06, 2012 8:45 pm

Philosopher wrote in Sat Oct 06, 2012 8:24 pm:I like the idea of a built-in Nasal coder, but it couldn't be a replacement for a separate IDE (or even gEdit) in my mind, because the sim would still have to be running, and you would have to make the changes in-sim, then exit, and couldn't make any changes until you started it up, and if you did something wrong and it crashed, you wouldn't be able to code in-sim anymore.


That's only a problem, because of the current way of "running" (loading) Nasal code - but there's no technical reason why this should stay this way, we'll need to clean up the way Nasal code is loaded for a handful of related efforts anyhow - so, I really wouldn't worry about this. In fact, it would be great if we were able to suspend/resume and re-init/re-load scripts from disks. Technically, most of this is already possible at the Nasal level - it just isn't done currently. But many of these things don't require any changes at the C/C++ level. The main Nasal repository contains lots of code that isn't even used in FG at all.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Re: Nasal highlighter for Gedit

Postby Philosopher » Sat Oct 06, 2012 10:21 pm

@xii: Glad to be of assistance, but believe me, it wasn't for more than personal use ;). And I haven't heard of KDevelop, do you use it? It looks like it is mostly C++ based.

@Hooray: The editor should be rather simple as Nasal has regex support. But other than that, I don't know.
Thanks,
Philosopher
(inactive but lurking occasionally...)
Philosopher
 
Posts: 1590
Joined: Sun Aug 12, 2012 6:29 pm
Location: Stuck in my head...
Callsign: AFTI
Version: Git
OS: Mac OS X 10.7.5

Re: Nasal highlighter for Gedit

Postby Hooray » Sat Oct 06, 2012 10:38 pm

KDevelop uses "Kate" as its editor component, so it's strictly specific to C++ - I once wrote a syntax highlighting file for kate and posted it here - can't seem to find it at the moment, but basically you'll just need to copy and customize a similar language spec file, i.e. using the JavaScript specs for example.

BTW: Kate/KDevelop has *extensive* support for "snippets":
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11923
Joined: Tue Mar 25, 2008 8:40 am

Next

Return to Nasal

Who is online

Users browsing this forum: No registered users and 0 guests