2
/******************************************************************************
3
* MODULE : lazy_paragraph.hpp
4
* DESCRIPTION: Make lines of a paragraph from a typesetted concatenation
5
* COPYRIGHT : (C) 1999 Joris van der Hoeven
6
*******************************************************************************
7
* This software falls under the GNU general public license and comes WITHOUT
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11
******************************************************************************/
13
#ifndef LAZY_PARAGRAPH_H
14
#define LAZY_PARAGRAPH_H
15
#include "formatter.hpp"
16
#include "Format/line_item.hpp"
17
#include "Format/format.hpp"
18
#include "Stack/stacker.hpp"
21
#define MODE_JUSTIFY 0
26
struct lazy_paragraph_rep: public lazy_rep {
27
edit_env env; // the environment
28
array<line_item> a; // the line items to format
29
hashmap<string,tree> style; // the style parameters
30
stacker_rep* sss; // the typesetted paragraph
33
array<box> items; // the boxes on the line in order
34
array<SI> items_sp; // the final spaces between boxes in lines
35
array<space> spcs; // the spacing between the boxes of items
36
array<lazy> fl; // floating insertions
37
array<tab> tabs; // tabulations
38
array<tree> decs; // decorations of the boxes on lines
39
SI cur_r; // the current right offset of the last line unit
40
space cur_w; // the current width of the line unit
41
int cur_start; // index of the start of the line unit
43
string mode; // justified, left, center or right
44
string hyphen; // hyphenation quality
45
SI width; // the width of the parbox
46
SI first; // indentation of first line (added to left)
47
SI left; // left indentation of paragraph lines
48
SI right; // right indentation of paragraph lines
49
SI height; // the minimal height of each line
50
SI sep; // min. separation between ink of successive lines
51
SI hor_sep; // min. hor. sep. when lines are shoved together
52
space line_sep; // space between consecutive lines
53
space par_sep; // space between consecutive paragraphs
54
SI bot; // next line will not ascend higher than this
55
SI top; // previous line will not descend lower than this
56
SI tab_sep; // separation between columns in tabular
57
int nr_cols; // number of columns
59
void line_print (line_item item);
60
void line_print (line_item item, path start, path end);
61
void line_print (path start, path end);
63
void handle_decoration (int& i, int& j, SI& xoff, box& b, SI& b_sp);
64
void handle_decorations (int& i, int& j, SI& xoff,
65
array<box>& bs, array<SI>& bs_sp);
66
void handle_decorations ();
69
void make_unit (string mode, SI the_width, bool break_flag);
70
void line_unit (path start, path end, bool break_flag,
71
string mode, SI the_left, SI the_right);
72
void line_end (space spc, int penalty);
73
void line_units (int start, int end, bool is_start, bool is_end,
74
string mode, string hyphen,
75
SI the_left, SI the_right, SI the_first, SI the_last);
77
void format_paragraph_unit (int start, int end);
80
lazy_paragraph_rep (edit_env env, path ip);
81
~lazy_paragraph_rep ();
83
void format_paragraph ();
84
lazy produce (lazy_type request, format fm);
85
format query (lazy_type request, format fm);
88
struct lazy_paragraph {
89
EXTEND_NULL(lazy,lazy_paragraph);
90
inline lazy_paragraph (edit_env env, path ip):
91
rep (new lazy_paragraph_rep (env, ip)) { rep->ref_count= 1; }
93
EXTEND_NULL_CODE(lazy,lazy_paragraph);
95
#endif // defined LAZY_PARAGRAPH_H