meprograms.c

Go to the documentation of this file.
00001 
00002 /*  $Id: meprograms.c 355 2005-01-11 22:48:55Z andreradke $    */
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 "kb.h"
00032 #include "strings.h"
00033 #include "frontierwindows.h"
00034 #include "lang.h"
00035 #include "langexternal.h"
00036 #include "shellmenu.h"
00037 #include "process.h"
00038 #include "scripts.h"
00039 #include "menueditor.h"
00040 #include "menuinternal.h"
00041 #include "meprograms.h"
00042 #include "menuverbs.h"
00043 #include "cancoon.h"
00044 
00045 
00046 
00047 #if !flruntime
00048 
00049 typedef struct findnodeinfo{
00050     
00051     hdlheadrecord hnode;
00052     
00053     hdlwindowinfo hinfo;
00054     } tyfindnodeinfo;
00055 
00056 
00057 static boolean mefindnodevisit (WindowPtr w, ptrvoid refcon) {
00058     
00059     tyfindnodeinfo *findinfo = (tyfindnodeinfo *) refcon;
00060     boolean fl;
00061     
00062     shellpushglobals (w);
00063     
00064     fl = opnodeinoutline ((*findinfo).hnode);
00065     
00066     (*findinfo).hinfo = shellwindowinfo; /*do now while globals are set*/
00067     
00068     shellpopglobals ();
00069     
00070     if (fl) /*found the outline we're looking for; stop visiting*/
00071         return (false);
00072     
00073     return (true); /*keep visiting*/
00074     } /*mefindnodevisit*/
00075 
00076 
00077 boolean mezoommenubarwindow (hdloutlinerecord houtline, boolean flbringtofront, hdlwindowinfo *hinfo) {
00078     
00079     /*
00080     trace the indicated outline's refcon back to the menubar variable 
00081     that contains it, and zoom that variable into its window.
00082     
00083     7/15/91 dmb: get the fullpath of the menubar for the title
00084     
00085     9/12/91 dmb: added flbringtofront, hinfo parameters to avoid window noise 
00086     during searches.
00087     */
00088     
00089     hdlmenurecord hm = (hdlmenurecord) (**houtline).outlinerefcon;
00090     hdlexternalvariable hv = (hdlexternalvariable) (**hm).menurefcon;
00091     hdlhashtable htable;
00092     bigstring bs, bstitle;
00093     Rect rzoom;
00094     hdlwindowinfo hparent;
00095     
00096     if (!langexternalfindvariable (hv, &htable, bs))
00097         return (false);
00098     
00099     if (!langexternalgetfullpath (htable, bs, bstitle, &hparent))
00100         return (false);
00101     
00102     if (flbringtofront)
00103         rzoom.top = -1;
00104     else
00105         rzoom.top = -2;
00106     
00107     if (!menuedit (hv, hparent, nil, bstitle, &rzoom))
00108         return (false);
00109     
00110     if (hinfo != nil)
00111         return (shellfinddatawindow ((Handle) (**hv).variabledata, hinfo));
00112     
00113     return (true);
00114     } /*mezoommenubarwindow*/
00115 
00116 #endif
00117 
00118 
00119 boolean mescripterrorroutine (long scripterrorrefcon, long lnum, short charnum, hdlhashtable *htable, bigstring bsname) {
00120     
00121     /*
00122     refcon points to a node with a linked script that generated a language
00123     error.  lnum, charnum indicates where in the script the error occurred.
00124     
00125     4.1b3 dmb: support getting htable, bsname instead of zooming
00126     */
00127     
00128     #if flruntime
00129     
00130     return (true);
00131     
00132     #else
00133     
00134     register hdlheadrecord h = (hdlheadrecord) scripterrorrefcon;
00135     register boolean fl = false;
00136     hdloutlinerecord houtline;
00137     hdlwindowinfo hinfo;
00138     tyfindnodeinfo findinfo;
00139     
00140     if (h == nil) /*defensive driving*/
00141         return (false);
00142     
00143     if (htable != nil) { /*4.1b3 dmb: caller wants table, name*/
00144         
00145         *htable = nil;
00146         
00147         getheadstring (h, bsname);
00148         
00149         return (true);
00150         }
00151     
00152     findinfo.hnode = h;
00153     
00154     if (!shellvisittypedwindows (idmenueditorconfig, &mefindnodevisit, &findinfo)) { /*found in open window*/
00155         
00156         hinfo = findinfo.hinfo;
00157         }
00158     else {
00159         
00160         if (!melocatemenubarnode (h, &houtline)) /*couldn't find the node in menu bar*/
00161             return (false);
00162         
00163         if (!mezoommenubarwindow (houtline, false, &hinfo)) /*probably out of memory*/
00164             return (false);
00165         }
00166     
00167     shellpushglobals ((**hinfo).macwindow);
00168     
00169     mesetglobals ();
00170     
00171     meexpandto (h); 
00172     
00173     if (mezoomscriptwindow ()) {
00174         
00175         shellpushglobals ((**menudata).scriptwindow);
00176         
00177         fl = opshowerror (lnum, charnum);
00178         
00179         shellpopglobals (); /*scriptwindow*/
00180         }
00181     
00182     shellpopglobals (); /*menuwindow*/
00183     
00184     return (fl);
00185     
00186     #endif
00187     } /*mescripterrorroutine*/
00188 
00189 
00190 boolean megetnodelangtext (hdlheadrecord hnode, Handle *htext, long *signature) {
00191     
00192     /*
00193     12/14/90 dmb: use meloadscriptoutline instead of taking care of loading 
00194     manually
00195     */
00196     
00197     register hdlheadrecord h = hnode;
00198     register hdloutlinerecord ho;
00199     hdloutlinerecord houtline;
00200     register boolean fl;
00201     boolean fldispose = false;
00202     
00203     #if !flruntime
00204     
00205     mesetglobals (); /*be sure op, db and lang have globals set up properly*/
00206     
00207     #endif
00208     
00209     if (!meloadscriptoutline (menudata, h, &houtline, &fldispose)) 
00210         return (false);
00211     
00212     ho = houtline; /*copy into register*/
00213     
00214     if (ho == nil) /*nothing to run*/
00215         return (false);
00216     
00217     *signature = (**ho).outlinesignature;
00218     
00219     fl = opgetlangtext (ho, false, htext);
00220     
00221     if (fldispose) 
00222         opdisposeoutline (ho, false);
00223     
00224     return (fl);
00225     } /*megetnodelangtext*/
00226 
00227 
00228 #if !flruntime
00229 
00230 boolean meshownode (hdlheadrecord hnode) {
00231     
00232     /*
00233     1/7/90 dmb: the option key case, must push/popglobals around mexpandto
00234     
00235     can assume that outlinedata is current for hnode
00236     */
00237     
00238     boolean flshowscript = keyboardstatus.flshiftkey || shiftkeydown ();
00239     hdlwindowinfo hinfo;
00240     
00241     if (!mezoommenubarwindow (outlinedata, !flshowscript, &hinfo)) /*make sure menubar window is open, in front*/
00242         return (false);
00243     
00244     shellpushglobals ((**hinfo).macwindow);
00245     
00246     meexpandto (hnode);
00247     
00248     if (flshowscript)
00249         mezoomscriptwindow ();
00250     
00251     shellpopglobals ();
00252     
00253     return (true);
00254     } /*meshownode*/
00255 
00256 
00257 static boolean meprocesscallback (void) {
00258     
00259     shellforcemenuadjust (); /*for menu dimming*/
00260     
00261     return (true);
00262     } /*meprocesscallback*/
00263 
00264 #endif
00265 
00266 
00267 boolean meuserselected (hdlheadrecord hnode) {
00268     
00269     /*
00270     1/7/90 dmb: in option key case, must push/popglobals around mexpandto
00271     
00272     3/29/91 dmb: moved option key case into it's own routine; caller checks.
00273     
00274     2.1b2 dmb: support osa scripts by using scriptbuildtree instead of langbuildtree
00275     
00276     3.0a dmb: we're now allowed to add the new process here for runtime too.
00277     
00278     4.1b3 dmb: don't set newlyaddedprocess here anymore; addprocess does it.
00279     */
00280     
00281     Handle htext;
00282     long signature;
00283     hdltreenode hcode;
00284     hdlprocessrecord hprocess;
00285     register hdlprocessrecord hp;
00286     
00287     boolean fl;
00288     
00289     #if !flruntime
00290         
00291         menudata = (hdlmenurecord) (**outlinedata).outlinerefcon;
00292     
00293     #endif
00294     
00295     if (!megetnodelangtext (hnode, &htext, &signature)) 
00296         return (false);
00297     
00298     if (!langpusherrorcallback (&mescripterrorroutine, (long) hnode))
00299         return (false);
00300     
00301     fl = scriptbuildtree (htext, signature, &hcode);
00302     
00303     langpoperrorcallback ();
00304     
00305     if (!fl) /*syntax error*/
00306         return (false);
00307     
00308     langerrorclear (); /*compilation produced no error, be sure error window is empty*/
00309     
00310     if (!newprocess (hcode, true, &mescripterrorroutine, (long) hnode, &hprocess)) {
00311         
00312         langdisposetree (hcode);
00313         
00314         return (false);
00315         }
00316     
00317     hp = hprocess; /*copy into register*/
00318     
00319     #if !flruntime
00320         
00321         (**hp).processkilledroutine = &meprocesscallback;
00322         
00323         shellforcemenuadjust (); /*for menu dimming*/
00324         
00325     #endif
00326     
00327     addprocess (hp);
00328     
00329     return (true);
00330     } /*meuserselected*/
00331 
00332 
00333 
00334 

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