mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 12:26:59 +00:00
c668ebf611
The algorithm used for breaking a paragraph in LaTeX export is changed for avoiding spurious blank lines causing too much vertical space. This change is tied to the introduction of a new inset (with two different specializations) helping in either outputing LaTeX paragraph breaks or separating environments in LyX. Both of the above goals were previously achieved by the ---Separator--- layout and can now be accomplished by the new inset in a more natural way. As an example, after leaving an environment by hitting the Return key for two times, a third return automatically inserts a parbreak inset, which is equivalent to the old separator layout, i.e., it also introduces a blank line in the output. If this blank line is not wanted, the parbreak separator can be changed to a plain separator by a right click of the mouse. Of course, an environment can still be separated by the following one by using the Alt+P+Return shortcut (or the corresponding menu key), but now the plain separator inset is used instead of the old separator layout, such that no blank line occurs in the LaTeX output. Old documents are converted such that the LaTeX output remains unchanged. As a result of this conversion, the old separator layout is replaced by the new parbreak inset, which may also appear in places where the old algorithm was introducing blank lines while the new one is not. Note that not all blank lines were actually affecting the LaTeX output, because a blank line is simply ignored by the TeX engine when it occurs in the so called "vertical mode" (e.g., after an alignment environment). The old ---Separator--- layout is now gone and old layout files using it are also automatically converted. Round trip conversions between old and new format should leave a document unchanged. This means that the new behavior about paragraph breaking is not "carried back" to the old format. Indeed, this would need introducing special LaTeX commands in ERT that would accumulate in roundtrip conversions, horribly cluttering the document. So, when converting a modified document to old formats, the LaTeX output may slightly differ in vertical spacing if the document is processed by an old version of LyX. In other words, forward compatibility is guaranteed, but not backwards.
96 lines
2.0 KiB
C++
96 lines
2.0 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file InsetSeparator.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Enrico Forestieri
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef INSET_SEPARATOR_H
|
|
#define INSET_SEPARATOR_H
|
|
|
|
#include "Inset.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
class InsetSeparatorParams
|
|
{
|
|
public:
|
|
/// The different kinds of separators we support
|
|
enum Kind {
|
|
///
|
|
PLAIN,
|
|
///
|
|
PARBREAK
|
|
};
|
|
///
|
|
InsetSeparatorParams() : kind(PLAIN) {}
|
|
///
|
|
void write(std::ostream & os) const;
|
|
///
|
|
void read(Lexer & lex);
|
|
///
|
|
Kind kind;
|
|
};
|
|
|
|
|
|
class InsetSeparator : public Inset
|
|
{
|
|
public:
|
|
///
|
|
InsetSeparator();
|
|
///
|
|
explicit InsetSeparator(InsetSeparatorParams const & par);
|
|
///
|
|
static void string2params(std::string const &, InsetSeparatorParams &);
|
|
///
|
|
static std::string params2string(InsetSeparatorParams const &);
|
|
private:
|
|
///
|
|
InsetSeparatorParams params() const { return params_; }
|
|
///
|
|
InsetCode lyxCode() const { return SEPARATOR_CODE; }
|
|
///
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
|
///
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
|
///
|
|
void latex(otexstream &, OutputParams const &) const;
|
|
///
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
|
size_t max_length = INT_MAX) const;
|
|
///
|
|
int docbook(odocstream &, OutputParams const &) const;
|
|
///
|
|
docstring xhtml(XHTMLStream &, OutputParams const &) const;
|
|
///
|
|
void read(Lexer & lex);
|
|
///
|
|
void write(std::ostream & os) const;
|
|
/// is this equivalent to a space (which is BTW different from
|
|
/// a line separator)?
|
|
bool isSpace() const { return true; }
|
|
///
|
|
ColorCode ColorName() const;
|
|
///
|
|
std::string contextMenuName() const;
|
|
///
|
|
Inset * clone() const { return new InsetSeparator(*this); }
|
|
///
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
|
///
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
|
|
|
///
|
|
InsetSeparatorParams params_;
|
|
};
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
#endif // INSET_SEPARATOR_H
|