Loading ...
Sorry, an error occurred while loading the content.

Indent question about modes

Expand Messages
  • jeremy@cowgar.com
    I have a syntax file I am creating a highlighting mode for and it has things such as: clearing : Room A simple room This is one simple room doEnter() {
    Message 1 of 4 , Dec 7, 2004
    • 0 Attachment
      I have a syntax file I am creating a highlighting mode for and it has
      things such as:

      clearing : Room
      'A simple room'
      "This is one simple room"

      doEnter() {
      say("Hello");
      }
      ;

      Where I am running into problems is the function doEnter() ... I have
      { set to indent 4, ; to outdent 4, and } to outdent 4.

      The ; needs to outdent 4 because it ends a definition, such as
      'clearing' in this case. But it also ends portions of other items such
      as commands 'say("Hello");' ...

      Can anyone offer a method to make this work correctly? So far for
      indenting this is what I have:

      !if &sin "d" .fhook-tads.setup
      ; define indentation scheme
      0 indent .hilight.tads 1 10

      indent .hilight.tads n ":" 4
      indent .hilight.tads o ";" -4
      indent .hilight.tads n "{" 4
      indent .hilight.tads o "}" -4
      indent .hilight.tads n "\\[" 4
      indent .hilight.tads o "\\]" -4
      indent .hilight.tads b "(" ")"
      indent .hilight.tads e "\"" "\"" "\\"
      indent .hilight.tads e "'" "'" "\\"
      !endif

      Thanks!

      Jeremy
    • Jon Green
      ... Suggest that the ; rule is changed to:- indent .hilight.tads o ^ s *; -4 That is the ; is only used for indentation when it appears as the first
      Message 2 of 4 , Dec 7, 2004
      • 0 Attachment
        jeremy@... wrote:
        > I have a syntax file I am creating a highlighting mode for and it has
        > things such as:
        >
        > clearing : Room
        > 'A simple room'
        > "This is one simple room"
        >
        > doEnter() {
        > say("Hello");
        > }
        > ;
        >
        > Where I am running into problems is the function doEnter() ... I have
        > { set to indent 4, ; to outdent 4, and } to outdent 4.
        >
        > The ; needs to outdent 4 because it ends a definition, such as
        > 'clearing' in this case. But it also ends portions of other items such
        > as commands 'say("Hello");' ...
        >
        > Can anyone offer a method to make this work correctly? So far for
        > indenting this is what I have:
        >
        > !if &sin "d" .fhook-tads.setup
        > ; define indentation scheme
        > 0 indent .hilight.tads 1 10
        >
        > indent .hilight.tads n ":" 4
        > indent .hilight.tads o ";" -4
        > indent .hilight.tads n "{" 4
        > indent .hilight.tads o "}" -4
        > indent .hilight.tads n "\\[" 4
        > indent .hilight.tads o "\\]" -4
        > indent .hilight.tads b "(" ")"
        > indent .hilight.tads e "\"" "\"" "\\"
        > indent .hilight.tads e "'" "'" "\\"
        > !endif
        >
        > Thanks!
        >
        > Jeremy
        >

        Suggest that the ';' rule is changed to:-

        indent .hilight.tads o "^\\s *;" -4

        That is the ';' is only used for indentation when
        it appears as the first non-whitespace character
        of the line.

        This fixes the code example that you sent, I'm not
        sure whether this witll break any other constructs.

        Jon.
      • jeremy@cowgar.com
        ... Great, that did the trick. I think I have only one other tricky section that I am now running across. doEnter() { descr = This is a big long string that
        Message 3 of 4 , Dec 7, 2004
        • 0 Attachment
          On Tue, 2004-12-07 at 22:24 +0000, Jon Green wrote:

          > Suggest that the ';' rule is changed to:-
          >
          > indent .hilight.tads o "^\\s *;" -4
          >

          Great, that did the trick. I think I have only one other tricky section
          that I am now running across.

          doEnter() {
          descr = "This is a big long string that just wraps lines
          with no regard for end-of-line or new-lines. All
          are stripped by the language."
          }

          That's what I would like a string to look like. The language (TADS) has
          no continue character like C, nor does it begin and end strings. The end
          result would be \r\n\t[ ] are replaced by 1 space. If I want a new line
          in the string I have to place it with a '\n' sequence of characters.

          Here is what the above function would currently look like:

          doEnter() {
          descr = "This is a big long string that just wraps lines
          with no regard for end-of-line or new-lines. All
          are stripped by the language."
          }

          When you are defining multiple variable it get's quite confusing as one
          could see.

          Any ideas on this one?

          Jeremy
        • Jon Green
          ... I do not have a solution for that at the moment. I agree with you it would be desirable if it performed the indent. I played around with it and the
          Message 4 of 4 , Dec 8, 2004
          • 0 Attachment
            jeremy@... wrote:
            > On Tue, 2004-12-07 at 22:24 +0000, Jon Green wrote:
            >
            >
            >>Suggest that the ';' rule is changed to:-
            >>
            >> indent .hilight.tads o "^\\s *;" -4
            >>
            >
            >
            > Great, that did the trick. I think I have only one other tricky section
            > that I am now running across.
            >
            > doEnter() {
            > descr = "This is a big long string that just wraps lines
            > with no regard for end-of-line or new-lines. All
            > are stripped by the language."
            > }
            >
            > That's what I would like a string to look like. The language (TADS) has
            > no continue character like C, nor does it begin and end strings. The end
            > result would be \r\n\t[ ] are replaced by 1 space. If I want a new line
            > in the string I have to place it with a '\n' sequence of characters.
            >
            > Here is what the above function would currently look like:
            >
            > doEnter() {
            > descr = "This is a big long string that just wraps lines
            > with no regard for end-of-line or new-lines. All
            > are stripped by the language."
            > }
            >
            > When you are defining multiple variable it get's quite confusing as one
            > could see.
            >
            > Any ideas on this one?
            >
            > Jeremy
            >
            >

            I do not have a solution for that at the moment. I agree with
            you it would be desirable if it performed the indent. I played
            around with it and the following are my set of rules, but no
            solution for the above yet.

            There are also some futher constructs such as if/else without
            the '{', '}' which are problematic. I also noted on the
            '(..)' was not returning to the correct column following a
            "say" when the line was broken over more than 1 line. This
            may be a problem with the current release I am using, I have
            not checked this with the 04/07 build.


            !if &sin "d" .fhook-tads.setup
            0 indent .hilight.tads 1 10
            indent .hilight.tads n "^\\w+\\s *:" 4
            indent .hilight.tads o "^\\s *;" -4
            indent .hilight.tads n "{" 4
            indent .hilight.tads o "}" -4
            indent .hilight.tads s "case" -4
            indent .hilight.tads n "\\[" 4
            indent .hilight.tads o "\\]" -4
            indent .hilight.tads b "(" ")"
            indent .hilight.tads e "\"" "\"" "\\"
            indent .hilight.tads e "'" "'" "\\"
            indent .hilight.tads i "//"

            !endif

            Jon.
          Your message has been successfully submitted and would be delivered to recipients shortly.