Back to index

texmacs  1.0.7.15
lazy_paragraph.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : lazy_paragraph.hpp
00004 * DESCRIPTION: Make lines of a paragraph from a typesetted concatenation
00005 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #ifndef LAZY_PARAGRAPH_H
00013 #define LAZY_PARAGRAPH_H
00014 #include "formatter.hpp"
00015 #include "Format/line_item.hpp"
00016 #include "Format/format.hpp"
00017 #include "Stack/stacker.hpp"
00018 #include "tab.hpp"
00019 
00020 #define MODE_JUSTIFY   0
00021 #define MODE_LEFT      1
00022 #define MODE_CENTER    2
00023 #define MODE_RIGHT     3
00024 
00025 struct lazy_paragraph_rep: public lazy_rep {
00026   edit_env             env;        // the environment
00027   array<line_item>     a;          // the line items to format
00028   hashmap<string,tree> style;      // the style parameters
00029   stacker_rep*         sss;        // the typesetted paragraph
00030 
00031 protected:
00032   array<box>    items;       // the boxes on the line in order
00033   array<SI>     items_sp;    // the final spaces between boxes in lines
00034   array<space>  spcs;        // the spacing between the boxes of items
00035   array<lazy>   fl;          // floating insertions
00036   array<tab>    tabs;        // tabulations
00037   array<tree>   decs;        // decorations of the boxes on lines
00038   SI            cur_r;       // the current right offset of the last line unit
00039   space         cur_w;       // the current width of the line unit
00040   int           cur_start;   // index of the start of the line unit
00041 
00042   string        mode;        // justified, left, center or right
00043   double        flexibility; // threshold for switching to ragged mode
00044   string        hyphen;      // hyphenation quality
00045   SI            width;       // the width of the parbox
00046   SI            first;       // indentation of first line (added to left)
00047   SI            left;        // left indentation of paragraph lines
00048   SI            right;       // right indentation of paragraph lines
00049   SI            height;      // the minimal height of each line
00050   SI            sep;         // min. separation between ink of successive lines
00051   SI            hor_sep;     // min. hor. sep. when lines are shoved together
00052   SI            ver_sep;     // min. ver. sep. when lines are shoved together
00053   space         line_sep;    // space between consecutive lines
00054   space         par_sep;     // space between consecutive paragraphs
00055   SI            bot;         // next line will not ascend higher than this
00056   SI            top;         // previous line will not descend lower than this
00057   SI            tab_sep;     // separation between columns in tabular
00058   int           nr_cols;     // number of columns
00059 
00060   void line_print (line_item item);
00061   void line_print (line_item item, path start, path end);
00062   void line_print (path start, path end);
00063 
00064   void handle_decoration (int& i, int& j, SI& xoff, box& b, SI& b_sp);
00065   void handle_decorations (int& i, int& j, SI& xoff,
00066                         array<box>& bs, array<SI>& bs_sp);
00067   void handle_decorations ();
00068 
00069   void line_start ();
00070   void make_unit (string mode, SI the_width, bool break_flag);
00071   void line_unit (path start, path end, bool break_flag,
00072                 string mode, SI the_left, SI the_right);
00073   void line_end (space spc, int penalty);
00074   void line_units (int start, int end, bool is_start, bool is_end,
00075                  string mode, string hyphen,
00076                  SI the_left, SI the_right, SI the_first, SI the_last);
00077 
00078   void format_paragraph_unit (int start, int end);
00079 
00080 public:
00081   lazy_paragraph_rep (edit_env env, path ip);
00082   ~lazy_paragraph_rep ();
00083   operator tree ();
00084   void format_paragraph ();
00085   lazy produce (lazy_type request, format fm);
00086   format query (lazy_type request, format fm);
00087 };
00088 
00089 struct lazy_paragraph {
00090   EXTEND_NULL(lazy,lazy_paragraph);
00091   inline lazy_paragraph (edit_env env, path ip):
00092     rep (tm_new<lazy_paragraph_rep> (env, ip)) { rep->ref_count= 1; }
00093 };
00094 EXTEND_NULL_CODE(lazy,lazy_paragraph);
00095 
00096 #endif // defined LAZY_PARAGRAPH_H