home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / JED / JED097-1.TAR / jed / lib / tmisc.sl < prev    next >
Encoding:
Text File  |  1994-12-12  |  894 b   |  51 lines

  1. %
  2. %  Miscellaneous text functions
  3. %
  4.  
  5. define text_justify_line ()
  6. {
  7.    variable space, min, max, r, count;
  8.    count = 100;
  9.    space = char (' ');
  10.    push_spot(); bol(); skip_white();
  11.    if (eolp) {pop_spot(); return; }
  12.    min = what_column();
  13.    eol(); trim();
  14.    max = what_column();
  15.    while ((max < WRAP) and count)
  16.      {
  17.     r = random(0, max);
  18.     --count;
  19.     if (r < min) continue;
  20.     goto_column(r); skip_white();
  21.     if (ffind(space)){ insert_single_space(); ++max; eol()}
  22.      }
  23.   pop_spot();
  24. }
  25.  
  26.  
  27. define format_paragraph_hook()
  28. {
  29.    variable n;
  30.    push_spot();
  31.    
  32.    backward_paragraph();
  33.    n = whatline();
  34.    forward_paragraph ();
  35.    go_up(2);
  36.    if (n - whatline() > 0) {pop_spot(); return; }
  37.    push_mark();
  38.    backward_paragraph();
  39.    if (whatline() != 1) go_down (1);
  40.    narrow();
  41.    bob();
  42.    forever
  43.      {
  44.     text_justify_line();
  45.     !if (down (1)) break;
  46.      }
  47.    widen();
  48.    pop_spot();
  49. }
  50.  
  51.