ophoist.c

Go to the documentation of this file.
00001 
00002 /*  $Id: ophoist.c 1203 2006-04-05 22:58:09Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "op.h"
00032 #include "opinternal.h"
00033 
00034 
00035 
00036 typedef struct tyrestorablehoist {
00037     
00038     hdlheadrecord hhoisted; /*the head that was hoisted, whose subs are the summits*/
00039     
00040     hdlheadrecord hcursor; /*the location of the bar cursor*/
00041     } tyrestorablehoist;
00042     
00043 
00044 tyrestorablehoist savedhoists [cthoists]; /*for saving and restoring the hoist state*/
00045 
00046 short ctsavedhoists = 0;
00047 
00048 
00049 
00050 
00051 void ophoistdisplay (void) {
00052     
00053     /*
00054     7/8/92 dmb: call opresetscrollbars after opgetscrollbarinfo to force update
00055     */
00056     
00057     if (!opdisplayenabled ())
00058         return;
00059     
00060     opsetdisplaydefaults (outlinedata);
00061     
00062     opdirtymeasurements (); //6.0a14 dmb
00063     
00064     opsetctexpanded (outlinedata);
00065     
00066     opgetscrollbarinfo (true);
00067     
00068     opredrawscrollbars ();
00069     
00070     opinvaldisplay ();
00071     
00072     oploadeditbuffer ();
00073     
00074     /*opupdatenow ();*/ /*uncomment for debugging*/
00075     } /*ophoistdisplay*/
00076     
00077 
00078 static boolean oppushhoistvisit (hdlheadrecord hnode, ptrvoid refcon) {
00079 #pragma unused (refcon)
00080 
00081     /*
00082     assume we are only being called for the 1st level subheads of the guy
00083     being hoisted.  we reset his left pointer to indicate that he's a summit,
00084     and his level to 0.  then we reset the levels of all his subordinate
00085     nodes.
00086     */
00087     
00088     (**hnode).headlinkleft = hnode; /*wire him back to himself*/
00089     
00090     (**hnode).flexpanded = true; /*all 0-th level items are expanded*/
00091     
00092     (**hnode).headlevel = 0;
00093     
00094     opresetlevels (hnode);
00095     
00096     return (true);
00097     } /*oppushhoistvisit*/
00098     
00099 
00100 boolean oppushhoist (hdlheadrecord hnode) {
00101     
00102     register hdloutlinerecord ho = outlinedata;
00103     hdlheadrecord hsummit = (**hnode).headlinkright;
00104     tyhoistelement item;
00105     
00106     if ((**ho).tophoist >= cthoists)
00107         return (false);
00108         
00109     if (hsummit == hnode) /*has no subs*/
00110         return (false);
00111     
00112     opunloadeditbuffer ();
00113     
00114     item.hhoisted = hnode;
00115     
00116     item.hbarcursor = (**ho).hbarcursor;
00117     
00118     item.hsummit = (**ho).hsummit;
00119     
00120     item.lnumbarcursor = (**ho).lnumbarcursor;
00121     
00122     item.hline1 = (**ho).hline1;
00123     
00124     (**ho).hoiststack [(**ho).tophoist++] = item;
00125     
00126     oprecursivelyvisit (hnode, 1, &oppushhoistvisit, nil);
00127     
00128     (**ho).hsummit = hsummit; /*first sub is the first summit*/
00129     
00130     if (!opcontainsnode (hsummit, (**ho).hbarcursor))
00131         (**ho).hbarcursor = hsummit;
00132     
00133     (**ho).hline1 = hsummit;
00134     
00135     ophoistdisplay (); /*a really thorough smash of all data structures*/
00136     
00137     opdirtyoutline ();
00138     
00139     return (true);
00140     } /*oppushhoist*/
00141         
00142     
00143 boolean oppophoist (void) {
00144 
00145     register hdloutlinerecord ho = outlinedata;
00146     hdlheadrecord nomad, nextnomad;
00147     hdlheadrecord hhoisted; 
00148     hdlheadrecord hfirstsummit;
00149     tyhoistelement item;
00150     
00151     if ((**ho).tophoist <= 0)
00152         return (false);
00153     
00154     opunloadeditbuffer ();
00155     
00156     item = (**ho).hoiststack [--(**ho).tophoist];
00157     
00158     hhoisted = item.hhoisted;
00159     
00160     nomad = hfirstsummit = (**ho).hsummit; /*start with the current first summit*/
00161     
00162     while (true) { /*re-link old summits to point at their old parents*/
00163         
00164         (**nomad).headlinkleft = hhoisted; /*point at his old parent*/
00165         
00166         nextnomad = (**nomad).headlinkdown;
00167         
00168         if (nextnomad == nomad) /*reached the end of the list*/
00169             break;
00170             
00171         nomad = nextnomad;
00172         } /*while*/
00173     
00174     (**hhoisted).headlinkright = hfirstsummit; /*old 1st summit might have been X'd*/
00175     
00176     opresetlevels (hhoisted);
00177     
00178     (**ho).hbarcursor = item.hbarcursor;
00179     
00180     (**ho).hsummit = item.hsummit;
00181     
00182     (**ho).lnumbarcursor = item.lnumbarcursor;
00183     
00184     (**ho).hline1 = item.hline1;
00185 
00186     ophoistdisplay (); /*a really thorough smash of all data structures*/
00187     
00188     opdirtyoutline ();
00189     
00190     return (true);
00191     } /*oppophoist*/
00192     
00193 
00194 boolean oppopallhoists (void) {
00195     
00196     /*
00197     restore the structure to a normal, nothing-hoisted state so that the caller can
00198     save the structure.  pop the hoists in such a way that they can be restored after
00199     the saving is finished.
00200     
00201     3/1/91 dmb: in order to support nested calls -- which needs to happen when a 
00202     menubar is saved, for instance, we can't use globals so save the hoist 
00203     information.  instead, we re-use the hoist stack, and set tophoist to the 
00204     negative of its original value
00205     */
00206     
00207     register hdloutlinerecord ho = outlinedata;
00208     tyhoistelement item;
00209     short i;
00210     short cthoisted;
00211     
00212     cthoisted = (**ho).tophoist;
00213     
00214     if (cthoisted <= 0)
00215         return (false);
00216     
00217     for (i = cthoisted - 1; i >= 0; i--) {
00218         
00219         item.hhoisted = ((**ho).hoiststack [i]).hhoisted;
00220         
00221         item.hbarcursor = (**ho).hbarcursor;
00222         
00223         oppophoist ();
00224         
00225         (**ho).hoiststack [i] = item; /*this is now just beyond the end of the stack*/
00226         } /*for*/
00227     
00228     (**ho).tophoist = -cthoisted;
00229     
00230     return (true);
00231     } /*oppopallhoists*/
00232     
00233     
00234 void oprestorehoists (void) {
00235     
00236     /*
00237     after the saving process is finished, call this routine to restore the hoist
00238     state of the structure.
00239     */
00240     
00241     register hdloutlinerecord ho = outlinedata;
00242     short i;
00243     short cthoisted;
00244     tyhoistelement item;
00245     
00246     cthoisted = -(**ho).tophoist;
00247     
00248     if (cthoisted == 0)
00249         return;
00250     
00251     (**ho).tophoist = 0; /*nothing is really pushed*/
00252     
00253     for (i = 0; i < cthoisted; i++) {
00254         
00255         item = (**ho).hoiststack [i]; /*grab saved hoist info from beyond end of stack*/
00256         
00257         oppushhoist (item.hhoisted);
00258         
00259         (**ho).hbarcursor = item.hbarcursor;
00260         } /*for*/
00261     
00262     ophoistdisplay (); /*a really thorough smash of all data structures*/
00263     } /*oprestorehoists*/
00264     
00265     
00266 void opoutermostsummit (hdlheadrecord *hsummit) {
00267     
00268     /*
00269     punch through the illusion created by hoisting, and return to the caller
00270     a handle to the topmost summit in the structure.
00271     
00272     beware that the headlinkleft's of some of the nodes may not be what you'd
00273     expect without hoisting, but the right and down pointers are valid for
00274     traversals.
00275     */
00276     
00277     register hdloutlinerecord ho = outlinedata;
00278     
00279     if ((**ho).tophoist <= 0) /*nothing hoisted*/
00280         *hsummit = (**ho).hsummit;
00281     else
00282         *hsummit = ((**ho).hoiststack [0]).hsummit;
00283     } /*opoutermostsummit*/
00284     
00285     
00286     
00287     
00288     
00289     

Generated on Wed May 31 18:19:57 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6