From: fairfield@umahe1.slac.stanford.edu
Subject: KHF$FORMAT.3-OF-3, V2.2  (EVE Justify/Unjustify)
Organization: Stanford Linear Accelerator Center
Date: Mon, 25 Jan 1993 23:10:15 GMT

-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
X`09`20`20`20`20temp`20:=`20\530F;
X\1E05Exitif`20(CURRENT_CHARACTER`20=`20"");`09\2504!`20Line_end`20condition.
X\1B05indx\5E04\0805+`201;\1706khf$x_word_array`20`7Bindx`7D`20:=`20Mark`20(NON
VE);
X`09Endloop;
X
X`09ngaps`20\4C07;`09`09`09\7C07Number\EA04gaps
X`09E\B307\3006<=`200);`09\2D08Can't`20justify`20one`20word...
X`09If`20(nspaces\3604ngaps)
X`09Then
X\3E05nsmall\8204\2707\CD07nbig\0703:=`200;\1206small_fil\2E05"`20";\1806the_
V\1605\2E05\1806Else\3608_size`20\1E06\8B08/`20ngaps;`09\C106Size`20of`20\630A
V\850D\3D0F-`20(s\5607*`20\D206\B508\CD06\3008gaps\2E03nbig;`09\6B07Number
V\6D0E`20gaps\4206If`20(\7605>`200)\1306Then\0A06`09t\EB08:=`20Substr`20(eve$kt
V_spaces,`201,\9E09+1))\9907Else\442D\4307\4009ndif\0C07\B80B\431D\440C\4007
X!+
X!`20`20Choose`20the`20filling`20pattern`20based`20on\1D05variable\2605_type.
V`20`20Patterns
X\4903are`20from`20\2E04center`20outward,`20\1909outside`20towards`20\2D0A
V\2506\4A04\1404right`20\260Cbeginn\A004of\1105line,`20and\5E0Aleft\3508\4A08en
Vd`20o\320A.
X!-
X`09Case`20\CA09`20F\41041`20To`204
X
X`09`20`20`20`20`5B1`5D:`09`09`09\0B04!`20Fill`20t\29041:`20`20\0E05gaps`20star
Vting
X`09`09indx1`20:=`20(ngaps/2)`20+`201;\4004`20!`09at`20t\E909\8E0C\BF04\3E072
V`20:=`20indx1;`09\7806`09worki\F104utward.`20`20Variable
X\3406`20`20:=`20\300A"indx"`20is`20just`20a`20coun\7204here.
X`09`09Loop\0703\2E04Exitif`20(\4705>`20(nsmall+nbig));
X\2506Position`20(khf$x_word_array`20`7Bindx1`7D)\2B08Copy_Text`20(the_fill)
V\1C08\AB09\0905+`201;\190B\F8092`20-`20\1A09If\9B07=`20(nbig+1))\1B07Then
V\0B03`09t\6707\4004small_fill\4108Endif;\ED4C2`7D\ED2A\EC171`20\19071`20\1A0B
V\EC4AEndloop;
X
X`09\1804`5B2`5D:\3D03\0B04!`20Fill`20type`202:`20\0E06gaps`20starting
X`09`09\A3091;\3607`09both`20ends`20of`20the`20line`20and`20work\34072`20:=`20n
Vgaps\3809toward\3205center.`20`20Variable
X\3606`20`20\6A0D"indx"`20is`20just`20a`20counter`20here.\3403Loop\F108xitif
V`20(i\4704>`20(nsmall+nbig));
X\2506Position`20(khf$x_word_array`20`7Bindx1`7D)\2B08Copy_Text`20(the_fill)
V\1C08\AB09\0906+`201;\1A0B1`20\1A071`20\1A0BIf\9C07=`20(nbig+1))\1B07Then
V\0B03`09t\6807\4004small_fill\4108Endif;\EE4C2`7D\EE33\ED0F2`20\19072`20-`20
V\ED53Endloop\0B04\3503\1B04!`20Fill`20type`203:`20\0E06gaps`20starting
X\2805`5B3`5D:\3308`09from`20the`20right,`20working`20toward
X`09`09\AE05:=`20ngaps;`09\3707\3204beginn\2D04of\4305line.
X`09`09Loop\AF08xiti\F408<=`20(ngaps-nsmall-nbig));\2C07Position`20(khf$x_word_
Varray`20`7Bindx`7D)\2A08Copy_Text`20(the_fill\1C09\B008\0805-`201;\1807If
V\8607\850Abig))\1F07Then\0B03\D904_fill\4304small_fill\4508Endif;\0D03Endloop
V\0B04\3503\1B04!`20Fill`20type`204:`20\0E06gaps`20starting
X\2805`5B4`5D:\3308`09from`20the`20left,`20working`20toward
X`09`09\CD081;\3208\2D04end`20of\3806ine.\2903Loop\A408xiti\ED08>`20(nsmall+n
V\EE05\C908Position`20(khf$x_word_array`20`7Bindx`7D)\2A08Copy_Text`20(the_fill
V\1C09If\6707=`20(nbig))\1907Then\0B03\AE04_fill\C404small_fill\3F08Endif;
V\0D07\EB08\0805+`201;\1803Endloop\0B04fill_type`20:=`200;`09`09!`20Reset`20so
V`20it's`201`20next`20time`20through
X`09Endcase;
X`09\400D\0D0A\6905\8C0B\0C05Move_Vertical`20(1);
X\8A09
XSet`20(saved_mode,`20CURRENT_BUFFER);
XPosition\2708po\1006);
X
XReturn`20(TRUE);
X
XEndprocedure;\D504Khf$Justify
X
X`0C
X!++
X!\9303This`20p\2A08`20prepares`20a`20range`20for`20(paragraph)`20filling`20and
V`20possibly
X\4904justifying.`20`20All`20leadi\2A07trai\3705spac\5E04re`20trimmed,\2105sent
Vences\4C05have`20an`20additional\3906`20appended`20to`20their`20ends.
X!\3704Author/Date:`09`09K.H.`20Fairfield,`09`0917-DEC-1992
X!--
X
XPr\F608Khf$Fill_Edit
X!`09`20`20------\0606-
X\1103`20(range_arg)`09`09!`20Range\8704edit.
X
XLocal`09saved_mode,`09!`20Save`20current`20mode`20of`20the`20buffer
X`09end_mark,\2D03End`20of`20\6609
X`09found_range\2104An\ED04\2404sentence
X`09term_patt;\2103Pattern`20\220B`20terminators
X
Xs\9E09`20:=`20Get_Info`20(CURRENT_BUFFER,`20"mode");
XSet`20(INSERT,`20C\260D);
X
X!+
X!`20`20Following`20p\8107assignment`20will`20match`20a\C005-of-\9E09within`20a
V\4704line`20or`20at`20the\EB08a`20line.
X!-
Xt\EC08\BD04("."`20`7C`20"!"\0604?")`20+`20("`20"\0E03LINE_END\A20ASqueeze`20ou
Vt`20excess`20spaces.
X!-
XEdit`20(range_arg,`20COMPRESS,`20TRIM,`20OFF\EE0Bind`20\C109terminators`20and
V`20add`20a\5D06.
X!-
Xend_mark`20:=`20End_Of\6A0B);
XPosition\160ELoop
X`20`20`20`20found_range\4204Search_Quietly`20(term_patt,`20FORWARD);
X\3804Exitif`20(\400C=`200)\1E06\750A\9308\280B))\430EMark`20(NONE)`20>`20e
V\D007\2507Copy_Text`20("`20");
XEndloop;
X
X!+
X!`20`20If`20there's`20a`20trailing`20final`20space`20at`20the\5904`20of`20
V\8305_arg`20(the`20usual`20case),\4F04erase`20it.
X!-
X\C70A\960BMove_Horizontal`20(-1);
XIf`20CURRENT_CHARACTER`20=`20"`20"
XThen
X\F105rase_Character`20(1);
XEndif;
X
XSet`20(saved_mode,\4F09BUFFER);
X
XReturn`20(TRUE);
X
XEndprocedure;`09`09!`20Khf$Fill_Edit
$ call unpack KHF$FORMAT.TPU;12 1850775168 ""
$ v=f$verify(v)
$ exit
-- 
 Dr. Kenneth H. Fairfield    |  Internet: Fairfield@Slac.Stanford.Edu
 SLAC, P.O.Box 4349, MS 98   |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
 Stanford, CA   94309        |  BITNET    Fairfield@Slacvx
 ----------------------------------------------------------------------------
 These opinions are mine, not SLAC's, Stanford's, nor the DOE's...