opverbs.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opverbs.c 1254 2006-04-12 20:27:14Z sethdill $    */
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 "frontierconfig.h"
00032 #include "memory.h"
00033 #include "strings.h"
00034 #include "quickdraw.h"
00035 #include "font.h"
00036 #include "cursor.h"
00037 #include "ops.h"
00038 #include "resources.h"
00039 #include "search.h"
00040 #include "threads.h"
00041 #include "shell.h"
00042 #include "shellbuttons.h"
00043 #include "shellhooks.h"
00044 #include "shellmenu.h"
00045 #include "shellundo.h"
00046 #include "lang.h"
00047 #include "langexternal.h"
00048 #include "langinternal.h"
00049 #include "langxml.h" //7.1b44 dmb
00050 #include "tablestructure.h"
00051 #include "tableverbs.h"
00052 #include "process.h"
00053 #include "op.h"
00054 #include "opinternal.h"
00055 #include "opverbs.h"
00056 #include "oplist.h" //6.2a6 AR
00057 #include "langsystem7.h" //6.2a6 AR
00058 #include "scripts.h"
00059 #include "cancoon.h"
00060 #include "kernelverbdefs.h"
00061 #ifdef flcomponent
00062     #include "osacomponent.h"
00063 #endif
00064 #include "opxml.h" /*7.0b21 PBS*/
00065 #include "wpengine.h"
00066 #include "opbuttons.h"
00067 
00068 
00069 
00070 #define opstringlist 159
00071 #define optypestring 1
00072 #define scripttypestring 2
00073 #define opsizestring 3
00074 
00075 #define operrorlist 259
00076 #define noooutlineerror 1
00077 #define internalerror 2
00078 #define namenotoutlineerror 3
00079 #define namenotscripterror 4
00080 #define rejectmenubarnum 5
00081 #define rejecttablenum 6 /*7.0b23 PBS*/
00082 
00083 
00084 typedef enum tyoptoken { /*verbs that are processed by op.c*/
00085     
00086     linetextfunc,
00087     
00088     levelfunc,
00089     
00090     countsubsfunc,
00091     
00092     countsummitsfunc,
00093     
00094     gofunc,
00095     
00096     firstsummitfunc,
00097     
00098     expandfunc,
00099     
00100     collapsefunc,
00101     
00102     getexpandedfunc,
00103 
00104     insertfunc,
00105     
00106     findfunc,
00107     
00108     sortfunc,
00109     
00110     setlinetextfunc,
00111     
00112     reorgfunc,
00113     
00114     promotefunc,
00115     
00116     demotefunc,
00117     
00118     hoistfunc,
00119     
00120     dehoistfunc,
00121     
00122     /*
00123     getmarkedfunc,
00124     
00125     setmarkedfunc,
00126     
00127     clearmarkedfunc,
00128     */
00129     
00130     deletesubsfunc,
00131     
00132     deletelinefunc,
00133     
00134     tabkeyreorgfunc,
00135     
00136     flatcursorkeysfunc,
00137     
00138     getdisplayfunc,
00139     
00140     setdisplayfunc,
00141     
00142     getcursorfunc,
00143     
00144     setcursorfunc,
00145     
00146     getrefconfunc,
00147     
00148     setrefconfunc,
00149     
00150     getexpansionstatefunc,
00151     
00152     setexpansionstatefunc,
00153     
00154     getscrollstatefunc,
00155     
00156     setscrollstatefunc,
00157     
00158     getsuboutlinefunc,
00159     
00160     insertoutlinefunc,
00161     
00162     setmodifiedfunc, /*7.0b5 PBS: new verb for setting dirty bit of outline*/
00163     
00164     getselectfunc, /*7.0b15 PBS: verb for getting selection as list of cursors*/
00165     
00166     getheadnumberfunc, /*7.0b17: one-based index of the current node*/
00167     
00168     visitallfunc, /*7.0b17: visit every headline in an outline*/
00169     
00170     getselectedsuboutlinesfunc, /*7.0b18: get selected headlines as an outline*/
00171     
00172     xmltooutlinefunc, /*7.0b21: XML outlineDocument to outline*/
00173     
00174     outlinetoxmlfunc, /*7.0b21: outline to XML outlineDocument*/
00175 
00176     sethtmlformattingfunc, /*7.0b28: turn on and off HTML semi-wizzy formatting*/
00177 
00178     gethtmlformattingfunc, /*7.0b28: return true if HTML semi-wizzy formatting is on*/
00179 
00180     setdynamicfunc, /*7.0b30: set the dynamic flag of a headline record*/
00181 
00182     getdynamicfunc, /*7.0b30: get the dynamic flag of a headline record*/
00183     
00184     /*opattributes verbs start here*/ /*7.0b16 PBS*/
00185     
00186     addgroupfunc,
00187     
00188     getallfunc,
00189     
00190     getonefunc,
00191     
00192     makeemptyfunc,
00193     
00194     setonefunc,
00195 
00196     /*script verbs start here*/
00197     
00198     compilefunc,
00199     
00200     uncompilefunc,
00201     
00202     getcodefunc,
00203             
00204     gettypefunc,
00205     
00206     settypefunc,
00207 
00208     makecommentfunc,
00209     
00210     uncommentfunc,
00211     
00212     iscommentfunc,
00213     
00214     getbreakpointfunc,
00215     
00216     setbreakpointfunc,
00217     
00218     clearbreakpointfunc,
00219     
00220     startprofilefunc,
00221     
00222     stopprofilefunc,
00223     
00224     getosacodefunc,
00225     
00226     getosasourcefunc,
00227     
00228     ctscriptverbs
00229     
00230     } tyoptoken;
00231 
00232 
00233 
00234 #if langexternalfind_optimization
00235 
00236     // 11/15/01 dmb: too messy trying to add linkedcode field to tyexternalvariable, so dup here
00237     typedef struct tyoutlinevariable {
00238         
00239         unsigned short id;  /*tyexternalid*/
00240         
00241         unsigned short flinmemory: 1; /*if true, variabledata is in a handle, else a dbaddress*/
00242         
00243         unsigned short flmayaffectdisplay: 1; /*not in memory, but being displayed in a table window*/
00244         
00245         unsigned short flpacked: 1; /* for wp doc; it isn't being edited, so we store it packed*/
00246 
00247         unsigned short flscript: 1; /* for outlines and scripts; they're identical, except for this bit*/
00248 
00249         unsigned short flsystemtable: 1; /*for tables: was it created by the system, or by a user script?*/
00250 
00251         #ifdef xmlfeatures
00252             unsigned short flxml: 1; /*preserve for tables; is it an xml table?*/
00253         #endif
00254         
00255         long variabledata; /*either a handle to data record or a dbaddress*/
00256         
00257         hdldatabaserecord hdatabase; // 5.0a18 dmb
00258 
00259         dbaddress oldaddress; /*last place this variable was stored in db*/
00260 
00261         hdlhashtable hexternaltable;
00262 
00263         hdlhashnode hexternalnode;
00264         
00265         Handle linkedcode; /*you can link code into any outline, mostly for scripts though*/
00266         } tyoutlinevariable, *ptroutlinevariable, **hdloutlinevariable;
00267 
00268 #else
00269     
00270     typedef struct tyoutlinevariable {
00271         
00272         unsigned short id; /*tyexternalid: managed by langexternal.c*/
00273         
00274         unsigned short flinmemory: 1; /*if true, variabledata is an hdloutlinerecord, else a dbaddress*/
00275         
00276         unsigned short flmayaffectdisplay: 1; /*not in memory, but being displayed in a table window*/
00277         
00278         unsigned short flscript: 1; /*outlines and scripts are identical, except for this bit*/
00279         
00280         long variabledata; /*either a hdloutlinerecord or a dbaddress*/
00281         
00282         hdldatabaserecord hdatabase; // 5.0a18 dmb
00283 
00284         dbaddress oldaddress; /*last place this outline was stored in db*/
00285         
00286         Handle linkedcode; /*you can link code into any outline, mostly for scripts though*/
00287         } tyoutlinevariable, *ptroutlinevariable, **hdloutlinevariable;
00288 
00289 #endif
00290 
00291 
00292 
00293 static short errornum = 0;
00294 
00295 
00296 static hdloutlinerecord outlinedataholder = nil;
00297 
00298 static void opverbresize (void); /*forward*/
00299 
00300 
00301 static boolean opverbsetglobals (void) {
00302     
00303     /*
00304     5.1.5b7 dmb: added this layer so we can trap the setting of outlinedata
00305     */
00306     
00307     opsetoutline (outlinedataholder);
00308     
00309     return (opeditsetglobals ());
00310     } /*opverbsetglobals*/
00311 
00312 
00313 
00314 #if !flruntime
00315 
00316 boolean opverbgettypestring (hdlexternalvariable hvariable, bigstring bs) {
00317     
00318     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00319     short id;
00320     
00321     if ((**hv).flscript)
00322         id = scripttypestring;
00323     else
00324         id = optypestring;
00325     
00326     getstringlist (opstringlist, id, bs);
00327     
00328     return (true);
00329     } /*opverbgettypestring*/
00330 
00331 #endif
00332 
00333 static boolean opverbdisposecode (hdloutlinevariable hvariable) {
00334     
00335     /*
00336     5/19/92 dmb: attempt to fix 1.0 crashing bug: if we dispose code that is 
00337     running, but isn't the main routine (i.e. it's been called by another script), 
00338     we crash.  we needed a call to processcodedisposed here, but didn't have 
00339     a pointer back to the node that produced the code, which is the refcon that 
00340     processcodedisposed expects.  scriptgetcode now stashes this link in the nodeval 
00341     at the top of the code tree, just as langaddhandler does to maintain the source 
00342     position when executing local procedures.  this ought to work.
00343     */
00344     
00345     register hdloutlinevariable hv = hvariable;
00346     register hdltreenode hcode = (hdltreenode) (**hv).linkedcode;
00347     
00348     if (hcode != nil) {
00349         
00350         if (!processdisposecode (hcode)) { /*process manager didn't handle it*/
00351             
00352             processcodedisposed ((**hcode).nodeval.data.longvalue); /*5/19/92 dmb*/
00353             
00354             langdisposetree (hcode);
00355             }
00356         
00357         (**hv).linkedcode = nil;
00358         }
00359     
00360     return (true);
00361     } /*opverbdisposecode*/
00362 
00363 
00364 static boolean opdisposevariable (hdlexternalvariable hvariable, boolean fldisk) {
00365     
00366     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00367     
00368     opdisposeoutline ((hdloutlinerecord) (**hv).variabledata, fldisk);
00369     
00370     return (true);
00371     } /*opdisposevariable*/
00372 
00373 
00374 boolean opverbdispose (hdlexternalvariable hvariable, boolean fldisk) {
00375     
00376     register hdlexternalvariable hv = hvariable;
00377     
00378     opverbdisposecode ((hdloutlinevariable) hv); /*must check for code even if outline isn't in memory*/
00379     
00380     return (langexternaldisposevariable (hv, fldisk, &opdisposevariable));
00381     } /*opverbdispose*/
00382 
00383 
00384 static boolean newoutlinevariable (boolean flinmemory, long variabledata, hdloutlinevariable *h) {
00385     
00386     tyoutlinevariable item;
00387     
00388     clearbytes (&item, sizeof (item));
00389     
00390     item.flinmemory = flinmemory;
00391     
00392     item.variabledata = variabledata;
00393     
00394     item.hdatabase = databasedata; // 5.0a18 dmb
00395 
00396     return (newfilledhandle (&item, sizeof (item), (Handle *) h));
00397     } /*newoutlinevariable*/
00398 
00399 
00400 void opverbunload (hdlexternalvariable hvariable, dbaddress adr) {
00401     
00402     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00403     register hdloutlinerecord ho = (hdloutlinerecord) (**hv).variabledata;
00404     
00405     assert ((**hv).flinmemory);
00406     
00407     // assert (adr != nildbaddress);
00408     
00409     opdisposeoutline (ho, false); /*reclaim memory used by outline*/
00410     
00411     if (adr == nildbaddress) { // 5.0d3 dmb: a file object, we're done with the variable
00412     
00413         disposehandle ((Handle) hv);
00414         }
00415     else {
00416         
00417         (**hv).flinmemory = false;
00418         
00419         (**hv).variabledata = adr;
00420         }
00421     } /*opverbunload*/
00422 
00423 
00424 boolean opverblinkcode (hdlexternalvariable hvariable, Handle hcode) {
00425     
00426     /*
00427     we have access to the declaration of an outlinevariable, so we have to
00428     bottleneck any setting of the linked code field.  it's a good idea anyway
00429     because we may have to do surgery on the code before linking it.
00430     */
00431     
00432     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00433     
00434     (**hv).linkedcode = hcode;
00435     
00436     if ((**hv).flinmemory) {
00437     
00438         register hdloutlinerecord ho = (hdloutlinerecord) (**hv).variabledata;
00439         hdlwindowinfo hinfo;
00440         
00441         (**ho).flrecentlychanged = false;
00442         
00443         if ((**ho).flwindowopen && shellfinddatawindow ((Handle) ho, &hinfo)) {
00444             
00445             shellpushglobals ((**hinfo).macwindow);
00446             
00447             shellinvalbuttons ();
00448             
00449             shellpopglobals ();
00450             }
00451         }
00452     
00453     return (true);
00454     } /*opverblinkcode*/
00455 
00456 
00457 boolean opverbgetlinkedcode (hdlexternalvariable hvariable, hdltreenode *hcode) {
00458     
00459     register hdltreenode h;
00460     
00461     *hcode = h = (hdltreenode) (**(hdloutlinevariable) hvariable).linkedcode;
00462     
00463     return (h != nil) ;
00464     } /*opverbgetlinkedcode*/
00465 
00466 #if !flruntime
00467 
00468 static void opverbsetcallbacks (hdloutlinevariable hvariable, hdloutlinerecord houtline) {
00469     
00470     /*
00471     register hdloutlinerecord ho = houtline;
00472     
00473     (**ho).setscrollbarsroutine = &opverbsetscrollbarsroutine;  // 1/31/97 dmb: default is ok now
00474     */
00475     
00476     if ((**hvariable).flscript)
00477         scriptsetcallbacks (houtline);
00478     } /*opverbsetcallbacks*/
00479 
00480 
00481 static void opverbcheckwindowrect (hdloutlinerecord houtline) {
00482     
00483     register hdloutlinerecord ho = houtline;
00484     hdlwindowinfo hinfo;
00485         
00486     if ((**ho).flwindowopen) { /*make windowrect reflect current window size & position*/
00487         
00488         if (shellfinddatawindow ((Handle) ho, &hinfo)) {
00489             
00490             Rect r;
00491             
00492             shellgetglobalwindowrect (hinfo, &r);
00493             
00494             if (!equalrects (r, (**ho).windowrect)) {
00495             
00496                 (**ho).windowrect = r;
00497                 
00498                 (**ho).fldirty = true;
00499                 }
00500             }
00501         }
00502     } /*opverbcheckwindowrect*/
00503 
00504 
00505 boolean opwindowopen (hdlexternalvariable hvariable, hdlwindowinfo *hinfo) {
00506     
00507     /*
00508     5.0b9 dmb: for clipboard operations, must test ho for nil
00509     */
00510 
00511     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00512     register hdloutlinerecord ho;
00513     
00514     if (!(**hv).flinmemory)
00515         return (false);
00516     
00517     ho = (hdloutlinerecord) (**hv).variabledata;
00518     
00519     if (ho == nil)
00520         return (false);
00521 
00522     shellfinddatawindow ((Handle) ho, hinfo); /*3/19/91 DW*/
00523     
00524     #ifndef version5orgreater
00525         if (*hinfo == nil && (**ho).flwindowopen) {
00526             
00527             shellinternalerror (idopwindowopenbug, STR_ourline_windowopen_inconsistency);
00528             
00529             (**ho).flwindowopen = false;
00530             }
00531     #endif
00532     
00533     return ((**ho).flwindowopen);
00534     } /*opwindowopen*/
00535 
00536 
00537 #else
00538 
00539     #define opverbsetcallbacks(hvariable, houtline) ((void *) 0)
00540 
00541     #define opverbcheckwindowrect(houtline) ((void *) 0)
00542 
00543     #define opwindowopen(hvariable, hinfo) 0
00544 
00545     #define fldatabasesaveas 0
00546 
00547 #endif
00548 
00549 static void opverbsetupoutline (hdloutlinerecord ho, hdloutlinevariable hv) {
00550 
00551     /*
00552     7.0d8 PBS: set structured text keys for outlines, not just odb outlines.
00553     When an outline is created, it's in text mode, not bar cursor mode,
00554     so you can actually start typing right away.
00555 
00556     7.0b33 PBS: For non-outline outlines, explicitly set flhtml to false.
00557     Fixes a bug where scripts may get HTML formatting.
00558     */
00559 
00560     (**ho).outlinerefcon = (long) hv; /*point back to variable*/
00561     
00562     if ((**hv).flscript)
00563         (**ho).outlinetype = outlineisdatabasescript;
00564     else
00565         (**ho).outlinetype = outlineisoutline;
00566     
00567     (**ho).flfatheadlines = true;
00568 
00569     (**ho).flhorizscrolldisabled = true; /*7.0b26 PBS: no horizontal scrolling.*/
00570 
00571 #ifdef PIKExxx /*7.1b29 PBS: this "feature" has been rolled back.*/
00572 
00573     /*7.0d8 PBS: type characters to find headline.*/
00574 
00575     (**ho).flstructuredtextkeys = true; 
00576 
00577 #endif
00578     
00579     if ((**ho).outlinetype == outlineisoutline)
00580         (**ho).flhtml = true;
00581     else
00582         (**ho).flhtml = false; /*7.0b33 PBS: make sure HTML formatting is off for scripts.*/
00583     
00584     opverbsetcallbacks (hv, ho);
00585     } /*opverbsetupoutline*/
00586 
00587 
00588 static boolean opverbpackoutline (hdloutlinerecord houtline, Handle *hpacked) {
00589     
00590     *hpacked = nil;
00591     
00592     return (oppackoutline (houtline, hpacked));
00593     } /*opverbpackoutline*/
00594 
00595 
00596 static boolean opverbinmemory (hdloutlinevariable hv) {
00597 
00598     /*
00599     5.0a18 dmb: support database linking
00600     */
00601     
00602     hdloutlinerecord ho;
00603     register boolean fl;
00604     dbaddress adr;
00605     Handle hpackedoutline;
00606     long ix = 0;
00607     
00608     if ((**hv).flinmemory) /*nothing to do, it's already in memory*/
00609         return (true);
00610     
00611     dbpushdatabase ((**hv).hdatabase);
00612 
00613     adr = (dbaddress) (**hv).variabledata;
00614     
00615     fl = dbrefhandle (adr, &hpackedoutline);
00616     
00617     if (fl) {
00618 
00619         fl = opunpack (hpackedoutline, &ix, &ho);
00620         
00621         disposehandle (hpackedoutline);
00622         }
00623 
00624     dbpopdatabase ();
00625     
00626     if (!fl) 
00627         return (false);
00628     
00629     (**hv).flinmemory = true;
00630     
00631     (**hv).variabledata = (long) ho; /*link into variable structure*/
00632     
00633     (**hv).oldaddress = adr; /*last place this outline was stored*/
00634     
00635     opverbsetupoutline (ho, hv);
00636     
00637     return (true);
00638     } /*opverbinmemory*/
00639 
00640 
00641 boolean opverbmemorypack (hdlexternalvariable h, Handle *hpacked) {
00642     
00643     /*
00644     a special entrypoint for the language's pack and upack verbs.
00645     */
00646     
00647     register hdloutlinevariable hv = (hdloutlinevariable) h;
00648     register hdloutlinerecord ho;
00649     boolean fl;
00650     Handle hpush = nil;
00651     
00652     if (!(**hv).flinmemory) {
00653     
00654         if (!langexternalrefdata ((hdlexternalvariable) hv, &hpush))
00655             return (false);
00656         
00657         goto pushandexit;
00658         }
00659     
00660     ho = (hdloutlinerecord) (**hv).variabledata;
00661     
00662     opverbcheckwindowrect (ho);
00663     
00664     if (!opverbpackoutline (ho, &hpush))
00665         return (false);
00666     
00667     pushandexit:
00668     
00669     if (hpush == nil)
00670         return (false);
00671     
00672     fl = pushhandle (hpush, *hpacked);
00673     
00674     disposehandle (hpush);
00675     
00676     return (fl);
00677     } /*opverbmemorypack*/
00678 
00679 
00680 boolean opverbmemoryunpack (Handle hpacked, long *ixload, hdlexternalvariable *hvariable) {
00681     
00682     /*
00683     xxx [create a new outline variable -- not in memory.]
00684     
00685     12/14/90 dmb: not good...
00686     can't create the variable on disk, because the database doesn't have 
00687     provisions for managing unsaved data on disk.  that is, there's no 
00688     mechanism to free the bytes allocated if the user doesn't save 
00689     changes (or the unpack was for temporary copy).  such a mechanism 
00690     could be added, but in the meanwhile...
00691     
00692     create a new outline variable, in memory.
00693     
00694     this is a special entrypoint for the pack and unpack verbs.
00695     
00696     5.0.2b12 dmb: if ixload is nil, we just unpack hpacked directly, and consume it.
00697     */
00698     
00699     hdloutlinevariable *h = (hdloutlinevariable *) hvariable;
00700     Handle hpackedop;
00701     hdloutlinerecord ho;
00702     boolean fl;
00703     long ix = 0;
00704     
00705     if (ixload == nil)
00706         hpackedop = hpacked;
00707     else
00708         if (!loadhandleremains (*ixload, hpacked, &hpackedop))
00709             return (false);
00710     
00711     /*
00712     fl = dballochandle (hpackedop, &adr);
00713     */
00714     
00715     fl = opunpack (hpackedop, &ix, &ho);
00716     
00717     disposehandle (hpackedop);
00718     
00719     if (!fl)
00720         return (false);
00721     
00722     if (!newoutlinevariable (true, (long) ho, h)) {
00723         
00724         opdisposeoutline (ho, false);
00725         
00726         return (false);
00727         }
00728     
00729     opverbsetupoutline (ho, *h);
00730     
00731     (**ho).fldirty = true; /*never been saved, can't be clean*/
00732     
00733     return (true);
00734     } /*opverbmemoryunpack*/
00735 
00736 
00737 boolean opverbscriptmemoryunpack (Handle hpacked, long *ixload, hdlexternalvariable *hvariable) {
00738     
00739     /*
00740     4/24/92 dmb: must call opverbsetcallbacks here, after setting flscript to 
00741     true.  this should explain while cmd-click wouldn't always toggle breakpoints.
00742     */
00743     
00744     register hdloutlinevariable hv;
00745     hdloutlinerecord ho;
00746     
00747     if (!opverbmemoryunpack (hpacked, ixload, hvariable))
00748         return (false);
00749     
00750     hv = (hdloutlinevariable) *hvariable;
00751     
00752     ho = (hdloutlinerecord) (**hv).variabledata;
00753     
00754     (**hv).flscript = true;
00755     
00756     opverbsetupoutline (ho, hv);
00757     
00758     /*
00759     (**ho).outlinetype = outlineisdatabasescript;
00760     
00761     (**hv).flscript = true;
00762     
00763     opverbsetcallbacks (hv, ho);
00764     */
00765     
00766     return (true);
00767     } /*opverbscriptmemoryunpack*/
00768 
00769 
00770 boolean opverbpack (hdlexternalvariable h, Handle *hpacked, boolean *flnewdbaddress) {
00771 
00772     /*
00773     6.2a15 AR: added flnewdbaddress parameter
00774     */
00775     
00776     register hdloutlinevariable hv = (hdloutlinevariable) h;
00777     register hdloutlinerecord ho;
00778     register boolean fl;
00779     Handle hpackedoutline;
00780     dbaddress adr;
00781     hdlwindowinfo hinfo;
00782     boolean fltempload = false;
00783     
00784     if (!(**hv).flinmemory) { /*simple case, outline is resident in the db*/
00785         
00786         if (flconvertingolddatabase) {
00787             
00788             if (!opverbinmemory (hv))
00789                 return (false);
00790             
00791             fltempload = true;
00792             }
00793         else {
00794         
00795             adr = (dbaddress) (**hv).variabledata;
00796             
00797             if (fldatabasesaveas)
00798                 if (!dbcopy (adr, &adr))
00799                     return (false);
00800             
00801             goto pushaddress;
00802             }
00803         }
00804     
00805     ho = (hdloutlinerecord) (**hv).variabledata;
00806     
00807     opverbcheckwindowrect (ho);
00808     
00809     adr = (**hv).oldaddress; /*place where this outline used to be stored*/
00810     
00811     if (!fldatabasesaveas && !(**ho).fldirty && !(**ho).fldirtyview) /*don't need to update the db version of the outline*/
00812         goto pushaddress;
00813     
00814     if (!opverbpackoutline (ho, &hpackedoutline))
00815         return (false);
00816     
00817     fl = dbassignhandle (hpackedoutline, &adr);
00818     
00819     disposehandle (hpackedoutline);
00820     
00821     if (!fl)
00822         return (false);
00823     
00824     if (fldatabasesaveas && !fltempload)
00825         goto pushaddress;
00826     
00827     if (!opwindowopen ((hdlexternalvariable) hv, &hinfo) /* (**ho).flwindowopen*/ ) /*it's been saved, we can reclaim some memory*/
00828         opverbunload ((hdlexternalvariable) hv, adr);
00829     
00830     else {
00831         
00832         assert (!fltempload);
00833         
00834         (**ho).fldirty = false; /*we just saved off a new db version*/
00835         
00836         (**ho).fldirtyview = false;
00837         
00838         if (hinfo != nil)
00839             shellsetwindowchanges (hinfo, false);
00840         }
00841     
00842     pushaddress:
00843     
00844     if (!fldatabasesaveas) {
00845     
00846         *flnewdbaddress = ((**hv).oldaddress != adr);
00847             
00848         (**hv).oldaddress = adr;
00849         }
00850     else
00851         *flnewdbaddress = true; 
00852     
00853     return (pushlongondiskhandle (adr, *hpacked));
00854     } /*opverbpack*/
00855     
00856     
00857 boolean opverbunpack (Handle hpacked, long *ixload, hdlexternalvariable *hvariable) {
00858 
00859     dbaddress adr;
00860     
00861     if (!loadlongfromdiskhandle (hpacked, ixload, &adr)) 
00862         return (false);
00863         
00864     return (newoutlinevariable (false, adr, (hdloutlinevariable *) hvariable));
00865     } /*opverbunpack*/
00866 
00867 
00868 boolean opverbscriptunpack (Handle hpacked, long *ixload, hdlexternalvariable *hvariable) {
00869     
00870     register hdloutlinevariable hv;
00871     
00872     if (!opverbunpack (hpacked, ixload, hvariable))
00873         return (false);
00874     
00875     hv = (hdloutlinevariable) *hvariable;
00876     
00877     (**hv).flscript = true;
00878     
00879     return (true);
00880     } /*opverbscriptunpack*/
00881 
00882 
00883 boolean opverbgetlangtext (hdlexternalvariable hvariable, boolean flpretty, Handle *htext, long *signature) {
00884     
00885     /*
00886     10/7/91 dmb: if we have to load the outline to get it's text, release 
00887     the outline structure when we're done.  our caller is going to compile 
00888     the code and link it into the variable; there typically won't be any 
00889     further need for the outline itself.
00890     
00891     2.1b12 dmb: if htext is nil, just return the signature
00892     */
00893     
00894     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00895     register hdloutlinerecord ho;
00896     register boolean fltempload;
00897     boolean fl;
00898     
00899     fltempload = !(**hv).flinmemory;
00900     
00901     if (!opverbinmemory (hv))
00902         return (false);
00903     
00904     ho = (hdloutlinerecord) (**hv).variabledata;
00905     
00906     *signature = (**ho).outlinesignature;
00907     
00908     if (htext == nil)
00909         fl = true;
00910     else
00911         fl = opgetlangtext (ho, flpretty, htext);
00912     
00913     if (fltempload)
00914         opverbunload ((hdlexternalvariable) hv, (**hv).oldaddress);
00915     
00916     return (fl);
00917     } /*opverbgetlangtext*/
00918 
00919 
00920 #if !flruntime
00921 
00922 boolean opverbgetsize (hdlexternalvariable hvariable, long *size) {
00923     
00924     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00925     register hdloutlinerecord ho;
00926     register long ctheads;
00927     
00928     if (!opverbinmemory (hv))
00929         return (false);
00930     
00931     ho = (hdloutlinerecord) (**hv).variabledata;
00932     
00933     oppushoutline (ho);
00934     
00935     ctheads = opcountheads ();
00936     
00937     oppopoutline ();
00938     
00939     *size = (long) ctheads;
00940     
00941     return (true);
00942     } /*opverbgetsize*/
00943 
00944 
00945 boolean opverbgetsummitstring (hdlexternalvariable h, bigstring bs) {
00946     
00947     /*
00948     get string for table display.  variable is in memory
00949     */
00950     
00951     long ctheads;
00952     
00953     if (!opverbgetsize (h, &ctheads))
00954         return (false);
00955     
00956     parsenumberstring (opstringlist, opsizestring, ctheads, bs);
00957     
00958     /*
00959     numbertostring (ctheads, bs);
00960     
00961     if (ctheads != 1)
00962         pushstring ("\p lines", bs);
00963     else
00964         pushstring ("\p line", bs);
00965     */
00966     
00967     return (true);
00968     } /*opverbgetsummitstring*/
00969     
00970 
00971 boolean opverbisdirty (hdlexternalvariable hvariable) {
00972     
00973     /*
00974     8/11/92 dmb: check windowrect now to ensure consistent results
00975     */
00976     
00977     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00978     register hdloutlinerecord ho;
00979     
00980     if (!(**hv).flinmemory)
00981         return (false);
00982     
00983     ho = (hdloutlinerecord) (**hv).variabledata;
00984     
00985     opverbcheckwindowrect (ho);
00986     
00987     return ((**ho).fldirty || (**ho).fldirtyview);
00988     } /*opverbisdirty*/
00989 
00990 
00991 boolean opverbsetdirty (hdlexternalvariable hvariable, boolean fldirty) {
00992     
00993     /*
00994     4/15/92 dmb: see comments in langexternalsetdirty
00995     */
00996     
00997     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
00998     register hdloutlinerecord ho;
00999     
01000     if (!opverbinmemory (hv))
01001         return (false);
01002     
01003     ho = (hdloutlinerecord) (**hv).variabledata;
01004     
01005     (**ho).fldirty = (**ho).fldirtyview = (**ho).flrecentlychanged = fldirty;
01006     
01007     return (true);
01008     } /*opverbsetdirty*/
01009 
01010 
01011 boolean opverbpacktotext (hdlexternalvariable h, Handle htext) {
01012     
01013     /*
01014     12/13/91 dmb: now that opgetlangtext can make it pretty, use it 
01015     when exporting scripts
01016     
01017     5.0.2b20 dmb: unload if just loaded
01018     */
01019     
01020     register hdloutlinevariable hv = (hdloutlinevariable) h;
01021     register hdloutlinerecord ho;
01022     register boolean fl;
01023     Handle hprogram;
01024     boolean fltempload = !(**hv).flinmemory;
01025     
01026     if (!opverbinmemory (hv))
01027         return (false);
01028     
01029     ho = (hdloutlinerecord) (**hv).variabledata;
01030     
01031     if ((**hv).flscript) {
01032         
01033         fl = opgetlangtext (ho, true, &hprogram);
01034         
01035         if (fl) {
01036             
01037             fl = pushhandle (hprogram, htext);
01038             
01039             disposehandle (hprogram);
01040             }
01041         }
01042     else
01043         fl = opoutlinetotextscrap (ho, false, htext);
01044     
01045     if (fltempload)
01046         opverbunload ((hdlexternalvariable) hv, (**hv).oldaddress);
01047     
01048     return (fl);
01049     } /*opverbpacktotext*/
01050 
01051 
01052 boolean opverbgettimes (hdlexternalvariable h, long *timecreated, long *timemodified) {
01053     
01054     register hdloutlinevariable hv = (hdloutlinevariable) h;
01055     register hdloutlinerecord ho;
01056     
01057     if (!opverbinmemory (hv))
01058         return (false);
01059     
01060     ho = (hdloutlinerecord) (**hv).variabledata;
01061     
01062     *timecreated = (**ho).timecreated;
01063     
01064     *timemodified = (**ho).timelastsave;
01065     
01066     return (true);
01067     } /*opverbgettimes*/
01068 
01069 
01070 boolean opverbsettimes (hdlexternalvariable h, long timecreated, long timemodified) {
01071     
01072     register hdloutlinevariable hv = (hdloutlinevariable) h;
01073     register hdloutlinerecord ho;
01074     
01075     if (!opverbinmemory (hv))
01076         return (false);
01077     
01078     ho = (hdloutlinerecord) (**hv).variabledata;
01079     
01080     (**ho).timecreated = timecreated;
01081     
01082     (**ho).timelastsave = timemodified;
01083     
01084     return (true);
01085     } /*opverbsettimes*/
01086 
01087 
01088 boolean opverbnew (short id, Handle hdata, hdlexternalvariable *hvariable) {
01089     
01090     /*
01091     9/6/91 dmb: now accept hdata parameter as an outline from which to copy 
01092     headline and formatting data.
01093     
01094     12/29/91 dmb: added call to opsetctexpanded()
01095     
01096     2.1b11 dmb: if source outline is given in hdata, grab its outlinesigature
01097     
01098     5.0.2b13 dmb: write the edit buffer of the source outline
01099     
01100     5.1.5b9 dmb: preserve barcursor in copied outline
01101     
01102     2006-03-03 aradke: if the source outline is hoisted, temporarily unhoist it
01103         in order to copy all lines. this fixes data loss when making an in-memory
01104         copy of an outline and it restores pre-5.0.2b12 behavior. until then,
01105         obverbcopyvalue used pack/unpack to make a copy which preserves hoisted lines.
01106         http://sourceforge.net/tracker/index.php?func=detail&aid=1259245&group_id=120666&atid=687798
01107     */
01108     
01109     register hdloutlinevariable hv;
01110     register hdloutlinerecord ho;
01111     hdlheadrecord hsummit = nil;
01112     hdloutlinerecord houtline;
01113     
01114     if (!newoutlinevariable (true, 0L, (hdloutlinevariable *) hvariable))
01115         return (false);
01116     
01117     hv = (hdloutlinevariable) *hvariable; /*copy into register*/
01118     
01119     if (!newoutlinerecord (&houtline)) {
01120         
01121         disposehandle ((Handle) hv);
01122         
01123         return (false);
01124         }
01125     
01126     ho = houtline; /*copy into register*/
01127     
01128     if (hdata != nil) {
01129         
01130         register hdloutlinerecord hsource = (hdloutlinerecord) hdata;
01131         long lnumcursor;
01132         boolean flpoppedhoists;
01133         
01134         oppushoutline (hsource);
01135         
01136             opwriteeditbuffer ();
01137             
01138             flpoppedhoists = oppopallhoists (); /*2006-03-03 aradke: temporarily unhoist before getting cursor position*/
01139         
01140             opgetnodeline ((**hsource).hbarcursor, &lnumcursor);
01141         
01142         oppopoutline ();
01143         
01144         oppushoutline (ho);
01145         
01146             opcopysiblings ((**hsource).hsummit, &hsummit);
01147             
01148             if (hsummit == nil) {
01149                 
01150                 oppopoutline ();
01151                 
01152                 opdisposeoutline (ho, false);
01153                 
01154                 disposehandle ((Handle) hv);
01155                 
01156                 return (false);
01157                 }
01158             
01159             opsetsummit (ho, hsummit);
01160             
01161             opcopyformatting (hsource, ho);
01162             
01163             (**ho).outlinesignature = (**hsource).outlinesignature;
01164             
01165             opsetctexpanded (ho);
01166                 
01167             (**ho).hbarcursor = oprepeatedbump (flatdown, lnumcursor, hsummit, true);
01168     
01169         oppopoutline ();
01170         
01171         if (flpoppedhoists) {   /*2006-03-03 aradke*/
01172             
01173             oppushoutline (hsource);
01174             
01175             oprestorehoists ();
01176             
01177             oppopoutline ();
01178             }
01179         }
01180     
01181     (**hv).variabledata = (long) ho; /*link the outline rec into the variable rec*/
01182     
01183     if (id == idscriptprocessor) {
01184     
01185         (**hv).flscript = true;
01186         
01187         if (hdata == nil) { //set the default font for new scripts
01188             
01189             shellgetconfig (idscriptconfig, &config);
01190             
01191             (**ho).fontnum = config.defaultfont;
01192             
01193             (**ho).fontsize = config.defaultsize;
01194             }
01195         }
01196     
01197     opverbsetupoutline (ho, hv); /*must be called after variable.flscript is set*/
01198     
01199     (**ho).fldirty = true; /*needs to be saved*/
01200     
01201     return (true);
01202     } /*opverbnew*/
01203 
01204 
01205 boolean opverbcopyvalue (hdlexternalvariable hsource, hdlexternalvariable *hcopy) {
01206     
01207     /*
01208     5.0.2b12 dmb: new routine, so we don't have to pack/unpack
01209     */
01210     
01211     register hdloutlinevariable hv = (hdloutlinevariable) hsource;
01212     dbaddress adr;
01213     Handle hpackedoutline;
01214     boolean fl;
01215     
01216     if ((**hv).flinmemory) { //in memory, make a new variable from the outline
01217         
01218         fl = opverbnew ((**hv).id, (Handle) (**hv).variabledata, hcopy);
01219         }
01220     else { //not in memory, unpack into new variable
01221         
01222         dbpushdatabase ((**hv).hdatabase);
01223         
01224         adr = (dbaddress) (**hv).variabledata;
01225         
01226         fl = dbrefhandle (adr, &hpackedoutline);
01227         
01228         dbpopdatabase ();
01229         
01230         if (!fl) 
01231             return (false);
01232         
01233         if ((**hv).flscript)
01234             fl = opverbscriptmemoryunpack (hpackedoutline, nil, hcopy);
01235         else
01236             fl = opverbmemoryunpack (hpackedoutline, nil, hcopy);
01237         }
01238     
01239     if (fl)
01240         (***hcopy).id = (**hv).id;
01241     
01242     return (fl);
01243     } /*opverbcopyvalue*/
01244 
01245 
01246 #endif // !flruntime
01247 
01248 
01249 static boolean getscriptparam (hdltreenode hfirst, short pnum, hdloutlinevariable *hv) {
01250     
01251     /*
01252     the caller wants an outline parameter.  we only accept them as "var"
01253     parameters, we just want the name of a variable that holds an outline.
01254     
01255     this keeps lang.c from having to know too much about outlines, but 
01256     more importantly, keeps them from being automatically copied!  could
01257     be very wasteful of memory because these things can get very large.
01258     
01259     we return a handle to the outline record and the identifier we 
01260     referenced to get the outline.  the string may used to name a window,
01261     for example.
01262     
01263     2.1b12 dmb: we now get scripts only, not outlines
01264     */
01265     
01266     short id;
01267     
01268     if (!langexternalgetexternalparam (hfirst, pnum, &id, (hdlexternalvariable *) hv)) {
01269         
01270         errornum = namenotscripterror;
01271         
01272         return (false);
01273         }
01274     
01275     if (id != idscriptprocessor) {
01276         
01277         errornum = namenotscripterror;
01278         
01279         return (false);
01280         }
01281     
01282     return (true);
01283     } /*getscriptparam*/
01284 
01285 
01286 boolean getoutlinevalue (hdltreenode hfirst, short pnum, hdloutlinerecord *houtline) {
01287     
01288     /*
01289     5.0.2b15 dmb: public routline - get an outline or script parameter, passed by reference
01290     */
01291     
01292     hdloutlinevariable hv;
01293     bigstring bserror;
01294     short id;
01295     
01296     if (!langexternalgetexternalparam (hfirst, pnum, &id, (hdlexternalvariable *) &hv) ||
01297          ((id != idoutlineprocessor) && (id != idscriptprocessor))) {
01298         
01299         getstringlist (operrorlist, namenotoutlineerror, bserror);
01300         
01301         langerrormessage (bserror);
01302         
01303         return (false);
01304         }
01305     
01306     if (!opverbinmemory (hv))
01307         return (false);
01308     
01309     *houtline = (hdloutlinerecord) (**hv).variabledata;
01310     
01311     return (true);
01312     } /*getoutlinevalue*/
01313 
01314 
01315 #if !flruntime
01316 
01317 boolean opverbarrayreference (hdlexternalvariable hvariable, long ix, hdlheadrecord *hnode) {
01318     
01319     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
01320     register boolean fl;
01321     
01322     *hnode = nil;
01323     
01324     if (!opverbinmemory (hv)) /*couldn't swap into memory*/
01325         return (false);
01326         
01327     oppushoutline ((hdloutlinerecord) (**hv).variabledata); /*assume it's in memory*/
01328     
01329     fl = oparrayreference (ix, hnode);
01330     
01331     oppopoutline ();
01332     
01333     return (fl);
01334     } /*opverbarrayreference*/
01335 
01336 
01337 boolean opedit (hdlexternalvariable hvariable, hdlwindowinfo hparent, ptrfilespec fs, bigstring bstitle, rectparam rzoom) {
01338     
01339     /*
01340     4.17.97 dmb: protect against globals smashing under Windows
01341 
01342     5.0b18 dmb: further protection: set flwindowopen bit before 
01343     newchildwindow, which will yield
01344 
01345     5.0.2b6 dmb: added flwindowopen loop to handle Windows async overlap
01346     */
01347 
01348     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
01349     register hdloutlinerecord ho;
01350     Rect rwindow;
01351     WindowPtr w;
01352     hdlwindowinfo hi;
01353     short id;
01354 
01355     if (!opverbinmemory (hv)) /*couldn't swap it into memory*/
01356         return (false);
01357     
01358     ho = (hdloutlinerecord) (**hv).variabledata; /*assume it's in memory*/
01359     
01360     while ((**ho).flwindowopen) { /*bring to front, return true*/
01361         
01362         if (shellfinddatawindow ((Handle) ho, &hi)) {
01363             
01364             if ((*rzoom).top > -2)
01365                 shellbringtofront (hi);
01366             
01367             return (true);
01368             }
01369         
01370         #ifdef MACVERSION
01371             break;
01372         #else
01373             if (!shellyield (false))
01374                 return (false);
01375         #endif
01376         }
01377     
01378     rwindow = (**ho).windowrect; /*window comes up where it was last time*/
01379     
01380     if ((**hv).flscript)
01381         id = idscriptconfig;
01382     else
01383         id = idoutlineconfig;
01384     
01385     (**ho).flwindowopen = true;
01386 
01387     if (!newchildwindow (id, hparent, &rwindow, rzoom, bstitle, &w)) {
01388         
01389         (**ho).flwindowopen = false;
01390 
01391         return (false);
01392         }
01393     
01394     getwindowinfo (w, &hi);
01395 
01396     if ((**hv).flscript)    
01397         (**hi).flhidebuttons = false;   
01398     else
01399         (**hi).flhidebuttons = true;
01400     
01401     (**hi).flsyntheticbuttons = false;
01402 
01403     (**hi).hdata = (Handle) ho;
01404     
01405     if (fs != nil)
01406         (**hi).fspec = *fs;
01407     
01408     if (hparent == nil)
01409         (**ho).outlinetype = outlineisstandalonescript;
01410     
01411     (**ho).outlinerect = (**hi).contentrect;
01412     
01413     shellpushglobals (w);
01414 
01415     shelladjustaftergrow ((**hi).macwindow);
01416     
01417     opsetdisplaydefaults (ho);
01418     
01419     opdirtymeasurements (); //6.0a14 dmb: need this too; may have bogus pre-display values
01420     
01421     opsetctexpanded (ho); //6.0a12 dmb: now that we set fatheadlines and outlinerect
01422     
01423     oprestorescrollposition ();
01424     
01425     opresetscrollbars ();
01426 
01427     shellpopglobals ();
01428     
01429     if ((**ho).fldirty)
01430         shellsetwindowchanges (hi, true);
01431     
01432     if ((**ho).outlinetype == outlineisoutline) { /*7.1b18 PBS: hide synthetic buttons*/
01433         
01434         (**hi).flhidebuttons = true;
01435 
01436         (**hi).buttonlist = nil;
01437         } /*if*/
01438 
01439     windowzoom (w);
01440 
01441     return (true);
01442     } /*opedit*/
01443     
01444     
01445 boolean opvaltoscript (tyvaluerecord val, hdloutlinerecord *houtline) {
01446     
01447     /*
01448     called externally -- you give us a value that holds a script that's
01449     a tableprocessor variable, we'll return you a handle to the outline.
01450     */
01451     
01452     register hdloutlinevariable hv;
01453     
01454     if (val.valuetype != externalvaluetype)
01455         return (false);
01456     
01457     hv = (hdloutlinevariable) val.data.externalvalue;
01458     
01459     if ((**hv).id != idscriptprocessor)
01460         return (false);
01461     
01462     if (!opverbinmemory (hv))
01463         return (false);
01464     
01465     *houtline = (hdloutlinerecord) (**hv).variabledata;
01466     
01467     return (true);
01468     } /*opvaltoscript*/
01469 
01470 /*
01471 static boolean oprunverb (hdltreenode hparam1, tyvaluerecord *v) {
01472     
01473     hdloutlinevariable hv;
01474     Handle htext;
01475     tyvaluerecord val;
01476     bigstring bs;
01477     
01478     setbooleanvalue (false, v); /%assume the worst%/
01479     
01480     flnextparamislast = true;
01481     
01482     if (!getscriptparam (hparam1, 1, bs, &hv))
01483         return (false);
01484     
01485     if (!opverbgetlangtext ((hdlexternalvariable) hv, &htext))
01486         return (false);
01487     
01488     return (langrun (htext, v));
01489     } /%oprunverb%/
01490 */
01491 
01492 
01493 boolean opinserthandle (Handle htext, tydirection dir) {
01494     
01495     /*
01496     12/13/91 dmb: take text handle instead of string, and potentially 
01497     deposit an entire structure.
01498     
01499     2.1b9 dmb: use new isoutlinetext routine to save code
01500     */
01501     
01502     register hdloutlinerecord ho = outlinedata;
01503     register hdlheadrecord hbarcursor;
01504     register boolean fl;
01505     hdlheadrecord hnode;
01506     boolean floutline;
01507     
01508     hbarcursor = (**ho).hbarcursor; /*copy into register*/
01509     
01510     if (dir == left) { /*special case: convert left to down from parent*/
01511         
01512         hbarcursor = (**hbarcursor).headlinkleft;
01513         
01514         if (hbarcursor == (**ho).hbarcursor) /*couln't move left*/
01515             return (false);
01516         
01517         opmoveto (hbarcursor);
01518         
01519         dir = down;
01520         }
01521     
01522     floutline = isoutlinetext (htext);
01523     
01524     if (floutline)
01525         if (!optexttooutline (ho, htext, &hnode))
01526             return (false);
01527     
01528     if (dir == right) { /*maybe we need to expand?*/
01529     
01530         if (!opsubheadsexpanded (hbarcursor))
01531             opexpand (hbarcursor, 1, false);
01532         }
01533     
01534     if (floutline) {
01535         
01536         fl = opinsertstructure (hnode, dir);
01537         
01538         if (!fl)
01539             opdisposestructure (hnode, false);
01540         }
01541     else {
01542         
01543         fl = copyhandle (htext, &htext);
01544         
01545         if (fl)
01546             fl = opinsertheadline (htext, dir, false);
01547         }
01548     
01549     if (fl)
01550         shellcheckdirtyscrollbars ();
01551     
01552     return (fl); 
01553     } /*opinserthandle*/
01554 
01555 
01556 static boolean opsetlinetextverb (Handle htext) {
01557     
01558     /*
01559     6.0b4 dmb: for wrapping headline display, this is a struc change
01560     */
01561     
01562     boolean fl;
01563     hdlheadrecord hcursor;
01564     hdlscreenmap hmap;
01565     
01566     opsettextmode (false);
01567     
01568     hcursor = (**outlinedata).hbarcursor;
01569     
01570     opbeforestrucchange (&hmap, false);
01571     
01572     fl = opsetheadtext (hcursor, htext); //consumes htext
01573     
01574     opgetlineheight (hcursor); //force recalc
01575     
01576     opafterstrucchange (hmap, false);
01577     
01578     if (fl) 
01579         opupdatenow ();
01580     
01581     return (fl);    
01582     } /*opsetlinetextverb*/
01583 
01584 
01585 typedef struct tybitinfo {
01586     
01587     boolean flset;
01588     
01589     boolean flanychanged;
01590     } tybitinfo, *ptrbitinfo;
01591 
01592 
01593 static boolean opsetbitverb (boolean fl, opvisitcallback visit) {
01594     
01595     /*
01596     9/22/92 dmb: shared code for opcommentverb and opbreakpoint verb
01597     */
01598     
01599     tybitinfo bitinfo;
01600     
01601     bitinfo.flset = bitboolean (fl); /*make sure it's a 1 or a 0*/
01602     
01603     bitinfo.flanychanged = false;
01604     
01605     opvisitmarked (down, visit, &bitinfo);
01606     
01607     if (!bitinfo.flanychanged)
01608         return (false);
01609     
01610     opdirtyoutline ();
01611     
01612     opupdatenow ();
01613     
01614     return (true);
01615     } /*opsetbitverb*/
01616 
01617 
01618 static boolean opcommentvisit (hdlheadrecord hnode, ptrvoid refcon) {
01619     
01620     hdlheadrecord h = hnode;
01621     ptrbitinfo bitinfo = (ptrbitinfo) refcon;
01622     
01623     if ((**h).flcomment != (*bitinfo).flset) { /*changing*/
01624         
01625         (**h).flcomment = (*bitinfo).flset;
01626         
01627         opinvalstructure (h);
01628         
01629         (*bitinfo).flanychanged = true;
01630         }
01631     
01632     return (true);
01633     } /*opcommentvisit*/
01634 
01635 
01636 static boolean opcommentverb (boolean fl) {
01637     
01638     /*
01639     change the comment state of the cursor line.  only update if it 
01640     actually changed.  fl == true means make it a comment.
01641     
01642     9/22/92 dmb: visit all marked headlines
01643     */
01644     
01645     return (opsetbitverb (fl, &opcommentvisit));
01646     } /*opcommentverb*/
01647 
01648 
01649 static boolean opbreakpointvisit (hdlheadrecord hnode, ptrvoid refcon) {
01650     
01651     ptrbitinfo bitinfo = (ptrbitinfo) refcon;
01652     hdlheadrecord h = hnode;
01653     
01654     if ((**h).flbreakpoint != (*bitinfo).flset) { /*changing*/
01655         
01656         (**h).flbreakpoint = (*bitinfo).flset;
01657         
01658         opinvalnode (h);
01659         
01660         (*bitinfo).flanychanged = true;
01661         }
01662     
01663     return (true);
01664     } /*opbreakpointvisit*/
01665 
01666 
01667 static boolean opbreakpointverb (boolean fl) {
01668     
01669     /*
01670     change the breakpoint state of the cursor line.  only update if it 
01671     actually changed.  fl == true means set a breakpoint.
01672     
01673     9/22/92 dmb: use new opsetbitverb to visit all marked headlines
01674     */
01675     
01676     return (opsetbitverb (fl, &opbreakpointvisit));
01677     } /*opbreakpointverb*/
01678 
01679 
01680 /*
01681 static boolean opmarkedverb (boolean fl) {
01682     
01683     /%
01684     change the marked state of the cursor line.  only update if it 
01685     actually changed.  fl == true means set a mark.
01686     %/
01687     
01688     hdlheadrecord hcursor;
01689     
01690     fl = bitboolean (fl); /%make sure it's a 1 or a 0%/
01691     
01692     hcursor = (**outlinedata).hbarcursor;
01693     
01694     if ((**hcursor).flmarked == fl) /%not changing%/
01695         return (false);
01696     
01697     (**hcursor).flmarked = fl;
01698     
01699     opinvalstructure (hcursor);
01700     
01701     opdirtyoutline ();
01702     
01703     opupdatenow ();
01704     
01705     return (true);
01706     } /%opmarkedverb%/
01707 */
01708 
01709 static boolean opsetdisplayverb (boolean fldisplay) {
01710     
01711     /*
01712     enable or disable display according to fl.  if display is becoming 
01713     enabled, force an full refresh
01714     
01715     return true if the display state changes
01716     
01717     6.0a14 dmb: need to do more stuff now when enabling
01718     */
01719     
01720     register hdloutlinerecord ho = outlinedata;
01721     
01722     if ((**ho).flinhibitdisplay != fldisplay) /*nothing to do*/
01723         return (false);
01724     
01725     (**ho).flinhibitdisplay = !fldisplay;
01726     
01727     if (opdisplayenabled ()) { /*waking up display*/
01728         
01729         opdirtymeasurements (); //6.0a14 dmb: need this too; may have bogus pre-display values
01730         
01731         opsetctexpanded (ho); //6.0a12 dmb: now that we set fatheadlines and outlinerect
01732         
01733         opgetscrollbarinfo (true); /*bring scroll position in range*/
01734         
01735         opresetscrollbars ();
01736         
01737         opvisibarcursor ();
01738         
01739         opsmashdisplay ();
01740         }
01741     
01742     return (true);
01743     } /*opsetdisplayverb*/
01744 
01745 
01746 static boolean opsetcursorverb (long cursor) {
01747     
01748     /*
01749     make the saved cursor the current bar cursor.  make sure it's still value 
01750     by visiting the entire outline.
01751     
01752     return true if the cursor was valid
01753     */
01754     
01755     register hdlheadrecord hcursor = (hdlheadrecord) cursor;
01756     
01757     if (!opnodeinoutline (hcursor)) /*it's been deleted, or something*/
01758         return (false);
01759     
01760     opexpandto (hcursor);
01761     
01762     return (true);
01763     } /*opsetcursorverb*/
01764 
01765 
01766 boolean opverbgetheadstring (hdlheadrecord hnode, bigstring bs) {
01767     
01768     getheadstring (hnode, bs);
01769     
01770     return (true);
01771     } /*opverbgetheadstring*/
01772 
01773 #endif  // !flruntime
01774 
01775 
01776 static boolean opcodeisrunning (hdlhashnode hnode) {
01777     
01778     /*
01779     return true if the hnode's code is running.  lacking a formal mechanism, 
01780     we determine this by walking through the error stack and looking for a 
01781     refcon that matched hnode.  see the last line of scriptpushsourcecode.
01782     */
01783     
01784     langerrorcallback errorcallback;
01785     
01786     return (langfinderrorrefcon ((long) hnode, &errorcallback));
01787     } /*opcodeisrunning*/
01788 
01789 
01790 static boolean opcompileverb (hdltreenode hparam1, tyvaluerecord *v) {
01791     
01792     hdlhashtable htable;
01793     bigstring bsname;
01794     hdlhashnode hnode;
01795     hdltreenode hcode;
01796     boolean fl;
01797     
01798     flnextparamislast = true;
01799     
01800     if (!getvarparam (hparam1, 1, &htable, bsname))
01801         return (false);
01802     
01803     pushhashtable (htable);
01804     
01805     fl = hashlookupnode (bsname, &hnode);
01806     
01807     pophashtable ();
01808     
01809     if (!processyieldtoagents ()) /*file closed while agents were finishing up*/
01810         return (false);
01811     
01812     if (fl) {
01813         
01814         if (opcodeisrunning (hnode)) /*can't uncompile running code; return false to caller*/
01815             fl = false;
01816         else
01817             fl = langcompilescript (hnode, &hcode);
01818         }
01819     
01820     return (setbooleanvalue (fl, v));
01821     } /*opcompileverb*/
01822 
01823 
01824 static boolean opuncompileverb (hdltreenode hparam1, tyvaluerecord *v) {
01825     
01826     hdlhashtable htable;
01827     bigstring bsname;
01828     tyvaluerecord val;
01829     hdltreenode hcode;
01830     hdlhashnode hnode;
01831     
01832     flnextparamislast = true;
01833     
01834     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
01835         return (false);
01836     
01837     if (!langexternalvaltocode (val, &hcode)) { /*easy way to check for a script*/
01838         
01839         errornum = namenotscripterror;
01840         
01841         return (false);
01842         }
01843     
01844     pushhashtable (htable);
01845     
01846     hashlookupnode (bsname, &hnode);
01847     
01848     pophashtable ();
01849     
01850     if (opcodeisrunning (hnode)) /*can't uncompile running code; return false to caller*/
01851         return (true);
01852     
01853     if (!processyieldtoagents ()) /*file closed while agents were finishing up*/
01854         return (false);
01855     
01856     opverbdisposecode ((hdloutlinevariable) val.data.externalvalue);
01857     
01858     return (setbooleanvalue (true, v));
01859     } /*opuncompileverb*/
01860 
01861 
01862 static boolean opgettypeverb (hdltreenode hparam1, tyvaluerecord *v) {
01863     
01864     /*
01865     2.1b12 dmb: new verb
01866     */
01867     
01868     register hdltreenode hp1 = hparam1;
01869     bigstring bsname;
01870     hdloutlinevariable hv;
01871     long signature;
01872     
01873     flnextparamislast = true;
01874     
01875     if (!getscriptparam (hp1, 1, &hv))
01876         return (false);
01877     
01878     if (!opverbgetlangtext ((hdlexternalvariable) hv, false, nil, &signature))
01879         return (false);
01880     
01881     scriptgettypename (signature, bsname);
01882     
01883     return (setstringvalue (bsname, v));
01884     } /*opgettypeverb*/
01885 
01886 
01887 static boolean opsettypeverb (hdltreenode hparam1, tyvaluerecord *v) {
01888     
01889     /*
01890     2.1b12 dmb: new verb
01891     */
01892     
01893     register hdltreenode hp1 = hparam1;
01894     bigstring bsname;
01895     hdloutlinevariable hv;
01896     hdloutlinerecord ho;
01897     long signature;
01898     hdlwindowinfo hinfo;
01899     
01900     if (!getscriptparam (hp1, 1, &hv))
01901         return (false);
01902     
01903     flnextparamislast = true;
01904     
01905     if (!getstringvalue (hp1, 2, bsname))
01906         return (false);
01907     
01908     if (!scriptgetnametype (bsname, &signature)) /*unknown, let verb return false*/
01909         return (true);
01910     
01911     if (!opverbinmemory (hv))
01912         return (false);
01913     
01914     ho = (hdloutlinerecord) (**hv).variabledata;
01915     
01916     (**ho).outlinesignature = signature;
01917     
01918     opverbsetdirty ((hdlexternalvariable) hv, true);
01919     
01920     if (opwindowopen ((hdlexternalvariable) hv, &hinfo)) /*crude, but effective update*/
01921         if (hinfo != nil)
01922             shellwindowinval (hinfo);
01923     
01924     return (setbooleanvalue (true, v));
01925     } /*opsettypeverb*/
01926 
01927 
01928 static boolean opgetcodeverb (hdltreenode hparam1, boolean flosacode, tyvaluerecord *v) {
01929     
01930     /*
01931     2.1b15 dmb: fixed memory leak; osagetcode does _not_ consume htext
01932     */
01933     
01934     register hdltreenode hp1 = hparam1;
01935     short pnum;
01936     hdlhashtable htable;
01937     bigstring bsname;
01938     tyvaluerecord val;
01939     hdlhashnode hnode;
01940     tyvaluerecord vcode;
01941     boolean fl;
01942     
01943     initvalue (&vcode, codevaluetype);
01944     
01945     if (flosacode) {
01946         
01947         #ifdef flcomponent
01948             hdloutlinevariable hv;
01949             Handle htext;
01950             long signature;
01951             boolean flexecuteonly;
01952             
01953             if (!havecomponentmanager ()) {
01954                 
01955                 langerror (nocomponentmanagererror);
01956                 
01957                 return (false);
01958                 }
01959             
01960             if (!getscriptparam (hp1, 1, &hv))
01961                 return (false);
01962             
01963             if (!getbooleanvalue (hp1, 2, &flexecuteonly))
01964                 return (false);
01965             
01966             if (!opverbgetlangtext ((hdlexternalvariable) hv, !flexecuteonly, &htext, &signature))
01967                 return (false);
01968             
01969             fl = osagetcode (htext, signature, flexecuteonly, &vcode);
01970             
01971             disposehandle (htext);
01972             
01973             if (!fl)
01974                 return (false);
01975             
01976             pnum = 3;
01977         #else
01978             langerror (nocomponentmanagererror);
01979             
01980             return (false);
01981         #endif
01982         }
01983     else {
01984         
01985         if (!getvarvalue (hp1, 1, &htable, bsname, &val, &hnode))
01986             return (false);
01987         
01988         if (!langexternalvaltocode (val, &vcode.data.codevalue)) {
01989             
01990             errornum = namenotscripterror;
01991             
01992             return (false);
01993             }
01994         
01995         if (vcode.data.codevalue == nil) {
01996             
01997             pushhashtable (htable);
01998             
01999             fl = hashlookupnode (bsname, &hnode);
02000             
02001             pophashtable ();
02002             
02003             if (!langcompilescript (hnode, &vcode.data.codevalue))
02004                 return (false);
02005             }
02006         
02007         if (!copyvaluerecord (vcode, &vcode))
02008             return (false);
02009         
02010         pnum = 2;
02011         }
02012     
02013     flnextparamislast = true;
02014     
02015     if (!getvarparam (hp1, pnum, &htable, bsname))
02016         return (false);
02017     
02018     if (!hashtableassign (htable, bsname, vcode))
02019         return (false);
02020     
02021     exemptfromtmpstack (&vcode);
02022     
02023     return (setbooleanvalue (true, v));
02024     } /*opgetcodeverb*/
02025 
02026 
02027 static boolean opgetsourceverb (hdltreenode hparam1, boolean flosacode, tyvaluerecord *v) {
02028 #pragma unused(flosacode)
02029 
02030     register hdltreenode hp1 = hparam1;
02031     hdlhashtable htable;
02032     bigstring bsname;
02033     tyvaluerecord vcode;
02034     tyvaluerecord vsource;
02035     tyvaluerecord vscript;
02036     hdlheadrecord hsummit;
02037     hdloutlinerecord houtline;
02038     register hdloutlinerecord ho;
02039     OSType signature;
02040     
02041     initvalue (&vcode, binaryvaluetype);
02042     
02043     if (!getbinaryvalue (hp1, 1, true, &vcode.data.binaryvalue))
02044         return (false);
02045     
02046     flnextparamislast = true;
02047     
02048     if (!getvarparam (hp1, 2, &htable, bsname))
02049         return (false);
02050     
02051     #ifdef flcomponent
02052         if (!osagetsource (&vcode, &signature, &vsource))
02053             return (false);
02054     #else
02055         langerror (nocomponentmanagererror);
02056         
02057         return (false);
02058     #endif
02059     
02060     if (!langexternalnewvalue (idscriptprocessor, nil, &vscript))
02061         return (false);
02062     
02063     opvaltoscript (vscript, &houtline);
02064     
02065     ho = houtline; /*copy into register*/
02066     
02067     (**ho).outlinesignature = signature;
02068     
02069     if (!optexttooutline (ho, vsource.data.stringvalue, &hsummit))
02070         goto error;
02071     
02072     //oppushoutline (ho);
02073     
02074     opsetsummit (ho, hsummit);
02075     
02076     opsetctexpanded (ho);
02077     
02078     //oppopoutline ();
02079     
02080     if (!hashtableassign (htable, bsname, vscript))
02081         goto error;
02082     
02083     return (setbooleanvalue (true, v));
02084     
02085     error: {
02086         
02087         disposevaluerecord (vscript, true);
02088         
02089         return (false);
02090         }
02091     } /*opgetsourceverb*/
02092 
02093 
02094 static boolean opstartprofileverb (hdltreenode hparam1, tyvaluerecord *v) {
02095 
02096     /*
02097     5.0.2b15 dmb: new feature: turn on profiling. this will create a new 
02098     profile data table internally if it's the first time for this process
02099     */
02100     
02101     boolean fltimesliced;
02102     
02103     flnextparamislast = true;
02104     
02105     if (!getbooleanvalue (hparam1, 1, &fltimesliced))
02106         return (false);
02107     
02108     return (setbooleanvalue (processstartprofiling (fltimesliced), v));
02109     } /*opstartprofileverb*/
02110 
02111 
02112 static boolean convertprofiletoticksvisit (hdlhashnode hnode, ptrvoid refcon) {
02113 #pragma unused (refcon)
02114 
02115     tyvaluerecord * val = &(**hnode).val;
02116     
02117     (*val).data.longvalue = ( ( (*val).data.longvalue * 3 ) / 50 );
02118     
02119     return (true);
02120 }
02121 
02122 static boolean opstopprofileverb (hdltreenode hp1, tyvaluerecord *v) {
02123     
02124     /*
02125     5.0.2b15 dmb: turn off profiling. If the user passes an address (not nil),
02126     we assign the profiledata table and remove it from the process.
02127     
02128     2005-01-14 SMD: results are stored in milliseconds, but the return values
02129        have been in ticks for a long time. So, added an optional param,
02130        flUseMilliseconds. Default is false. If true, we convert the milliseconds
02131        to ticks.
02132     */
02133     
02134     hdlprocessrecord hp = currentprocess;
02135     hdlhashtable ht;
02136     bigstring bs;
02137     tyvaluerecord val;
02138     short ctconsumed = 1;
02139     short ctpositional = 1;
02140     tyvaluerecord vflusemilliseconds; /* for optional flUseMilliseconds param */
02141     
02142     if (!getvarparam (hp1, 1, &ht, bs))
02143         return (false);
02144     
02145     setbooleanvalue (false, &vflusemilliseconds);
02146     
02147     flnextparamislast = true;
02148     
02149     if (!getoptionalparamvalue (hp1, &ctconsumed, &ctpositional, BIGSTRING ("\x11" "flUseMilliseconds"), &vflusemilliseconds))
02150         return (false);
02151     
02152     if (!processstopprofiling ())
02153         return (setbooleanvalue (false, v));
02154     
02155     if (!isemptystring (bs)) { // move our table to caller's address
02156         
02157         if ((**hp).hprofiledata == nil)
02158             setnilvalue (&val);
02159         else
02160         {
02161             if (! vflusemilliseconds.data.flvalue) /* convert values to ticks */
02162             {
02163                 if (!hashtablevisit ((hdlhashtable) (**(**hp).hprofiledata).variabledata, &convertprofiletoticksvisit, (ptrvoid) nil))
02164                     return (false);
02165             }
02166             
02167             setexternalvalue ((Handle) (**hp).hprofiledata, &val);
02168         }
02169         
02170         hashtableassign (ht, bs, val);
02171         
02172         (**hp).hprofiledata = nil;
02173     }
02174     
02175     return (setbooleanvalue (true, v));
02176 } /*opstopprofileverb*/
02177 
02178 
02179 static boolean opverbrejectmenubar (bigstring bserror) {
02180     
02181     if ((**shellwindowinfo).configresnum == idmenueditorconfig) {
02182         
02183         getstringlist (operrorlist, rejectmenubarnum, bserror);
02184         
02185         return (true);
02186         }
02187     
02188     return (false);
02189     } /*opverbrejectmenubar*/
02190 
02191 
02192 static boolean opverbrejecttable (bigstring bserror) {
02193     
02194     /*
02195     PBS 7.0b21: for some op verbs, tables should be rejected.
02196     For instance, you can't set the refcon of an item in a table.
02197     */
02198     
02199     if ((**shellwindowinfo).configresnum == idtableconfig) {
02200         
02201         getstringlist (operrorlist, rejecttablenum, bserror);
02202         
02203         return (true);
02204         }
02205     
02206     return (false);
02207     } /*opverbrejecttable*/
02208 
02209 
02210 static boolean opgetrefconverb (hdltreenode hparam1, hdlheadrecord hnode, tyvaluerecord *v) {
02211     
02212     /*
02213     4/16/92 dmb: new verb, value = op.setRefcon ()
02214     
02215     7/20/92 dmb: don't try to coerce external types -- no can do!
02216     
02217     11/6/92 dmb: use new langgoodbinarytype
02218     
02219     5.0.2b17 dmb: use langpack/unpack, not binary coercion
02220     */
02221     
02222     Handle hrefcon = (**hnode).hrefcon;
02223     tyvaluerecord linkedval;
02224     //tyvaluetype valuetype;
02225     
02226     if (!langcheckparamcount (hparam1, 0))
02227         return (false);
02228     
02229     /*
02230     flnextparamislast = true;
02231     
02232     if (!getvarparam (hparam1, 1, &htable, bs)) /%returned handle holder%/
02233         return (false);
02234     */
02235     
02236     if (hrefcon == nil)
02237         setlongvalue (0, &linkedval);
02238     
02239     else {
02240         #ifdef version5orgreater
02241             
02242             if (!langunpackvalue (hrefcon, &linkedval))
02243                 return (false);
02244             
02245             pushvalueontmpstack (&linkedval);
02246             
02247         #else
02248             if (!copyhandle (hrefcon, &hrefcon)) /*handles nil*/
02249                 return (false);
02250             
02251             if (!setheapvalue (hrefcon, binaryvaluetype, &linkedval))
02252                 return (false);
02253             
02254             valuetype = langgetvaluetype (getbinarytypeid (hrefcon));
02255             
02256             if (langgoodbinarytype (valuetype)) { /*unpack-able*/
02257                 
02258                 if (!coercevalue (&linkedval, valuetype))
02259                     return (false);
02260                 }
02261         #endif
02262         }
02263     
02264     *v = linkedval;
02265     
02266     /*
02267     if (!langsetsymboltableval (htable, bs, linkedval)) /%probably a memory error%/
02268         return (false);
02269     
02270     exemptfromtmpstack (linkedval);
02271     
02272     (*v).data.flvalue = true;
02273     */
02274     
02275     return (true);
02276     } /*opgetrefconverb*/
02277 
02278 
02279 static boolean opsetrefconverb (hdltreenode hparam1, hdlheadrecord hnode, tyvaluerecord *v) {
02280     
02281     /*
02282     4/16/92 dmb: new verb, op.setrefcon (value)
02283     
02284     4.1b8 dmb: dirty the outline
02285     
02286     5.0.2b17 dmb: use langpack/unpack, not binary coercion
02287     */
02288     
02289     tyvaluerecord val;
02290     Handle hbinary;
02291     boolean fl;
02292     
02293     flnextparamislast = true;
02294     
02295     if (!getparamvalue (hparam1, 1, &val))
02296         return (false);
02297     
02298     if ((val.valuetype == longvaluetype) && (val.data.longvalue == 0)) {
02299         
02300         opemptyrefcon (hnode);
02301         
02302         fl = true;
02303         }
02304     else {
02305         
02306         #ifdef version5orgreater
02307             
02308             if (!langpackvalue (val, &hbinary, HNoNode))
02309                 return (false);
02310             
02311             disposehandle ((**hnode).hrefcon);
02312             
02313             (**hnode).hrefcon = hbinary;
02314             
02315             fl = true;
02316             
02317         #else
02318             
02319             if (!coercetobinary (&val))
02320                 return (false);
02321             
02322             hbinary = val.data.binaryvalue; /*copy into register*/
02323         
02324             lockhandle (hbinary);
02325             
02326             fl = opsetrefcon (hnode, *hbinary, gethandlesize (hbinary));
02327             
02328             unlockhandle (hbinary);
02329             
02330         #endif
02331         }
02332     
02333     if (fl)
02334         opdirtyoutline ();
02335     
02336     return (setbooleanvalue (fl, v));
02337     } /*opsetrefconverb*/
02338 
02339 
02340 #define str_searchfor       (BIGSTRING ("\x09" "searchfor"))
02341 #define str_replacewith     (BIGSTRING ("\x0b" "replacewith"))
02342 #define str_casesensitive   (BIGSTRING ("\x0d" "casesensitive"))
02343 #define str_wholewords      (BIGSTRING ("\x0a" "wholewords"))
02344 #define str_wraparound      (BIGSTRING ("\x0a" "wraparound"))
02345 #define str_flatsearch      (BIGSTRING ("\x0a" "flatsearch"))
02346 #define str_frontwindowonly (BIGSTRING ("\x0f" "frontwindowonly"))
02347 #define str_closewindows    (BIGSTRING ("\x0c" "closewindows"))
02348 
02349 static boolean opfindverb (hdltreenode hp1, tyvaluerecord *vreturned) {
02350 
02351     /*
02352     5.1.5b15 dmb: on find (bs, wholewords=user.prefs.search.wholewords,
02353             casesensitive=user.prefs.search.casesensitive)
02354     
02355     6.0b2 dmb: restore original searchparams when we're done.
02356     
02357     2003-05-17 AR: Updated to reflect changes opflatfind related to the
02358     new Find & Replace dialog with regexp support
02359     
02360     2003-05-24 AR: avoid errors if there is currently an invalid regexp
02361     specified in the Find & Replace dialog
02362     */
02363     
02364     bigstring bs;
02365     short ctconsumed = 0;
02366     short ctpositional;
02367     tyvaluerecord vwholewords, vcasesensitive;
02368     tysearchparameters savesearchparams;
02369     boolean fl;
02370     
02371     disablelangerror (); /*2003-05-24 AR*/
02372     
02373     getsearchparams (); //side effect: protects search strings
02374     
02375     enablelangerror ();
02376     
02377     savesearchparams = searchparams;
02378     
02379     setsearchparams (); //restore search strings
02380     
02381     if (!getstringvalue (hp1, ++ctconsumed, bs))
02382         return (false);
02383     
02384     ctpositional = ctconsumed;
02385     
02386     setbooleanvalue (searchparams.flwholewords, &vwholewords);
02387     
02388     if (!getoptionalparamvalue (hp1, &ctconsumed, &ctpositional, str_wholewords, &vwholewords))
02389         return (false);
02390     
02391     setbooleanvalue (!searchparams.flunicase, &vcasesensitive);
02392     
02393     flnextparamislast = true;
02394     
02395     if (!getoptionalparamvalue (hp1, &ctconsumed, &ctpositional, str_casesensitive, &vcasesensitive))
02396         return (false);
02397     
02398     endcurrentsearch ();
02399     
02400     searchparams.flonelevel = true; /*don't dive into scripts, if in a menubar*/
02401     
02402     searchparams.floneobject = true;
02403     
02404     searchparams.flwraparound = false;
02405     
02406     searchparams.flregexp = false;
02407     
02408     searchparams.flunicase = !vcasesensitive.data.flvalue;
02409     
02410     searchparams.flwholewords = vwholewords.data.flvalue;
02411     
02412     copystring (bs, searchparams.bsorigfind);
02413     
02414     copystring (bs, searchparams.bsfind);
02415     
02416     if (searchparams.flunicase)
02417         alllower (searchparams.bsfind);
02418     
02419     startnewsearch (false, false);
02420     
02421     startingtosearch (0);
02422     
02423     fl = opflatfind (false, searchparams.flwraparound);
02424     
02425     searchparams = savesearchparams; //don't leave anything lying around
02426     
02427     return (setbooleanvalue (fl, vreturned));
02428     } /*opfindverb*/
02429 
02430 
02431 static boolean opgetexpansionstatevisit (hdlheadrecord hnode, long *lp, hdllistrecord hlist) {
02432 
02433     register hdlheadrecord nomad;
02434 
02435     while (true) {
02436 
02437         (*lp)++;
02438 
02439         nomad = hnode;
02440 
02441         if (opsubheadsexpanded (nomad))         
02442             if (!langpushlistlong (hlist, *lp))
02443                 return (false);
02444 
02445         hnode = opbumpflatdown (nomad, true);
02446 
02447         if (nomad == hnode)
02448             break;
02449         }
02450 
02451     return (true);
02452     }/*opgetexpansionstatevisit*/
02453 
02454 
02455 boolean opgetexpansionstateverb (tyvaluerecord *v) {
02456 
02457     /*
02458     6.2a6 AR: Returns a list of numbers; each number is the
02459                 line number (one-based) of an expanded headline
02460     
02461     7.0b21 PBS: no longer static -- needed by opxml.c to get the
02462     expansion state of an outline.
02463     */
02464     register hdloutlinerecord ho = outlinedata;
02465     hdlheadrecord hnode;
02466     hdllistrecord hlist;
02467     long ct = 0;
02468 
02469     assert ((ho != nil) && (*ho != nil));
02470 
02471     assert ((**ho).hsummit != nil);
02472 
02473     hnode = (**ho).hsummit;
02474 
02475     opnewlist (&hlist, false);
02476 
02477     if (!opgetexpansionstatevisit (hnode, &ct, hlist)) {
02478 
02479         opdisposelist (hlist);
02480 
02481         return (false);
02482         }
02483 
02484     return (setheapvalue ((Handle) hlist, listvaluetype, v));
02485     }/*opgetexpansionstateverb*/
02486 
02487 
02488 boolean opsetexpansionstateverb (tyvaluerecord *vlist, tyvaluerecord *v) {
02489 #pragma unused(v)
02490 
02491     /*
02492     6.2a6 AR: Takes the output of op.getExpansionState and sets the outline state accordingly.
02493                 Returns true if successful, otherwise false, e.g. if a line number
02494                 given in explist doesn't exist in the outline. 
02495                 
02496     7.0b21 PBS: no longer static -- needed by opxml.c to set the expansion state of an XML
02497     outlineDocument.
02498     */
02499     
02500     hdloutlinerecord ho = outlinedata;
02501     hdlheadrecord nomad;
02502     hdlheadrecord hnode;
02503     tyvaluerecord vitem;
02504     long ct;
02505     long ix = 1;
02506     long ixlist = 0;
02507     long ixoutline = 0;
02508 
02509     assert ((ho != nil) && (*ho != nil));
02510 
02511     if (!langgetlistsize (vlist, &ct))
02512         return (false);
02513 
02514     if (ct > 0) {
02515 
02516         if (!langgetlistitem (vlist, ix++, nil, &vitem))
02517             return (false);
02518 
02519         if (!coercevalue (&vitem, longvaluetype))
02520             return (false);
02521 
02522         ixlist = vitem.data.longvalue;
02523         }
02524 
02525     opsetdisplayverb (false);
02526 
02527     opsettextmode (false);
02528 
02529     hnode = (**ho).hsummit;
02530 
02531     while (true) {
02532 
02533         ++ixoutline;
02534 
02535         nomad = hnode;
02536 
02537         if (ixoutline == ixlist) {
02538 
02539             if (!opsubheadsexpanded (nomad) && (**nomad).flexpanded)
02540                 opexpand (nomad, 1, true);
02541 
02542             if (ix <= ct) {
02543                 if (!langgetlistitem (vlist, ix++, nil, &vitem))
02544                     goto error;
02545 
02546                 if (!coercevalue (&vitem, longvaluetype))
02547                     goto error;
02548 
02549                 ixlist = vitem.data.longvalue;
02550                 }
02551             }
02552         else {
02553             if (opsubheadsexpanded (nomad))
02554                 opcollapse (nomad);
02555             }
02556 
02557         hnode = opbumpflatdown (nomad, true);
02558 
02559         if (hnode == nomad)
02560             break;
02561         }
02562 
02563     hnode = (**ho).hbarcursor;
02564 
02565     while (!(**hnode).flexpanded) {
02566 
02567         if (hnode == (**hnode).headlinkleft)
02568             break;
02569 
02570         hnode = (**hnode).headlinkleft;
02571         }
02572 
02573     opmoveto (hnode);
02574         
02575     opsetdisplayverb (true);
02576 
02577     return (true);
02578 
02579 error:
02580     opsetdisplayverb (true);
02581 
02582     return (false);
02583     }/*opsetexpansionstateverb*/
02584                 
02585 
02586 boolean opgetscrollstateverb (tyvaluerecord *v) {
02587 
02588     /*
02589     6.2a6 AR: Returns the line number (one-based) of the first headline
02590                 displayed in the outline window.
02591                 
02592     7.0b21 PBS: no longer static -- needed in opxml.c to get the scroll state of an outline.
02593     */
02594 
02595     register hdloutlinerecord ho = outlinedata;
02596     register hdlheadrecord nomad, hsummit;
02597     register long ctheadlines = 1;
02598 
02599     assert ((ho != nil) && (*ho != nil));
02600 
02601     assert ((**ho).hline1 != nil);
02602 
02603     assert ((**ho).hsummit != nil);
02604 
02605     hsummit = (**ho).hsummit;
02606 
02607     nomad = (**ho).hline1;
02608 
02609     while (nomad != hsummit) {
02610 
02611         nomad = opbumpflatup (nomad, true);
02612 
02613         ++ctheadlines;
02614         }
02615 
02616     return (setlongvalue (ctheadlines, v));
02617     }/*opgetscrollstateverb*/
02618 
02619 
02620 boolean opsetscrollstateverb (long line1, tyvaluerecord *v) {
02621 
02622     /*
02623     6.2a6 AR: Scrolls the outline so that lnum is the first line displayed in the window.
02624                 If lnum is out of range, it scrolls to the last line.
02625                 
02626     7.0b21 PBS: no longer static -- needed by opxml.c to set scroll state of converted
02627     outlineDocument.
02628     */
02629 
02630     register hdloutlinerecord ho = outlinedata;
02631     register hdlheadrecord nomad;
02632 
02633     assert ((ho != nil) && (*ho != nil));
02634 
02635     assert ((**ho).hsummit != nil);
02636 
02637     nomad = (**ho).hsummit;
02638 
02639     while (--line1 > 0 && nomad != nil)
02640         nomad = opbumpflatdown (nomad, true);
02641 
02642     opsetdisplayverb (false); //hide display updates
02643 
02644     opsettextmode (false); //switch to select mode
02645     
02646     opmotionkey (flatdown, longinfinity, false); //move to the last headline
02647 
02648     opmoveto (nomad); //move to our headline -- BUG: only works if expanded
02649 
02650     opsetdisplayverb (true); //reenable display updates
02651 
02652     return (setbooleanvalue (true, v));
02653     }/*opsetscrollstateverb*/
02654 
02655 
02656 static boolean opgetselvisit (hdlheadrecord hnode, ptrvoid refcon) {
02657     
02658     /*
02659     7.0b15 PBS: for each marked item, store the cursor in a list.
02660     
02661     Used by opgetselectverb, which is called by op.getSelect ().
02662     
02663     Code based on tablegetselvisit.
02664     */
02665     
02666     hdllistrecord hlist = (hdllistrecord) refcon;
02667     tyvaluerecord val;
02668     
02669     if (!setlongvalue ((long) hnode, &val)) /*cursors are hdlheadrecords, coerced to a long*/
02670         return (false);
02671     
02672     if (!langpushlistval (hlist, nil, &val)) /*add value to list*/
02673         return (false);
02674     
02675     disposevaluerecord (val, true); /*don't let them accumulate*/
02676     
02677     return (true);
02678     } /*opgetselvisit*/
02679 
02680 
02681 static boolean opgetselectverb (hdltreenode hp1, tyvaluerecord *v) {
02682     
02683     /*
02684     7.0b15 PBS: get a list of cursors, the current selection in an outline.
02685     
02686     Based on tablegetselectionverb, which returns a list of addresses,
02687     the selections in a table.
02688     */
02689     
02690     hdllistrecord hlist;
02691     
02692     if (!langcheckparamcount (hp1, 0)) /*too many parameters were passed*/
02693         return (false);
02694     
02695     if (!opnewlist (&hlist, false)) /*create a list*/
02696         return (false);
02697     
02698     if (!opvisitmarked (down, &opgetselvisit, (ptrvoid) hlist)) {
02699         
02700         opdisposelist (hlist);
02701         
02702         return (false);
02703         }
02704     
02705     return (setheapvalue ((Handle) hlist, listvaluetype, v));
02706     } /*opgetselectverb*/
02707 
02708 
02709 static boolean opgetsuboutlinevisit (hdlheadrecord hnode, boolean flindent, long level, handlestream *str) {
02710 
02711     /*
02712     6.2a6 AR: Recursively get the current headline and all its subheads as a string
02713     */
02714 
02715     hdlheadrecord nomad = hnode;
02716     long indent = (flindent ? level : 0);
02717 
02718     if (!writehandlestreamhandleindent (str, (**hnode).headstring, indent))
02719         return (false);
02720 
02721     if (opnavigate (right, &nomad)) {
02722 
02723         level++;
02724 
02725         while (true) {
02726 
02727             if (!opgetsuboutlinevisit (nomad, flindent, level, str)) //recurse
02728                 return (false);
02729 
02730             if (!opnavigate (down, &nomad))
02731                 break;
02732             }
02733         }
02734 
02735     return (true);
02736     }/*opgetsuboutlinevisit*/
02737 
02738 
02739 static boolean opgetsuboutlineverb (hdlheadrecord hnode, boolean flindent, tyvaluerecord *v) {
02740 
02741     /*
02742     6.2a6 AR: See opgetsuboutlinevisit
02743     */
02744 
02745     handlestream s;
02746 
02747     assert ((hnode != nil) && (*hnode != nil));
02748 
02749     openhandlestream (nil, &s);
02750 
02751     if (!opgetsuboutlinevisit (hnode, flindent, 0L, &s)) {
02752 
02753         disposehandlestream (&s);
02754 
02755         return (false);
02756         }
02757 
02758     return (setheapvalue (closehandlestream (&s), stringvaluetype, v));
02759     }/*opgetsuboutlineverb*/
02760 
02761 
02762 static boolean opinsertoutlineverb (hdloutlinerecord hosource, tydirection dir, tyvaluerecord *v) {
02763     
02764     /*
02765     7.0d2 AR: Insert hosource into current outline, similar to op.insert but better at preserving outline state
02766     
02767     7.0b13 PBS: Set cursor back to original cursor.
02768     */
02769 
02770     hdlheadrecord hbarcursor = (**outlinedata).hbarcursor;
02771     hdlheadrecord horigcursor = hbarcursor; /*7.0b13 PBS*/
02772     hdlheadrecord hcopy;
02773 
02774     if (dir == left) { /*special case: convert left to down from parent*/
02775         
02776         hbarcursor = (**hbarcursor).headlinkleft;
02777         
02778         if (hbarcursor == (**outlinedata).hbarcursor) /*couln't move left*/
02779             return (setbooleanvalue (false, v));
02780         
02781         opmoveto (hbarcursor);
02782         
02783         dir = down;
02784         }
02785     
02786     if (!opcopysiblings ((**hosource).hsummit, &hcopy))
02787         return (false);
02788         
02789     if (dir == right) { /*maybe we need to expand?*/
02790     
02791         if (!opsubheadsexpanded (hbarcursor))
02792             opexpand (hbarcursor, 1, false);
02793         }
02794 
02795     if (!opinsertstructure (hcopy, dir)) {
02796     
02797         opdisposestructure (hcopy, false);
02798     
02799         return (false);
02800         }
02801     
02802     opmoveto (horigcursor);
02803 
02804     return (setbooleanvalue (true, v)); 
02805     }/*opinsertoutlineverb*/
02806 
02807 
02808 static long opgetheadnumberverb (hdlheadrecord hnode) {
02809     
02810     /*
02811     7.0b17 PBS: return the index, one-based, of the current node.
02812     If hnode is the third head at this level, return 3.
02813     */
02814     
02815     long ixnode;
02816     
02817     opgetsiblingnumber (hnode, &ixnode); /*zero-based*/
02818     
02819     ixnode++; /*add 1 -- scripters expect one-based indexes*/
02820     
02821     return (ixnode);
02822     } /*opgetheadnumberverb*/
02823 
02824 
02825 extern boolean langsettarget (hdlhashtable htable, bigstring bsname, tyvaluerecord *prevtarget);
02826 
02827 extern boolean langcleartarget (tyvaluerecord *prevtarget);
02828 
02829 static boolean opvisitallvisit (hdlheadrecord hnode, ptrvoid bsscriptname) {
02830 
02831     /*
02832     7.0b17 PBS: visit every headline in an outline, calling a callback script for each.
02833     
02834     It's a wrapper for opvisiteverything.
02835 
02836     2004-11-03 aradke: Take advantage of langrunscript now accepting
02837     a nil pointer if the script doesn't take any parameters.
02838     We don't need to create an empty list anymore.
02839     */
02840     
02841     tyvaluerecord vreturned;
02842     
02843     /*
02844     tyvaluerecord vparams;
02845     hdllistrecord hlist;
02846         
02847     if (!opnewlist (&hlist, false)) /%create a list%/
02848         return (false);
02849 
02850     if (!setheapvalue ((Handle) hlist, listvaluetype, &vparams))
02851         return (false);
02852     */
02853 
02854     oppushoutline (outlinedata);
02855         
02856     (**outlinedata).hbarcursor = hnode;
02857         
02858     (**outlinedata).flwindowopen = true;
02859     
02860     langrunscript (bsscriptname, nil, nil, &vreturned);
02861     
02862     oppopoutline ();
02863     
02864     return (true);
02865     } /*opvisitallvisit*/
02866 
02867 
02868 static boolean opvisitallverb (hdltreenode hparam1, tyvaluerecord *v, bigstring bserror) {
02869 #pragma unused (bserror)
02870 
02871     /*
02872     7.0b17 PBS: visit every headline, running the specified callback script.
02873     */
02874     
02875     bigstring bsscriptname;
02876     hdloutlinerecord ho;
02877     hdlhashtable htable, htableoldtarget;
02878     bigstring bsname, bsnameoldtarget;
02879     tyvaluerecord val, prevtarget;
02880     hdlhashnode hnode;
02881     hdlheadrecord horigcursor;
02882     boolean fl = false;
02883     boolean flhadtarget = false;
02884 
02885     /*Get outline parameter.*/
02886     
02887     if (!getoutlinevalue (hparam1, 1, &ho))
02888         goto exit1;
02889     
02890     /*Set the target to the outline.*/
02891     
02892     if (!getvarvalue (hparam1, 1, &htable, bsname, &val, &hnode))
02893         goto exit1;
02894     
02895     if (!langsettarget (htable, bsname, &prevtarget))
02896         goto exit1;
02897 
02898     if (getaddressvalue (prevtarget, &htableoldtarget, bsnameoldtarget)) /*get info about previous target*/
02899         flhadtarget = true;
02900 
02901     if (htableoldtarget == nil)
02902         flhadtarget = false;
02903     
02904     /*Open window as hidden.*/
02905 
02906     if (!langzoomvalwindow  (htable, bsname, val, false))
02907         goto exit2;
02908         
02909     /*Get script parameter.*/
02910     
02911     flnextparamislast = true;
02912     
02913     if (!getstringvalue (hparam1, 2, bsscriptname))
02914         goto exit2;
02915 
02916 //  if (!getvarvalue (hparam1, 2, &htable, bsname, &val, &hnode))
02917 //      goto exit2;
02918     
02919     oppushoutline (ho);
02920     
02921     horigcursor = (**ho).hbarcursor; /*get cursor*/
02922 
02923     opvisiteverything (&opvisitallvisit, bsscriptname); /*call the visit routine*/
02924 
02925 //  opvisiteverything (&opvisitallvisit, val); /*call the visit routine*/
02926 
02927     (**ho).hbarcursor = horigcursor; /*restore cursor*/
02928 
02929     oppopoutline ();
02930     
02931     fl = true;
02932     
02933     exit2:
02934     
02935     /*Restore the previous target.*/
02936     
02937     if (flhadtarget)
02938         langsettarget (htableoldtarget, bsnameoldtarget, &prevtarget);
02939     else
02940         langcleartarget (nil);
02941     
02942     exit1:
02943     
02944     setbooleanvalue (fl, v);
02945 
02946     return (fl);
02947     } /*opvisitallverb*/
02948 
02949 
02950 static boolean opgetselectedsuboutlinesvisit (hdlheadrecord hnode, ptrvoid refcon) {
02951     
02952     /*
02953     7.0b18 PBS: callback routine for op.getSelectesSubOutlines.
02954     */
02955     
02956     hdloutlinerecord ho = (hdloutlinerecord) refcon;
02957     hdlheadrecord hcopy;
02958     hdlheadrecord hbarcursor = (**ho).hbarcursor;
02959 
02960     hcopy = opcopyoutline (hnode);
02961     
02962     if (hcopy == nil)
02963         return (false);
02964     
02965     oppushoutline (ho);
02966     
02967     opstartinternalchange ();
02968     
02969     opdeposit (hbarcursor, down, hcopy);
02970         
02971     opresetlevels ((**hbarcursor).headlinkdown);
02972     
02973     opendinternalchange ();
02974     
02975     oppopoutline ();    
02976 
02977     return (true);
02978     } /*opgetselectedsuboutlinesvisit*/
02979 
02980 
02981 static boolean opgetselectedsuboutlinesverb (hdloutlinerecord ho) {
02982     
02983     /*
02984     7.0b18 PBS: get selected headlines and their subheads as an outline.
02985     */
02986     
02987     bigstring bsheadstring;
02988     
02989     /*Copy selected headlines*/
02990     
02991     if (!opvisitmarked (up, &opgetselectedsuboutlinesvisit, (ptrvoid) ho))
02992         return (false);
02993     
02994     /*Delete the top, empty summit*/
02995     
02996     oppushoutline (ho);
02997     
02998     opmoveto ((**ho).hsummit); /*go back to first summit*/
02999     
03000     getheadstring ((**ho).hsummit, bsheadstring);
03001     
03002     if (equalstrings (bsheadstring, emptystring)) /*if it's "", delete it*/
03003 
03004         opdelete ();
03005         
03006     oppopoutline ();
03007     
03008     return (true);
03009     } /*opgetselectedsuboutlinesverb*/
03010 
03011 
03012 static boolean getoptionaltablevalue (hdltreenode hp1, short pnum, hdlhashtable *ht) {
03013 
03014     tyvaluerecord v;
03015 
03016     if (!getparamvalue (hp1, pnum, &v))
03017         return (false);
03018 
03019     if (v.valuetype == novaluetype) {
03020 
03021         *ht = nil;
03022 
03023         return (true);
03024         }
03025 
03026     return (gettablevalue (hp1, pnum, ht));
03027     } /*getoptionaltablevalue*/
03028 
03029 
03030 static boolean getoptionaltablereference (hdltreenode hp1, short pnum, hdlhashtable *ht) {
03031 
03032     /*
03033     7.1b45 dmb: new function to get an optional table reference that may be nil
03034     */
03035 
03036     tyvaluerecord v;
03037     xmladdress adr;
03038 
03039     if (!getparamvalue (hp1, pnum, &v))
03040         return (false);
03041 
03042     if (v.valuetype == novaluetype) {
03043 
03044         *ht = nil;
03045 
03046         return (true);
03047         }
03048 
03049     if (!getvarparam (hp1, pnum, &adr.ht, adr.bs))
03050         return (false);
03051 
03052     return (langassignnewtablevalue (adr.ht, adr.bs, ht));
03053     } /*getoptionaltablereference*/
03054 
03055 
03056 static boolean opxmltooutlineverb (hdltreenode hparam1, tyvaluerecord *v) {
03057 
03058     /*
03059     7.0b21 PBS -- convert an XML outlineDocument to an outline.
03060     
03061     Two parameters: xml text and the address of an outline.
03062     
03063     opxmltooutline is in opxml.c.
03064 
03065     7.1b43 dmb: added optional cloudSpec parameter. table can be null.
03066     */
03067     
03068     hdloutlinerecord ho;
03069     hdlhashtable htable;
03070     bigstring bsname;
03071     tyvaluerecord val;
03072     hdlhashnode hnode;
03073     boolean fl = false;
03074     Handle htext;
03075     boolean flnewoutline;
03076     hdlhashtable hcloud = nil;
03077 
03078     if (!getreadonlytextvalue (hparam1, 1, &htext))
03079         goto exit;
03080         
03081     if (!getoutlinevalue (hparam1, 2, &ho))
03082         goto exit;
03083     
03084     if (!getvarvalue (hparam1, 2, &htable, bsname, &val, &hnode))
03085         goto exit;
03086         
03087     if (!getbooleanvalue (hparam1, 3, &flnewoutline))
03088         goto exit;
03089 
03090     if (langgetparamcount (hparam1) > 3) {
03091         
03092         flnextparamislast = true;
03093 
03094         if (!getoptionaltablereference (hparam1, 4, &hcloud))
03095             return (false);
03096         }
03097     
03098     oppushoutline (ho);
03099     
03100     fl = opxmltooutline (htext, ho, flnewoutline, htable, bsname, val, hcloud);
03101     
03102     oppopoutline ();
03103         
03104     exit:
03105     
03106     setbooleanvalue (fl, v);
03107     
03108     return (fl);
03109     } /*opxmltooutlineverb*/
03110 
03111 
03112 static boolean opoutlinetoxmlverb (hdltreenode hparam1, tyvaluerecord *v) {
03113     
03114     /*
03115     7.0b21 PBS: convert an outline to outlineDocument XML.
03116 
03117     7.1b43 dmb; handle optional cloud parameter. also, fixed handle disposal
03118     in error condition
03119     */
03120     
03121     boolean fl = false;
03122     Handle htext = nil;
03123     Handle hname = nil;
03124     Handle hemail = nil;
03125     hdloutlinerecord ho;
03126     hdlhashtable ht;
03127     tyvaluerecord val;
03128     hdlhashnode hnode;
03129     bigstring bsname;
03130     hdlhashtable hcloud = nil;
03131         
03132     if (!getoutlinevalue (hparam1, 1, &ho)) /*Get the outline pointed to in first parameter*/
03133         goto exit;
03134     
03135     if (!getvarvalue (hparam1, 1, &ht, bsname, &val, &hnode)) /*We'll be opening the window.*/
03136         goto exit;
03137     
03138     if (!getexempttextvalue (hparam1, 2, &hname)) /*ownerName*/
03139         goto exit;
03140     
03141     if (!getexempttextvalue (hparam1, 3, &hemail)) /*ownerEmail*/
03142         goto exit;
03143 
03144     if (langgetparamcount (hparam1) > 3) {
03145         
03146         flnextparamislast = true;
03147 
03148         if (!getoptionaltablevalue (hparam1, 4, &hcloud))
03149             return (false);
03150         }
03151 
03152     if (!opoutlinetoxml (ho, hname, hemail, &htext, ht, bsname, val, hcloud)) /*Convert from outline to XML text*/
03153         goto exit;
03154     
03155     fl = setheapvalue (htext, stringvaluetype, v); /*htext is returned XML text*/
03156     
03157     exit:
03158     
03159     disposehandle (hname);
03160     
03161     disposehandle (hemail);
03162     
03163     return (fl);
03164     } /*opoutlinetoxmlverb*/
03165 
03166 
03167 static boolean opfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) {
03168     
03169     /*
03170     bridges op.c with the language.  the name of the verb is bs, its first parameter
03171     is hparam1, and we return a value in vreturned.
03172     
03173     we use a limited number of support routines from lang.c to get parameters and
03174     to return values. 
03175     
03176     return false only if the error is serious enough to halt the running of the script
03177     that called us, otherwise error values are returned through the valuerecord, which
03178     is available to the script.
03179     
03180     if we return false, we try to provide a descriptive error message in the 
03181     returned string bserror.
03182     
03183     2/18/91 dmb: use new opverbfindtarget instead of opsetverbglobals -- we no 
03184     longer require that the outline window be in the front.
03185     
03186     12/16/91 dmb: on getlinetext, writeeditbuffer instead of forcing textmode false
03187     
03188     4/3/92 dmb: findfunc now calls newly-public get/setsearchparams
03189     
03190     8/25/92 dmb: added firstsummitfunc; levelfunc now returns 1-based value so glue 
03191     isn't needed; removed mark functions -- unused & undocumented
03192     
03193     9/4/92 dmb: disable hoist when there's a multiple selection
03194     
03195     6/1/93 dmb: when vreturned is nil, return whether or not verb token must 
03196     be run in the Frontier process
03197     
03198     2.1b12 dmb: added getosacodefunc & getosasourcefunc to list not needing process swap
03199 
03200     5.1.4 dmb: don't call setsearchparams
03201     
03202     5.1.5 dmb: findfunc take optional params
03203     */
03204     
03205     register tyvaluerecord *v = vreturned;
03206     register boolean fl;
03207     register hdloutlinerecord ho;
03208     register hdlheadrecord hbarcursor;
03209     WindowPtr targetwindow;
03210     
03211     if (v == nil) { /*need Frontier process?*/
03212         
03213         switch (token) {
03214             
03215             case tabkeyreorgfunc:
03216             case compilefunc:
03217             case uncompilefunc:
03218             case getcodefunc:
03219             case gettypefunc:
03220             case getosacodefunc:
03221             case getosasourcefunc:
03222             case startprofilefunc:
03223             case stopprofilefunc:
03224                 return (false);
03225             
03226             default:
03227                 return (true);
03228             }
03229         }
03230     
03231     errornum = 0;
03232     
03233     setbooleanvalue (false, v); /*by default, op functions return false*/
03234     
03235     switch (token) { /*these verbs don't require an open outline window*/
03236         
03237         #if !flruntime
03238         
03239         /*
03240         case runfunc:
03241             if (!oprunverb (hparam1, v))
03242                 goto error;
03243             
03244             return (true);
03245         */
03246         
03247         case tabkeyreorgfunc:
03248             
03249             flnextparamislast = true;
03250             
03251             if (!getbooleanvalue (hparam1, 1, &opprefs.fltabkeyreorg))
03252                 goto error;
03253             
03254             (*v).data.flvalue = true;
03255             
03256             return (true);
03257             
03258         case flatcursorkeysfunc:
03259             
03260             flnextparamislast = true;
03261             
03262             if (!getbooleanvalue (hparam1, 1, &opprefs.flflatcursorkeys))
03263                 goto error;
03264             
03265             (*v).data.flvalue = true;
03266             
03267             return (true);
03268         
03269         #endif
03270         
03271         case compilefunc:
03272             
03273             if (!opcompileverb (hparam1, v))
03274                 goto error;
03275             
03276             return (true);
03277         
03278         case uncompilefunc:
03279             
03280             if (!opuncompileverb (hparam1, v))
03281                 goto error;
03282             
03283             return (true);
03284         
03285         case getcodefunc:
03286             
03287             if (!opgetcodeverb (hparam1, false, v))
03288                 goto error;
03289             
03290             return (true);
03291         
03292         case gettypefunc:
03293             
03294             if (!opgettypeverb (hparam1, v))
03295                 goto error;
03296             
03297             return (true);
03298         
03299         case getosacodefunc:
03300             
03301             if (!opgetcodeverb (hparam1, true, v))
03302                 goto error;
03303             
03304             return (true);
03305         
03306         case settypefunc:
03307             
03308             if (!opsettypeverb (hparam1, v))
03309                 goto error;
03310             
03311             return (true);
03312         
03313         case getosasourcefunc:
03314             
03315             if (!opgetsourceverb (hparam1, true, v))
03316                 goto error;
03317             
03318             return (true);
03319             
03320         case startprofilefunc:
03321             if (!opstartprofileverb (hparam1, v))
03322                 goto error;
03323             
03324             return (true);
03325         
03326         case stopprofilefunc:
03327             if (!opstopprofileverb (hparam1, v))
03328                 goto error;
03329             
03330             return (true);
03331         
03332         case visitallfunc: { /*7.0b17 PBS: visit all nodes in an outline*/
03333             
03334             if (!opvisitallverb (hparam1, v, bserror))
03335                 goto error;
03336             
03337             return (true);
03338             }
03339         
03340         case xmltooutlinefunc: { /*7.0b21 PBS: convert from XML to an outline*/
03341             
03342             if (!opxmltooutlineverb (hparam1, v))
03343                 goto error;
03344             
03345             return (true);
03346             }
03347         
03348         case outlinetoxmlfunc: { /*7.0b21 PBS: convert outline to XML*/
03349             
03350             if (!opoutlinetoxmlverb (hparam1, v))
03351                 goto error;
03352             
03353             return (true);
03354             }
03355             
03356         } /*switch*/
03357     
03358     #if !flruntime
03359     
03360     if (!langfindtargetwindow (idoutlineprocessor, &targetwindow)) { /*all other verbs require an outline window in front*/
03361         
03362         errornum = noooutlineerror;
03363         
03364         goto error;
03365         }
03366     
03367     shellpushglobals (targetwindow); /*following verbs assume that an outline is in front*/
03368     
03369     (*shellglobals.gettargetdataroutine) (idoutlineprocessor); /*set op globals*/
03370     
03371     ho = outlinedata; /*copy into register*/
03372     
03373     hbarcursor = (**ho).hbarcursor;
03374     
03375     fl = false; /*default return value*/
03376     
03377     switch (token) {
03378             
03379         case linetextfunc: {
03380             Handle htext;
03381             
03382             if (!langcheckparamcount (hparam1, 0))
03383                 break;
03384             
03385             opwriteeditbuffer (); /*if headline is being edited, update text handle*/
03386             
03387             if (!copyhandle ((**hbarcursor).headstring, &htext))
03388                 break;
03389             
03390             fl = setheapvalue (htext, stringvaluetype, v);
03391             
03392             break;
03393             }
03394             
03395         case levelfunc:
03396             if (!langcheckparamcount (hparam1, 0))
03397                 break;
03398             
03399             fl = setlongvalue ((**hbarcursor).headlevel + 1, v);
03400             
03401             break;
03402             
03403         case countsubsfunc: {
03404             short level;
03405             
03406             flnextparamislast = true;
03407             
03408             if (!getintvalue (hparam1, 1, &level))
03409                 break;
03410             
03411             fl = setlongvalue (opcountsubheads (hbarcursor, level), v);
03412             
03413             break;
03414             }
03415             
03416         case countsummitsfunc:
03417             if (!langcheckparamcount (hparam1, 0))
03418                 break;
03419             
03420             fl = setlongvalue (opcountatlevel ((**ho).hsummit), v);
03421             
03422             break;
03423             
03424         case gofunc: {
03425             tydirection dir;
03426             long units;
03427             
03428             if (!getdirectionvalue (hparam1, 1, &dir))
03429                 break;
03430             
03431             flnextparamislast = true;
03432             
03433             if (!getlongvalue (hparam1, 2, &units))
03434                 break;
03435             
03436             opsettextmode (false);
03437             
03438             (*v).data.flvalue = opmotionkey (dir, units, false);
03439             
03440             fl = true;
03441             
03442             break;
03443             }
03444         
03445         case firstsummitfunc:
03446             if (!langcheckparamcount (hparam1, 0))
03447                 break;
03448             
03449             opsettextmode (false);
03450             
03451             (*v).data.flvalue = opmotionkey (flatup, longinfinity, false);
03452             
03453             fl = true;
03454             
03455             break;
03456             
03457         case expandfunc: {
03458             short level;
03459             
03460             flnextparamislast = true;
03461             
03462             if (!getintvalue (hparam1, 1, &level))
03463                 break;
03464 
03465 //          if (langopruncallbackscripts (idopexpandscript)) /*7.0b30: call callback script*/
03466                 
03467 //              (*v).data.flvalue = true;  /*fuction consumed the click*/
03468 
03469 //          else
03470             
03471                 (*v).data.flvalue = opexpand (hbarcursor, level, true);
03472             
03473             fl = true;
03474             
03475             break;
03476             }
03477         
03478         case collapsefunc:
03479             if (!langcheckparamcount (hparam1, 0))
03480                 break;
03481 
03482 //          if (langopruncallbackscripts (idopcollapsescript)) /*7.0b30: call callback script*/
03483             
03484 //              (*v).data.flvalue = true;
03485 
03486 //          else
03487 
03488                 (*v).data.flvalue = opcollapse (hbarcursor);
03489             
03490             fl = true;
03491             
03492             break;
03493         
03494         case getexpandedfunc:
03495             if (!langcheckparamcount (hparam1, 0))
03496                 break;
03497             
03498             (*v).data.flvalue = opsubheadsexpanded (hbarcursor);
03499             
03500             fl = true;
03501             
03502             break;
03503 
03504         case insertfunc: {
03505             Handle htext;
03506             tydirection dir;
03507             
03508             if (!getexempttextvalue (hparam1, 1, &htext)) /*headline string*/
03509                 break;
03510             
03511             flnextparamislast = true;
03512             
03513             if (!getdirectionvalue (hparam1, 2, &dir)) /*direction*/
03514                 break;
03515                 
03516             (*v).data.flvalue = opinserthandle (htext, dir);
03517             
03518             disposehandle (htext);
03519             
03520             fl = true;
03521             
03522             break;
03523             }
03524         
03525         case findfunc:
03526             fl = opfindverb (hparam1, v);
03527             
03528             break;
03529         
03530         case sortfunc:
03531             if (!langcheckparamcount (hparam1, 0))
03532                 break;
03533             
03534             (*v).data.flvalue = opsortlevel (hbarcursor);
03535             
03536             fl = true;
03537             
03538             break;
03539         
03540         case setlinetextfunc: {
03541             Handle htext;
03542             
03543             flnextparamislast = true;
03544             
03545             if (!getexempttextvalue (hparam1, 1, &htext))
03546                 break;
03547             
03548             (*v).data.flvalue = opsetlinetextverb (htext);
03549             
03550             fl = true;
03551             
03552             break;
03553             }
03554         
03555         case reorgfunc: {
03556             tydirection dir;
03557             long units;
03558             
03559             if (!getdirectionvalue (hparam1, 1, &dir))
03560                 break;
03561             
03562             flnextparamislast = true;
03563             
03564             if (!getlongvalue (hparam1, 2, &units))
03565                 break;
03566             
03567             (*v).data.flvalue = opreorgcursor (dir, units);
03568             
03569             fl = true;
03570             
03571             break;
03572             }
03573             
03574         case deletesubsfunc:
03575             if (!langcheckparamcount (hparam1, 0))
03576                 break;
03577             
03578             (*v).data.flvalue = opdeletesubs (hbarcursor);
03579             
03580             fl = true;
03581             
03582             break;
03583             
03584         case deletelinefunc:
03585             if (!langcheckparamcount (hparam1, 0))
03586                 break;
03587             
03588             opdeleteline ();
03589             
03590             (*v).data.flvalue = true;
03591             
03592             fl = true;
03593             
03594             break;
03595         
03596         case promotefunc:
03597             if (!langcheckparamcount (hparam1, 0))
03598                 break;
03599             
03600             (*v).data.flvalue = oppromote ();
03601             
03602             fl = true;
03603             
03604             break;
03605         
03606         case demotefunc:
03607             if (!langcheckparamcount (hparam1, 0))
03608                 break;
03609             
03610             (*v).data.flvalue = opdemote ();
03611             
03612             fl = true;
03613             
03614             break;
03615             
03616         case hoistfunc:
03617             if (!langcheckparamcount (hparam1, 0))
03618                 break;
03619             
03620             if (!opanymarked ())
03621                 (*v).data.flvalue = oppushhoist (hbarcursor);
03622             
03623             fl = true;
03624             
03625             break;
03626             
03627         case dehoistfunc:
03628             if (!langcheckparamcount (hparam1, 0))
03629                 break;
03630             
03631             (*v).data.flvalue = oppophoist ();
03632             
03633             fl = true;
03634             
03635             break;
03636         
03637         case makecommentfunc: case uncommentfunc:
03638             if (!langcheckparamcount (hparam1, 0))
03639                 break;
03640             
03641             (*v).data.flvalue = opcommentverb (token == makecommentfunc);
03642             
03643             fl = true;
03644             
03645             break;
03646             
03647         case iscommentfunc:
03648             if (!langcheckparamcount (hparam1, 0))
03649                 break;
03650             
03651             (*v).data.flvalue = (**hbarcursor).flcomment;
03652             
03653             fl = true;
03654             
03655             break;
03656         
03657         case getbreakpointfunc:
03658             if (!langcheckparamcount (hparam1, 0))
03659                 break;
03660             
03661             (*v).data.flvalue = (**hbarcursor).flbreakpoint;
03662             
03663             fl = true;
03664             
03665             break;
03666             
03667         case setbreakpointfunc: case clearbreakpointfunc:
03668             if (!langcheckparamcount (hparam1, 0))
03669                 break;
03670             
03671             (*v).data.flvalue = opbreakpointverb (token == setbreakpointfunc);
03672             
03673             fl = true;
03674             
03675             break;
03676         
03677         /*
03678         case getmarkedfunc:
03679             if (!langcheckparamcount (hparam1, 0))
03680                 break;
03681             
03682             (*v).data.flvalue = (**hbarcursor).flmarked;
03683             
03684             fl = true;
03685             
03686             break;
03687         
03688         case setmarkedfunc: case clearmarkedfunc:
03689             if (!langcheckparamcount (hparam1, 0))
03690                 break;
03691             
03692             (*v).data.flvalue = opmarkedverb (token == setmarkedfunc);
03693             
03694             fl = true;
03695             
03696             break;
03697         */
03698         
03699         case getdisplayfunc:
03700             if (!langcheckparamcount (hparam1, 0))
03701                 break;
03702             
03703             (*v).data.flvalue = !(**ho).flinhibitdisplay;
03704             
03705             fl = true;
03706             
03707             break;
03708         
03709         case setdisplayfunc: {
03710             boolean fldisplay;
03711             
03712             flnextparamislast = true;
03713             
03714             if (!getbooleanvalue (hparam1, 1, &fldisplay))
03715                 break;
03716             
03717             (*v).data.flvalue = opsetdisplayverb (fldisplay);
03718             
03719             fl = true;
03720             
03721             break;
03722             }
03723         
03724         case getcursorfunc:
03725             if (!langcheckparamcount (hparam1, 0))
03726                 break;
03727             
03728             fl = setlongvalue ((long) hbarcursor, v);
03729             
03730             break;
03731         
03732         case setcursorfunc: {
03733             long cursor;
03734             
03735             flnextparamislast = true;
03736             
03737             if (!getlongvalue (hparam1, 1, &cursor))
03738                 break;
03739             
03740             (*v).data.flvalue = opsetcursorverb (cursor);
03741             
03742             fl = true;
03743             
03744             break;
03745             }
03746         
03747         case getrefconfunc:
03748             if (opverbrejectmenubar (bserror))
03749                 break;
03750             
03751             if (opverbrejecttable (bserror)) /*7.0b23 PBS*/
03752                 break;
03753             
03754             fl = opgetrefconverb (hparam1, hbarcursor, v);
03755             
03756             break;
03757             
03758         case setrefconfunc:
03759             if (opverbrejectmenubar (bserror))
03760                 break;
03761             
03762             if (opverbrejecttable (bserror)) /*7.0b23 PBS*/
03763                 break;
03764             
03765             fl = opsetrefconverb (hparam1, hbarcursor, v);
03766             
03767             break;
03768         
03769         case getexpansionstatefunc:
03770             if (!langcheckparamcount (hparam1, 0))
03771                 break;
03772 
03773             fl = opgetexpansionstateverb (v);
03774             
03775             break;
03776             
03777         case setexpansionstatefunc: {
03778             tyvaluerecord vlist;
03779             
03780             flnextparamislast = true;
03781             
03782             if (!getparamvalue (hparam1, 1, &vlist))
03783                 break;
03784 
03785             if (!coercevalue (&vlist, listvaluetype))
03786                 return (false);
03787 
03788             fl = opsetexpansionstateverb (&vlist, v);
03789             
03790             break;
03791             }
03792 
03793         case getscrollstatefunc:
03794             if (!langcheckparamcount (hparam1, 0))
03795                 break;
03796 
03797             fl = opgetscrollstateverb (v);
03798             
03799             break;
03800 
03801         case setscrollstatefunc: {
03802             long firstline;
03803             
03804             flnextparamislast = true;
03805             
03806             if (!getlongvalue (hparam1, 1, &firstline))
03807                 break;
03808 
03809             fl = opsetscrollstateverb (firstline, v);
03810             
03811             break;
03812             }
03813 
03814         case getsuboutlinefunc: {
03815             tyvaluerecord vindent;
03816             short ctconsumed = 0;
03817             short ctpositional = 0;
03818             
03819             setbooleanvalue (true, &vindent);
03820 
03821             flnextparamislast = true;
03822 
03823             if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, BIGSTRING ("\x08" "flindent"), &vindent))
03824                 return (false);
03825 
03826             fl = opgetsuboutlineverb (hbarcursor, vindent.data.flvalue, v);
03827             
03828             break;
03829             }
03830         
03831         case insertoutlinefunc: {
03832             
03833             /*
03834             7.0b13 PBS: menus can be inserted into menus now.
03835             */
03836 
03837             hdloutlinevariable hv;
03838             short id;
03839             tydirection dir;
03840             boolean floutline = true;
03841 
03842             if (!langexternalgetexternalparam (hparam1, 1, &id, (hdlexternalvariable *) &hv))
03843                 floutline = false;
03844 
03845             if (floutline) {
03846 
03847                 switch (id) {
03848 
03849                     case idoutlineprocessor:
03850                     case idmenuprocessor:
03851                     case idscriptprocessor:
03852                     
03853                         floutline = true;
03854 
03855                         break;
03856 
03857                     default:
03858 
03859                         floutline = false;
03860                     } /*switch*/
03861                 } /*if*/
03862             
03863             //if (!langexternalgetexternalparam (hparam1, 1, &id, (hdlexternalvariable *) &hv) || (id != idoutlineprocessor)) {
03864             if (!floutline) {
03865                     
03866                 bigstring lbserror;
03867                 
03868                 getstringlist (operrorlist, namenotoutlineerror, lbserror);
03869                 
03870                 langerrormessage (lbserror);
03871                 
03872                 return (false);
03873                 }
03874             
03875             if (!opverbinmemory (hv))
03876                 return (false);
03877             
03878             flnextparamislast = true;
03879             
03880             if (!getdirectionvalue (hparam1, 2, &dir)) /*direction*/
03881                 break;
03882 
03883             if (id == idmenuprocessor) { /*menubar*/
03884 
03885                 hdlmenurecord hm;
03886             
03887                 hm = (hdlmenurecord) (**hv).variabledata;
03888 
03889                 fl = opinsertoutlineverb ((hdloutlinerecord)(**hm).menuoutline, dir, v);
03890                 } /*if*/
03891             
03892             else /*outline*/
03893 
03894                 fl = opinsertoutlineverb ((hdloutlinerecord)(**hv).variabledata, dir, v);
03895             
03896             break;
03897             }       
03898         
03899         case setmodifiedfunc: { /*7.0b5 PBS: set or un-set dirty bits*/
03900             
03901             boolean fldirty;
03902             
03903             flnextparamislast = true;
03904             
03905             if (!getbooleanvalue (hparam1, 1, &fldirty))
03906                 break;
03907             
03908             if (fldirty)
03909             
03910                 opdirtyoutline ();
03911                         
03912             else {
03913             
03914                 register hdloutlinerecord lho = outlinedata;
03915                     
03916                 (**lho).fldirty = false; /*the outline structure is not dirty*/
03917     
03918                 (**lho).flrecentlychanged = false; /*in case someone is maintaining a parallel structure*/
03919                 } /*else*/
03920                         
03921             fl = true;
03922             
03923             break;          
03924             }
03925         
03926         case getselectfunc: { /*7.0b15 PBS: get list of cursors, the current selection*/
03927             
03928             fl = opgetselectverb (hparam1, v);
03929             
03930             break;
03931             }
03932         
03933         case getheadnumberfunc: { /*7.0b17 PBS: get the index of the current headline*/
03934 
03935             /*7.0b21: changed name to op.getHeadNumber -- because op.index suggests the search engine*/
03936             
03937             if (!langcheckparamcount (hparam1, 0))
03938                 break;
03939 
03940             fl = setlongvalue (opgetheadnumberverb (hbarcursor), vreturned);
03941 
03942             break;
03943             }
03944         
03945         case getselectedsuboutlinesfunc: { /*7.0b18 PBS: get selected headlines as an outline*/
03946             
03947             hdloutlinerecord lho;
03948             
03949             flnextparamislast = true;
03950             
03951             /*Get outline parameter.*/
03952     
03953             if (getoutlinevalue (hparam1, 1, &lho)) /*First param is an outline to add to*/
03954                 
03955                 fl = opgetselectedsuboutlinesverb (lho);
03956             
03957             setbooleanvalue (fl, vreturned);
03958 
03959             break;
03960             }
03961         
03962         case sethtmlformattingfunc: { /*7.0b28: turn on and off HTML formatting.*/
03963 
03964             boolean lfl = false;
03965             boolean flchanged = false;
03966 
03967             flnextparamislast = true;
03968 
03969             if (!getbooleanvalue (hparam1, 1, &lfl))
03970                 break;
03971             
03972             if ((**outlinedata).outlinetype == outlineisoutline) { /*outlines only*/
03973                 
03974                 if ((**outlinedata).flhtml != lfl) { /*Don't bother if it's already set as requested.*/
03975                     
03976                     long startsel, endsel;
03977 
03978                     boolean fltextmode = (**outlinedata).fltextmode;
03979 
03980                     if (fltextmode) {
03981 
03982                         wpgetselection (&startsel, &endsel);
03983 
03984                         opunloadeditbuffer ();
03985                         }
03986 
03987                     (**outlinedata).flhtml = lfl;
03988 
03989                     opdirtyview ();
03990 
03991                     opdirtymeasurements ();
03992 
03993                     opinvaldisplay ();
03994                     
03995                     if (fltextmode) {
03996 
03997                         oploadeditbuffer ();
03998 
03999                         wpsetselection (startsel, endsel); /*restore selection*/
04000                         }
04001 
04002                     flchanged = true;
04003                     } /*if*/
04004                 } /*if*/
04005 
04006             lfl = setbooleanvalue (flchanged, vreturned);
04007 
04008             break;
04009             }
04010 
04011         case gethtmlformattingfunc: { /*7.0b28 PBS: return true if HTML formatting is on.*/
04012 
04013             boolean flhtml;
04014 
04015             flhtml = (**outlinedata).flhtml;
04016 
04017             if ((**outlinedata).outlinetype != outlineisoutline) /*outlines only*/
04018                 flhtml = false;
04019 
04020             fl = setbooleanvalue (flhtml, vreturned);
04021 
04022             break;
04023             }
04024         
04025         case setdynamicfunc: { /*7.0b30 PBS: set the dynamic flag for a headline record.*/
04026             
04027             boolean fldynamic;
04028 
04029             flnextparamislast = true;
04030 
04031             if (!getbooleanvalue (hparam1, 1, &fldynamic))
04032                 break;
04033 
04034             (**hbarcursor).fldynamic = fldynamic;
04035 
04036             fl = setbooleanvalue (true, vreturned);
04037 
04038             break;
04039             }
04040 
04041         case getdynamicfunc: { /*7.0b30 PBS: get the dynamic flag for a headline record.*/
04042 
04043             boolean fldynamic = (**hbarcursor).fldynamic;
04044 
04045             fl = setbooleanvalue (fldynamic, vreturned);
04046 
04047             break;
04048             }
04049 
04050         /*7.0b16 PBS: opattributes verbs*/
04051         
04052         case addgroupfunc: { /*7.0b16 PBS: op.attributes.addGroup*/
04053             
04054             
04055             
04056             break;
04057             }
04058         
04059         case getallfunc: { /*7.0b16 PBS: op.attributes.getAll*/
04060             
04061             hdlhashtable ht;
04062             bigstring bsvarname;
04063             tyvaluerecord val;
04064 
04065             flnextparamislast = true;
04066 
04067             if (!getvarparam (hparam1, 1, &ht, bsvarname))
04068                 break;
04069             
04070             if (!opattributesgetpackedtablevalue (hbarcursor, &val)) {
04071             
04072                 break;
04073                 }
04074             
04075             if (!langsetsymboltableval (ht, bsvarname, val)) {
04076         
04077                 disposevaluerecord (val, false);
04078         
04079                 break;
04080                 }
04081             
04082             fl = true;
04083             
04084             break;
04085             }
04086         
04087         case getonefunc: { /*7.0b16 PBS: op.attributes.getOne*/
04088         
04089             bigstring bsattname, bsvarname;
04090             tyvaluerecord val;
04091             hdlhashtable ht;
04092             
04093             fl = true;
04094                         
04095             if (!getstringvalue (hparam1, 1, bsattname))
04096                 break;
04097         
04098             flnextparamislast = true;
04099             
04100             if (!getvarparam (hparam1, 2, &ht, bsvarname))
04101                 break;
04102             
04103             (*v).data.flvalue = opattributesgetoneattribute (hbarcursor, bsattname, &val);
04104             
04105             if ((*v).data.flvalue) {
04106                 
04107                 if (!langsetsymboltableval (ht, bsvarname, val)) {
04108         
04109                     disposevaluerecord (val, false);
04110 
04111                     break;
04112                     } /*if*/
04113                 } /*if*/
04114 
04115             break;
04116             }
04117         
04118         case makeemptyfunc: { /*7.0b16 PBS: op.attributes.makeEmpty*/
04119             
04120             
04121             break;
04122             }
04123         
04124         case setonefunc: { /*7.0b16 PBS: op.attributes.setOne*/
04125             
04126             
04127             break;
04128             }
04129     
04130         } /*switch*/
04131     
04132     shellupdatescrollbars (outlinewindowinfo);
04133             
04134     shellpopglobals ();
04135             
04136     return (fl);
04137     
04138     #endif // !flruntime
04139     
04140     error:
04141     
04142     if (errornum != 0) /*get error string*/
04143         getstringlist (operrorlist, errornum, bserror);
04144     
04145     return (false);
04146     } /*opfunctionvalue*/
04147 
04148 
04149 static boolean opinitverbs (void) {
04150     
04151     return (loadfunctionprocessor (idopverbs, &opfunctionvalue));
04152     } /*opinitverbs*/
04153 
04154 
04155 #if !flruntime
04156 
04157 static void opverbresize (void) {
04158     
04159     opresize ((**outlinewindowinfo).contentrect);
04160     
04161     #ifdef WIN95VERSION
04162         opupdatenow ();
04163     #endif
04164     } /*opverbresize*/
04165 
04166 
04167 boolean opverbclose (void) {
04168     
04169     register hdloutlinerecord ho = outlinedata;
04170     register hdloutlinevariable hv;
04171     
04172     if (ho == nil) //already closed & disposed?
04173         return (true);
04174     
04175     hv = (hdloutlinevariable) (**ho).outlinerefcon;
04176     
04177     langexternalwindowclosed ((hdlexternalvariable) hv);
04178     
04179     opverbcheckwindowrect (ho);
04180     
04181     killundo (); /*must toss undos before they're stranded*/
04182     
04183     if ((**ho).fldirty || isfilewindow (shellwindow)) { /*we have to keep the in-memory version around*/
04184         
04185         (**ho).flwindowopen = false;
04186         
04187         opcloseoutline (); /*prepare for dormancy, not in a window anymore*/
04188         }
04189     
04190     else { /*the db version is identical to memory version, save memory*/
04191         
04192         if (hv == nil) /*defensive driving*/
04193             return (true);
04194         
04195         opverbunload ((hdlexternalvariable) hv, (**hv).oldaddress);
04196         
04197         //opsetoutline (nil); // 4.15.97 dmb
04198         }
04199     
04200     return (true);
04201     } /*opverbclose*/
04202 
04203 
04204 boolean opverbfind (hdlexternalvariable hvariable, boolean *flzoom) {
04205 #pragma unused(flzoom)
04206 
04207     register hdloutlinevariable hv = (hdloutlinevariable) hvariable;
04208     register hdloutlinerecord ho;
04209     register boolean fl;
04210     boolean fltempload;
04211     boolean flwindowopen;
04212     hdlwindowinfo hinfo;
04213     boolean fldisplaywasenabled = true;
04214     
04215     fltempload = !(**hv).flinmemory;
04216     
04217     if (!opverbinmemory (hv))
04218         return (false);
04219     
04220     ho = (hdloutlinerecord) (**hv).variabledata;
04221     
04222     flwindowopen = opwindowopen ((hdlexternalvariable) hv, &hinfo) && hinfo;
04223     
04224     if (flwindowopen)
04225         shellpushglobals ((**hinfo).macwindow);
04226     
04227     else {
04228         shellpushglobals (nil);
04229         
04230         oppushoutline (ho);
04231         
04232         fldisplaywasenabled = opdisabledisplay ();
04233         }
04234     
04235     fl = opflatfind (true, false);
04236     
04237     if (!flwindowopen) {
04238         
04239         if (fldisplaywasenabled)
04240             openabledisplay ();
04241         
04242         oppopoutline ();
04243         }
04244     
04245     shellpopglobals ();
04246     
04247     if (fltempload && !fl && !(**ho).fldirty)
04248         opverbunload ((hdlexternalvariable) hv, (**hv).oldaddress);
04249     
04250     return (fl);
04251     } /*opverbfind*/
04252 
04253 
04254 static boolean opverbsearch (void) {
04255     
04256     register long oprefcon = (**outlinedata).outlinerefcon;
04257     
04258     startingtosearch (oprefcon); /*will be accepted if not part of larger search*/
04259     
04260     if (opflatfind (false, searchshouldwrap (oprefcon)))
04261         return (true);
04262     
04263     if (!searchshouldcontinue (oprefcon))
04264         return (false);
04265     
04266     return (langexternalcontinuesearch ((hdlexternalvariable) oprefcon));
04267     } /*opverbsearch*/
04268 
04269 
04270 boolean opverbruncursor (void) {
04271     
04272     bigstring bs, bsresult;
04273     
04274     opgetheadstring ((**outlinedata).hbarcursor, bs);
04275     
04276     return (langrunstring (bs, bsresult));
04277     } /*opverbruncursor*/
04278 
04279 
04280 boolean opverbgetvariable (hdlexternalvariable *hvariable) {
04281     
04282     if (outlinedata == nil)
04283         return (false);
04284     
04285     *hvariable = (hdlexternalvariable) (**outlinedata).outlinerefcon;
04286     
04287     return (true);
04288     } /*opverbgetvariable*/
04289 
04290 
04291 static boolean opverbtitleclick (Point pt) {
04292     
04293     return (langexternaltitleclick (pt, (hdlexternalvariable) (**outlinedata).outlinerefcon));
04294     } /*opverbtitleclick*/
04295 
04296 
04297 static void opverbidle (void) {
04298     
04299     opidle ();
04300     } /*opverbidle*/
04301 
04302 
04303 static boolean opverbsetfont (void) {
04304     
04305     return (opsetfont ((**outlinewindowinfo).selectioninfo.fontnum));
04306     } /*opverbsetfont*/
04307 
04308 
04309 static boolean opverbsetsize (void) {
04310     
04311     return (opsetsize ((**outlinewindowinfo).selectioninfo.fontsize));
04312     } /*opverbsetsize*/
04313 
04314 
04315 boolean opverbgettargetdata (short id) {
04316     
04317     /*
04318     a verb is about to be executed that acts on the indicated external type, or 
04319     on any shell window if id == -1.
04320     
04321     return true if we can handle verbs of that type and are able to set the 
04322     relevant globals
04323     */
04324     
04325     switch (id) {
04326         
04327         case -1:
04328             return (true);
04329         
04330         case idoutlineprocessor:
04331             return (true);
04332         
04333         case idwordprocessor:
04334             return (opeditsetglobals ());
04335         
04336         default:
04337             return (false);
04338         }
04339     } /*opverbgettargetdata*/
04340 
04341 
04342 static boolean opverbkeystroke (void) {
04343 
04344     if (langexternalsurfacekey ((hdlexternalvariable) (**outlinedata).outlinerefcon))
04345         return (true);
04346     
04347     return (opkeystroke ());
04348     } /*opverbkeystroke*/
04349 
04350 #endif // !flruntime
04351 
04352 
04353 static boolean opmenuroutine (short idmenu, short ixmenu) {
04354     
04355     /*
04356     carefull - we have no idea what window is in front, we must 
04357     only take action if our globals are set
04358     
04359     return false if we successfully handle the menu item, so no further 
04360     action is taken
04361     */
04362     
04363     tydirection dir = nodirection;
04364     
04365     if ((idmenu == virtualmenu) &&
04366         (outlinewindow == shellwindow) && 
04367         (outlinedata != NULL)) {
04368 
04369         switch (ixmenu) {
04370             case moveupitem:
04371                 dir = up;
04372                 break;
04373 
04374             case movedownitem:
04375                 dir = down;
04376                 break;
04377 
04378             case moveleftitem:
04379                 dir = left;
04380                 break;
04381 
04382             case moverightitem:
04383                 dir = right;
04384                 break;
04385             }
04386         }
04387     
04388     if (dir == nodirection)
04389         return (true);
04390     
04391     opreorgcursor (dir, 1);
04392 
04393     return (false);
04394     } /*opmenuroutine*/
04395 
04396 
04397 boolean opstart (void) {
04398     
04399     /*
04400     set up callback routines record, and link our data into the shell's 
04401     data structure.
04402     */
04403     
04404     ptrcallbacks callbacks;
04405     register ptrcallbacks cb;
04406     
04407     assert (sizeof (tyexternalvariable) == sizeof (tyoutlinevariable) - sizeof (Handle));
04408     
04409     if (!opinitverbs ())
04410         return (false);
04411     
04412     opinitdisplayvariables ();
04413     
04414     #if !flruntime
04415     
04416     shellpushscraphook (&opscraphook);
04417     
04418     shellpushmenuhook (&opmenuroutine);
04419 
04420     shellnewcallbacks (&callbacks);
04421     
04422     cb = callbacks; /*copy into register*/
04423     
04424     loadconfigresource (idoutlineconfig, &(*cb).config);
04425     
04426     (*cb).configresnum = idoutlineconfig;
04427         
04428     (*cb).windowholder = &outlinewindow;
04429     
04430     (*cb).dataholder = (Handle *) &outlinedataholder;
04431     
04432     (*cb).infoholder = &outlinewindowinfo;
04433     
04434     (*cb).setglobalsroutine = &opverbsetglobals;
04435     
04436     (*cb).pushroutine = &oppushglobals;
04437 
04438     (*cb).poproutine = &oppopglobals;
04439     
04440 #ifdef version42orgreater
04441     
04442     (*cb).disposerecordroutine = ccdisposefilerecord;
04443     
04444     (*cb).saveroutine = ccsavespecialfile;
04445 
04446 #endif
04447     
04448     (*cb).updateroutine = &opupdate;
04449     
04450     (*cb).activateroutine = &opactivate;
04451     
04452     (*cb).getcontentsizeroutine = &opgetoutinesize;
04453     
04454     (*cb).resizeroutine = &opverbresize;
04455     
04456     (*cb).scrollroutine = &opscroll;
04457     
04458     (*cb).setscrollbarroutine = &opresetscrollbars;
04459     
04460     (*cb).mouseroutine = &opmousedown;
04461 
04462     (*cb).rmouseroutine = &oprmousedown; /*7.0b10 PBS: right-click menus*/
04463     
04464     (*cb).keystrokeroutine = &opverbkeystroke;
04465     
04466     (*cb).getundoglobalsroutine = &opeditgetundoglobals;
04467     
04468     (*cb).setundoglobalsroutine = &opeditsetundoglobals;
04469     
04470     (*cb).cutroutine = &opcut;
04471     
04472     (*cb).copyroutine = &opcopy;
04473     
04474     (*cb).pasteroutine = &oppaste;
04475     
04476     (*cb).clearroutine = &opclear;
04477     
04478     (*cb).selectallroutine = &opselectall;
04479     
04480     (*cb).fontroutine = &opverbsetfont;
04481     
04482     (*cb).sizeroutine = &opverbsetsize;
04483     
04484     (*cb).setselectioninforoutine = &opsetselectioninfo;
04485     
04486     (*cb).idleroutine = &opverbidle;
04487     
04488     (*cb).adjustcursorroutine = &opsetcursor;
04489     
04490     (*cb).gettargetdataroutine = &opverbgettargetdata;
04491     
04492     (*cb).setprintinfoproutine = &opsetprintinfo;
04493     
04494     (*cb).beginprintroutine = &opbeginprint;
04495     
04496     (*cb).endprintroutine = &opendprint;
04497     
04498     (*cb).printroutine = &opprint;
04499     
04500     (*cb).titleclickroutine = &opverbtitleclick;
04501     
04502     (*cb).getvariableroutine = (shellgetvariablecallback) &opverbgetvariable;
04503     
04504     (*cb).settextmoderoutine = &opsettextmode;
04505     
04506     (*cb).searchroutine = &opverbsearch;
04507     
04508     (*cb).executeroutine = &opverbruncursor;
04509     
04510     (*cb).cmdkeyfilterroutine = &opcmdkeyfilter;
04511     
04512     (*cb).closeroutine = &opverbclose;
04513 
04514     (*cb).buttonstatusroutine = &opbuttonstatus; /*7.1b18 PBS*/
04515 
04516     (*cb).buttonroutine = &opbutton; /*7.1b18 PBS*/
04517     
04518     #endif
04519     
04520     return (true);
04521     } /*opstart*/
04522 
04523 
04524 
04525 
04526 
04527 

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