home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: vmsnet.tpu
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!unixhub!slacvx.slac.stanford.edu!fairfield
- From: fairfield@slacvx.slac.stanford.edu
- Subject: KHF$FORMAT.3-OF-3 (Eve Justify procedures)
- Message-ID: <1992Dec18.154259.1@slacvx.slac.stanford.edu>
- Lines: 172
- Sender: news@unixhub.SLAC.Stanford.EDU
- Organization: Stanford Linear Accelerator Center
- Date: Fri, 18 Dec 1992 23:42:59 GMT
-
- -+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+
- X`09`09indx2`20:=`20indx1;`09`09`20`20`20`20!`09working`20outward.`20`20Variabl
- Ve
- X`09`09indx`20`20:=`201;`09`09`20`20`20`20!`09"indx"`20is`20just`20a`20counter
- V`20here.
- X`09`09Loop
- X`09`09`20`20`20`20Exitif`20(indx`20>`20(nsmall+nbig));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx1`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20indx`20`20:=`20indx`20+`201;
- X`09`09`20`20`20`20indx2`20:=`20indx2`20-`201;
- X`09`09`20`20`20`20If`20(indx`20=`20(nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09`20`20`20`20Exitif`20(indx`20>`20(nsmall+nbig));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx2`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20indx`20:=`20indx`20+`201;
- X`09`09`20`20`20`20indx1`20:=`20indx1`20+`201;
- X`09`09`20`20`20`20If`20(indx`20=`20(nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09Endloop;
- X
- X`09`20`20`20`20`5B2`5D:`09`09`09`20`20`20`20!`20Fill`20type`202:`20`20Fill`20g
- Vaps`20starting
- X`09`09indx1`20:=`202;`09`09`20`20`20`20!`09both`20ends`20of`20the`20line`20and
- V`20work
- X`09`09indx2`20:=`20ngaps`20+`201;`09`20`20`20`20!`09toward`20the`20center.`20
- V`20Variable
- X`09`09indx`20`20:=`201;`09`09`20`20`20`20!`09"indx"`20is`20just`20a`20counter
- V`20here.
- X`09`09Loop
- X`09`09`20`20`20`20Exitif`20(indx`20>`20(nsmall+nbig));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx1`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20indx`20`20:=`20indx`20`20+`201;
- X`09`09`20`20`20`20indx1`20:=`20indx1`20+`201;
- X`09`09`20`20`20`20If`20(indx`20=`20(nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09`20`20`20`20Exitif`20(indx`20>`20(nsmall+nbig));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx2`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20indx`20`20:=`20indx`20+`201;
- X`09`09`20`20`20`20indx2`20:=`20indx2`20-`201;
- X`09`09`20`20`20`20If`20(indx`20=`20(nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09Endloop;
- X`09`09`09`09`09`20`20`20`20!`20Fill`20type`203:`20`20Fill`20gaps`20starting
- X`09`20`20`20`20`5B3`5D:`09`09`09`20`20`20`20!`09from`20the`20right,`20working
- V`20toward
- X`09`09indx`20:=`20ngaps`20+`201;`09`20`20`20`20!`09the`20beginning`20of`20the
- V`20line.
- X`09`09Loop
- X`09`09`20`20`20`20Exitif`20(indx`20<=`20(ngaps-nsmall-nbig+1));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20indx`20:=`20indx`20-`201;
- X`09`09`20`20`20`20If`20(indx`20=`20(ngaps-nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09Endloop;
- X`09`09`09`09`09`20`20`20`20!`20Fill`20type`204:`20`20Fill`20gaps`20starting
- X`09`20`20`20`20`5B4`5D:`09`09`09`20`20`20`20!`09from`20the`20left,`20working
- V`20toward
- X`09`09indx`20:=`202;`09`09`20`20`20`20!`09the`20end`20of`20the`20line.
- X`09`09Loop
- X`09`09`20`20`20`20Exitif`20(indx`20>`20(nsmall+nbig+1));
- X`09`09`20`20`20`20Position`20(khf$x_word_array`20`7Bindx`7D);
- X`09`09`20`20`20`20Copy_Text`20(the_fill);
- X`09`09`20`20`20`20If`20(indx`20=`20(nbig+1))
- X`09`09`20`20`20`20Then
- X`09`09`09the_fill`20:=`20small_fill;
- X`09`09`20`20`20`20Endif;
- X`09`09`20`20`20`20indx`20:=`20indx`20+`201;
- X`09`09Endloop;
- X`09Endcase;
- X
- X`09If`20fill_type`20<`204
- X`09Then
- X`09`20`20`20`20fill_type`20:=`20fill_type`20+`201;
- X`09Else
- X`09`20`20`20`20fill_type`20:=`201;
- X`09Endif;
- X`20`20`20`20Endif;
- X
- X`20`20`20`20Move_Vertical`20(1);
- XEndloop;
- X
- XSet`20(saved_mode,`20CURRENT_BUFFER);
- XPosition`20(saved_position);
- X
- XReturn`20(TRUE);
- X
- XEndprocedure;`09`09!`20Khf$Justify
- X
- X`0C
- X!++
- X!`20`20`20This`20procedure`20prepares`20a`20range`20for`20(paragraph)`20fillin
- Vg`20and`20possibly
- X!`20`20`20justifying.`20`20All`20leading`20and`20trailing`20spaces`20are`20tri
- Vmmed,`20and`20sentences
- X!`20`20`20have`20an`20additional`20space`20appended`20to`20their`20ends.
- X!
- X!`20`20Author/Date:`09`09K.H.`20Fairfield,`09`0917-DEC-1992
- X!--
- X
- XProcedure`20Khf$Fill_Edit
- X!`09`20`20-------------
- X`09`20`20`20(range_arg)`09`09!`20Range`20to`20edit.
- X
- XLocal`09saved_mode,`09!`20Save`20current`20mode`20of`20the`20buffer
- X`09end_mark,`09!`20End`20of`20range_arg
- X`09found_range,`09!`20An`20end`20of`20sentence
- X`09term_patt;`09!`20Pattern`20of`20sentence`20terminators
- X
- Xsaved_mode`20:=`20Get_Info`20(CURRENT_BUFFER,`20"mode");
- XSet`20(INSERT,`20CURRENT_BUFFER);
- X
- X!+
- X!`20`20Following`20pattern`20assignment`20will`20match`20an`20end-of-sentence
- V`20within`20a
- X!`20`20line`20or`20at`20the`20end`20of`20a`20line.
- X!-
- Xterm_patt`20:=`20("."`20`7C`20"!"`20`7C`20"?")`20+`20("`20"`20`7C`20LINE_END);
- V
- X
- X!+
- X!`20`20Squeeze`20out`20excess`20spaces.
- X!-
- XEdit`20(range_arg,`20COMPRESS,`20TRIM,`20OFF);
- X
- X!+
- X!`20`20Find`20sentence`20terminators`20and`20add`20a`20space.
- X!-
- Xend_mark`20:=`20End_Of`20(range_arg);
- XPosition`20(range_arg);
- XLoop
- X`20`20`20`20found_range`20:=`20Search_Quietly`20(term_patt,`20FORWARD);
- X`20`20`20`20Exitif`20(found_range`20=`200);
- X`20`20`20`20Position`20(End_Of`20(found_range));
- X`20`20`20`20Exitif`20(Mark`20(NONE)`20>`20end_mark);
- X`20`20`20`20Copy_Text`20("`20");
- XEndloop;
- X
- X!+
- X!`20`20If`20there's`20a`20trailing`20final`20space`20at`20the`20end`20of`20ran
- Vge_arg`20(the`20usual`20case),
- X!`20`20erase`20it.
- X!-
- XPosition`20(end_mark);
- XMove_Horizontal`20(-1);
- XIf`20CURRENT_CHARACTER`20=`20"`20"
- XThen
- X`20`20`20`20Erase_Character`20(1);
- XEndif;
- X
- XSet`20(saved_mode,`20CURRENT_BUFFER);
- X
- XReturn`20(TRUE);
- X
- XEndprocedure;`09`09!`20Khf$Fill_Edit
- $ call unpack KHF$FORMAT.TPU;8 946030369 ""
- $ v=f$verify(v)
- $ exit
-