Commit Graph

153 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
ba738d0167 Use new rowFlags() values to remove some inset hardcoding.
The enum DisplayType is replaced with the flags RowFlags that can be
combined. Here is the correspondence between the old DisplayType and
the new Inset::RowFlags:

DisplayType   RowFLags             Meaning
 Inline        Inline               plain inline inset
  --           BreakBefore          row ends before this inset
  --           BreakAfter           the row ends after this inset
 AlignCenter   Display	            the inset is centered on its own row
 AlignLeft     Display | AlignLeft  the inset is left-aligned on its row
 AlignRight    Display | AlignRight the inset is right-aligned on its row
  --           RowAfter             an extra row is needed after this inset

Display is just a shortcut for BreakBefore | BreakAfter.

The flags for the newline inset will be BreakAfter | RowAfter,
while the separator inset will just use BreakAfter.

This groundwork does not introduce any new feature at this point. It
aims to remve the numerous isNewLine and isSeparator all over the
code, and to eventually optional break after some insets like spaces
(see #11621).

Most display() methods are renamed to rowFlags(). Some are removed
because they returned Inline.

Now display() is only a helper function for hull insets.
2020-06-22 23:11:40 +02:00
Thibaut Cuvelier
a6b07608d8 Rename XHTMLStream to XMLStream, move it to another file, and prepare for DocBook adoption.
xml.cpp/h also merges functionalities from sgml.cpp/h.
2020-06-15 13:01:56 +02:00
Juergen Spitzmueller
c0f734bcef Fix some listings/minted incompatibilities
The basic problem here is that rather than using an abstract syntax,
backend-specific param strings are produced in the listings dialog,
depending on whether listings or minted is used.

Of course this breaks if a user switches backends inbetween (s/he would
have to open and re-apply each and every listings inset!)

Do at least the most basic translations in InsetListings::latex().
A sane solution would imply the use of only one param syntax with
respective interpretation for each backend. But this would be a file
format change.
2019-04-19 19:03:29 +02:00
Juergen Spitzmueller
3e516a6219 Use proper listings font styles with polyglossia and RTL
Fixes: #11554

Also load color with minted and polyglossia/RTL, as minted loads it
too late.
2019-04-19 17:18:18 +02:00
Günter Milde
6dd505c67a Don't force encoding switch for Japanese "listings" auto-strings.
listings copes with variable-width encodings under platex.
2019-04-18 15:27:24 +02:00
Günter Milde
da23637d7f Do not switch the input encoding inside documents using platex.
Fixes wrong and missing characters in text parts in other languages
(platex does not support "inputenc").

Fixes compilation errors due to desynchronized encoding switches.
2019-04-12 18:08:17 +02:00
Günter Milde
406b1e7fcf Small formatting and comments update. 2019-03-16 12:59:34 +01:00
Juergen Spitzmueller
85b36769cb Handle \protect'ion of label in listings
Since listings labels are passed as an argument of their own, we need
to strip the \protect flag.
2019-03-16 09:05:04 +01:00
Jean-Marc Lasgouttes
ad29b0067f Revert "Use new display() values to remove some inset hardcoding."
This is a work in progress that committed by mistake.

This reverts commit b28ec44476.
2018-09-12 15:26:15 +02:00
Jean-Marc Lasgouttes
b28ec44476 Use new display() values to remove some inset hardcoding.
The enum is now made of flags that can be combined.

This introduces several new values for Inset::DisplayType:
BreakBefore, BreakAfter and Display=BreakBefore|BreakAfter. This
last value replaces AlignCenter.

Additionally the flags NoBoundary and CanBreakAfter are introduced for
future use.

Now a left aligned displayed inset will be defined as Display|LeftAlign.

A newline inset is characterized as BreakAfter.

This structure is used in breakRow to avoid explicit calls to
isNewline() or isEnvSeparator(). More improvements will be built on
top of this.

Additionally several redundant display() methods (which returned
Inline) have been removed.
2018-09-12 11:38:01 +02:00
Enrico Forestieri
16ca5290c0 Fix bug #11203
Minted does not have a language option but it is possible to enter
this option in the LyX interface for compatibility with the listings
package, and also for letting to enter a language not present in the
gui. So, this option is only used for properly specifying a language
in a listing, unless it is entered in the document settings dialog.
This case was not foreseen and thus the option was being passed to
the package as is, causing havoc. With this commit the option is
still available but is used to set a default language for a new
listing in place of the default "tex" language used so far.
2018-07-22 22:22:13 +02:00
Juergen Spitzmueller
a756299c50 revert accidental commit 2018-05-01 21:47:41 +02:00
Juergen Spitzmueller
2009469219 Group the switch of encoding for listings in utf8 documents
Else, \cprotect'ed documents fail.
2018-05-01 14:21:05 +02:00
Richard Kimberly Heck
4e8730b57e Const. 2018-04-25 22:51:57 -04:00
Juergen Spitzmueller
cbf2a329c9 Do not force singlebyte encoding for listings with XeTeX/LuaTeX.
Fixes: #11056
2018-03-05 15:39:27 +01:00
Juergen Spitzmueller
f924ef2966 Properly communicate forced encodings
This is currently only relevant fo InsetListings, which falls back to
a fixed-width encoding under specific conditions. It is now possible
to query the inset about that and report the correct encoding in
DocIterator::getEncoding.

Addresses the second part of #10995
2018-01-26 08:38:52 +01:00
Juergen Spitzmueller
1249e5e13e Mark some intentional fall-throughs (in a way understandable to gcc)
This silences -Wimplicit-fallthrough warnings with gcc7.

(Re-Apply without the unintended commits)
2017-08-12 09:06:29 +02:00
Juergen Spitzmueller
0120c3fc10 Revert "Mark some intentional fall-throughs (in a way understandable to gcc)"
This reverts commit 6dc1884d05.
2017-08-12 09:04:23 +02:00
Juergen Spitzmueller
6dc1884d05 Mark some intentional fall-throughs (in a way understandable to gcc)
This silences -Wimplicit-fallthrough warnings with gcc7.
2017-08-12 08:57:02 +02:00
Enrico Forestieri
28be7d552f Account for old versions of Pygments
Pygments versions prior to 2.0 only accept lower case names for lexers.
This commit makes sure to always use lower case names for the language
that is written in the LaTeX file, while retaining the proper casing
for the presentation in the GUI, which is dictated by compatibility
with the listings package. Moreover, if one switches from listings
to minted in a document, the language combo is properly updated even
if the used language had attached a dialect (a concept not shared by
minted), or even when importing a LaTeX document with tex2lyx.
2017-06-26 23:23:23 +02:00
Enrico Forestieri
d87513a94d Fix bug #10705
Seemingly, std::regex does not account for newlines in the string.
2017-06-26 16:14:27 +02:00
Enrico Forestieri
3dfa1cb417 Allow captions also on non-floating minted listings
Minted provides for captions only with floating listings. However,
listings always allows captions, and our machinery is geared accordingly.
So, instead of discriminating the floating and non-floating cases,
always allow for captions with minted, too. When minted does not provide
for a caption, we will provide one.
In the child document case the caption will always be before the listing,
while for the inset case the caption will be before the listing if it
is entered as the first line, after the listing otherwise.
2017-06-10 18:43:23 +02:00
Enrico Forestieri
ca2d972a36 Amend fd075614
Actually, only when using minted it is not possible to insert a
caption in a non-floating listing.
2017-06-09 12:37:05 +02:00
Enrico Forestieri
3cc3ff39a0 Simplify preamble code when using listings
Following an idea from Guillame.
2017-06-08 04:25:53 +02:00
Enrico Forestieri
fd0756141c Don't allow captions in non-floating listings
It was possible to insert a caption in a listing not marked as
floating. This didn't cause errors but the caption simply was
disappearing in the output.
2017-06-07 18:15:59 +02:00
Jean-Marc Lasgouttes
a98df58537 Fix warning about signed/unsigned 2017-06-07 11:05:29 +02:00
Enrico Forestieri
8dab1cfe7e Fix bug #9101
Update the listings inset to optionally use the minted package
(instead of the listings one) for typesetting code listings.
Only one of the two packages can be used in a document, but it
is possible to switch packages without issues if the used options
are the same. If a switch is made and the options differ, one needs
to manually adjust them if they were entered in the advanced options
tab, or apply again the gui settings.
Note that minted requires the -shell-escape option for the latex
backend and the installation of additional software (python pygments).
2017-06-07 00:55:23 +02:00
Juergen Spitzmueller
e8c932ff84 Enable InsetQuote in verbatim and Hebrew
In this context, the inset outputs straight quotes in LaTeX.

File format change.

Fixes: #7309
2016-12-10 11:53:42 +01:00
Guillaume Munch
e798db5739 Safe line break to increase precision of error reporting in Listings caption 2016-10-22 22:39:33 +02:00
Guillaume Munch
676a0639c5 Use otexstringstream for the captions of InsetCaptionables
* Enable TexRow for InsetListings caption.

* Move getCaption* from InsetText to InsetCaptionable.

* Clean-up caption generation for InsetFloat.
2016-10-17 00:16:59 +02:00
Guillaume Munch
3fd2398a28 Remove option to disable texrow
I suspect that the gain was negligible, yet it made debugging and maintainance
harder.
2016-09-23 23:39:48 +02:00
Richard Heck
ab3a49973f Fix display of code listings in XHTML.
Fixes bug #8362.
2016-07-31 01:47:30 -04:00
Juergen Spitzmueller
ad9887da9c Simplify BufferParams::bufferFormat()
The differentiation of "xetex" and "platex" is not needed here,
is ambiguous and confusing (see #10013). The code that relies on
it can/should get its information otherwise.

Furthermore, polyglossia-exclusive languages now also work with
LuaTeX, since we support LuaTeX + polyglossia.
2016-07-11 11:18:55 +02:00
Guillaume Munch
670efa8f64 Rationalise includes
Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
2016-07-04 02:42:17 +02:00
Georg Baum
dfe3a7d9fc Fix InsetListings::getCaption() for std::regex
Back references in the format string of regex_replace use the syntax $n both
in std::regex and in boost::regex for the default format. Boost seems to
support the syntax \n in addition, but it is not documented at
http://www.boost.org/doc/libs/master/libs/regex/doc/html/boost_regex/format.html.
Therefore it is a good idea to use $n also for boost.
2015-11-22 17:43:10 +01:00
Georg Baum
3b842d5a62 Add unit test for InsetListings::getCaption()
The regex in InsetListings::getCaption() does not work with C++11 and
std::regex. This can now be checked easily by this new unit test.
2015-11-22 17:36:32 +01:00
Juergen Spitzmueller
dd6340cfcc Do not switch listings to singlebyte encoding with pLateX/Japanese
Also improve Listings warning about uncodable characters
if the encoding has been switched by LyX.

Fixes: #8439
2015-11-17 10:30:03 +01:00
Guillaume Munch
9b7ccbfc80 New class InsetCaptionable
This generalises the new use of TocBuilder (97e8101) to listings and wraps and
removes some duplicate code.

Make sure that we will never write an empty float type again in the future
(#9760)
2015-09-15 15:25:33 +01:00
Guillaume Munch
94e992c5ed Better construction of the TOC for floats and captions
We introduce TocBuilder for building TOCs that take into account both float
insets and their captions.

* Floats without caption are shown with their content.

* Floats with a caption are shown with their caption, but clicking the entry now
  correctly moves to the float and not to the caption.

* Subsequent captions produce additional entries in the TOC.

* Figures and subfigures are correctly ordered in the outliner.

* New TOC "senseless" for captions appearing alone (a bit like broken references
are still displayed in the menu and outliner).

* Disable LFUN_CAPTION_INSERT if there is already a caption in a listing

Known issues:

* Inconsistent output for includes located inside floats

* We should record the end of the float in addition of the beginning for a more
  accurate cursor -> outliner entry conversion
2015-09-15 15:25:33 +01:00
Georg Baum
84cca2dd94 Fix indentation 2015-05-17 17:27:27 +02:00
Jean-Marc Lasgouttes
11ca140667 Clean-up the undo API
* Remove the UndoKind parameter in the general interface
* move recordUndoInset to Cursor
* remove one variant of Undo::recordUndo.
* get rid of Text::recUndo.
2015-04-01 14:18:23 +02:00
Jean-Marc Lasgouttes
b627b8701b Some performance stuff reported by cppcheck 2015-02-24 18:38:20 +01:00
Georg Baum
5d6351d476 Fix wrong listings preamble encoding (bug #9382)
The listings package employs some dirty tricks internally, therefore it does
not work with utf8 encoding, but requires fixed width encodings. This version
of the fix uses ugly hardcoding instead of a layout file format change, so it
could be backported if needed.
2015-01-11 19:17:51 +01:00
Juergen Spitzmueller
8e6d367f94 InsetListings: Rewrite C-ism in C++ and fix terminator bug.
The rewriting is completely done by JMarc. The terminator bug fix has been added to that by me.

Fixes: #8985
2014-04-21 11:51:57 -04:00
Vincent van Ravesteijn
99c5a46c68 Fix comparing a pointer with a char
Fixes: #8985.
2014-03-19 21:08:50 +01:00
Georg Baum
be468136df Silence unwanted error popup on copying
The new HTML clipboard export could cause error message boxes on copying
data to the clipboard (bug #8866). These are now suppressed, like all other
errors which might occur for preparing the clipboard data.
2013-11-12 20:52:35 +01:00
Richard Heck
7dac3a2715 Fix bug #8604: Forgot not to escape the caption string in listings. 2013-03-23 10:05:56 -04:00
Richard Heck
c4bed8dbe8 Don't convert --- and -- to entities in XHTML listings output.
Fixes bug #8561.
2013-02-21 18:12:53 -05:00
Richard Heck
99402cd09c Don't hardcode listings but use InsetLayout. 2013-02-08 09:48:48 -05:00
Juergen Spitzmueller
c246076ed5 Fix the 'caption inset mess' (bug #4647) 2012-12-30 18:29:02 +01:00