]> git.lyx.org Git - features.git/commitdiff
Introduce the latexpar separator.
authorEnrico Forestieri <forenr@lyx.org>
Wed, 6 Apr 2016 03:25:27 +0000 (05:25 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 6 Apr 2016 03:25:27 +0000 (05:25 +0200)
This is the same as the parbreak separator and is represented on screen
as the old parbreak. Old parbreak separators are converted to latexpar
separators when they are used for introducing blank lines in the
latex output rather than for separating environments.
Instead, parbreak separators are now represented on screen by a
double line. In essence, latexpar and parbreak separators produce
the same output but are represented differently on screen.
The context menu does not account for latexpar separators and only
"true" separators can be turned each into the other one.

24 files changed:
development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_2_2.py
src/LyXAction.cpp
src/factory.cpp
src/insets/InsetSeparator.cpp
src/insets/InsetSeparator.h
src/tex2lyx/test/CJK.lyx.lyx
src/tex2lyx/test/CJKutf8.lyx.lyx
src/tex2lyx/test/DummyDocument.lyx.lyx
src/tex2lyx/test/Dummy~Document.lyx.lyx
src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
src/tex2lyx/test/algo2e.lyx.lyx
src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/test/test-insets-basic.lyx.lyx
src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-memoir.lyx.lyx
src/tex2lyx/test/test-modules.lyx.lyx
src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
src/tex2lyx/test/test-scr.lyx.lyx
src/tex2lyx/test/test-structure.lyx.lyx
src/tex2lyx/test/test.lyx.lyx
src/tex2lyx/test/verbatim.lyx.lyx
src/version.h

index 9384409b530a56a32166c7dc06c3148e81c89041..01319dff51b5b713358ca75130f1a2d50434132b 100644 (file)
@@ -11,6 +11,16 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2016-04-05 Enrico Forestieri <forenr@lyx.org>
+       * Format incremented to 508
+         New kind of Separator inset (latexpar). The old parbreak separator
+         used specifically to introduce a LaTeX paragraph break in the output
+         (and thus not as a proper separator) is turned into a latexpar kind.
+         The only difference with the parbreak kind is the representation
+         on screen. The new latexpar kind is represented by the same symbol
+         used previously for the parbreak one, while the latter is now
+         represented as a double line.
+
 2016-03-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
        * Format incremented to 507
          Convert caption subtype LongTableNoNumber to Unnumbered
index e7078f148c83c15b4bd5422ee8d57b5d1e998367..66108dca2cbe2fc2733575db6cc5a7cded515c3e 100644 (file)
@@ -86,7 +86,7 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
                    ("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
                    ("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
-                   ("2_2", list(range(475,508)), minor_versions("2.2" , 0))
+                   ("2_2", list(range(475,509)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
index 04c32ce7aa6d6d2b813445b5b5640a4de0c0e53c..37a26be592b04ab9e8a08a01efc7246c0bbd4ead 100644 (file)
@@ -334,6 +334,46 @@ def revert_separator(document):
         i = i + 1
 
 
+def convert_parbreak(document):
+    """
+    Convert parbreak separators not specifically used to separate
+    environments to latexpar separators.
+    """
+    parbreakinset = "\\begin_inset Separator parbreak"
+    i = 0
+    while 1:
+        i = find_token(document.body, parbreakinset, i)
+        if i == -1:
+            return
+        lay = get_containing_layout(document.body, i)
+        if lay == False:
+            document.warning("Malformed LyX document: Can't convert separator inset at line " + str(i))
+            i += 1
+            continue
+        if lay[0] == "Standard":
+            # Convert only if not alone in the paragraph
+            k1 = find_nonempty_line(document.body, lay[1] + 1, i + 1)
+            k2 = find_nonempty_line(document.body, i + 1, lay[2])
+            if (k1 < i) or (k2 > i + 1) or not check_token(document.body[i], parbreakinset):
+                document.body[i] = document.body[i].replace("parbreak", "latexpar")
+        else:
+            document.body[i] = document.body[i].replace("parbreak", "latexpar")
+        i += 1
+
+
+def revert_parbreak(document):
+    """
+    Revert latexpar separators to parbreak separators.
+    """
+    i = 0
+    while 1:
+        i = find_token(document.body, "\\begin_inset Separator latexpar", i)
+        if i == -1:
+            return
+        document.body[i] = document.body[i].replace("latexpar", "parbreak")
+        i += 1
+
+
 def revert_smash(document):
     " Set amsmath to on if smash commands are used "
 
@@ -2284,10 +2324,12 @@ convert = [
            [504, [convert_save_props]],
            [505, []],
            [506, [convert_info_tabular_feature]],
-           [507, [convert_longtable_label]]
+           [507, [convert_longtable_label]],
+           [508, [convert_parbreak]]
           ]
 
 revert =  [
+           [507, [revert_parbreak]],
            [506, [revert_longtable_label]],
            [505, [revert_info_tabular_feature]],
            [504, []],
index 1e8390575a714cc8ca19d45060d13286ed1c59eb..831c3f619c2f95620a49350c80c58b99eeda096e 100644 (file)
@@ -635,9 +635,9 @@ void LyXAction::init()
                { LFUN_NEWLINE_INSERT, "newline-insert", Noop, Edit },
 /*!
  * \var lyx::FuncCode lyx::LFUN_SEPARATOR_INSERT
- * \li Action: Inserts an environment separator or paragraph break.
+ * \li Action: Inserts an environment separator or latex paragraph break.
  * \li Syntax: separator-insert [<ARG>]
- * \li Params: <ARG>: <plain|parbreak> default: plain
+ * \li Params: <ARG>: <plain|parbreak|latexpar> default: plain
  * \li Origin: ef, 2 May 2014
  * \endvar
  */
index b7320d0143bb6e1e49db03fec77f6580cc2f3a0a..b8d94336b9f74294f14d61161e360294a9251d23 100644 (file)
@@ -107,6 +107,8 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
                                inp.kind = InsetSeparatorParams::PLAIN;
                        else if (name == "parbreak")
                                inp.kind = InsetSeparatorParams::PARBREAK;
+                       else if (name == "latexpar")
+                               inp.kind = InsetSeparatorParams::LATEXPAR;
                        else {
                                lyxerr << "Wrong argument for LyX function 'separator-insert'." << endl;
                                break;
index b981d2cc5dff0b18362c59f08a4bddc301df6eb3..a759f1f3955f893efba50eab35fed1c4f7421b63 100644 (file)
@@ -52,6 +52,9 @@ void InsetSeparatorParams::write(ostream & os) const
        case InsetSeparatorParams::PARBREAK:
                os <<  "parbreak";
                break;
+       case InsetSeparatorParams::LATEXPAR:
+               os <<  "latexpar";
+               break;
        }
 }
 
@@ -65,6 +68,8 @@ void InsetSeparatorParams::read(Lexer & lex)
                kind = InsetSeparatorParams::PLAIN;
        else if (token == "parbreak")
                kind = InsetSeparatorParams::PARBREAK;
+       else if (token == "latexpar")
+               kind = InsetSeparatorParams::LATEXPAR;
        else
                lex.printError("Unknown kind: `$$Token'");
 }
@@ -139,6 +144,7 @@ void InsetSeparator::latex(otexstream & os, OutputParams const &) const
                                os << breakln << "%\n";
                                break;
                        case InsetSeparatorParams::PARBREAK:
+                       case InsetSeparatorParams::LATEXPAR:
                                os << breakln << "\n";
                                break;
                        default:
@@ -177,7 +183,7 @@ void InsetSeparator::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.asc = fm.maxAscent();
        dim.des = fm.maxDescent();
        dim.wid = fm.width('n');
-       if (params_.kind == InsetSeparatorParams::PLAIN)
+       if (params_.kind != InsetSeparatorParams::LATEXPAR)
                dim.wid *= 8;
 }
 
@@ -194,7 +200,7 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
        int xp[7];
        int yp[7];
 
-       if (params_.kind == InsetSeparatorParams::PLAIN) {
+       if (params_.kind != InsetSeparatorParams::LATEXPAR) {
                yp[0] = int(y - 0.500 * asc * 0.75);
                yp[1] = yp[0];
 
@@ -202,6 +208,12 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
                xp[1] = int(x + wid * 8);
 
                pi.pain.lines(xp, yp, 2, ColorName());
+
+               if (params_.kind == InsetSeparatorParams::PARBREAK) {
+                       yp[0] += 0.25 * asc * 0.75;
+                       yp[1] = yp[0];
+                       pi.pain.lines(xp, yp, 2, ColorName());
+               }
        } else {
                yp[0] = int(y - 0.500 * asc * 0.5);
                yp[1] = int(y - 0.250 * asc * 0.5);
@@ -266,6 +278,9 @@ void InsetSeparator::draw(PainterInfo & pi, int x, int y) const
 
 string InsetSeparator::contextMenuName() const
 {
+       if (params_.kind == InsetSeparatorParams::LATEXPAR)
+               return string();
+
        return "context-separator";
 }
 
index 2049c222a711641169a8b1cf8c4161e8a6e3582c..66a0c5515aa3636db4908f07316f72b6fec0d0c5 100644 (file)
@@ -22,10 +22,9 @@ class InsetSeparatorParams
 public:
        /// The different kinds of separators we support
        enum Kind {
-               ///
                PLAIN,
-               ///
-               PARBREAK
+               PARBREAK,
+               LATEXPAR
        };
        ///
        InsetSeparatorParams() : kind(PLAIN) {}
index eaee0894f6ecc4bd4caeb8b11761506b21eca299..97845522f06cc727a761bf719a52ecb14858a9c4 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index d065946b7b14386836475c4eceb5163cd56023c5..d06868bd93c53b0a164fb607a973ebf6f7a5516d 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 583c8e414a742ca75e7f31b4affed9fa5a6755d4..9f96ad64c4fb7c8705cc64f3f60d23b4d539c4fa 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 5f1ac1f4df8d8ea282a31b16485d0743cf601061..ccaee94667f774cbebaa93e58f229b5a7db03575 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index eb50ffe2cf64cb4519f5774ecbe46e95a95a1933..7bc985996da33215120ccce0d4527186b2fd0241 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 7f1de8a1c9cd76414ab80b71c0f0bee6a1716d67..4b3ce67f7390255e0e75cc397a00020349324f23 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 4a572e0d7f08d9d40f0b805eeea8c39daebb8f83..63b4c70f5dcc62ecb2af68791ef33d63ae527119 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 369a4798fcb281c28b9d0b910f3b9fcf82035163..47be549cc8ff921e6c3b85bf1b888c67cc2aa39c 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index e22b2da361756d60342e1492250c46c6d2d7bb2a..fbfba6f482e3fe4f6257fcf4c000d7c04ffba6b9 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 73bc66a3df5597e21e82093c3b41d844059bc479..b383241d3bd35b75f9a0a1762c84cd5a78ff9f9e 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 3de655608337301eb02198f48ed4f475511185ac..54b413f533f67c69bffade10578584dcb91b3de1 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index eeae6ffba1a0cf2ea15e43a41a0324d65736d53d..7da0d9602424d1c5aaa5d7b878e3f3b03b9545f7 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 6e6688ef4f3170b0604f0cf54e2a73dd0f4c00de..9958abe5a6ad340a3b07115ee6dd81ce0b3a95c0 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index db2763ca2b3375db3858533c4a2fccf8d8209146..feff755cd2b70d47b6fa3883cd64fea0aef7ed2c 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index dfc628cfcf82b1e56955085383d3da14b38c7223..efe77aa7c0101daffeb76c4f0027c913e8707c9a 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index 6438247dd827a74cdefadf92107416fd225b61d4..831dc6bf9609226c60c2d7bc687c994eac71f54b 100644 (file)
@@ -1,5 +1,5 @@
 #LyX file created by tex2lyx 2.2
-\lyxformat 507
+\lyxformat 508
 \begin_document
 \begin_header
 \save_transient_properties true
index a87b5bcd448781474596ec450ead38cf5dce5c67..757f43f3c1dfffe864a9c49a5b9636a8387cec92 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 507 // lasgouttes: rename LongTableNoNumber to Unnumbered
-#define LYX_FORMAT_TEX2LYX 507
+#define LYX_FORMAT_LYX 508 // forenr: convert parbreak to latexpar
+#define LYX_FORMAT_TEX2LYX 508
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER