IntroducingObjectsintoDocumentsstoredon:{phylum}library>Imageobj.TEditlastchanged:July16,1984by:R.BurtonJ.SybalskyThefollowingproposalaroseoutofdiscussionsbetweenJohnSybalsky,RonKaplanandRichardBurtonaboutputtingobjectsintoTeditandintegratingshiftselectionamongvarioustypesofwindows.Thegoalsare:1)defineanobjectinterfaceforTeditthatallowsobjectstoexistinadocumentandbeedittedwiththeirowneditor.(Currentlyforformatting,Teditwillviewanobjectasalargecharacterandnottryto"flow"textaroundit.Maybelater.)2)provideafacilityinwhichobjectscouldbeshiftselected(hereafterreferredtoas"copyselected"asinStar)betweenwindowsinwhichthesourcewindow(wheretheobjectwascomingfrom)doesnothavetoknowwhatsortofwindowthedestinationwindowisandthedestinationdoesnothavetoknowwheretheinsertioncamefrom.Asasimpleexample,wewanttobeabletocopyselectfromaGrapherwindowintoaTeditwindow.Morecomplicated,wewantcopyselectfromaDeditwindowintoaTeditwindowtopreservestructure(ifdesired)whilecopyselectintoatypescriptwindowtotreatitastype-in.ImageObjectsTodothis,weprovideanewdatatype,IMAGEOBJ,whichcontainsthedataandtheproceduresnecessarytomanipulateanobjectthatistobepartofadocument.Additionally,thereisanewdatatype,IMAGEFNS,whichisavectoroftheproceduresnecessarytodefinethebehaviorofatypeofIMAGEOBJ.Havingtheoperationsgroupedinaseparatedatatypeallowsmultipleinstancesofthesametypeofimageobjecttosharetheirprocedurevectors.ThedataandprocedurefieldsofanIMAGEOBJhaveauniforminterfacethroughthefunctionIMAGEOBJPROP.IMAGEOBJsarecreatedwiththefunctionIMAGEOBJCREATE.IMAGEFNSarecreatedwiththefunctionIMAGEFNSCREATE.(IMAGEFNSCREATEDISPLAYFNIMAGEBOXFNPUTFNGETFNCOPYFNBUTTONEVENTINFNCOPYBUTTONEVENTINFNWHENMOVEDFNWHENINSERTEDFNWHENDELETEDFNWHENCOPIEDFNWHENOPERATEDONFNPREPRINTFN)ReturnsanIMAGEFNSwhichcontainsthefunctionsnecessarytodefinethebehaviorofanIMAGEOBJ.Theargumentsareasfollows:DISPLAYFN-fnof{imageObjimageStream}calledtodisplaytheobjectatthecurrentpositiononimageStream-typeofstreamindicateswhetherdeviceisDISPLAY,PRESSorINTERPRESS.IMAGEBOXFN-fnof{imageObjimageStreamcurrentXrightMargin}shouldreturnthesizeoftheobjectasalistwhose1stand2ndelementsarethewidthandheightoftheobjectimageandwhose3rdand4thelementsarethepositionoftheleftedgeandbaselineoftheimagerelativetothecurrentposition.Forcharacters,the3rdelementwouldbethedescentand4thelementwouldbe0sincewedon'tsupportleftkerning.Wewillalsowanttosupport5thand6thelementswhicharetheamountstomovethecurrentpositionintheXandYdirectionsaftertheobjectisdisplayed.TheRECORDIMAGEBOXisprovidedwithfields(XSIZEYSIZEYDESCXKERN).TheIMAGEBOXFNlooksatthetypeofthestreamtodeterminetheoutputdeviceifthesizechangesfromdevicetodevice.(Forexample,abitmapobjectmayspecifyascalefactorthatisignoredwhenitisdisplayedonthescreen.){note:thisdoesnotaddress,forexample,thelayingoutofannotationsasinlinetext,footnotesorbetweenlinetext.)ThecurrentXandRightMarginfieldsallowanobjecttotakeaccountofitsenvironmentwhendecidinghowbigitis.Ifthesearenotavailable,theywillbeNIL. q?` p q?` g_p bq NE) b `r ` _cs tW($_c ^H   ^H^Hc^H^H4^H ]- ]-]- ]-]-7]-]-=]- [r [ Z Z XS!$<'*A 4f;0?uGKHKHXS V &,38W=A5 KIKIV Udn#&(0*1sU SwcSw QK/%)h.28?yB GIKIKIQK OL#_(,23!4. =A4 KHKHO N8 #%*3y7:>;@GKHKHN MC1MC KC!L&y-U25+:YB KHKHK I6&(+1O8o?B|GKIKII Hgi%h(.48X;@"BGKHKHHg GY# $+ -1O4 ?#CGKIKIG E @"^&+,/17?XB F>HKHKHE D_ }"`$,$279?GKHKHD_ C  J&K*,l17;=BHKHKHC Aa%+ /y5:; EhKIKIA @W yK@W > > =uql=ur=ur=u ;R F!%X-6;CGKHKH; 9 ^ "% .f06;)=@OBGIKHKH9 8nu &)+/9B GIKHKH8n 7YcD !),3`7@?TB^DHKHKH7 5U (/25&=GEhKIKI5 4f $C(+0068=BKHKH4f 3qX(/]2m5~=BWDKHKH3 1g$ 09%<CGKHKH1 0^*"B+x0|8>CKHKH0^ // - - ,Vt4!i +v1O7)=KIKI,V * &l 3 @^ KIKI* ); !x)r)!~) 'zQ"c*/-6j? AGKHKH'z &"#&+.1m8+&" #t*#r#=($N /v58U?JBHKHKH# " ,M d + -J25&;DKIKI" !FZ!x *!F t ru' 19 EhKIKI  $&(,2&59.<DiGKIKI j.$)-?2e59T<DvGKIKIj C  ^#+.'16>tADKHKH  !X%8)0V58<D GKHKH b "y'.2:;>ZBGKHKHb   I~&L+//29<@DKHKH  *k/3:< FGKHKH Zg#(.5k;@GKIKIZ  ?WT"%)(.19<BHKHKH   }#&k-g19;AGKHKH R" $+/2w5=@@CKHKHR N##'T/28<> HKIKI % V'1+126=A5 KIKI J j$+.:1 ;@=GKHKH J  P1"O +/36w9  q?`92TEDITNOTE:TEditonlycallsthisfunctionduringlineformatting,thencachestheimageboxas(IMAGEOBJPROPobj'BOUNDBOX).ThisavoidstheneedtocallIMAGEBOXFNwhenincompleteX&margininfoisavailable.PUTFN-fnof{imageObjfileStream}calledtosavetheobjectonafile.PrintscharactersorwhateveronfileStreamthatwhenreadbyGETFN(seebelow)willregeneratetheTeditobject.(TedittakescareofwritingoutthenameoftheGETFN.)GETFN-fnof{fileStreamTextStream}calledwhentheobjectisencounteredonthefileduringinput.ItshouldreadthestuffthatwasputoutbythePUTFNandreturnanIMAGEOBJ.{note:wemaywanttohavealibraryofimageobjecttypesthatissearchedwhenaGETFNisencounteredthatisundefinedwhichwouldloadtheinformationnecessarytohandlethattypeofobject.)COPYFN-fnof{imageObj}shouldreturnacopyofimageObj.TheCOPYFNiscalledduringacopy-selectoperation.)BUTTONEVENTINFN-fnof{imageObjwindowStreamSelectionrelXrelYwindowTextStreamButton}.Theuserhaspressedabuttoninsidetheobject.TheBUTTONEVENTINFNshoulddecidewhetherornottodohandlethebutton,trackthecursorandrespondtothebuttonpressestobringaboutwhateveredit(orselectionbutseeCOPYBUTTONEVENTINFNbelow)protocolstheobjectwishedtosupport.IfBUTTONEVENTINFNreturnsNIL,TEditwilltreatthebuttonpressasaselectionatitslevel.Notethatwhenitisfirstcalled,abuttonwillbedown.ItisenvisionedthatTedititselfcouldbeusedrecursivelytoedittextthatwaswithinanobject.AlsotheBUTTONEVENTINFNshouldsupportthebuttondownprotocoltodescentinsideofanycompositeobjectswithit.ItisalsoenvisionedthattheBUTTONEVENTINFNwillrelinquishcontrol(i.e.RETURN)whenthecursorleavesitsobject'sregionalthoughtheremaybecaseswhereitwouldnot.Inanycase,standardusefulfunctionsforcursortrackingandedittingintheTedittraditionwillbemadeavailabletolessenthetaskofbuildingBUTTONEVENTINFNs.)TEDITNOTE:Whenthisfunctiongetscalled,thewindow'sclippingregionandoffsetshavebeenchangedsothatthelowerleftcorneroftheobject'simageisat(0,0),andonlytheobject'simagecanbechanged.TheSelectionisavailableforchangingtofityourneeds;themousebuttonwentdownat(relX,relY)withintheobject'simage.YoucanaffecthowTEdittreatstheselectionbyreturningoneofseveralvalues:ReturnNILandTEditwillforgetthatyouselectedanobject;returntheatomDON'TandTEditwon'tpermittheselection;returntheatomCHANGED,andTEditwillupdatethescreen.UsethislattertosignalTEditthattheobjecthaschangedsizeorshouldhavesideeffectsonotherpartsofthescreenimage.COPYBUTTONEVENTINFN-fnof{imageObjwindowStream}.Theuserhasbuttonedinsideanobjectandacopykeyishelddown.(Ininitialimplementations,thecopykeyswillbetheshiftkeys.Thisisprobablysomethingthatshouldbesettable(intheterminaltable?).)ManyofthecommentsaboutBUTTONEVENTINFNapplyherealso.Alsoseethediscussionbelowaboutcopy-selectingobjectsbelow.WHENINSERTEDFN-WHENMOVEDFN-WHENDELETEDFN-WHENCOPIEDFN-fnsof{imageObjTargetWindowStreamSourceTextStreamTargetTextStream}.ProvidehooksbywhichtheobjectcangetnotifiedwhenTeditperformsanoperationonthewholeobject.Thedifferentoperationsare:INSERT,MOVE,DELETE,COPY.{Alsoneedahookfordeleteundonewhichmaybethesameasinsert.}WHENCOPIEDFNwillgetcalledinadditionto(andafter)theCOPYFNabove.Thesefunctionsallowobjectstohavesideeffects.Forexample,annotationsinadocumentationmaintainsawindow9 g,r h hb5u"'-2;PBFRFRb5` %*B26@ BFSFS`_ R C&*/328$ BFRFR_^- '!d%( 0^- \t\r\d *038;ADbF>KHLL\ Z2 $' 15:;>AGKHKHZ YQl !i&-.49>LAGKIKIYQ W PdKW UtUrU' & 2#9>lBHKHKHU Tu  L$9*&+ -37;/@EDGKHKHTu S >$}'0i69=BbEgIKHKHS Q$ (+<27b9B>~A5 KIKIQ PmJ{#(++ 5>jAGKIKIPm O'jO LtLrLEj !'-/N36!>?yBHKHKHL Kd !x *K Iet4IerIe6 q) 4<A EgKHKHIe H _!$ '.}0Y6hD GKHKH? > <]#)--48@yBGKHKH> =Mvj$5'-19<BHKHKH=M ;q%%)+/@28: BGKHKH; :v % +07<?tEgKHKH: 9E l"'+Z-3 8F:@ DZEMGKIKI9E 7{&*09<DGKIKI7 6_ }%H.F1c7;@CKHKH6 5=5=3u{!%.A32:>FRFR31 6'+v/69e=AIFSFS10a (.41.4(:~>OBFRFR0a/ "d*3+J.7:QBFSFS/ -7{#*&.A4 :?CFRFR-,Y  "z*014q7=AIFSFS,Y+Q #f+/R18?@rFSFS+)M 5&l*.69e@rFSFS)(Qq$)/3 <BFSFS(Q&0A#^'-178<+@qFRFR&%!'$*.459l<BFRFR%$IZ!d&n(,O207@$I "t"r"9#&j/ =>BGKHKH" %"Q&O(-t1r49n?@DKHKH mB %T),0i5;)IB KIKI e 'Y,ie 9t ]9r949  t  r  t r]: t r#mT M#n,q=KIKI ] !').2b8f;?dGKIKI] 4"R% (-459oB KHKH DB!&?'3,[02w6:A@@F>KHKH U 2#{$ /4q8#>ZA4HKHKH U k/T$y%*38?BGKHKH ( )\,H.] :CSEhKIKI  . q?`3whichhassummaryofallannotationsinthedocument.ThesefunctionsallowsthatsummarytobeupdatedastheannotationisoperatedonbyTedit.WHENOPERATEDONFN-fnof{imageObjwindowStreamhowOperatedOnSelectionTextStream}.Providesahookformiscellaneouseditoperations.FornowthevaluesofhowOperatedOnareSELECTEDandDESELECTED,HIGHLIGHTEDandUNHILIGHTED.ThisisdifferentfromtheBUTTONEVENTINFNbecauseitwillbecalledwhentheuserisextendingaselectionthroughtheobjecti.e.theobjectisbeingtreatedintotoasacharacterfromTedit.HIGHLIGHTEDandUNHIGHLIGHTEDrefertotheselectionbeinghighlightedonthescreen,andtohavingthehighlightingturnedoff.Thesearecalledwhentheselectionisinsidetheobject,soitmayhandleit.TEDITNOTE:AswiththeBUTTONEVENTINFN,theoffsetandclippingregionforthedisplayaresetsotheobject'simageisat(0,0),andonlythatimageareacanbemodified.PREPRINTFN-fnof{imageObj}calledtoconverttheobjectintosomethingthatcanbeprintedforinclusionindocuments.Itshouldreturnanobjectthatthereceivingwindowcanprint(usingeitherPRIN1orPRIN2-itschoice)toobtainacharacterrepresentationoftheobject.IfPREPRINTFNisNIL,theOBJECTDATUMitselfisused.Teditwouldusethisfunctionwhentheuserindicatesthathewantsthecharactersfromanobjectratherthantheobjectitself(presumablyusingPRIN1case).(Interfacetothis"unstructure"operationisnotyetdetermined.)(IMAGEFNSPX)-ReturnsXifXisanIMAGEFNS,NILotherwise.(IMAGEOBJCREATEOBJECTDATUMIMAGEFNS)ReturnsanIMAGEOBJwhichcontainstheobjectdatumOBJECTDATUMandtheoperationsvectorIMAGEFNS.OBJECTDATUMcanbearbitrarydata.(IMAGEOBJPX)-ReturnsXifXisanIMAGEOBJ,NILotherwise.(IMAGEOBJPROPIMAGEOBJECTPROPERTY{NEWVALUE})AccessesandsetspropertiesofanIMAGEOBJ.Itcanbeusedonthesystemproperties:OBJECTDATUM,DISPLAYFN,IMAGEBOXFN,PUTFN,GETFN,COPYFN,BUTTONEVENTINFN,COPYBUTTONEVENTINFN,WHENOPERATEDONFN,andPREPRINTFN.Additionally,itcanbeusedtosavearbitrarypropertiesonanIMAGEOBJ.CopyselectingbetweenwindowsThegeneralideabehindcopyingbetweenwindowsisthatthesourcewindowbuildsanimageobjectofwhattheusershasselectedandcallsasystemfunction.Thesystemfunctionfindsthecurrentttywindowandcallsafunctionassociatedwithitthatknowshowtoinsertimageobjects.ThesimplecasedonenowwithBKSYSBUFtocopystringsisdonebyhavingthesystemfunctioncallBKSYSBUFonthePREPRINTFNoftheimageobjectifthetargetwindowdoesn'thaveaninsertfunction.Thefollowingthingswillbeaddedtothesystemtoimplementcopyselectingofthingsbetweenwindows.AnewwindowpropertyCOPYBUTTONEVENTFNwillbecalled(ifitexists)whenabuttoneventoccursandacopykeyisdown.IfnoCOPYBUTTONEVENTFNexists,theBUTTONEVENTFNiscalled.AnewwindowpropertyCOPYINSERTFNwillbecalledbyCOPYINSERT(seebelow)whenanotherwindowwantstoinsertsomethingintothiswindowasaresultofacopyselect.Argumentsarethethingtobeinsertedandthiswindowandthethingtobeinserted.Thethingtobeinsertedcanbe(1)aSTRINGP,(2)anIMAGEOBJ,or(3)alistofIMAGEOBJsandSTRINGPs.Asaconvention,COPYINSERTFNsshouldcallBKSYSBUFiftheobjecttheyaretoinsertisaSTRINGP.ForTeditwindows,theCOPYINSERTFNwillbeafunctionKI g,rIhJjh b5c! ,#/-3 ;=TBKHKHb5 `E&),c 58%?B9DI` ^t ^r^Wzu"o+K 6 BKHKH^ ]Y )J# $(> 4J8 C%DFGKHKH]Y \  #A'//\\2 /\b 5;F\\=f GKHKH\ Z ]%)-q;ADHKIKIZ YQ/o(* 29=QCvGKHKHYQ W!5%(()2w6<= GKHKHW V x )\.w 8;2>EhHKIKIV UIw $()/28<@^HKIKIUI S1n"O(0*SQuX$(8 CFSFSPmOoP#(,O/209O Lt LrLu %+.,58>BKHKHL KDa6'3) 314%6<BEgKHKHK J9vV!%+ 1d7=C@AEGKHKHJ9 H$6 137T>B?PB KHKHH G a $'3,[-P2w7;?iGKHKHG F1 !&*e 389:AGKIKIF1 D9 &,29 CGKHKHD C  #'Y 1sC AUt AUrAU] !q#%()*36p >AU ?)t #*?)r?)*?) <|]"*.I4|9 D>GKHKH< ; 1!x"O ,c/2D:>; 9yt 9yr9y] !q#%()*36p >9y 8! 8! 5t ] !q) 2=5r52C5 36 $(&)K12538;.?mAEgKHKH3 2q  !! +u 6=DKHKH2q 1s,M<A5 KIL L 1 / ;"O$)1m :=/?GI/ .i .i - - + + *a *a (q&(r(&( 'T 'T %(L Q'-.47;?cEgKHKH%( #$Q!V%).2:f>CjEgKHKH# "x2&3+/{6:q@DIKHKH"x !  k"'X,0i3D9{>FGKHKH! $(!V)4,07:f>AGKHKH p-#&*3 36Y9?#E6GKIKIp n #&)0 C$"'T- 0<4D:>GKHKH Z!x(6 h YU-14[:L=@MGKHKHh  c/!$(,/~46@95<*KHKH  "O(6  > _ +03:.=F GKHKH 4t!&)/8W<A5GIKIKI4 $ !')-]-]0688;CGGKHKH d!;')*.!3D58@*CF>IKHKH ,|!@$#').y1[:=F>GIKHKH , z '+36:o@EgHKHKH |t/ %/,04 ;,?lACKHKH | X q?`%4thatcallsTEDIT.INSERTifgivenastringandcallsTEDIT.INSERT.OBJECTifgivenaTeditobject.(John,canthecurrentcopyselectbetweenTEditwindowsbechangedtousethisbyhavingacaseintheCOPYINSERTFNthathandlesPIECEs?)Anewfunction(COPYINSERTimageObject)willinsertimageObjectintothewindowthatcurrentlyhastheTTY.Itfindsthewindowthathasthetty(sayttyWindow).IfttyWindowhasaCOPYINSERTFN,thisiscalled,passingitimageObject.IfnoCOPYINSERTFNexists,ifimageObjectisanimageObject,theresultofcallingitsPREPRINTFNonitisBKSYSBUFed;otherwiseimageObjectisBKSYSBUFed.(ThedefaultBKSYSBUFwillusePRINT2withareadtabletakenfromtheprocessassociatedwiththettyWindow.AwindowwhichwishestousePRIN1oradifferentreadtablecanprovideitsownCOPYINSERTFNthatdoesthis.)ThustheCOPYBUTTONEVENTFNforawindowshouldallowtheusertoselectanobjectandthencallsCOPYINSERTonanimageobjectbuilt(viaIMAGEOBJCREATE)fromtheselectedobjectandninefunctionsthatdefineitsbehavior.Miscnotes:ThelayoutanddisplayingfunctionofTEditwillbemadeavailableforusewithinimageobjectdisplayfns.Thus,anannotationcouldcalltheTEditformattingroutinestolayitselfoutwithinabox.{Thisactuallyalsoneedstodeterminethesizeoftheboxwhichshoulddependonthemargins.}InthecaseofDeditcopyselectingalistintoaTEditwindow,thedisplayfncouldPRINTDEFthestructureandpossiblyDedititafteritwasintheTeditdocument.Inthiscasethestructurewouldneedtohavesomeideaofthewidthtobeprintedinto(whichshouldalsobeeditablesomehow).PossiblythestructurethatTeditbuildscouldhaveanextrafieldforwidthwhichitdefaultsuponcreationbutwhichcouldbechanged.ThiscaseisinterestingbecauseitrepresentsacasewherewemightwantTedittopassinformationintotheobject(ie.howwidetoprintitself).Thisdoesnotaddresstheproblemofimageobjectsthatprintastext.Forexample,annotationsmightbeprintedinlineinasmallerfontorasfootnotesatthebottomofthepageorasmarginnotesorbetweenthelinesintermixedwiththemaintext.Thisisadifficultproblemthatisindependentofthespecificationofthisproposal.ProvidedImageObjecttypesMenus.SupportedbyJohnSybalsky.Bitmaps-supportedbyGregNuyensRichardBurton.Annotations-supportedbyRichardBurton.FutureobjecttypesGraphergraphs-supportedbyRonKaplan.S-expressions-volunteers?KH | g,r h h b5i !&(/ 27HKHKHb5 `f| L%)Y-4<8? F?KIKI` _!V%(.05\80; GKHKH_ ^-j^- \ + #U .29 CvGKHKH\ ZJ $)*3-2U5<%@DGGKHKHZ YQ] q% (* 6}:=DKHKHYQ W m +L25 @+C5F>KHKHW VNR#'T 03\68 BKIKIV UI o[ !#'.6;]? EhIKIKIUI SY6 ' 159 BCEhKIKIS Rw"*%)'P009<DGKHKHR QA q6%n&+/?:C(EhKIKIQA Os e&)_/307= F>HKHKHO NPb-$15V=6CiGKIKIN M9Zn'_M9 K K Jv JrJ J HHa !)J+0587<DGKIKIHH Fs %',q/@ 8>BF>KHKHF E "e(,249?GKHKHE D@E!x#'Y*/5;>AbHD@ B~39$y-`/4D8;(@GKHKHB @i!"+.m6 ;%=BEgHKHKH@ ?d \rX"&*?27<>BGKHKH?d >  "',-c38#:BKHLL> <o!&,168=BF>KHKH< ;\B T&')/4c7,>@DHKHKH;\ : :$ 'J)*-25:?#D_GKIKI: 8 ;!x%)-:/4;8 6$`n#!*/- 2k9y>CcF>KHLL6 5( s %%'.16B9; B F>HKHKH5( 3v!+$(+.24.9T;BF?KIKI3 2x !')P.B13=DHKHKH2x 1  %(0,c31 / / .pv^.pr.p.p - - +'_+ *SZEE*S*S!x&*S*S-:2D*S*S3!*S (  'Y-@( ' ' &K&K $ $ #; #&&,i# "C d !x"O"O"CI q?` HELVETICA ~GACHA ~GACHA  HELVETICA~GACHA  HELVETICA ~GACHA M .& ?/j/20iAS({ERIS}LIBRARY>IMAGEOBJ.TEDIT;6SYBALSKY 7-Sep-84 22:06:06