]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/context.h
improve tex2lyx paragraph and comment handling
[lyx.git] / src / tex2lyx / context.h
1 // -*- C++ -*-
2 /**
3  * \file context.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONTEXT_H
13 #define CONTEXT_H
14
15 #include "lyxtextclass.h"
16
17 // A helper struct
18 struct Context {
19         Context(bool need_layout_,
20                 LyXTextClass const & textclass_,
21                 LyXLayout_ptr layout_ = LyXLayout_ptr(),
22                 LyXLayout_ptr parent_layout_= LyXLayout_ptr());
23
24         // Output a \begin_layout is requested
25         void check_layout(std::ostream & os);
26
27         // Output a \end_layout if needed
28         void check_end_layout(std::ostream & os);
29
30         // Output a \begin_deeper if needed
31         void check_deeper(std::ostream & os);
32
33         // Output a \end_deeper if needed
34         void check_end_deeper(std::ostream & os);
35
36         // dump content on stream (for debugging purpose), with
37         // description \c desc.
38         void dump(std::ostream &, std::string const & desc = "context") const;
39
40         /// Are we just beginning a new paragraph?
41         bool atParagraphStart() const { return need_layout; }
42
43         /// Begin an item in a list environment
44         void set_item();
45
46         /// Start a new paragraph
47         void new_paragraph(std::ostream & os);
48
49         /// Add extra stuff if not already there
50         void add_extra_stuff(std::string const &);
51
52         // Do we need to output some \begin_layout command before the
53         // next characters?
54         bool need_layout;
55         // Do we need to output some \end_layout command
56         bool need_end_layout;
57         // We may need to add something after this \begin_layout command
58         std::string extra_stuff;
59         // If there has been an \begin_deeper, we'll need a matching
60         // \end_deeper
61         bool need_end_deeper;
62         // If we are in an itemize-like environment, we need an \item
63         // for each paragraph, otherwise this has to be a deeper
64         // paragraph.
65         bool has_item;
66         // we are handling a standard paragraph in an itemize-like
67         // environment
68         bool deeper_paragraph;
69
70         // The textclass of the document. Could actually be a global variable
71         LyXTextClass const & textclass;
72         // The layout of the current paragraph
73         LyXLayout_ptr layout;
74         // The layout of the outer paragraph (for environment layouts)
75         LyXLayout_ptr parent_layout;
76 };
77
78
79 #endif