menufind.c

Go to the documentation of this file.
00001 
00002 /*  $Id: menufind.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 "search.h"
00032 #include "cursor.h"
00033 #include "kb.h"
00034 #include "langexternal.h"
00035 #include "opinternal.h"
00036 #include "menueditor.h"
00037 #include "menuinternal.h"
00038 
00039 
00040 
00041 
00042 static boolean flfoundinscript;
00043 
00044 
00045 boolean mesearchrefconroutine (hdlheadrecord hnode) {
00046     
00047     /*
00048     load the script linked into the headrecord, search it for the search string, and
00049     return with hnodesearch (a global) pointing at the menu item where the match was
00050     found.
00051     
00052     9/19/90 DW: we weren't checking for a nil outlinerecord handle.  it happens when
00053     the menu item has no script linked to it.
00054     */
00055     
00056     hdloutlinerecord houtline;
00057     hdloutlinerecord hmenuoutline;
00058     register hdloutlinerecord ho;
00059     boolean flfound;
00060     boolean fljustloaded;
00061     hdlwindowinfo hinfo;
00062     boolean fldirty;
00063     boolean fldisplaywasenabled;
00064     
00065     if (searchparams.flonelevel)
00066         return (false);
00067     
00068     if (keyboardescape ())
00069         return (false);
00070     
00071     if (!meloadscriptoutline (menudata, hnode, &houtline, &fljustloaded)) /*error loading script*/
00072         return (false);
00073     
00074     ho = houtline; /*copy into register*/
00075     
00076     if (ho == nil) /*no script linked into the menu item*/
00077         return (false);
00078     
00079     oppushoutline (ho);
00080     
00081     fldisplaywasenabled = opdisabledisplay (); /*we pushed outline, but not its window*/
00082     
00083     flfound = opflatfind (true, false);
00084     
00085     fldirty = (**ho).fldirty; /*in case of replace all*/
00086     
00087     if (fldisplaywasenabled)
00088         openabledisplay ();
00089     
00090     oppopoutline (); /*restore original*/
00091     
00092     if (flfound) { /*match found, position bar cursor and return true*/
00093         
00094         mesetscriptoutline (hnode, ho); /*make loaded state stick*/
00095         
00096         hmenuoutline = outlinedata;
00097         
00098         oppushoutline (nil); /*save on stack*/
00099         
00100         if (!mezoommenubarwindow (hmenuoutline, false, &hinfo)) { /*probably out of memory*/
00101             
00102             oppopoutline ();
00103             
00104             return (false);
00105             }
00106         
00107         shellpushglobals ((**hinfo).macwindow);
00108         
00109         if (searchparams.flwindowzoomed)
00110             (**hinfo).flopenedforfind = true;
00111         
00112         meexpandto (hnode);
00113         
00114         mezoomscriptwindow ();
00115         
00116         shellpopglobals ();
00117         
00118         oppopoutline ();
00119         
00120         flfoundinscript = true; /*so caller will know display is already done*/
00121         
00122         return (true);
00123         }
00124     
00125     if (fljustloaded) {
00126         
00127         if (fldirty) { /*must be doing a replace all*/
00128             
00129             mesetscriptoutline (hnode, ho); /*make loaded state stick*/
00130             
00131             (**outlinedata).fldirty = true; /*percolate up to parent outline*/
00132             }
00133         else
00134             opdisposeoutline (ho, false);
00135         }
00136     
00137     return (false);
00138     } /*mesearchrefconroutine*/
00139 
00140 
00141 boolean mesearchoutline (boolean flfromtop, boolean flwrap, boolean *flzoom) {
00142     
00143     flfoundinscript = false;
00144     
00145     if (!opflatfind (flfromtop, flwrap))
00146         return (false);
00147     
00148     *flzoom = !flfoundinscript;
00149     
00150     /*
00151     if (flfoundinscript && searchparams.flwindowzoomed) {
00152         
00153         hdlwindowinfo hinfo;
00154         
00155         if (getfrontwindowinfo (&hinfo))
00156             (**hinfo).flopenedforfind = true;
00157         }
00158     */
00159     
00160     return (true);
00161     } /*mesearchoutline*/
00162 
00163 
00164 boolean mecontinuesearch (hdlwindowinfo hinfo, hdlheadrecord hnode) {
00165     
00166     /*
00167     9/12/91 dmb: new search logic checks for flat search before calling here; 
00168     we don't have enought info to check
00169     
00170     5.0.2b20 dmb: start search from headline _after_ hnode; don't get stuck here.
00171     */
00172     
00173     boolean fl, flzoom;
00174     long menurefcon;
00175     
00176     shellpushglobals ((**hinfo).macwindow);
00177     
00178     mecheckglobals ();
00179     
00180     menurefcon = (**menudata).menurefcon;
00181     
00182     if (!opnavigate (flatdown, &hnode))
00183         fl = false;
00184     
00185     else {
00186         opmoveto (hnode);
00187         
00188         opsettextmode (false); /*make sure we search text of new headline*/
00189         
00190         fl = mesearchoutline (false, searchshouldwrap (menurefcon), &flzoom);
00191         }
00192     
00193     if (fl) {
00194         
00195         if (searchparams.flzoomfound && flzoom)
00196             shellbringtofront (shellwindowinfo);
00197         }
00198     else {
00199         
00200         if (searchshouldcontinue (menurefcon))
00201             fl = langexternalcontinuesearch ((hdlexternalvariable) menurefcon);
00202         }
00203     
00204     shellpopglobals ();
00205     
00206     return (fl);
00207     } /*mecontinuesearch*/
00208 
00209 
00210 boolean menuverbsearch (void) {
00211     
00212     boolean flzoom;
00213     long menurefcon;
00214     
00215     mecheckglobals ();
00216     
00217     menurefcon = (**menudata).menurefcon;
00218     
00219     startingtosearch (menurefcon);
00220     
00221     if (mesearchoutline (false, searchshouldwrap (menurefcon), &flzoom))
00222         return (true);
00223     
00224     if (keyboardescape ()) {
00225         
00226         /*
00227         keyboardclearescape ();
00228         */
00229         
00230         return (false);
00231         }
00232     
00233     if (!searchshouldcontinue (menurefcon))
00234         return (false);
00235     
00236     return (langexternalcontinuesearch ((hdlexternalvariable) menurefcon));
00237     } /*menuverbsearch*/
00238 
00239 
00240 
00241 

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