[comp.sys.atari.st] SCREEN

trb@stag.UUCP ( Todd Burkey ) (02/02/89)

[I'm adding the atari.st group to this discussion, since FOLDED will
 be released on the ST at the same time as the Unix version is...if
 and when I find time to finish it. Since it sounds like there already
 is a folding editor for the MAC, I'll probably tweak it for the IBM
 PC next. -Todd]

In article <1385@raven.ukc.ac.uk> arc1@ukc.ac.uk (A.R.Curtis) writes:
>
>[mentions one type of folding using pointers to text files] 
>[and...]
>GNU emacs might be a good starting point in fact, since we can use
>text maps to define the fold structure (no nasty BEL characters etc)
>and then OPEN FOLD/ENTER FOLD invoke functions to manipulate this
>map. The map could either prefix the file (as is done in emacs rmail
>and news interfaces) or be a separate file altogether (cf. the MAC
>folding editor which I think uses separate files). Defining and
>selecting regions would give a nice way of representing the folds.

If anyone is interested, I did implement a simple minded folding
mechanism for the Apollo DM editor and vi quite a while back.
The approach I used was to simply allow the user to mark a region, and
then invoke an external command called 'fold' which took the marked
region, created a file for the region in a 'folded' directory, and
returned a single line of text to the editor such that:

int working_proc()
{
  i=i+1;
  return(i);
  }

becomes:

%include "folded/fld001";/* int working_proc() */

By attaching a similar program to a key that unfolds the 'current'
line, and by defining still a third key to toggle between three
different fold types (C, Pascal, and Troff), it actually turned out
to be a useful tool on the Apollos. If there is enough interest, I
will dig out the code and post it.

The main reason I decided I needed a folding editor rather than stay
with the above methodology was simply that I wanted to be able to use
the same folding mechanism on all the systems I program on (plus
having a seperate file for each fold tends to get a bit slow and
messy). FOLDED does create a control file for each file that has folds in
it (I originally tried a single control file per directory, but that
gets messy when you want to move things around.) The program also will
optionally create a configuration file when you exit it such that the
next time you invoke FOLDED it will open all the files you were
previously editing and place you at the same locations (I used to
do this with Emacs). All these extra files may be a bit messy, but they
are a LOT better than trying to deal with embedded characters in your
source code.

I am not sure how easy a true folding capability would be to add to
Emacs. To obtain efficient management of the folded text, you really
need to build a linked list of all the folds (assuming you are
modifying the Emacs source code...and I'm further assuming that Emacs
uses a next/prev list structure for lines). If you are doing a Lisp level
implementation of the folding, you may go insane trying to keep the
folding process managed using a text map. I felt I was losing it
many a night while trying to keep all the lists and pointers sane
every time something internal got realloced or freed.

Some things I still haven't decided on yet for the editor:
  1) is it worth searching inside of folded text as well as out (and
     if something is 'found', then what is the best way to present it
     to the user)...maybe just a temporary 'unfoldall' mode would
     suffice.
  2) ditto for global substitutes, deletes, etc.
  3) slow terminal support...does anyone out there actually bother to
     even use visual editors over modems slower than 2400 baud?
  4) graphics window support...I am very tempted to put in hooks to
     allow multiple buffers to pop up seperate windows in something
     like the Bellcore mgr package (X and NeWS still seem too slow and
     bulky to bother with). Has anyone out there programmed on top of
     mgr yet?

     -Todd Burkey   "A member of STdNET-The ST developers' Network"
      trb@stag.UUCP

t19@np1.hep.nl (Geert J v Oldenborgh) (02/03/89)

It may be of interest to hear that a folding editor for the Atari has been for
sale for the last 1.5 year or so.  It implements folds as special lines
that start with three arbitrary characters (to comment out the line), followed
by #[ name: (beginning), #] name: (end).  This leaves all folding in the editor,
so the speed is OK (instanteneous for all operations).  A UNIX port is being
beta-tested right now, the PC port is in the same stage.

As my linker is much slower than the compiler I tend to have large files
and I cannot imagine how awful editing was without folds ...

*  #[ signature:
Geert Jan van Oldenborgh
t19@nikhefh.hep.nl
*  #] signature: