mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Merge branch 'master' of git.lyx.org:lyx
This commit is contained in:
commit
c29f31e982
@ -100,5 +100,11 @@ ctests : export/export/lyx2lyx/revert-languages-polyglossia-primary_lyx22
|
|||||||
|
|
||||||
|
|
||||||
Report : https://github.com/latex3/latex2e/issues/836
|
Report : https://github.com/latex3/latex2e/issues/836
|
||||||
Fix : none yet, but confirmed as a bug.
|
Fix : https://github.com/latex3/latex2e/commit/878a4715df024fc3425d2bfd5d3d138b9395c178
|
||||||
ctests : doc/EmbeddedObjects
|
ctests : doc/EmbeddedObjects
|
||||||
|
|
||||||
|
|
||||||
|
Report : https://github.com/gsilano/EuropeCV/issues/29
|
||||||
|
Fix : none yet
|
||||||
|
ctests : Modern_CV
|
||||||
|
|
||||||
|
12
src/Row.cpp
12
src/Row.cpp
@ -562,7 +562,7 @@ Row::Elements Row::shortenIfNeeded(int const w, int const next_width)
|
|||||||
Element brk = *cit_brk;
|
Element brk = *cit_brk;
|
||||||
/* If the current element is an inset that allows breaking row
|
/* If the current element is an inset that allows breaking row
|
||||||
* after itself, and if the row is already short enough after
|
* after itself, and if the row is already short enough after
|
||||||
* this inset, then cut right after this element.
|
* this element, then cut right after it.
|
||||||
*/
|
*/
|
||||||
if (wid_brk <= w && brk.row_flags & CanBreakAfter) {
|
if (wid_brk <= w && brk.row_flags & CanBreakAfter) {
|
||||||
end_ = brk.endpos;
|
end_ = brk.endpos;
|
||||||
@ -572,6 +572,16 @@ Row::Elements Row::shortenIfNeeded(int const w, int const next_width)
|
|||||||
}
|
}
|
||||||
// assume now that the current element is not there
|
// assume now that the current element is not there
|
||||||
wid_brk -= brk.dim.wid;
|
wid_brk -= brk.dim.wid;
|
||||||
|
/* If the current element is an inset that allows breaking row
|
||||||
|
* before itself, and if the row is already short enough before
|
||||||
|
* this element, then cut right before it.
|
||||||
|
*/
|
||||||
|
if (wid_brk <= w && brk.row_flags & CanBreakBefore && cit_brk != beg) {
|
||||||
|
end_ = (cit_brk -1)->endpos;
|
||||||
|
dim_.wid = wid_brk;
|
||||||
|
moveElements(elements_, cit_brk, tail);
|
||||||
|
return tail;
|
||||||
|
}
|
||||||
/* We have found a suitable separable element. This is the common case.
|
/* We have found a suitable separable element. This is the common case.
|
||||||
* Try to break it cleanly at a length that is both
|
* Try to break it cleanly at a length that is both
|
||||||
* - less than the available space on the row
|
* - less than the available space on the row
|
||||||
|
@ -16,10 +16,9 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
/* The list of possible flags, that can be combined.
|
/* The list of possible flags, that can be combined. Some flags that
|
||||||
* Some flags that should logically be here (e.g.,
|
* should logically be here (e.g., AlwaysBreakBefore), do not exist.
|
||||||
* CanBreakBefore), do not exist. This is because the need has not
|
* This is because the need has not been identitfied yet.
|
||||||
* been identitfied yet.
|
|
||||||
*
|
*
|
||||||
* Priorities when before/after disagree:
|
* Priorities when before/after disagree:
|
||||||
* AlwaysBreak* > NoBreak* > Break* or CanBreak*.
|
* AlwaysBreak* > NoBreak* > Break* or CanBreak*.
|
||||||
@ -30,26 +29,28 @@ enum RowFlags {
|
|||||||
Inline = 0,
|
Inline = 0,
|
||||||
// break row before this element if the row is not empty
|
// break row before this element if the row is not empty
|
||||||
BreakBefore = 1 << 0,
|
BreakBefore = 1 << 0,
|
||||||
|
// break row whenever needed before this element
|
||||||
|
CanBreakBefore = 1 << 1,
|
||||||
// Avoid breaking row before this element
|
// Avoid breaking row before this element
|
||||||
NoBreakBefore = 1 << 1,
|
NoBreakBefore = 1 << 2,
|
||||||
// flush the row before this element (useful with BreakBefore)
|
// flush the row before this element (useful with BreakBefore)
|
||||||
FlushBefore = 1 << 2,
|
FlushBefore = 1 << 3,
|
||||||
// force new (maybe empty) row after this element
|
// force new (maybe empty) row after this element
|
||||||
AlwaysBreakAfter = 1 << 3,
|
AlwaysBreakAfter = 1 << 4,
|
||||||
// break row after this element if there are more elements
|
// break row after this element if there are more elements
|
||||||
BreakAfter = 1 << 4,
|
BreakAfter = 1 << 5,
|
||||||
// break row whenever needed after this element
|
// break row whenever needed after this element
|
||||||
CanBreakAfter = 1 << 5,
|
CanBreakAfter = 1 << 6,
|
||||||
// Avoid breaking row after this element
|
// Avoid breaking row after this element
|
||||||
NoBreakAfter = 1 << 6,
|
NoBreakAfter = 1 << 7,
|
||||||
// The contents of the row may be broken in two (e.g. string)
|
// The contents of the row may be broken in two (e.g. string)
|
||||||
CanBreakInside = 1 << 7,
|
CanBreakInside = 1 << 8,
|
||||||
// Flush the row that ends with this element
|
// Flush the row that ends with this element
|
||||||
Flush = 1 << 8,
|
Flush = 1 << 9,
|
||||||
// specify an alignment (left, right) for a display element
|
// specify an alignment (left, right) for a display element
|
||||||
// (default is center)
|
// (default is center)
|
||||||
AlignLeft = 1 << 9,
|
AlignLeft = 1 << 10,
|
||||||
AlignRight = 1 << 10,
|
AlignRight = 1 << 11,
|
||||||
// A display element breaks row at both ends
|
// A display element breaks row at both ends
|
||||||
Display = FlushBefore | BreakBefore | BreakAfter,
|
Display = FlushBefore | BreakBefore | BreakAfter,
|
||||||
// Flags that concern breaking after element
|
// Flags that concern breaking after element
|
||||||
|
@ -43,6 +43,8 @@ public:
|
|||||||
static std::string params2string(InsetIndexParams const &);
|
static std::string params2string(InsetIndexParams const &);
|
||||||
///
|
///
|
||||||
static void string2params(std::string const &, InsetIndexParams &);
|
static void string2params(std::string const &, InsetIndexParams &);
|
||||||
|
///
|
||||||
|
int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
bool hasSettings() const override;
|
bool hasSettings() const override;
|
||||||
|
@ -29,6 +29,8 @@ public:
|
|||||||
docstring const & counterValue() const { return counter_value_; }
|
docstring const & counterValue() const { return counter_value_; }
|
||||||
///
|
///
|
||||||
docstring const & prettyCounter() const { return pretty_counter_; }
|
docstring const & prettyCounter() const { return pretty_counter_; }
|
||||||
|
///
|
||||||
|
int rowFlags() const override { return CanBreakBefore | CanBreakAfter; }
|
||||||
/// Updates only the label string, doesn't handle undo nor references.
|
/// Updates only the label string, doesn't handle undo nor references.
|
||||||
void updateLabel(docstring const & new_label, bool const active = true);
|
void updateLabel(docstring const & new_label, bool const active = true);
|
||||||
/// Updates the label and the references to it.
|
/// Updates the label and the references to it.
|
||||||
|
@ -1111,7 +1111,7 @@ private:
|
|||||||
** @todo Normalization should also expand macros, if the corresponding
|
** @todo Normalization should also expand macros, if the corresponding
|
||||||
** search option was checked.
|
** search option was checked.
|
||||||
**/
|
**/
|
||||||
string normalize(docstring const & s, bool ignore_fomat) const;
|
string convertLF2Space(docstring const & s, bool ignore_fomat) const;
|
||||||
// normalized string to search
|
// normalized string to search
|
||||||
string par_as_string;
|
string par_as_string;
|
||||||
// regular expression to use for searching
|
// regular expression to use for searching
|
||||||
@ -3669,7 +3669,7 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions & opt)
|
|||||||
previous_single_replace = true;
|
previous_single_replace = true;
|
||||||
}
|
}
|
||||||
// When using regexp, braces are hacked already by escape_for_regex()
|
// When using regexp, braces are hacked already by escape_for_regex()
|
||||||
par_as_string = normalize(ds, opt.ignoreformat);
|
par_as_string = convertLF2Space(ds, opt.ignoreformat);
|
||||||
open_braces = 0;
|
open_braces = 0;
|
||||||
close_wildcards = 0;
|
close_wildcards = 0;
|
||||||
|
|
||||||
@ -3794,7 +3794,7 @@ MatchResult MatchStringAdv::findAux(DocIterator const & cur, int len, MatchStrin
|
|||||||
|
|
||||||
docstring docstr = stringifyFromForSearch(opt, cur, len);
|
docstring docstr = stringifyFromForSearch(opt, cur, len);
|
||||||
string str;
|
string str;
|
||||||
str = normalize(docstr, opt.ignoreformat);
|
str = convertLF2Space(docstr, opt.ignoreformat);
|
||||||
if (!opt.ignoreformat) {
|
if (!opt.ignoreformat) {
|
||||||
str = correctlanguagesetting(str, false, !opt.ignoreformat);
|
str = correctlanguagesetting(str, false, !opt.ignoreformat);
|
||||||
// remove closing '}' and '\n' to allow for use of '$' in regex
|
// remove closing '}' and '\n' to allow for use of '$' in regex
|
||||||
@ -3988,8 +3988,7 @@ static bool simple_replace(string &t, string from, string to)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
string MatchStringAdv::convertLF2Space(docstring const &s, bool ignore_format) const
|
||||||
static string convertLF2Space(docstring const &s, bool ignore_format)
|
|
||||||
{
|
{
|
||||||
// Using original docstring to handle '\n'
|
// Using original docstring to handle '\n'
|
||||||
|
|
||||||
@ -4056,77 +4055,6 @@ static string convertLF2Space(docstring const &s, bool ignore_format)
|
|||||||
return(t.str());
|
return(t.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
static string convertLF2Space(docstring const & s, bool ignore_format)
|
|
||||||
{
|
|
||||||
// Using utf8-converted string to handle '\n'
|
|
||||||
|
|
||||||
string t;
|
|
||||||
t = lyx::to_utf8(s);
|
|
||||||
// Remove \n at begin
|
|
||||||
while (!t.empty() && t[0] == '\n')
|
|
||||||
t = t.substr(1);
|
|
||||||
// Remove \n* at end
|
|
||||||
while (!t.empty() && t[t.size() - 1] == '\n') {
|
|
||||||
t = t.substr(0, t.size() - 1);
|
|
||||||
}
|
|
||||||
size_t pos;
|
|
||||||
// Handle all other '\n'
|
|
||||||
while ((pos = t.find("\n")) != string::npos) {
|
|
||||||
if (pos > 1 && t[pos-1] == '\\' && t[pos-2] == '\\' ) {
|
|
||||||
// Handle '\\\n'
|
|
||||||
if (isPrintableNonspace(t[pos+1]) && ((pos < 3) || isPrintableNonspace(t[pos-3]))) {
|
|
||||||
t.replace(pos-2, 3, " ");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Already a space there
|
|
||||||
t.replace(pos-2, 3, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!isAlnumASCII(t[pos+1]) || !isAlnumASCII(t[pos-1])) {
|
|
||||||
// '\n' adjacent to non-alpha-numerics, discard
|
|
||||||
t.replace(pos, 1, "");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Replace all other \n with spaces
|
|
||||||
t.replace(pos, 1, " ");
|
|
||||||
}
|
|
||||||
if (!ignore_format) {
|
|
||||||
size_t count = 0;
|
|
||||||
while ((pos > count + 1) && (t[pos - 1 -count] == '%')) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
if (count > 0) {
|
|
||||||
t.replace(pos - count, count, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(t);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
string MatchStringAdv::normalize(docstring const & s, bool ignore_format) const
|
|
||||||
{
|
|
||||||
string t = convertLF2Space(s, ignore_format);
|
|
||||||
|
|
||||||
// The following replaces are not appropriate in non-format-search mode
|
|
||||||
if (!ignore_format) {
|
|
||||||
// Remove stale empty \emph{}, \textbf{} and similar blocks from latexify
|
|
||||||
// Kornel: Added textsl, textsf, textit, texttt and noun
|
|
||||||
// + allow to seach for colored text too
|
|
||||||
LYXERR(Debug::FINDVERBOSE, "Removing stale empty macros from: " << t);
|
|
||||||
while (regex_replace(t, t, "\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave)(\\{(\\{\\})?\\})+", ""))
|
|
||||||
LYXERR(Debug::FINDVERBOSE, " further removing stale empty \\emph{}, \\textbf{} macros from: " << t);
|
|
||||||
while (regex_replace(t, t, "\\\\((sub)?(((sub)?section)|paragraph)|part)\\*?(\\{(\\{\\})?\\})+", ""))
|
|
||||||
LYXERR(Debug::FINDVERBOSE, " further removing stale empty \\section{}, \\part{}, \\paragraph{} macros from: " << t);
|
|
||||||
while (regex_replace(t, t, "\\\\(foreignlanguage|textcolor|item)\\{[a-z]+\\}(\\{(\\{\\})?\\})+", ""));
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
docstring stringifyFromCursor(DocIterator const & cur, int len)
|
docstring stringifyFromCursor(DocIterator const & cur, int len)
|
||||||
{
|
{
|
||||||
LYXERR(Debug::FINDVERBOSE, "Stringifying with len=" << len << " from cursor at pos: " << cur);
|
LYXERR(Debug::FINDVERBOSE, "Stringifying with len=" << len << " from cursor at pos: " << cur);
|
||||||
|
Loading…
Reference in New Issue
Block a user