Fold_Expand
Author: Rainer Kowallik


Purpose:  Fold and expand C, FORTRAN and TCL subroutines
          

   The following Menu entries are added:
   
      Language/Fold+Expand/Fold  Folds the function which starts at the
                                 insert cursor position.
                                 It tries to guess the language used
                                 (subroutine / function => FORTRAN, proc => TCL
                                 , "(*)" => C
                                 The whole function will be replaced by an
                                 entry with the Name of the function.
                                 A "" as the first character in the line
                                 denotes, that this function is folded
                                 (should be highlighted in violett if you have
                                 loaded any HighLight macro)
      Language/Fold+Expand/Expand  Expands a previously folded function
      Language/Fold+Expand/Fold All
                                 Scans all functions and folds them
                                 Not implemented (and probably never will...)
      Language/Fold+Expand/Fold Again
                                 This is part of a "Program Temporary Fix" to
                                 the Problem, that linenumbers refer to the
                                 folded text and any goto operation needs
                                 to expand the text before it can work
                                 correctly.
                                 This function folds all functions that have
                                 been unfolded by the "goto" operation or
                                 "Expand All".
      Language/Fold+Expand/Expand All
                                 Expands All folded functions

NOTE: The old "tkedit" function "SaveTo_" had to be replaced !

WARNING: you should consider this macro as a "Demo Version" which shows
      that it is possible to do such things with tkedit.
      It is NOT thoroughly tested nor is it recommended to be used in
      your "all day work".
      The main pitfall is, that no extensive check is made, wether you are at
      a procedure definition or elsewhere. This can lead to a complete mess !
      On the other hand, If you think it does the trick for you (and you do not
      try to cheat this macro) take it as it is.      

BUGS (and fixes since 1.6.3):
      - After folding of functions, the text appeared to be shorter. The File
        length widget now shows the correct number of bytes (fix in 1.6.4) and
        the file status is not changed
      - After folding of functions the linenumbers are incorrect.
        This can not be fixed easy (and fast) within TCL.
      - After folding of functions any "goto" operations (either by direct
        number or by "make_support") have gone to the incorrect linenumbers
        of the folded text.
        This bug has been temporarily fixed by expanding the text before
        any "goto" operation is performed. To get back the original
        state you can use the "fold again" function

-------------------------------------------------------------------------------
Rainer Kowallik             postdoc at       DESY-IfH Zeuthen (Germany)
Email: kowallik@ifh.de                       Platanenallee 6, D-15738 Zeuthen
