Menu

open folder and the close folder definition

2007-05-29
2012-11-14
  • Nobody/Anonymous

    I'm trying make User Language Define for CiCode ( http://www.citect.com/ ), and this language consist next construction:
    FUNCTION Func0()
    WHILE 1 DO
      SELECT CASE Rand(1)
       CASE 0    Func1()
       CASE 1    Funk2()
      END SELECT
    END
    END

    i.e. close folder definition for words: FUNCTION, WHILE is equally - END;
    and open folder definition "SELECT CASE" and close folder definition "END SELECT" consists of two words.

    How to define this in the User Language Define?

     
    • Nobody/Anonymous

      PS: try collapse the WHILE or SELECT or IF in this code with settings:
      open folder definition: SELECT WHILE THEN ELSE IF FUNCTION
      close folder definition: END
      right wirks only ELSE collapse :(

      FUNCTION Func0(INT x)
          WHILE 1 DO
              SELECT CASE Rand(1)
                  CASE 0 Func1()
                  CASE 1 Funk2()
              END SELECT
             
              IF x THEN
                  Func5()
              ELSE
                  Func6()
              END
          END
      END

       
    • Nobody/Anonymous

      I have nearly the same issue - in my user-defined language (PCL)I would like to fold on :
      start         end
      "FUNCTION"  "END FUNCTION"
      "WHILE"     "END WHILE"
      "SWITCH"    "END SWITCH"
      "IF"        "END IF"
      "FOR"       "END FOR"

      Is it possible to escape the space character?

       
      • Nobody/Anonymous

        What's wrong with using END as a folder closing word???

         
        • Nobody/Anonymous

          If you use END for everything then it does not work because the open's and close's do not match:
          for example
              FOR( n = 1 TO numWords )    /* open folding for FOR */
                  WHILE( word_id(n) >0 )    /* open folding for WHILE */
                      . . .
                  END WHILE                /* want to close folding for WHILE  */
                  /* - if you use 'END' will close folding for FOR */
              END FOR                        /* want to close folding for FOR */
              /* - if you use 'END' to close folding 'open' and 'close' are out of synch. */

           
          • Nobody/Anonymous

            The problem here is that WHILE after END is opening a folder again.
            This seems to undo the closing of the previous folder.

            Just notice what happens when you put a linebreak between END and WHILE.

            By the way, you need to separate your keywords from the other code.

            Wrong___: WHILE(
            Correct_: WHILE (

             
            • Nobody/Anonymous

              This word separating seems to be necessary for syntax coloring and folding.
              LET'S EXPLOIT THIS!

              Try this code:

              FOR ( n = 1 TO numWords ) /* open folding for FOR */
              WHILE ( word_id(n) >0 ) /* open folding for WHILE */
              . . . 
              END WHILE/* >WHILE and comment not colored */
              /* - if you use 'END' will close folding for FOR */
              END FOR/* >FOR and comment not colored */

              The WHILE and FOR after the END won't be colored, because they are not separated. The same goes for the WHILE and FOR inside the comments.

              The words aren't highlighted now and they are not recognized as opening folder keywords anymore. As far as I know, this "sticked" code should compile just as well.