Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!bu.edu!m2c!wpi.WPI.EDU!rcarter From: rcarter@wpi.WPI.EDU (Randolph Carter (nee. Joseph H. Allen)) Newsgroups: comp.editors Subject: Re: REPOST: editor.101 Message-ID: <1991Jun11.195732.25500@wpi.WPI.EDU> Date: 11 Jun 91 19:57:32 GMT References: <1991Jun4.155657.4357@mks.com> Organization: Kadath Tours, Inc. Lines: 31 The ghost of ant@mks.com (Anthony Howe) writes: >From: jhallen@wpi.wpi.edu (Joseph H Allen) >Subject: Editor 101 ... Ooof! The spelling errors I made when I wrote that... :-) Another buffer technique I recently found is the "pieces" method from the pointing editor (I can't remember the author's name). As you edit, you break a contiguous buffer up into pieces and add or delete characters from the edges of the pieces. Each piece is stored in a malloc-like structure in a virtual memory file. You have to maintain a list of all the pieces and search through this list when you move out of a piece. You also glue pieces together when possible. This is a neat technique, but it's complicated. An important technique for this and other buffer methods is to have routines which adjust pointer/size pairs as you move between pieces (or blocks or over the gap). This way, high level routines (like screen update) only have to keep track of the pointer and size and can simply call a function to update these when the beginning or end of a block is reached. Another usefull technique is to try to keep buffer pointers in the form of a byte offset from the beginning of the file in the buffer. There then needs to be logical to physical translation functions but keeping the pointer this simple will make implementing higher level functions much easier. -- /* rcarter@wpi.wpi.edu */ /* Amazing */ /* Joseph H. Allen */ int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0) +r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2 ]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}