File: tmisc.sl

package info (click to toggle)
jed 1%3A0.99.19-7
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,368 kB
  • ctags: 5,809
  • sloc: ansic: 48,117; sh: 2,977; makefile: 518
file content (45 lines) | stat: -rw-r--r-- 845 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%
%  Miscellaneous text functions
%

define text_justify_line ()
{
   variable min, max, r, count;
   count = 100;
   push_spot(); bol_skip_white();
   if (eolp) {pop_spot(); return; }
   min = what_column();
   eol_trim();
   max = what_column();
   while ((max < WRAP) and count)
     {
	r = random(0, max);
	--count;
	if (r < min) continue;
	goto_column(r); skip_white();
	if (ffind_char (' ')) { insert_single_space(); ++max; eol();}
     }
  pop_spot();
}


define format_paragraph_hook()
{
   variable n;
   push_spot();
   
   backward_paragraph();
   n = what_line();
   forward_paragraph ();
   go_up(2);
   if (n - what_line() > 0) {pop_spot(); return; }
   push_mark();
   backward_paragraph();
   if (what_line() != 1) go_down_1 ();
   narrow();
   bob();
   do text_justify_line (); while (down_1 ());
   widen();
   pop_spot();
}