opedit.c

Go to the documentation of this file.
00001 
00002 /*  $Id: opedit.c 1206 2006-04-05 23:21:19Z karstenw $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "memory.h"
00032 #include "font.h"
00033 #include "mouse.h"
00034 #include "quickdraw.h"
00035 #include "strings.h"
00036 #include "scrap.h"
00037 #include "kb.h"
00038 #include "op.h"
00039 #include "opinternal.h"
00040 #include "shell.rsrc.h"
00041 #include "shellundo.h"
00042 #include "wpengine.h"
00043 
00044 
00045 
00046 
00047 static boolean fleditingnow = false;
00048 
00049 
00050 
00051 boolean opeditsetglobals (void) {
00052     
00053     /*
00054     set up the word processing engine's globals
00055 
00056     5.0b15 dmb: handle nil outlinedata
00057     */
00058     
00059     if (outlinedata == nil)
00060         return (false);
00061 
00062     wpdata = (hdlwprecord) (**outlinedata).hbuffer;
00063     
00064     wpwindow = outlinewindow;
00065     
00066     wpwindowinfo = outlinewindowinfo;
00067     
00068     return (wpdata != nil);
00069     } /*opeditsetglobals*/
00070 
00071 
00072 boolean opeditingtext (hdlheadrecord hnode) {
00073     
00074     /*
00075     return true if the indicated node is being edited by the text editor
00076     */
00077     
00078     register hdloutlinerecord ho = outlinedata;
00079     
00080     if ((**ho).hbuffer && (hnode == (**ho).heditcursor)) {
00081         
00082         //assert ((**ho).fltextmode);
00083         
00084         assert ((**ho).hbarcursor == (**ho).heditcursor);
00085         
00086         return (true);
00087         }
00088     
00089     return (false);
00090     } /*opeditingtext*/
00091 
00092 
00093 boolean opdefaultgetedittextrect (hdlheadrecord hnode, const Rect *linerect, Rect *textrect) {
00094     
00095     /*
00096     5.0b7 dmb: add our width to the default text rect here, cleanly
00097     */
00098     
00099     opdefaultgettextrect (hnode, linerect, textrect);
00100     
00101     if (!opisfatheadlines (outlinedata))
00102         (*textrect).right += 1600; /*leave room for long lines; not too large, but enough*/
00103     
00104     (*textrect).top += textvertinset;
00105     
00106     return (true);
00107     } /*opdefaultgetedittextrect*/
00108 
00109 
00110 boolean opdefaultsetwpedittext (hdlheadrecord hnode) {
00111     
00112     /*
00113     2/7/97 dmb: we are called with the wp globals set up. 
00114     our job it to set the wp to contain the right text.
00115     */
00116     
00117     return (wpsettexthandle ((**hnode).headstring));
00118     } /*opdefaultsetwpedittext*/
00119 
00120 
00121 boolean opdefaultgetwpedittext (hdlheadrecord hnode, boolean flunload) {
00122 #pragma unused (flunload)
00123 
00124     /*
00125     2/7/97 dmb: we are called with the wp globals set up. 
00126     our job it to extract the current text from the wp.
00127     
00128     return true if the text actually changed
00129     
00130     6.0a1 dmb: use handles  [xxx bypassing opsetheadstring bigstrings and special cases]
00131     */
00132     
00133     Handle htext;
00134     
00135     if (!wpgettexthandle (&htext)) 
00136         return (false);
00137     
00138     opsetheadtext (hnode, htext);
00139     
00140     /*
00141     if (!equalhandles (htext, (**hnode).headstring)) {
00142         
00143         (**hnode).fldirty = true;
00144         
00145         opdirtyoutline ();
00146         }
00147     
00148     disposehandle ((**hnode).headstring);
00149     
00150     (**hnode).headstring = htext;
00151     */
00152     
00153     return (true);
00154     } /*opdefaultgetwpedittext*/
00155 
00156 
00157 static boolean opgettextbufferrect (hdlheadrecord hnode, Rect *rclip, Rect *rtext) {
00158     
00159     /*
00160     6.0a12 dmb: clip to linerect _and_ outlinerect. linerect may extend above display.
00161     
00162     6.0b2 dmb: if line is off screen, return a rect above the screen, not false.
00163     */
00164     
00165     register hdloutlinerecord ho = outlinedata;
00166     Rect rline;
00167     
00168     if (!opgetnoderect (hnode, &rline)) {
00169     
00170         rline = (**ho).outlinerect;
00171         
00172         rline.bottom = rline.top;
00173         
00174         rline.top -= opgetlineheight (hnode);
00175         
00176         // return (false);
00177         }
00178     
00179     intersectrect ((**ho).outlinerect, rline, rclip);
00180     
00181     (*(**ho).getedittextrectcallback) (hnode, &rline, rtext);
00182     
00183     #ifdef WIN95VERSION
00184         (*rtext).top += 1;
00185     #endif
00186     
00187     return (true);
00188     } /*opgettextbufferrect*/
00189 
00190 
00191 boolean opseteditbufferrect (void) {
00192     
00193     /*
00194     5.0d1 dmb: return false if setglobals fails. can happen if outline was
00195     just unpacked
00196     */
00197     
00198     register hdloutlinerecord ho = outlinedata;
00199     register hdlheadrecord hcursor = (**ho).heditcursor;
00200     Rect r, rclip;
00201     
00202     if (!(**ho).fltextmode || !opeditsetglobals ())
00203         return (true);
00204     
00205     opgettextbufferrect (hcursor, &rclip, &r);
00206     
00207     intersectrect (rclip, r, &rclip);
00208     
00209     wpsetbufferrect (rclip, r);
00210     
00211     return (true);
00212     } /*opseteditbufferrect*/
00213 
00214 
00215 static boolean oppreedit (void) {
00216     
00217     fleditingnow = true;
00218     
00219     return (true);
00220     } /*oppreedit*/
00221 
00222 
00223 void oppostedit (void) {
00224     
00225     /*
00226     6.0a1 dmb: for outline text, wpdata maintains text measurements, which we need
00227     to pass on to the headline
00228 
00229     7.0b16 PBS: no longer static, needed by opdisplay.c to fix display glitch
00230     when resizing window after editing.
00231 
00232     7.0b19 PBS: Fix a major Windows display glitch. When computing the difference
00233     needed to scroll, there was no check that the vertical height of the current line
00234     had been dirtied. If dirtied, then there will always be a difference, and
00235     a scroll will occur.
00236     */
00237     
00238     hdloutlinerecord ho = outlinedata;
00239     hdlwprecord hwp = wpdata;
00240     hdlheadrecord hcursor = (**ho).heditcursor;
00241     
00242     fleditingnow = false;
00243     
00244     if ((**hwp).fltextchanged)
00245         opschedulevisi ();
00246     
00247     (**hcursor).hpixels = (**hwp).hpixels;
00248     
00249     if (!(**hwp).floneline && (**hwp).vpixels) {
00250     
00251         short vdiff;
00252         Rect r;
00253         long lnum, oldlines, linediff;
00254 
00255         if ((**hcursor).vpixels == opdirtymeasurevalue) /*7.0b19 PBS: if dirty, measure*/
00256             opeditmeasuretext (hcursor);
00257 
00258         vdiff = (**hwp).vpixels - (**hcursor).vpixels; //vertical growth
00259         
00260         if (vdiff != 0) {
00261             
00262             opgetscreenline (hcursor, &lnum);
00263             
00264             // scroll headlines below up or down
00265             if (opdisplayenabled () && (lnum >= 0) && opgetnoderect (hcursor, &r)) {
00266                 
00267                 r.top = r.bottom;
00268                 
00269                 if (vdiff < 0)
00270                     r.top += vdiff;
00271                 
00272                 r.bottom = (**ho).outlinerect.bottom;
00273                 
00274                 wphidecursor ();
00275                 
00276                 opscrollrect (r, 0, vdiff);
00277                 }
00278             
00279             // adjust expansion count
00280             oldlines = opgetnodelinecount (hcursor);
00281             
00282             (**hcursor).vpixels = (**hwp).vpixels;
00283             
00284             linediff = opgetnodelinecount (hcursor) - oldlines;
00285             
00286             (**ho).ctexpanded += linediff;
00287             
00288             if (lnum < 0)
00289                 (**ho).vertscrollinfo.cur += linediff;
00290             
00291             opresetscrollbars (); // scroll range depends on ctexpanded
00292             
00293             if (opdisplayenabled ()) {
00294                 
00295                 opseteditbufferrect ();
00296                 
00297                 opupdatenow (); //fill in behind scroll
00298                 
00299                 opvisibarcursor ();
00300                 
00301                 (**ho).flcheckvisi = false; //undo opschedulevisi above
00302                 }
00303             }
00304         }
00305     } /*oppostedit*/
00306 
00307 
00308 static pascal void opedittrackclick (hdlwprecord wp, Point pt) {
00309 #pragma unused(wp)
00310 
00311     /*
00312     5.0a3 dmb: check outlinerect, now windowinfo's contentrect (via shellcheckautoscroll)
00313     */
00314     
00315     tydirection dir;
00316     
00317     if (mousecheckautoscroll (pt, (**outlinedata).outlinerect, true, &dir)) {
00318         
00319     //  ClipRect (&(**outlinedata).outlinerect);
00320 
00321         opscroll (dir, false, 1);
00322         }
00323     } /*opedittrackclick*/
00324 
00325 
00326 //Code change by Timothy Paustian Friday, June 16, 2000 1:23:53 PM
00327 //Changed to Opaque call for Carbon
00328 //try just a plain proc ptr, this may not work
00329 
00330 #if !TARGET_RT_MAC_CFM
00331     
00332     #define opedittrackclickUPP (&opedittrackclick)
00333 
00334 #else
00335      #if TARGET_API_MAC_CARBON == 1
00336         #define opedittrackclickUPP opedittrackclick
00337      #else
00338     static RoutineDescriptor opedittrackclickDesc = BUILD_ROUTINE_DESCRIPTOR (uppTrackClickProcInfo, opedittrackclick);
00339     #define opedittrackclickUPP (&opedittrackclickDesc)
00340     #endif
00341 #endif
00342 
00343 
00344 
00345 boolean oploadeditbuffer (void) {
00346     
00347     /*
00348     10/1/91 dmb: don't hook up the dirtyroutine callback until after 
00349     we've done the wpsettext.
00350     
00351     12/25/91 dmb: added recovery from wpsettext failure
00352     
00353     2/13/92 dmb: make sure opstyle is still pushed when opsetdisplaypixels is called
00354     
00355     5.0.2b4 dmb: don't reference hbuffer after setting it to nil
00356     */
00357     
00358     register hdloutlinerecord ho = outlinedata;
00359     register hdlwprecord hbuffer;
00360     register hdlheadrecord hcursor = (**ho).hbarcursor;
00361     Rect rbounds, rclip;
00362     tywpflags flags;
00363     
00364     if (opeditsetglobals ())
00365         wpdispose ();
00366     
00367     (**ho).hbuffer = nil;
00368     
00369     if (!(**ho).fltextmode)
00370         return (true);
00371     
00372     if (!(**ho).flwindowopen)
00373         return (false);
00374     
00375     opgettextbufferrect (hcursor, &rclip, &rbounds);
00376     
00377     intersectrect (rclip, rbounds, &rclip);
00378     
00379     oppushheadstyle (hcursor);
00380     
00381     flags = wpalwaysmeasure;
00382     
00383     if (!(**ho).flfatheadlines)
00384         flags |= wponeline;
00385     
00386 //  if (!(**ho).flhorizscrolldisabled) /*7.0b26 PBS: fix display glitch when horizontal scrolling is disabled.*/
00387         flags |= wpneverscroll;
00388     
00389     hbuffer = wpnewbuffer (nil, &rclip, &rbounds, flags, true);
00390     
00391     (**ho).hbuffer = (Handle) hbuffer;
00392     
00393     (**ho).heditcursor = hcursor;
00394     
00395     if (hbuffer != nil) {
00396         
00397         opeditsetglobals ();
00398         
00399         (**hbuffer).preeditroutine = &oppreedit;
00400         
00401         (**hbuffer).posteditroutine = &oppostedit;
00402         
00403         (**hbuffer).flinhibitdisplay = (**ho).flinhibitdisplay;
00404         
00405         (**hbuffer).flwindowopen = (**ho).flwindowopen;
00406         
00407         if ((!(**ho).flactive) && (!(**ho).flalwaysshowtextselection))
00408             wpactivate (false);
00409         
00410         if (!(*(**outlinedata).setwpedittextcallback) (hcursor)) { /*out of memory?*/
00411             
00412             wpdisposerecord (hbuffer);
00413             
00414             (**ho).hbuffer = nil;
00415             
00416             hbuffer = nil;
00417             }
00418         else
00419             wpsetselection (longinfinity, longinfinity);
00420         }
00421     
00422     if (hbuffer == nil) { /*allocation error*/
00423         
00424         (**ho).fltextmode = false; /*keep things consistant*/
00425         
00426         popstyle ();
00427         
00428         return (false);
00429         }
00430     
00431     if ((**hbuffer).flneverscroll) /*callback may have changed it*/
00432         (**hbuffer).trackclickroutine = opedittrackclickUPP;
00433     
00434     (**hbuffer).flstartedtyping = false; /*for undo -- haven't started typing here yet*/
00435     
00436     (**hbuffer).dirtyroutine = &opdirtyoutline;
00437     
00438     popstyle ();
00439     
00440     return (true);
00441     } /*oploadeditbuffer*/
00442 
00443 
00444 boolean opwriteeditbuffer (void) {
00445     
00446     /*
00447     returns true if the text changed.
00448     
00449     7/9/91 dmb: don't set edit globals when hbuffer is nil, so we can be 
00450     called indiscriminantly from oppack.c (or whereever) and not smash 
00451     existing wp globals
00452     */
00453     
00454     register hdloutlinerecord ho = outlinedata;
00455     register hdlheadrecord hcursor = (**ho).heditcursor;
00456     
00457     if ((**ho).hbuffer == nil)
00458         return (false);
00459     
00460     opeditsetglobals ();
00461     
00462     return ((*(**outlinedata).getwpedittextcallback) (hcursor, false));
00463     } /*opwriteeditbuffer*/
00464 
00465 
00466 boolean opunloadeditbuffer (void) {
00467 
00468     hdloutlinerecord ho = outlinedata;
00469     hdlwprecord hbuffer = (hdlwprecord) (**ho).hbuffer;
00470     hdlheadrecord hcursor = (**ho).heditcursor;
00471     
00472     if (hbuffer == nil)
00473         return (true);
00474     
00475     opeditsetglobals ();
00476     
00477     if (!(*(**outlinedata).getwpedittextcallback) (hcursor, true))
00478         return (false);
00479     
00480     wpactivate (-1);
00481     
00482     wpdispose ();
00483     
00484     (**ho).hbuffer = nil;
00485     
00486     return (true);
00487     } /*opunloadeditbuffer*/
00488 
00489 
00490 boolean opsaveeditbuffer (void) {
00491     
00492     register hdloutlinerecord ho = outlinedata;
00493     tytextinfo textinfo;
00494     
00495     if ((**ho).hbuffer == nil) /*no buffer open*/
00496         return (false);
00497     
00498     opeditsetglobals ();
00499     
00500     textinfo.flvalid = wpgetselection (&textinfo.selStart, &textinfo.selEnd);
00501     
00502     (**ho).textinfo = textinfo;
00503     
00504     opunloadeditbuffer ();
00505     
00506     return (true);
00507     } /*opsaveeditbuffer*/
00508 
00509 
00510 boolean oprestoreeditbuffer (void) {
00511     
00512     register hdloutlinerecord ho = outlinedata;
00513     tytextinfo textinfo;
00514     
00515     if ((**ho).hbuffer != nil) /*already loaded -- don't smash selection*/
00516         return (true);
00517     
00518     if (!oploadeditbuffer ())
00519         return (false);
00520     
00521     if ((**ho).hbuffer == nil) 
00522         return (true);
00523     
00524     textinfo = (**ho).textinfo;
00525     
00526     if (textinfo.flvalid) {
00527         
00528         opeditsetglobals ();
00529         
00530         wpsetselection (textinfo.selStart, textinfo.selEnd);
00531         
00532         textinfo.flvalid = false;
00533         }
00534     
00535     return (true);
00536     } /*oprestoreeditbuffer*/
00537 
00538 
00539 boolean opeditmeasuretext (hdlheadrecord hnode) {
00540     
00541     /*
00542     6.0a1 dmb: measure the height of the node's text using the current
00543     font, size, outlinerect, etc.
00544     */
00545     
00546     register hdloutlinerecord ho = outlinedata;
00547     Rect rbounds, rclip;
00548     tywpflags flags = 0;
00549     long width, height;
00550     
00551     if ((**hnode).hpixels >= 0 && (**hnode).vpixels >= 0) //already measured
00552         return (true);
00553     
00554     if (opeditingtext (hnode)) {
00555         
00556         opeditsetglobals ();
00557         
00558         wpgetcontentsize (&width, &height);
00559         }
00560     else {
00561         
00562         rclip = (**ho).outlinerect;
00563         
00564         opgettextrect (hnode, &rclip, &rbounds);
00565         
00566         //intersectrect (rclip, rbounds, &rclip);
00567         
00568         oppushheadstyle (hnode);
00569         
00570         if (!(**ho).flfatheadlines)
00571             flags = wponeline;
00572         
00573         if ((**ho).flprinting)
00574             flags |= wpprinting;
00575         
00576         wpmeasuretext ((**hnode).headstring, &rbounds, flags);
00577         
00578         popstyle ();
00579         
00580         width = rbounds.right - rbounds.left;
00581         
00582         height = rbounds.bottom - rbounds.top;
00583         }
00584     
00585     if (height == 0)
00586         height = (**ho).defaultlineheight;
00587     
00588     (**hnode).hpixels = width;
00589     
00590     (**hnode).vpixels = height;
00591     
00592     return (true);
00593     } /*opeditmeasuretext*/
00594 
00595 
00596 boolean opeditdrawtext (hdlheadrecord hnode, const Rect *rtext) {
00597     
00598     /*
00599     6.0a1 dmb: measure the height of the node's text using the current
00600     font, size, outlinerect, etc.
00601     */
00602     
00603     register hdloutlinerecord ho = outlinedata;
00604     Rect r, rclip;
00605     tywpflags flags = 0;
00606     
00607     if (opeditingtext (hnode)) {
00608         
00609         opeditupdate ();
00610         
00611         return (true);
00612         }
00613     
00614     rclip = (**ho).outlinerect;
00615     
00616     r = *rtext;
00617     
00618     #ifdef WIN95VERSION
00619         r.top += 1;
00620     #endif
00621     
00622     intersectrect (rclip, r, &rclip);
00623     
00624     oppushheadstyle (hnode);
00625     
00626     if (!(**ho).flfatheadlines)
00627         flags = wponeline;
00628     
00629     if ((**ho).flprinting)
00630         flags |= wpprinting;
00631 
00632     wpdrawtext ((**hnode).headstring, &rclip, &r, flags);
00633     
00634     popstyle ();
00635     
00636     return (true);
00637     } /*opeditdrawtext*/
00638 
00639 
00640 void opeditgetmaxpos (long *maxpos) {
00641     
00642     opeditsetglobals ();
00643     
00644     wpgetmaxpos (maxpos);
00645     } /*opeditgetmaxpos*/
00646 
00647 
00648 void opeditgetselection (long *startsel, long *endsel) {
00649     
00650     opeditsetglobals ();
00651     
00652     wpgetselection (startsel, endsel);
00653     } /*opeditgetselection*/
00654 
00655 
00656 void opeditsetselection (long startsel, long endsel) {
00657     
00658     /*
00659     2/26/91 dmb: to support searching things that aren't in windows (yet), 
00660     we need to handle the case where the buffer hasn't been loaded
00661     */
00662     
00663     if (opeditsetglobals ())
00664         wpsetselection (startsel, endsel);
00665     
00666     else {
00667         tytextinfo textinfo;
00668         
00669         textinfo.selStart = startsel;
00670         
00671         textinfo.selEnd = endsel;
00672         
00673         textinfo.flvalid = true;
00674         
00675         (**outlinedata).textinfo = textinfo;
00676         }
00677     } /*opeditsetselection*/
00678 
00679 
00680 void opeditgetseltext (bigstring bs) {
00681     
00682     opeditsetglobals ();
00683     
00684     wpgetseltext (bs);
00685     } /*opeditgetseltext*/
00686 
00687 
00688 void opeditgetselrect (Rect * r) {
00689     
00690     opeditsetglobals ();
00691     
00692     wpgetselrect (r);
00693     } /*opeditgetselrect*/
00694 
00695 
00696 void opeditgetselpoint (Point *pt) {
00697     
00698     opeditsetglobals ();
00699     
00700     wpgetselpoint (pt);
00701     } /*opeditgetselpoint*/
00702 
00703 
00704 void opeditresetselpoint (void) {
00705     
00706     /*
00707     the next time the up or down cursor key is pressed, a new horizontal 
00708     offset should be maintained from that point.  we just clear our field.
00709     */
00710     
00711     (**outlinedata).selpoint.h = -1;
00712     } /*opeditresetselpoint*/
00713 
00714 
00715 void opeditsetselpoint (Point pt) {
00716     
00717     register hdloutlinerecord ho = outlinedata;
00718     
00719     opeditsetglobals ();
00720     
00721     if ((**ho).selpoint.h < 0) /*we already have established a horizontal position*/
00722         (**ho).selpoint = pt;
00723     
00724     wpsetselpoint ((**ho).selpoint);
00725     
00726     opschedulevisi ();
00727     } /*opeditsetselpoint*/
00728 
00729 
00730 boolean opeditcango (tydirection dir) {
00731     
00732     /*
00733     6.0a1 dmb: return true if the current arrow key should be handled in this headline
00734     
00735     6.0b2 dmb: don't use wprect; it's clipped. get the textbufferrect from scratch.
00736     */
00737     
00738     long startsel, endsel, maxpos;
00739     Rect rwhole, rsel, rclip;
00740     boolean fl;
00741     
00742     opeditsetglobals ();
00743     
00744     wpgetselection (&startsel, &endsel);
00745     
00746     wpgetselrect (&rsel);
00747     
00748     //rwhole = (**wpdata).wprect;
00749     opgettextbufferrect ((**outlinedata).heditcursor, &rclip, &rwhole);
00750     
00751     insetrect (&rwhole, texthorizinset, textvertinset);
00752     
00753     switch (dir) {
00754         
00755         case up: case flatup:
00756             fl = (rsel.top > rwhole.top);
00757             
00758             break;
00759         
00760         case down: case flatdown:
00761             fl = (rsel.bottom < rwhole.bottom);
00762             
00763             break;
00764         
00765         case left:
00766             fl = ((startsel != 0) || (endsel != 0));
00767             
00768             break;
00769         
00770         case right:
00771             wpgetmaxpos (&maxpos);
00772             
00773             fl = ((startsel != maxpos) || (endsel != maxpos));
00774             
00775             break;
00776         
00777         default:
00778             fl = false;
00779         }
00780     
00781     return (fl);
00782     } /*opeditcango*/
00783 
00784 
00785 static boolean opeditrecalcheadline (void) {
00786 
00787     /*
00788     7.0b28 PBS: The headline may need to be redrawn to apply
00789     HTML styles.
00790 
00791     Return true if the headline was redrawn, false otherwise.
00792 
00793     7.0b33 PBS: Because redrawing the headline may collapse it to
00794     fewer lines, the headlines below the current headline should
00795     also be redrawn.
00796     */
00797 
00798     if (outlinedata != NULL) {
00799 
00800         if ((**outlinedata).flhtml) {
00801 
00802             long startsel, endsel;
00803 
00804             wpgetselection (&startsel, &endsel);
00805 
00806             opunloadeditbuffer ();
00807 
00808             oploadeditbuffer ();
00809 
00810             wpsetselection (startsel, endsel);
00811 
00812             opinvalafter ((**outlinedata).heditcursor); /*7.0b33 PBS: redraw below current headline.*/
00813 
00814             return (true);
00815             } /*if*/
00816         } /*if*/
00817 
00818     return (false);
00819     } /*opeditrecalcheadline*/
00820 
00821 
00822 boolean opeditkey (void) {
00823 
00824     char chkb = keyboardstatus.chkb;
00825 
00826     opeditsetglobals ();
00827     
00828     wpkeystroke ();
00829 
00830     if (chkb == '>')
00831         opeditrecalcheadline ();
00832     
00833     (**outlinedata).blocksupersmartvisi = true;
00834     
00835     opschedulevisi ();
00836     
00837     opeditresetselpoint ();
00838     
00839     return (true);
00840     } /*opeditkey*/
00841 
00842 
00843 boolean opeditcopy (void) {
00844 
00845     opeditsetglobals ();
00846     
00847     return (wpcopy ());
00848     } /*opeditcopy*/
00849 
00850 
00851 boolean opeditcut (void) {
00852 
00853     opeditsetglobals ();
00854     
00855     return (wpcut ());
00856     } /*opeditcut*/
00857 
00858 
00859 boolean opeditpaste (void) {
00860     
00861     opeditsetglobals ();
00862     
00863     return (wppaste (false));
00864     } /*opeditpaste*/
00865 
00866 
00867 boolean opeditclear (void) {
00868     
00869     opeditsetglobals ();
00870     
00871     return (wpclear ());
00872     } /*opeditclear*/
00873 
00874 
00875 boolean opeditinsert (bigstring bs) {
00876     
00877     opeditsetglobals ();
00878     
00879     return (wpinsert (bs));
00880     } /*opeditinsert*/
00881 
00882 
00883 boolean opeditclick (Point pt, tyclickflags flags) {
00884     
00885     //opclearallmarks (); /*9/11/91*/
00886     
00887     opeditsetglobals ();
00888     
00889     wpclick (pt, flags);
00890     
00891     opeditresetselpoint ();
00892     
00893     return (true);
00894     } /*opeditclick*/
00895 
00896 
00897 void opeditselectall (void) {
00898     
00899     opeditsetglobals ();
00900     
00901     wpselectall ();
00902     } /*opeditselectall*/
00903 
00904 
00905 void opeditactivate (boolean flactivate) {
00906     
00907     if (flactivate) {
00908         
00909         oprestoreeditbuffer ();
00910         
00911         if (opeditsetglobals ())
00912             wpactivate (true);
00913         }
00914     else {
00915     //  if (!(**outlinedata).flalwaysshowtextselection) { /*DW 8/16/93*/
00916         
00917             if (opeditsetglobals ())
00918                 wpactivate (false);
00919     //      }
00920         
00921         opwriteeditbuffer (); /*update text handle*/
00922         }
00923     } /*opeditactivate*/
00924 
00925 
00926 void opeditupdate (void) {
00927     
00928     opeditsetglobals ();
00929     
00930     wpupdate ();
00931     } /*opeditupdate*/
00932 
00933 
00934 void opeditidle (void) {
00935     
00936     opeditsetglobals ();
00937     
00938     wpidle ();
00939     } /*opeditidle*/
00940 
00941 
00942 void opeditdispose (void) {
00943     
00944     /*
00945     7/20/91 dmb: as a disposal routine, this call get called at odd times, 
00946     perhaps when a wp window is active or some other outline.  we need to 
00947     preserve all wp globals that we touch
00948     */
00949     
00950     hdlwprecord savewpdata;
00951     WindowPtr savewpwindow;
00952     hdlwindowinfo savewpwindowinfo;
00953     
00954     savewpdata = wpdata;
00955     
00956     savewpwindow = wpwindow;
00957     
00958     savewpwindowinfo = wpwindowinfo;
00959     
00960     opeditsetglobals ();
00961     
00962     wpdispose ();
00963     
00964     wpdata = savewpdata;
00965     
00966     wpwindow = savewpwindow;
00967     
00968     wpwindowinfo = savewpwindowinfo;
00969     } /*opeditdispose*/
00970 
00971 
00972 boolean opeditgetundoglobals (long *globals) {
00973     
00974     register hdloutlinerecord ho = outlinedata;
00975     
00976     if (fleditingnow && (**ho).hbuffer)
00977         *globals = (long) (**ho).heditcursor;
00978     else
00979         *globals = 0L;
00980     
00981     return (true);
00982     } /*opeditgetundoglobals*/
00983 
00984 
00985 boolean opeditsetundoglobals (long globals, boolean flundo) {
00986     
00987     /*
00988     7/2/91 dmb: now takes flundo parameter.  since wpengine doesn't need its 
00989     globals set up to dispose an undo, we can just exit when flundo is 
00990     false.  if this weren't the case, we'd have to store the wpdata handle 
00991     in the undoglobals to avoid having to recreate the context when just 
00992     tossing an undo.
00993     */
00994     
00995     register hdloutlinerecord ho = outlinedata;
00996     register hdlheadrecord hnode = (hdlheadrecord) globals;
00997     
00998     if (!globals || !flundo)
00999         return (true);
01000     
01001     if ((**ho).hbarcursor == hnode) { /*cursor is already on the node*/
01002         
01003         opsettextmode (true);
01004         
01005         opvisinode (hnode, false);
01006         }
01007     
01008     else {
01009         (**ho).fltextmode = true;
01010         
01011         opclearallmarks ();
01012         
01013         opexpandto (hnode);
01014         }
01015     
01016     opeditsetglobals ();
01017     
01018     return (true);
01019     } /*opeditsetundoglobals*/
01020 
01021 
01022 

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