]> git.lyx.org Git - lyx.git/blobdiff - src/TexRow.h
Avoid duplicating mode changing commands
[lyx.git] / src / TexRow.h
index 7468386be4edfbef55b3d2af10c6d69602085e1d..9e41b0ab06fa20b7e20df41079c982bf878d41dd 100644 (file)
  * Full author contact details are available in file CREDITS.
  */
 
+/* Note about debugging options:
+ *
+ * When compiled in devel mode and run with the option -dbg latex, two ways
+ * of debugging TexRow are available:
+ *
+ * 1. The source view panel prepends the full TexRow information to the LaTeX
+ *    output.
+ *
+ * 2. Clicking on any line in the source view moves the buffer to the location
+ *    recognised by TexRow.
+ *
+ */
+
 #ifndef TEXROW_H
 #define TEXROW_H
 
@@ -33,31 +46,32 @@ typedef void const * uid_type;
 typedef size_t idx_type;
 
 
+/// an individual par id/pos <=> row mapping
+struct TextEntry { int id; int pos; };
+
+/// an individual math id/cell <=> row mapping
+struct MathEntry { uid_type id; idx_type cell; };
+
+/// a container for passing entries around
+struct RowEntry {
+       bool is_math;// true iff the union is a math
+       union {
+               struct TextEntry text;
+               struct MathEntry math;
+       };
+};
+
+
 /// Represents the correspondence between paragraphs and the generated
 /// LaTeX file
 
 class TexRow {
 public:
-       /// an individual par id/pos <=> row mapping
-       struct TextEntry { int id; int pos; };
-
-       /// an individual math id/cell <=> row mapping
-       struct MathEntry { uid_type id; idx_type cell; };
-
-       /// a container for passing entries around
-       struct RowEntry {
-               bool is_math;// true iff the union is a math
-               union {
-                       struct TextEntry text;
-                       struct MathEntry math;
-               };
-       };
-
-       // For each row we store a list of one TextEntry and several
-       // MathEntries. (The order is important.)  We only want one text entry
+       // For each row we store a list of one special TextEntry and several
+       // RowEntries. (The order is important.)  We only want one text entry
        // because we do not want to store every position in the lyx file. On the
-       // other hand we want to record all math cells positions for enough
-       // precision. Usually the count of math cells is easier to handle.
+       // other hand we want to record all math and table cells positions for
+       // enough precision. Usually the count of cells is easier to handle.
        class RowEntryList : public std::vector<RowEntry> {
        public:
                RowEntryList() : std::vector<RowEntry>(), text_entry_(-1) {}
@@ -65,12 +79,19 @@ public:
                // returns true if the row entry will appear in the row entry list
                bool addEntry(RowEntry const &);
 
+               // the row entry will appear in the row entry list, but it never counts
+               // as a proper text entry.
+               void forceAddEntry(RowEntry const &);
+
                // returns the TextEntry or TexRow::text_none if none
                TextEntry getTextEntry() const;
 
                // returns the first entry, or TexRow::row_none if none
                RowEntry entry() const;
 
+               // appends a row
+               void append(RowEntryList const &);
+
        private:
                size_t text_entry_;
        };
@@ -79,7 +100,7 @@ public:
        static bool isNone(RowEntry const &);
        static const TextEntry text_none;
        static const RowEntry row_none;
-       
+
        /// Returns true if TextEntry is devoid of information
        static bool isNone(TextEntry const &);
 
@@ -118,9 +139,16 @@ public:
        /// returns true if this entry will appear on the current row
        bool start(int id, int pos);
 
-       /// Defines a cell and position for the current line
-       /// returns true if this entry will appear on the current row
-       bool startMath(uid_type id, idx_type cell);
+       /// Defines a cell and position for the current line.  Always appear in the
+       /// current row.
+       void startMath(uid_type id, idx_type cell);
+
+       /// Defines the paragraph for the current cell-like inset.  Always appears
+       /// in the current row like a math cell, but is detached from the normal
+       /// text flow. Note: since the cell idx is not recorded it does not work as
+       /// well as for math grids; if we were to do that properly we would need to
+       /// access the id of the parent Tabular inset from the CursorSlice.
+       void forceStart(int id, int pos);
 
        /// Insert node when line is completed
        void newline();
@@ -155,6 +183,10 @@ public:
        /// Returns the number of rows contained
        int rows() const { return rowlist_.size(); }
 
+       /// appends texrow. the final line of this is merged with the first line of
+       /// texrow.
+       void append(TexRow const & texrow);
+
        /// for debugging purpose
        void prepend(docstring_list &) const;
 
@@ -174,7 +206,7 @@ private:
        bool enabled_;
 };
 
-bool operator==(TexRow::RowEntry const &, TexRow::RowEntry const &);
+bool operator==(RowEntry const &, RowEntry const &);
 
 LyXErr & operator<<(LyXErr &, TexRow &);