[LyX features/biginset] Text::dispatch: ignore single par update when there is a full update

2024-06-08 Thread Jean-Marc Lasgouttes
commit cd3453ec453f811e4204eaad8d4df73fde7fa9c9
Author: Jean-Marc Lasgouttes 
Date:   Fri Jun 7 16:49:25 2024 +0200

Text::dispatch: ignore single par update when there is a full update

Reorder the tests so that, when the flag Update::SinglePar has been
specified, it does not take precedence over Update::Force flag.

This fixes the crash with inset-split.

(cherry picked from commit a1856427468cd4e442c77f394715c825d919f902)
---
 src/Text.cpp | 16 +++-
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 4749f36d2c..642eb284c5 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -6374,27 +6374,17 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
}
}
 
-   // FIXME: The cursor flag is reset two lines below
-   // so we need to check here if some of the LFUN did touch that.
-   // for now only Text::erase() and Text::backspace() do that.
-   // The plan is to verify all the LFUNs and then to remove this
-   // singleParUpdate boolean altogether.
-   if (cur.result().screenUpdate() & Update::Force) {
-   singleParUpdate = false;
-   needsUpdate = true;
-   }
-
// FIXME: the following code should go in favor of fine grained
// update flag treatment.
-   if (singleParUpdate || cur.result().screenUpdate() & Update::SinglePar) 
{
+   if (needsUpdate || cur.result().screenUpdate() & Update::Force)
+   cur.screenUpdateFlags(Update::Force | Update::FitCursor);
+   else if (singleParUpdate || cur.result().screenUpdate() & 
Update::SinglePar) {
// Inserting characters does not change par height in general. 
So, try
// to update _only_ this paragraph. BufferView will detect if a 
full
// metrics update is needed anyway.
cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
return;
}
-   if (needsUpdate)
-   cur.screenUpdateFlags(Update::Force | Update::FitCursor);
else {
// oldSelection is a backup of cur.selection() at the beginning 
of the function.
if (!oldSelection && !cur.selection())
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.1-devel] Do not draw appendix lines below en of document

2024-06-09 Thread Jean-Marc Lasgouttes
commit 13a6be1f9c4668dd661bc197df226b20e420e24b
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 6 14:32:00 2024 +0200

Do not draw appendix lines below en of document

This bug is pretty old, but it was not visible because the grey area
below the document would overwrite it.

It would be better to close the frame at the end of the document, but
this is for later.

(cherry picked from commit 7acfbe0fccc729dcf5d910a4049b25e9943329fc)
(cherry picked from commit c96d3a03400893f440dca7e68ed87bd70bea0b39)
---
 src/RowPainter.cpp | 4 ++--
 status.24x | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 77e0ff67e6..19d83c13a3 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -313,8 +313,8 @@ void RowPainter::paintAppendix() const
if (par_.params().startOfAppendix())
y += 2 * defaultRowHeight();
 
-   pi_.pain.line(1, y, 1, yo_ + row_.height(), Color_appendix);
-   pi_.pain.line(tm_.width() - 2, y, tm_.width() - 2, yo_ + row_.height(), 
Color_appendix);
+   pi_.pain.line(1, y, 1, yo_ + row_.descent(), Color_appendix);
+   pi_.pain.line(tm_.width() - 2, y, tm_.width() - 2, yo_ + 
row_.descent(), Color_appendix);
 }
 
 
diff --git a/status.24x b/status.24x
index 154a255304..a62ec4aac1 100644
--- a/status.24x
+++ b/status.24x
@@ -43,6 +43,8 @@ What's new
 
 - fix display of equation numbers in right-to-left context.
 
+- fix overflow of appendix red frame in document-bottom grey area.
+
 * INTERNALS
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.1-devel] Fixup 39c7199a: the code did not do what it was supposed to

2024-06-09 Thread Jean-Marc Lasgouttes
commit 312dacb7f32ce5465e1fe3d5d7ac5e0b9b51e045
Author: Jean-Marc Lasgouttes 
Date:   Wed Jun 5 23:05:22 2024 +0200

Fixup 39c7199a: the code did not do what it was supposed to

(cherry picked from commit 92ef555abde86466b7ca3c3401ab8132258fc497)
---
 src/insets/InsetLayout.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 7593d844d5..ffa0380f17 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -200,7 +200,7 @@ public:
///
bool docbookrenderasimage() const { return docbookrenderasimage_; }
///
-   std::set required() const & { return required_; }
+   std::set const & required() const { return required_; }
///
bool isMultiPar() const { return multipar_; }
///
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Remove debug code that is not very useful as it is.

2024-06-10 Thread Jean-Marc Lasgouttes
commit 30338ec6b36f654e32a6ac5fc85e8d3716d42abf
Author: Jean-Marc Lasgouttes 
Date:   Mon Jun 10 20:32:47 2024 +0200

Remove debug code that is not very useful as it is.
---
 src/insets/InsetIndex.cpp | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp
index eb16a543ce..4a4c036a99 100644
--- a/src/insets/InsetIndex.cpp
+++ b/src/insets/InsetIndex.cpp
@@ -1463,10 +1463,6 @@ public:
 private:
bool isModern()
{
-#ifdef LYX_INSET_INDEX_DEBUG
-   std::cout << to_utf8(entry_) << std::endl;
-#endif // LYX_INSET_INDEX_DEBUG
-
// If a modern parameter is present, this is definitely a 
modern index inset. Similarly, if it contains the
// usual LaTeX symbols (!|@), then it is definitely a legacy 
index inset. Otherwise, if it has features of
// neither, it is both: consider this is a modern inset, to 
trigger the least complex code. Mixing both types
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Enable Update::SinglePar in nested insets too

2024-06-10 Thread Jean-Marc Lasgouttes
commit 13c7fd78c6c4876330598e89146ef4c7e44998bd
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 17 14:43:29 2023 +0200

Enable Update::SinglePar in nested insets too

The idea of single par update is to try to re-break only the paragraph
containing the cursor (if this paragraph contains insets etc.,
re-breaking will recursively descend).

The existing single paragraph update mechanism was tailored to work
only at top level. Indeed changing a paragraph nested into an inset may
lead to larger changes.

This commit tries a rather naive approach that seems to work well: we
need a full redraw if either

1/ the height has changed
or
2/ the width has changed and it was equal to the text metrics width;
   the goal is to catch the case of a one-row inset that grows with
   its contents, but optimize the case of typing in a short paragraph
   part of a larger inset.

NOTE: if only the height has changed, then it should be
  possible to update all metrics at minimal cost. However,
  since this is risky, we do not try that right now.

Part of bug #12297.

(cherry picked from commit 9a96726bcd06d565c3027011fea954656aa46668)
---
 src/BufferView.cpp | 42 +++---
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index e20b0a7978..4065a464b6 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3118,24 +3118,36 @@ Cursor const & BufferView::cursor() const
 
 bool BufferView::singleParUpdate()
 {
-   Text & buftext = buffer_.text();
-   pit_type const bottom_pit = d->cursor_.bottom().pit();
-   TextMetrics & tm = textMetrics(&buftext);
-   Dimension const old_dim = tm.parMetrics(bottom_pit).dim();
+   CursorSlice const & its = d->cursor_.innerTextSlice();
+   pit_type const pit = its.pit();
+   TextMetrics & tm = textMetrics(its.text());
+   Dimension const old_dim = tm.parMetrics(pit).dim();
 
// make sure inline completion pointer is ok
if (d->inlineCompletionPos_.fixIfBroken())
d->inlineCompletionPos_ = DocIterator();
 
-   // In Single Paragraph mode, rebreak only
-   // the (main text, not inset!) paragraph containing the cursor.
-   // (if this paragraph contains insets etc., rebreaking will
-   // recursively descend)
-   tm.redoParagraph(bottom_pit);
-   ParagraphMetrics & pm = tm.parMetrics(bottom_pit);
-   if (pm.height() != old_dim.height()) {
-   // Paragraph height has changed so we cannot proceed to
-   // the singlePar optimisation.
+   /* Try to rebreak only the paragraph containing the cursor (if
+* this paragraph contains insets etc., rebreaking will
+* recursively descend). We need a full redraw if either
+* 1/ the height has changed
+* or
+* 2/ the width has changed and it was equal to the textmetrics
+*width; the goal is to catch the case of a one-row inset that
+*grows with its contents, but optimize the case of typing at
+*the end of a mmultiple-row paragraph.
+*
+* NOTE: if only the height has changed, then it should be
+*   possible to update all metrics at minimal cost. However,
+*   since this is risky, we do not try that right now.
+*/
+   tm.redoParagraph(pit);
+   ParagraphMetrics & pm = tm.parMetrics(pit);
+   if (pm.height() != old_dim.height()
+   || (pm.width() != old_dim.width() && old_dim.width() == 
tm.width())) {
+   // Paragraph height or width has changed so we cannot proceed
+   // to the singlePar optimisation.
+   LYXERR(Debug::PAINTING, "SinglePar optimization failed.");
return false;
}
// Since position() points to the baseline of the first row, we
@@ -3143,11 +3155,11 @@ bool BufferView::singleParUpdate()
// the height does not change but the ascent does.
pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
 
-   tm.updatePosCache(bottom_pit);
+   tm.updatePosCache(pit);
 
LYXERR(Debug::PAINTING, "\ny1: " << pm.position() - pm.ascent()
<< " y2: " << pm.position() + pm.descent()
-   << " pit: " << bottom_pit
+   << " pit: " << pit
<< " singlepar: 1");
return true;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] In the no-draw phase, do not cache the positions of not visible insets

2024-06-10 Thread Jean-Marc Lasgouttes
commit 5e1c414a21cd5d3345e7d3ff9181d7fa08c86830
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 24 17:53:16 2023 +0200

In the no-draw phase, do not cache the positions of not visible insets

This can make a big difference for a very large branch that contains
lots of equations.

This is complementary to the previous patch, since instead of reducing
the number of calls to updatePosCache, we make it faster.

In the same test of scrolling with mouse wheel through the
branch-test.lyx document, one finds a 23% improvement for
BufferView::updateMetrics().

Part of bug #12297.

(cherry picked from commit 7f85024f80601b15634fb5e771bba51435ad429f)
---
 src/TextMetrics.cpp | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 6968279c23..06e00f4220 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -2000,6 +2000,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
if (pm.rows().empty())
return;
size_t const nrows = pm.rows().size();
+   int const wh = bv_->workHeight();
// Remember left and right margin for drawing math numbers
Changer changeleft = changeVar(pi.leftx, x + leftMargin(pit));
Changer changeright = changeVar(pi.rightx, x + width() - 
rightMargin(pit));
@@ -2014,15 +2015,17 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
if (i)
y += row.ascent();
 
-   RowPainter rp(pi, *text_, row, row_x, y);
-
-   rp.paintOnlyInsets();
+   // It is not needed to draw on screen if we are not 
inside
+   bool const inside = (y + row.descent() >= 0 && y - 
row.ascent() < wh);
+   if (inside) {
+   RowPainter rp(pi, *text_, row, row_x, y);
+   rp.paintOnlyInsets();
+   }
y += row.descent();
}
return;
}
 
-   int const ww = bv_->workHeight();
Cursor const & cur = bv_->cursor();
DocIterator sel_beg = cur.selectionBegin();
DocIterator sel_end = cur.selectionEnd();
@@ -2065,7 +2068,7 @@ void TextMetrics::drawParagraph(PainterInfo & pi, 
pit_type const pit, int const
 
// It is not needed to draw on screen if we are not inside.
bool const inside = (y + row.descent() >= 0
-   && y - row.ascent() < ww);
+   && y - row.ascent() < wh);
if (!inside) {
// Inset positions have already been set in nodraw 
stage.
y += row.descent();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Introduce new helpers ParagraphMetrics::top/bottom

2024-06-10 Thread Jean-Marc Lasgouttes
commit b1a0983570b01348685fbcb3070fc071f1b40c15
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 25 16:31:13 2023 +0200

Introduce new helpers ParagraphMetrics::top/bottom

This avoids code with position/ascent/descent that is difficult to follow.

No change in function intended.

(cherry picked from commit 0b6105b9245350e428c73deee88af2cd7c0d4732)
---
 src/BufferView.cpp   | 18 --
 src/ParagraphMetrics.h   |  6 +-
 src/TextMetrics.cpp  | 20 ++--
 src/frontends/qt/GuiWorkArea.cpp |  2 +-
 4 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 27ad1ad8f2..c433487884 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -648,8 +648,8 @@ void BufferView::updateScrollbarParameters()
<< d->par_height_[pit]);
}
 
-   int top_pos = first.second->position() - first.second->ascent();
-   int bottom_pos = last.second->position() + last.second->descent();
+   int top_pos = first.second->top();
+   int bottom_pos = last.second->bottom();
bool first_visible = first.first == 0 && top_pos >= 0;
bool last_visible = last.first + 1 == int(parsize) && bottom_pos <= 
height_;
if (first_visible && last_visible) {
@@ -2781,7 +2781,7 @@ int BufferView::scrollDown(int pixels)
int const ymax = height_ + pixels;
while (true) {
pair last = tm.last();
-   int bottom_pos = last.second->position() + 
last.second->descent();
+   int bottom_pos = last.second->bottom();
if (lyxrc.scroll_below_document)
bottom_pos += height_ - minVisiblePart();
if (last.first + 1 == int(text->paragraphs().size())) {
@@ -2806,7 +2806,7 @@ int BufferView::scrollUp(int pixels)
int ymin = - pixels;
while (true) {
pair first = tm.first();
-   int top_pos = first.second->position() - first.second->ascent();
+   int top_pos = first.second->top();
if (first.first == 0) {
if (top_pos >= 0)
return 0;
@@ -3157,10 +3157,8 @@ bool BufferView::singleParUpdate()
 
tm.updatePosCache(pit);
 
-   LYXERR(Debug::PAINTING, "\ny1: " << pm.position() - pm.ascent()
-   << " y2: " << pm.position() + pm.descent()
-   << " pit: " << pit
-   << " singlepar: 1");
+   LYXERR(Debug::PAINTING, "\ny1: " << pm.top() << " y2: " << pm.bottom()
+   << " pit: " << pit << " singlepar: 1");
return true;
 }
 
@@ -3708,7 +3706,7 @@ void BufferView::draw(frontend::Painter & pain, bool 
paint_caret)
 
// and possibly grey out below
pair lastpm = tm.last();
-   int const y2 = lastpm.second->position() + 
lastpm.second->descent();
+   int const y2 = lastpm.second->bottom();
 
if (y2 < height_) {
Color color = buffer().isInternal()
@@ -3729,7 +3727,7 @@ void BufferView::draw(frontend::Painter & pain, bool 
paint_caret)
pair lastpm = tm.last();
for (pit_type pit = firstpm.first; pit <= lastpm.first; ++pit) {
ParagraphMetrics const & pm = tm.parMetrics(pit);
-   if (pm.position() + pm.descent() > 0) {
+   if (pm.bottom() > 0) {
if (d->anchor_pit_ != pit
|| d->anchor_ypos_ != pm.position())
LYXERR(Debug::PAINTING, "Found new anchor pit = 
" << d->anchor_pit_
diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h
index 0d186f158b..805d056541 100644
--- a/src/ParagraphMetrics.h
+++ b/src/ParagraphMetrics.h
@@ -69,9 +69,13 @@ public:
///
bool hfillExpansion(Row const & row, pos_type pos) const;
 
-   ///
+   /// The vertical position of the baseline of the first line of the 
paragraph
int position() const { return position_; }
void setPosition(int position);
+   /// The vertical position of the top of the paragraph
+   int top() const { return position_ - dim_.ascent(); }
+   /// The vertical position of the bottom of the paragraph
+   int bottom() const { return position_ + dim_.descent(); }
///
int id() const { return id_; }
 
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 06e00f4220..837ad5766f 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -191,8 +191,7 @@ void TextMetrics::newParMetricsDown()
 
// do it and update its position.
  

[LyX/2.4.x] Do not compute metrics at each preview when loading file

2024-06-10 Thread Jean-Marc Lasgouttes
commit 15eef6a2c7cdca128a3476f2109371f35b372eba
Author: Jean-Marc Lasgouttes 
Date:   Thu Dec 21 16:33:06 2023 +0100

Do not compute metrics at each preview when loading file

With the branch-test.lyx file from #12297, loading takes forever when
previews are activated. This is because each preview element causes a
full screen metrics recomputation.

This commit just skips these calls and only does one when all previews
have been obtained. As a result, computing the previews takes 1 second
instead of 25 seconds on branch-test.lyx.

Part of bug #12297.

(cherry picked from commit 244969330108a89f4be93d3b2eb9024bdb756204)
---
 src/graphics/PreviewLoader.cpp | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index 4c37f7a8d0..004ced6d89 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -787,6 +787,16 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, 
int retval)
// Remove the item from the list of still-executing processes.
in_progress_.erase(git);
 
+#if 0
+   /* FIXME : there is no need for all these calls, which recompute
+* all metrics for each and every preview. The single call at the
+* end of this method is sufficient.
+
+* It seems that this whole imageReady mechanism is actually not
+* needed. If it is the case, the whole updateFrontend/updateInset
+* bloat can go too.
+*/
+
// Tell the outside world
list::const_reverse_iterator
nit  = newimages.rbegin();
@@ -795,6 +805,8 @@ void PreviewLoader::Impl::finishedGenerating(pid_t pid, int 
retval)
for (; nit != nend; ++nit) {
imageReady(*nit->get());
}
+#endif
+
finished_generating_ = true;
buffer_.scheduleRedrawWorkAreas();
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Implement quick scroll

2024-06-10 Thread Jean-Marc Lasgouttes
commit 2434a3a28848669f7d8463bef70c668e0d6e615a
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 24 23:23:40 2023 +0200

Implement quick scroll

Replace flag parameter for updateMetrics() by a `force' boolean. When
it is false, the method keeps the metrics of paragraphs that are still
visible in WorkArea instead of computing everything afresh. All it has
to do is update their positions.

Add code to updateMetrics() to update the value of the anchor pit/ypos
(similar to the one in draw()).

Update processUpdateFlags() to use this when update flag is ForceDraw.

Modify scrollDocView() to just change the anchor paragraph position
when the scrolling operation would re-use some of the existing
paragraphs.

The time needed to update the metrics when scrolling with mouse in the
branch-test.lyx document is now divided by 20!

Part of bug #12297.

(cherry picked from commit 08010c6a5e425b3f2d0d625536e3a571c90a0482)
---
 src/BufferView.cpp  | 102 ++--
 src/BufferView.h|  14 ++--
 src/TextMetrics.cpp |   6 
 src/TextMetrics.h   |   2 ++
 4 files changed, 86 insertions(+), 38 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index c433487884..a37ebcd814 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -552,10 +552,13 @@ void BufferView::processUpdateFlags(Update::flags flags)
 
// First check whether the metrics and inset positions should be updated
if (flags & Update::Force) {
-   // This will update the CoordCache items and replace Force
-   // with ForceDraw in flags.
-   updateMetrics(flags);
-   }
+   // This will compute all metrics and positions.
+   updateMetrics(true);
+   // metrics is done, full drawing is necessary now
+   flags = (flags & ~Update::Force) | Update::ForceDraw;
+   } else if (flags & Update::ForceDraw)
+   // This will compute only the needed metrics and update 
positions.
+   updateMetrics(false);
 
// Detect whether we can only repaint a single paragraph (if we
// are not already redrawing all).
@@ -564,7 +567,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
if (!(flags & Update::ForceDraw)
&& (flags & Update::SinglePar)
&& !singleParUpdate())
-   updateMetrics(flags);
+   updateMetrics(true);
 
// Then make sure that the screen contains the cursor if needed
if (flags & Update::FitCursor) {
@@ -573,13 +576,13 @@ void BufferView::processUpdateFlags(Update::flags flags)
// (which is just the cursor when there is no selection)
scrollToCursor(d->cursor_.selectionBegin(), 
SCROLL_VISIBLE);
// Metrics have to be recomputed (maybe again)
-   updateMetrics();
+   updateMetrics(true);
// Is the cursor visible? (only useful if cursor is at 
end of selection)
if (needsFitCursor()) {
// then try to make cursor visible instead
scrollToCursor(d->cursor_, SCROLL_VISIBLE);
// Metrics have to be recomputed (maybe again)
-   updateMetrics(flags);
+   updateMetrics(true);
}
}
flags = flags & ~Update::FitCursor;
@@ -761,10 +764,13 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
if (pixels == 0)
return;
 
-   // If the offset is less than 2 screen height, prefer to scroll instead.
-   if (abs(pixels) <= 2 * height_) {
+   // If part of the existing paragraphs will remain visible, prefer to
+   // scroll
+   TextMetrics const & tm = textMetrics(&buffer_.text());
+   if (tm.first().second->top() - pixels <= height_
+&&  tm.last().second->bottom() - pixels >= 0) {
d->anchor_ypos_ -= pixels;
-   processUpdateFlags(Update::Force);
+   processUpdateFlags(Update::ForceDraw);
return;
}
 
@@ -3165,12 +3171,14 @@ bool BufferView::singleParUpdate()
 
 void BufferView::updateMetrics()
 {
-   updateMetrics(d->update_flags_);
+   updateMetrics(true);
+   // metrics is done, full drawing is necessary now
+   d->update_flags_ = (d->update_flags_ & ~Update::Force) | 
Update::ForceDraw;
d->update_strategy_ = FullScreenUpdate;
 }
 
 
-void BufferView::updateMetrics(Update::flags & update_flags)
+void BufferView::updateMetrics(bool force)
 {
if (height_ == 0

[LyX/2.4.x] Remove some redundant calls to updatePosCache

2024-06-10 Thread Jean-Marc Lasgouttes
commit e51f9d9f885bdf76ba6a20671d0f730d6be87483
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 24 15:35:16 2023 +0200

Remove some redundant calls to updatePosCache

The setting of insets positions was done twice in updateMetrics.
When one of the paragraph is a huge branch, this can be very expensive.

This leads to a 17% improvement on updateMetrics time on a scrolling test.

Part of bug #12297

(cherry picked from commit d19ade9a611d3ecf6840c5eb43291cb268ad6f4f)
---
 src/BufferView.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4065a464b6..27ad1ad8f2 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3216,7 +3216,6 @@ void BufferView::updateMetrics(Update::flags & 
update_flags)
}
}
anchor_pm.setPosition(d->anchor_ypos_);
-   tm.updatePosCache(d->anchor_pit_);
 
LYXERR(Debug::PAINTING, "metrics: "
<< " anchor pit = " << d->anchor_pit_
@@ -3232,7 +3231,6 @@ void BufferView::updateMetrics(Update::flags & 
update_flags)
y1 -= pm.descent();
// Save the paragraph position in the cache.
pm.setPosition(y1);
-   tm.updatePosCache(pit1);
y1 -= pm.ascent();
}
 
@@ -3246,7 +3244,6 @@ void BufferView::updateMetrics(Update::flags & 
update_flags)
y2 += pm.ascent();
// Save the paragraph position in the cache.
pm.setPosition(y2);
-   tm.updatePosCache(pit2);
y2 += pm.descent();
}
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Always repaint the gray area below main inset

2024-06-10 Thread Jean-Marc Lasgouttes
commit c9f5f34fd703117981cc198ba910328b93e43e99
Author: Jean-Marc Lasgouttes 
Date:   Tue Apr 16 23:55:24 2024 +0200

Always repaint the gray area below main inset

Now that SingleParUpdate does not always lead to a full screen update
when the height of the paragraph changes (see new behavior of
updateMatrics(bool)), it is necessary to make sure that the grey area
below the main page is always repainted.

(cherry picked from commit 1a11abe4394272f521cd63993e426c136e0e9b6c)
---
 src/BufferView.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index e7f6bd04ed..1b2752e638 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3701,7 +3701,11 @@ void BufferView::draw(frontend::Painter & pain, bool 
paint_caret)
// Draw everything.
tm.draw(pi, 0, y);
 
-   // and possibly grey out below
+   break;
+   }
+
+   // Possibly grey out below
+   if (d->update_strategy_ != NoScreenUpdate) {
pair lastpm = tm.last();
int const y2 = lastpm.second->bottom();
 
@@ -3710,8 +3714,8 @@ void BufferView::draw(frontend::Painter & pain, bool 
paint_caret)
? Color_background : Color_bottomarea;
pain.fillRectangle(0, y2, width_, height_ - y2, color);
}
-   break;
}
+
LYXERR(Debug::PAINTING, (pain.isNull() ? "\t\t --- END NODRAW ---"
: "\t\t *** END DRAWING ***"));
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Improve the code that limits scrolling at top/bottom

2024-06-10 Thread Jean-Marc Lasgouttes
commit e5aaa64b63ab0a0090df90b034925decd1c84061
Author: Jean-Marc Lasgouttes 
Date:   Fri Nov 17 18:30:37 2023 +0100

Improve the code that limits scrolling at top/bottom

The most visible part of this commit is the move of part of
BufferView::updateMetrics to a new TextMetrics::updateMetrics. This
new method makes sure that metrics are known for all visible paragraphs
(starting from anchor), and that the positions of the paragraphs have
been recorded.

This method is called up to 3 times in BufferView::updateMetrics:
* unconditionally, to update all visible metrics,
* then, if the bottom of the document is visible and too high, after
  updating the anchor ypos,
* and similarly if the top of the document is visible and too low.

This fixes for example the case where one jumps to Section 5.3 at the
end of Tutorial and 'scroll_below_document' is false.

Some now redundant code is removed from BufferView::scrollToCursor.

The anchor-setting code in BufferView::draw is not clearly useful, but
left here just in case. It generates a debug warning, though.

Part of bug #12297.

(cherry picked from commit f15d2ebf3819913114ab93d1ff7e140cb26b03d5)
---
 src/BufferView.cpp  | 99 ++---
 src/TextMetrics.cpp | 50 +++
 src/TextMetrics.h   |  4 +++
 3 files changed, 88 insertions(+), 65 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index a37ebcd814..e7f6bd04ed 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -769,6 +769,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
TextMetrics const & tm = textMetrics(&buffer_.text());
if (tm.first().second->top() - pixels <= height_
 &&  tm.last().second->bottom() - pixels >= 0) {
+   LYXERR(Debug::SCROLLING, "small skip");
d->anchor_ypos_ -= pixels;
processUpdateFlags(Update::ForceDraw);
return;
@@ -791,6 +792,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
return;
}
 
+   LYXERR(Debug::SCROLLING, "search paragraph");
// find paragraph at target position
int par_pos = d->scrollbarParameters_.min;
pit_type i = 0;
@@ -1104,8 +1106,6 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
ScrollType how)
d->anchor_ypos_ = - offset + row_dim.ascent();
if (how == SCROLL_CENTER)
d->anchor_ypos_ += height_/2 - row_dim.height() / 2;
-   else if (!lyxrc.scroll_below_document && d->anchor_pit_ == max_pit)
-   d->anchor_ypos_ = height_ - offset - row_dim.descent();
else if (offset > height_)
d->anchor_ypos_ = height_ - offset - defaultRowHeight();
else
@@ -3184,7 +3184,7 @@ void BufferView::updateMetrics(bool force)
return;
 
Text & buftext = buffer_.text();
-   pit_type const npit = int(buftext.paragraphs().size());
+   pit_type const lastpit = int(buftext.paragraphs().size()) - 1;
 
if (force) {
// Clear out the position cache in case of full screen redraw,
@@ -3203,62 +3203,35 @@ void BufferView::updateMetrics(bool force)
if (d->inlineCompletionPos_.fixIfBroken())
d->inlineCompletionPos_ = DocIterator();
 
-   if (d->anchor_pit_ >= npit)
+   if (d->anchor_pit_ > lastpit)
// The anchor pit must have been deleted...
-   d->anchor_pit_ = npit - 1;
+   d->anchor_pit_ = lastpit;
 
-   if (!tm.contains(d->anchor_pit_))
-   // Rebreak anchor paragraph.
-   tm.redoParagraph(d->anchor_pit_);
-   ParagraphMetrics & anchor_pm = tm.parMetrics(d->anchor_pit_);
+   // Update metrics around the anchor
+   tm.updateMetrics(d->anchor_pit_, d->anchor_ypos_, height_);
 
-   // make sure than first paragraph of document is not too low
-   if (d->anchor_pit_ == 0) {
-   int scrollRange = d->scrollbarParameters_.max - 
d->scrollbarParameters_.min;
+   // Check that the end of the document is not too high
+   int const min_visible = lyxrc.scroll_below_document ? minVisiblePart() 
: height_;
+   if (tm.last().first == lastpit && tm.last().second->bottom() < 
min_visible) {
+   d->anchor_ypos_ += min_visible - tm.last().second->bottom();
+   LYXERR(Debug::SCROLLING, "Too high, adjusting anchor ypos to " 
<< d->anchor_ypos_);
+   tm.updateMetrics(d->anchor_pit_, d->anchor_ypos_, height_);
+   }
 
-   // Complete buffer visible? Then it's easy.
-   if (scrollRange == 0)
-   d->

[LyX/2.4.x] Document biginset branch

2024-06-10 Thread Jean-Marc Lasgouttes
commit 9b4b05e64ea0e692035052e5c5797545a6915b5a
Author: Jean-Marc Lasgouttes 
Date:   Sun Apr 21 22:26:41 2024 +0200

Document biginset branch
---
 status.24x | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/status.24x b/status.24x
index 350e94d4da..78494339b1 100644
--- a/status.24x
+++ b/status.24x
@@ -35,6 +35,9 @@ What's new
 - Allow relative statistics values in statusbar, improve update times for
   some UI and buffer operations.
 
+- The performance of LyX with large insets on slower computers has
+  been improved a lot (bug 12297).
+
 
 * DOCUMENTATION AND LOCALIZATION
 
@@ -63,7 +66,11 @@ What's new
 - Fix wrong position of conversion windows of the input method (bugs 11723,
   13054).
 
-- Speed up mouse movement when there is no selection (part of bug 13050).
+- Speed up mouse movement when there is no selection (part of bug
+  13050).
+
+- Fix incorrect scrolling when using outline to jump to a paragraph
+  (bug 10425).
 
 
 * INTERNALS
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Sanitize cursors after a buffer has been reloaded

2024-06-10 Thread Jean-Marc Lasgouttes
commit 21096f696a0de7a95b0a12b1d9530c3b4aa399e7
Author: Jean-Marc Lasgouttes 
Date:   Tue Apr 16 11:45:09 2024 +0200

Sanitize cursors after a buffer has been reloaded

When a buffer is reloaded, its content may remain the same, but the
memory allocation is new, so that the inset pointers in cursors are
now wrong. This requires to sanitize the cursors held by the buffer
views.

Before the biginset branch, some full metrics computation call that is
now removed probably did that as a side effect. Now we have to be more
precise.

To this effect, introduce WorkAreaManager::sanitizeCursors() and use
it in Buffer::reload().

(cherry picked from commit c1fd622c51752d790576600f5911813ff8dac3fa)
---
 src/Buffer.cpp|  3 +++
 src/frontends/WorkArea.h  |  7 +++
 src/frontends/WorkAreaManager.cpp | 12 
 src/frontends/WorkAreaManager.h   |  2 ++
 src/frontends/qt/GuiWorkArea.h|  4 ++--
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index de7f4d217c..38d236964a 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5562,6 +5562,9 @@ Buffer::ReadStatus Buffer::reload()
Buffer const * oldparent = d->parent();
d->setParent(nullptr);
ReadStatus const status = loadLyXFile();
+   // The inset members in cursors held by buffer views are now wrong.
+   workAreaManager().sanitizeCursors();
+   setBusy(false);
if (status == ReadSuccess) {
updateBuffer();
changed(true);
diff --git a/src/frontends/WorkArea.h b/src/frontends/WorkArea.h
index d6912fc7fa..c0e673554a 100644
--- a/src/frontends/WorkArea.h
+++ b/src/frontends/WorkArea.h
@@ -18,6 +18,8 @@
 
 namespace lyx {
 
+class BufferView;
+
 namespace frontend {
 
 /**
@@ -40,6 +42,11 @@ public:
 
/// Update window titles of all users.
virtual void updateWindowTitle() = 0;
+
+   ///
+   virtual BufferView & bufferView() = 0;
+   ///
+   virtual BufferView const & bufferView() const = 0;
 };
 
 } // namespace frontend
diff --git a/src/frontends/WorkAreaManager.cpp 
b/src/frontends/WorkAreaManager.cpp
index 8d32c6b6d8..324d5571af 100644
--- a/src/frontends/WorkAreaManager.cpp
+++ b/src/frontends/WorkAreaManager.cpp
@@ -13,6 +13,9 @@
 
 #include "WorkAreaManager.h"
 
+#include "BufferView.h"
+#include "Cursor.h"
+
 #include "Application.h"
 #include "WorkArea.h"
 
@@ -69,6 +72,15 @@ void WorkAreaManager::scheduleRedraw()
 }
 
 
+void WorkAreaManager::sanitizeCursors()
+{
+   for (WorkArea * wa : work_areas_) {
+   wa->bufferView().cursor().sanitize();
+   wa->bufferView().resetInlineCompletionPos();
+   }
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
diff --git a/src/frontends/WorkAreaManager.h b/src/frontends/WorkAreaManager.h
index 94c528b3a6..73548592fa 100644
--- a/src/frontends/WorkAreaManager.h
+++ b/src/frontends/WorkAreaManager.h
@@ -49,6 +49,8 @@ public:
/// If there is no work area, create a new one in the current view 
using the
/// buffer buf. Returns false if not possible.
bool unhide(Buffer * buf) const;
+   /// Fix cursors in all buffer views held by work areas.
+   void sanitizeCursors();
 
 private:
typedef std::list::iterator iterator;
diff --git a/src/frontends/qt/GuiWorkArea.h b/src/frontends/qt/GuiWorkArea.h
index 148b79b73a..86bbfda939 100644
--- a/src/frontends/qt/GuiWorkArea.h
+++ b/src/frontends/qt/GuiWorkArea.h
@@ -59,9 +59,9 @@ public:
/// is GuiView in fullscreen mode?
bool isFullScreen() const;
///
-   BufferView & bufferView();
+   BufferView & bufferView() override;
///
-   BufferView const & bufferView() const;
+   BufferView const & bufferView() const override;
///
void scheduleRedraw(bool update_metrics) override;
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Set buffer_ correctly when inseting a math macro over a selection

2024-06-10 Thread Jean-Marc Lasgouttes
commit 13a34d6cd1bbf2a93d5b51624de7085d594cf8fa
Author: Jean-Marc Lasgouttes 
Date:   Thu Apr 25 14:28:10 2024 +0200

Set buffer_ correctly when inseting a math macro over a selection

The code that handles this special macro insertion (in
Cursor::mathMacroClose())) is very weird: it inserts the contents of
the macro _after_ the macro and later, since the macro is 'greedy', it
will eat this contents and put it in its first macro cell.

Does it make sense to you? It does not ake sense to me either. Anyway,
this is the point where one should make sure that the buffer is set.

Fixes ticket #12682.

(cherry picked from commit b45a957929a78cefc729a0fa984214eb83357d42)
---
 po/cs.gmo | Bin 627180 -> 627292 bytes
 po/de.gmo | Bin 653622 -> 653742 bytes
 po/sk.gmo | Bin 636629 -> 636898 bytes
 src/mathed/InsetMathMacro.cpp |   2 ++
 status.24x|   2 ++
 5 files changed, 4 insertions(+)

diff --git a/po/cs.gmo b/po/cs.gmo
index 77e6cdb0b6..a2e7997798 100644
Binary files a/po/cs.gmo and b/po/cs.gmo differ
diff --git a/po/de.gmo b/po/de.gmo
index 9fc86c4547..6677f06738 100644
Binary files a/po/de.gmo and b/po/de.gmo differ
diff --git a/po/sk.gmo b/po/sk.gmo
index 848fb84684..be2c5419d8 100644
Binary files a/po/sk.gmo and b/po/sk.gmo differ
diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp
index a90bf87f5e..9caf4853dc 100644
--- a/src/mathed/InsetMathMacro.cpp
+++ b/src/mathed/InsetMathMacro.cpp
@@ -1078,6 +1078,8 @@ void InsetMathMacro::attachArguments(vector 
const & args, size_t arity
 {
LASSERT(d->displayMode_ == DISPLAY_NORMAL, return);
cells_ = args;
+   for (auto & cell : cells_)
+   cell.setBuffer(*buffer_);
d->attachedArgsNum_ = args.size();
cells_.resize(arity);
d->expanded_ = MathData();
diff --git a/status.24x b/status.24x
index 78494339b1..421226bba1 100644
--- a/status.24x
+++ b/status.24x
@@ -75,6 +75,8 @@ What's new
 
 * INTERNALS
 
+- Fix case where insets do not have proper information about current buffer
+  (bug 12682).
 
 
 * DOCUMENTATION AND LOCALIZATION
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Try to make sure that math insets have a properly set buffer_ member

2024-06-10 Thread Jean-Marc Lasgouttes
commit 76188dcdf11e06e8772e900de04ccbfb079bafac
Author: Jean-Marc Lasgouttes 
Date:   Fri Oct 14 22:42:21 2022 +0200

Try to make sure that math insets have a properly set buffer_ member

Set the buffer of contents that is added to a MathData object through
MathData::insert() (both versions)
MathData::push_back()
asArray()

Also in math macros, initialize look_ with the relevant buffer.

This reduces the number of insets hat do not have a proper buffer.

See #13050 for discussion of this issue.

(cherry picked from commit f3c5ff9cb72c5231f1e1e81452e67d6f12dadecb)
---
 src/mathed/InsetMathMacroTemplate.cpp |  8 +---
 src/mathed/MathData.cpp   | 24 ++--
 src/mathed/MathData.h |  7 +--
 src/mathed/MathSupport.cpp|  3 +++
 4 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/mathed/InsetMathMacroTemplate.cpp 
b/src/mathed/InsetMathMacroTemplate.cpp
index 2a721833b0..cf830fbf3b 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -394,7 +394,7 @@ void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) 
const
 
 
 InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf)
-   : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0),
+   : InsetMathNest(buf, 3), look_(buf), numargs_(0), argsInLook_(0), 
optionals_(0),
  type_(MacroTypeNewcommand), redefinition_(false), lookOutdated_(true),
  premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
 {
@@ -405,8 +405,8 @@ InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf)
 InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf, docstring const & 
name, int numargs,
int optionals, MacroType type, vector const & optionalValues,
MathData const & def, MathData const & display)
-   : InsetMathNest(buf, optionals + 3), numargs_(numargs), 
argsInLook_(numargs),
- optionals_(optionals), optionalValues_(optionalValues),
+   : InsetMathNest(buf, optionals + 3), look_(buf), numargs_(numargs),
+ argsInLook_(numargs), optionals_(optionals), 
optionalValues_(optionalValues),
  type_(type), redefinition_(false), lookOutdated_(true),
  premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0)
 {
@@ -536,6 +536,8 @@ void InsetMathMacroTemplate::createLook(int args) const
look_.push_back(MathAtom(
new InsetDisplayLabelBox(buffer_, MathAtom(
new InsetMathWrapper(&cell(displayIdx(, _("LyX"), 
*this)));
+
+   look_.setContentsBuffer();
 }
 
 
diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 24b4d86fb9..4c33934828 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -52,11 +52,18 @@ MathData::MathData(Buffer * buf, const_iterator from, 
const_iterator to)
 {}
 
 
+void MathData::setContentsBuffer()
+{
+   if (buffer_)
+   for (MathAtom & at : *this)
+   at.nucleus()->setBuffer(*buffer_);
+}
+
+
 void MathData::setBuffer(Buffer & b)
 {
buffer_ = &b;
-   for (MathAtom & at : *this)
-   at.nucleus()->setBuffer(b);
+   setContentsBuffer();
 }
 
 
@@ -78,6 +85,8 @@ void MathData::insert(size_type pos, MathAtom const & t)
 {
LBUFERR(pos <= size());
base_type::insert(begin() + pos, t);
+   if (buffer_)
+   operator[](pos)->setBuffer(*buffer_);
 }
 
 
@@ -85,6 +94,17 @@ void MathData::insert(size_type pos, MathData const & ar)
 {
LBUFERR(pos <= size());
base_type::insert(begin() + pos, ar.begin(), ar.end());
+   if (buffer_)
+   for (size_type i = 0 ; i < ar.size() ; ++i)
+   operator[](pos + i)->setBuffer(*buffer_);
+}
+
+
+void MathData::push_back(MathAtom const & t)
+{
+   base_type::push_back(t);
+   if (buffer_)
+   back()->setBuffer(*buffer_);
 }
 
 
diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h
index 865742df4c..c2d731efcb 100644
--- a/src/mathed/MathData.h
+++ b/src/mathed/MathData.h
@@ -59,7 +59,6 @@ public:
using base_type::clear;
using base_type::begin;
using base_type::end;
-   using base_type::push_back;
using base_type::pop_back;
using base_type::back;
using base_type::front;
@@ -85,6 +84,8 @@ public:
void insert(size_type pos, MathAtom const & at);
/// inserts multiple atoms at position pos
void insert(size_type pos, MathData const & ar);
+   /// inserts single atom at end
+   void push_back(MathAtom const & at);
 
/// erase range from pos1 to pos2
void erase(iterator pos1, iterator pos2);
@@ -187,8 +188,10 @@ public:
void updateMacros(Cursor * cur, MacroContext const & mc, UpdateType, 
int nestin

[LyX/2.4.x] Set buffer when creating a MathData from parts of another one

2024-06-10 Thread Jean-Marc Lasgouttes
commit 2699a58cd7c98e54cb5cfbaf3f6cdf2621651a64
Author: Jean-Marc Lasgouttes 
Date:   Thu Apr 25 17:13:15 2024 +0200

Set buffer when creating a MathData from parts of another one

This is triggered by selecting part of an equation under Xcb platform
(x11). Indeed, the current selection has to be sent to the X11 server
and BufferView::requestSelection() is called. Eventually
cap::grabSelection() is the function that creates this partial
MathData object.

Fixes ticket #12947.

(cherry picked from commit ed2f3cb9cfa1e871d48a92d41791a77bd218ab67)
---
 src/mathed/MathData.cpp | 4 +++-
 status.24x  | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
index 4c33934828..38f44a696e 100644
--- a/src/mathed/MathData.cpp
+++ b/src/mathed/MathData.cpp
@@ -49,7 +49,9 @@ namespace lyx {
 
 MathData::MathData(Buffer * buf, const_iterator from, const_iterator to)
: base_type(from, to), buffer_(buf)
-{}
+{
+   setContentsBuffer();
+}
 
 
 void MathData::setContentsBuffer()
diff --git a/status.24x b/status.24x
index 0328af480b..e7f677295e 100644
--- a/status.24x
+++ b/status.24x
@@ -90,6 +90,8 @@ What's new
 
 - Fix initialization of an internal value.
 
+- Fix "Unassigned buffer_" error with math references (bug 12947).
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Add "full" drawing strategy

2024-06-11 Thread Jean-Marc Lasgouttes
commit f48cf461010daa8aceb220a6762cb50c1192db0d
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 15 11:46:25 2023 +0200

Add "full" drawing strategy

With this patch, 3 draw strategies (set in prefs with
\draw_strategy partial|backingstore|full) are available:

- "partial": only draw the parts of text that have changed since last
  paint event (default for X11 and windows)

- "backingstore": the same, but drawing happens on an offspring
  pixmap; this breaks subpixel rendering (default for Wayland and
  macOS)

- "full": the screen is fully redrawn at each paint event and should
  therefore always be correct; this is presumably slower but
  introducing it will allow to test it.

This would deserve a proper UI eventually.
---
 src/BufferView.cpp  |  3 +++
 src/LyXRC.cpp   |  6 +-
 src/LyXRC.h |  4 ++--
 src/frontends/qt/GuiApplication.cpp |  9 +
 src/frontends/qt/GuiApplication.h   |  4 ++--
 src/frontends/qt/GuiWorkArea.cpp| 10 +++---
 6 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 755e2f7b4e..4e81bcbe3f 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -592,6 +592,9 @@ void BufferView::processUpdateFlags(Update::flags flags)
flags = (flags & ~Update::FitCursor) | Update::ForceDraw;
}
 
+   if (lyxrc.draw_strategy == LyXRC::DS_FULL)
+   flags = flags | Update::ForceDraw;
+
// Add flags to the the update flags. These will be reset to None
// after the redraw is actually done
d->update_flags_ = d->update_flags_ | flags;
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index 9c8decab43..edd9a58240 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -1147,8 +1147,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
draw_strategy = DS_PARTIAL;
else if (tmp == "backingstore")
draw_strategy = DS_BACKINGSTORE;
+   else if (tmp == "full")
+   draw_strategy = DS_FULL;
else {
-   draw_strategy = DS_PARTIAL;
LYXERR0("Unrecognized draw strategy " 
<< tmp <<'"');
}
}
@@ -2055,6 +2056,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, 
string const & name) c
draw_strategy != system_lyxrc.draw_strategy) {
string status;
switch (draw_strategy) {
+   case DS_FULL:
+   status = "full";
+   break;
case DS_PARTIAL:
status = "partial";
break;
diff --git a/src/LyXRC.h b/src/LyXRC.h
index c437021c06..753a6f4f61 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -580,8 +580,8 @@ public:
BookmarksVisibility bookmarks_visibility = BMK_NONE;
 
enum DrawStrategy {
-   // draw all (not implemented yet)
-   // FS_FULL,
+   // draw all
+   DS_FULL,
// draw only what has changed
DS_PARTIAL,
// draw in backing store (only what has changed)
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index 516c970e71..d903e85f5d 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -2730,13 +2730,14 @@ Menus & GuiApplication::menus()
 }
 
 
-bool GuiApplication::needsBackingStore() const
+bool GuiApplication::noPartialDraw() const
 {
/* Qt on macOS and Wayland does not respect the
 * Qt::WA_OpaquePaintEvent attribute and resets the widget backing
-* store at each update. Therefore, we use our own backing store
-* in these two cases. It is also possible to force the use of the
-* backing store for cases like x11 with transparent WM themes.
+* store at each update. Therefore, if it not good to use
+* "partial" draw strategy in these cases. It is also possible to
+* force the use of the backing store for cases like x11 with
+* transparent WM themes.
 */
return platformName() == "cocoa" || platformName().contains("wayland");
 }
diff --git a/src/frontends/qt/GuiApplication.h 
b/src/frontends/qt/GuiApplication.h
index b27964dde4..67ba9590e5 100644
--- a/src/frontends/qt/GuiApplication.h
+++ b/src/frontends/qt/GuiApplication.h
@@ -113,8

[LyX/master] InsetMathMacoTemplate: recompute metrics on editXY too

2024-06-11 Thread Jean-Marc Lasgouttes
commit b54d3520753f79231c9f09a45f4efd9c8ac2d90a
Author: Jean-Marc Lasgouttes 
Date:   Tue Jun 11 17:04:58 2024 +0200

InsetMathMacoTemplate: recompute metrics on editXY too

This inset can change dimensions when edited (like macros can).
Therefore Update::SinglePar should be set with editXY() like it is
already set for edit().
---
 src/mathed/InsetMathMacroTemplate.cpp | 8 
 src/mathed/InsetMathMacroTemplate.h   | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/src/mathed/InsetMathMacroTemplate.cpp 
b/src/mathed/InsetMathMacroTemplate.cpp
index 9b2fd19dab..94760d4060 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -625,6 +625,14 @@ void InsetMathMacroTemplate::edit(Cursor & cur, bool 
front, EntryDirection entry
 }
 
 
+Inset * InsetMathMacroTemplate::editXY(Cursor & cur, int x, int y)
+{
+   updateLook();
+   cur.screenUpdateFlags(Update::SinglePar);
+   return InsetMathNest::editXY(cur, x, y);
+}
+
+
 bool InsetMathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & 
cur)
 {
unsigned int const nargs_before = nargs();
diff --git a/src/mathed/InsetMathMacroTemplate.h 
b/src/mathed/InsetMathMacroTemplate.h
index 785385a7db..ba17a91742 100644
--- a/src/mathed/InsetMathMacroTemplate.h
+++ b/src/mathed/InsetMathMacroTemplate.h
@@ -43,6 +43,8 @@ public:
///
void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
///
+   Inset * editXY(Cursor & cur, int x, int y) override;
+   ///
bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
///
void read(support::Lexer & lex) override;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX features/biginset] InsetMathMacoTemplate: recompute metrics on editXY too

2024-06-11 Thread Jean-Marc Lasgouttes
commit b2b565e6cbfda5c62b22610617fef0b6d5472c62
Author: Jean-Marc Lasgouttes 
Date:   Tue Jun 11 17:04:58 2024 +0200

InsetMathMacoTemplate: recompute metrics on editXY too

This inset can change dimensions when edited (like macros can).
Therefore Update::SinglePar should be set with editXY() like it is
already set for edit().

(cherry picked from commit b54d3520753f79231c9f09a45f4efd9c8ac2d90a)
---
 src/mathed/InsetMathMacroTemplate.cpp | 8 
 src/mathed/InsetMathMacroTemplate.h   | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/src/mathed/InsetMathMacroTemplate.cpp 
b/src/mathed/InsetMathMacroTemplate.cpp
index 2a721833b0..4fb50b1a4c 100644
--- a/src/mathed/InsetMathMacroTemplate.cpp
+++ b/src/mathed/InsetMathMacroTemplate.cpp
@@ -613,6 +613,14 @@ void InsetMathMacroTemplate::edit(Cursor & cur, bool 
front, EntryDirection entry
 }
 
 
+Inset * InsetMathMacroTemplate::editXY(Cursor & cur, int x, int y)
+{
+   updateLook();
+   cur.screenUpdateFlags(Update::SinglePar);
+   return InsetMathNest::editXY(cur, x, y);
+}
+
+
 bool InsetMathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & 
cur)
 {
unsigned int const nargs_before = nargs();
diff --git a/src/mathed/InsetMathMacroTemplate.h 
b/src/mathed/InsetMathMacroTemplate.h
index 105dcfb7ff..4cf993918c 100644
--- a/src/mathed/InsetMathMacroTemplate.h
+++ b/src/mathed/InsetMathMacroTemplate.h
@@ -41,6 +41,8 @@ public:
///
void edit(Cursor & cur, bool front, EntryDirection entry_from) override;
///
+   Inset * editXY(Cursor & cur, int x, int y) override;
+   ///
bool notifyCursorLeaves(Cursor const & old, Cursor & cur) override;
///
void read(Lexer & lex) override;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix depth bar optics

2024-06-14 Thread Jean-Marc Lasgouttes
commit 92aeaf5d73923af03b6ab0e1711b157375d4c8e4
Author: Daniel Ramoeller 
Date:   Thu Aug 13 16:36:15 2020 +0200

Fix depth bar optics
---
 src/RowPainter.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 19d83c13a3..e84343a7aa 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -352,12 +352,12 @@ void RowPainter::paintDepthBar() const
int const starty = yo_ - row_.ascent();
int const h =  row_.height() - 1 - (i - next_depth - 1) * 3;
 
-   pi_.pain.line(x, starty, x, starty + h, Color_depthbar);
+   pi_.pain.line(x, starty + (i > prev_depth ? 1 : 0), x, starty + 
h, Color_depthbar);
 
if (i > prev_depth)
pi_.pain.fillRectangle(x, starty, w, 2, Color_depthbar);
if (i > next_depth)
-   pi_.pain.fillRectangle(x, starty + h, w, 2, 
Color_depthbar);
+   pi_.pain.fillRectangle(x, starty + h - 1, w, 2, 
Color_depthbar);
}
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Support qmake with Qt5 too

2024-06-17 Thread Jean-Marc Lasgouttes
commit 5d76b4bb8f7b59a9c7baf6d457de6c05f5a07f47
Author: Jean-Marc Lasgouttes 
Date:   Fri Jun 14 19:17:27 2024 +0200

Support qmake with Qt5 too

This extends the support of qmake to Qt5. Currently, the other
configuration methods are tried if qmake fails, but a message is
printed.

A nice goal would be to get rid of those legacy methods (pkg-config,
plain autoconf-style), if this proves possible.
---
 config/qt.m4 | 110 +--
 1 file changed, 69 insertions(+), 41 deletions(-)

diff --git a/config/qt.m4 b/config/qt.m4
index 7e7ffd6df2..f947ae042d 100644
--- a/config/qt.m4
+++ b/config/qt.m4
@@ -166,40 +166,43 @@ AC_DEFUN([QT_DO_IT_ALL],
esac
AC_SUBST(QT_CPPFLAGS)
 
-   dnl Check if it possible to do a pkg-config
+   dnl Check if it possible to do a pkg-config (for later)
PKG_PROG_PKG_CONFIG
-   dnl Not possible with Qt6 (QTBUG-86080)
-   if test x$USE_QT6 = xno ; then
-   if test -n "$PKG_CONFIG" ; then
-   QT_DO_PKG_CONFIG
-   fi
-   if test "$pkg_failed" != "no" ; then
-   QT_DO_MANUAL_CONFIG
+
+   dnl Try qmake first
+   QT_QMAKE_CONFIG([$USE_QT6])
+   if test -z "$QT_LIB"; then
+   dnl pkg-config does not work with Qt6 (QTBUG-86080)
+   if test x$USE_QT6 = xno ; then
+   if test -n "$PKG_CONFIG" ; then
+   QT_DO_PKG_CONFIG
+   fi
fi
-   else
-   QT6_QMAKE_CONFIG
-   if test -z "$QT_LIB"; then
-   QT_DO_MANUAL_CONFIG
+   fi
+   dnl last chance: old-style configuration
+   if test -z "$QT_LIB"; then
+   QT_DO_MANUAL_CONFIG
+   fi
+
+   if test -z "$QT_LIB"; then
+   dnl Try again with Qt5 if configuring for Qt6 failed
+   dnl this is mostly the same logic as above
+   if test x$USE_QT6 = xyes ; then
+   USE_QT6=no
+   QT_QMAKE_CONFIG([$USE_QT6])
+   if test -z "$QT_LIB"; then
+   if test -n "$PKG_CONFIG" ; then
+   QT_DO_PKG_CONFIG
+   fi
+   fi
+   if test -z "$QT_LIB"; then
+   QT_DO_MANUAL_CONFIG
+   fi
fi
fi
 
if test -z "$QT_LIB"; then
- dnl Try again with Qt5 and if configuring for Qt6/5 fails
- if test x$USE_QT6 = xyes ; then
-   USE_QT6=no
-   AC_SUBST([USE_QT6])
-   if test -n "$PKG_CONFIG" ; then
- QT_DO_PKG_CONFIG
-   fi
-   if test "$pkg_failed" != "no" ; then
- QT_DO_MANUAL_CONFIG
-   fi
-   if test -z "$QT_LIB"; then
- AC_MSG_ERROR([cannot find qt libraries.])
-   fi
- else
-   AC_MSG_ERROR([cannot find qt libraries.])
- fi
+   AC_MSG_ERROR([Cannot find Qt libraries.])
fi
 
dnl Check qt version
@@ -375,13 +378,20 @@ AC_DEFUN([QT_DO_MANUAL_CONFIG],
fi
 ])
 
-AC_DEFUN([QT6_QMAKE_CONFIG],
+dnl QT_QMAKE_CONFIG(USE_QT6)
+dnl
+AC_DEFUN([QT_QMAKE_CONFIG],
 [
-   dnl Use first suitable qmake in PATH
-   AC_CHECK_PROGS([QT_QMAKE], [qmake-qt6 qmake6], [qmake], $PATH)
-   AC_MSG_CHECKING([for Qt6])
+dnl Use first suitable qmake in PATH
+   if test $1 = "yes"; then
+ qt_major=6
+   else
+ qt_major=5
+   fi
+   AC_CHECK_PROGS([QT_QMAKE], [qmake-qt$qt_major qmake$qt_major qmake], 
[], $PATH)
+   AC_MSG_CHECKING([for Qt$qt_major])
qtver=`$QT_QMAKE -v | grep -o "Qt version ."`
-   if test "$qtver" = "Qt version 6"; then
+   if test "$qtver" = "Qt version $qt_major"; then
qt_cv_libexec=`$QT_QMAKE -query QT_INSTALL_LIBEXECS`
dnl Use a .pro file for getting qmake's variables
lyx_test_qt_dir=`mktemp -d`
@@ -412,18 +422,28 @@ EOF1
AC_SUBST(QT_CORE_LIB)
cat > $lyx_test_qt_pro << EOF2
 QMAKE_EXTRA_VARIABLES = MISSING
+percent.target = %
+percent.commands = @echo -n "\$(\$(@))\ "
+QMAKE_EXTRA_TARGETS += percent
+QMAKE_PROJECT_DEPTH = 0
 qtHaveModule(core) {QT += core} else {MISSING += core}
 qtHaveModule(concurrent)   {QT += concurrent} else {MISSING += concurrent}
 qtHaveModule(gui)  {QT += gui} else {MISSING += gui}
 qtHaveModule(gui-private)  {QT += gui-private} else {MISSING += 
gui-private}
 qtHaveModule(svg)  {QT += svg} else {MISSING += svg}
-qtHaveModule(svgwidgets)   {QT += svgwidgets} else {MISSING += svgwidgets}
 qtHaveModule(widgets)  {QT += widget

[LyX/master] Move DrawStrategy enum to update_flags.h.

2024-06-18 Thread Jean-Marc Lasgouttes
commit c263463cadc92a9e5b29df97a825328c9300b76a
Author: Jean-Marc Lasgouttes 
Date:   Tue Jun 18 14:28:28 2024 +0200

Move DrawStrategy enum to update_flags.h.

Introduce new drawStrategy() and drawStrategyDescription() methods to
frontend::Application.

Show the current draw strategy in About dialog.
---
 src/BufferView.cpp  |  3 ++-
 src/LyXRC.cpp   | 12 ++--
 src/LyXRC.h | 11 ++-
 src/frontends/Application.h |  6 ++
 src/frontends/qt/GuiAbout.cpp   |  5 +
 src/frontends/qt/GuiApplication.cpp | 28 
 src/frontends/qt/GuiApplication.h   |  5 +++--
 src/frontends/qt/GuiWorkArea.cpp| 10 ++
 src/update_flags.h  | 12 
 9 files changed, 62 insertions(+), 30 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4e81bcbe3f..8a4d0b2c20 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -58,6 +58,7 @@
 #include "mathed/MathRow.h"
 
 #include "frontends/alert.h"
+#include "frontends/Application.h"
 #include "frontends/CaretGeometry.h"
 #include "frontends/Delegates.h"
 #include "frontends/FontMetrics.h"
@@ -592,7 +593,7 @@ void BufferView::processUpdateFlags(Update::flags flags)
flags = (flags & ~Update::FitCursor) | Update::ForceDraw;
}
 
-   if (lyxrc.draw_strategy == LyXRC::DS_FULL)
+   if (theApp()->drawStrategy() == DrawStrategy::Full)
flags = flags | Update::ForceDraw;
 
// Add flags to the the update flags. These will be reset to None
diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index edd9a58240..feda5110c0 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -1144,11 +1144,11 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
if (lexrc.next()) {
string const tmp = lexrc.getString();
if (tmp == "partial")
-   draw_strategy = DS_PARTIAL;
+   draw_strategy = DrawStrategy::Partial;
else if (tmp == "backingstore")
-   draw_strategy = DS_BACKINGSTORE;
+   draw_strategy = 
DrawStrategy::Backingstore;
else if (tmp == "full")
-   draw_strategy = DS_FULL;
+   draw_strategy = DrawStrategy::Full;
else {
LYXERR0("Unrecognized draw strategy " 
<< tmp <<'"');
}
@@ -2056,13 +2056,13 @@ void LyXRC::write(ostream & os, bool 
ignore_system_lyxrc, string const & name) c
draw_strategy != system_lyxrc.draw_strategy) {
string status;
switch (draw_strategy) {
-   case DS_FULL:
+   case DrawStrategy::Full:
status = "full";
break;
-   case DS_PARTIAL:
+   case DrawStrategy::Partial:
status = "partial";
break;
-   case DS_BACKINGSTORE:
+   case DrawStrategy::Backingstore:
status = "backingstore";
break;
}
diff --git a/src/LyXRC.h b/src/LyXRC.h
index 753a6f4f61..e0c2da3178 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -19,6 +19,7 @@
 #define LYXRC_H
 
 #include "LyX.h"
+#include "update_flags.h"
 
 #include "support/Length.h"
 #include "support/strfwd.h"
@@ -579,16 +580,8 @@ public:
///
BookmarksVisibility bookmarks_visibility = BMK_NONE;
 
-   enum DrawStrategy {
-   // draw all
-   DS_FULL,
-   // draw only what has changed
-   DS_PARTIAL,
-   // draw in backing store (only what has changed)
-   DS_BACKINGSTORE
-   };
///
-   DrawStrategy draw_strategy = DS_PARTIAL;
+   DrawStrategy draw_strategy = DrawStrategy::Partial;
 };
 
 
diff --git a/src/frontends/Application.h b/src/frontends/Application.h
index 75298ca67a..4d2d249b23 100644
--- a/src/frontends/Application.h
+++ b/src/frontends/Application.h
@@ -13,6 +13,7 @@
 
 #include "ColorCode.h"
 #include "FuncCode.h"
+#include "update_flags.h"
 
 #include "support/strfwd.h"
 
@@ -203,6 +204,11 @@ public:
/// Like getRgbColor(), but static and slower
static bool g

[LyX/master] Add missing override keyword

2024-06-19 Thread Jean-Marc Lasgouttes
commit b78d2a4edae4da0d20ea413c508e6420bf5eeac3
Author: Jean-Marc Lasgouttes 
Date:   Wed Jun 19 15:05:04 2024 +0200

Add missing override keyword
---
 src/frontends/qt/GuiApplication.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/GuiApplication.h 
b/src/frontends/qt/GuiApplication.h
index 07a8b167dd..38c3c0a6e0 100644
--- a/src/frontends/qt/GuiApplication.h
+++ b/src/frontends/qt/GuiApplication.h
@@ -114,8 +114,8 @@ public:
Menus & menus();
 
/// \returns the draw strategy used by the application
-   DrawStrategy drawStrategy() const;
-   virtual docstring drawStrategyDescription() const override;
+   DrawStrategy drawStrategy() const override;
+   docstring drawStrategyDescription() const override;
 
/// \name Methods inherited from QApplication class
//@{
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Remove trailing underscore on members x and y of Point class.

2024-06-20 Thread Jean-Marc Lasgouttes
commit c7c16fe9fa304e2adf68b4cc0ca85e19eaf36404
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 20 14:28:45 2024 +0200

Remove trailing underscore on members x and y of Point class.

These members are not private.
---
 src/BufferView.cpp   | 74 
 src/CoordCache.cpp   |  2 +-
 src/CoordCache.h | 30 
 src/Cursor.cpp   | 14 
 src/Dimension.cpp| 10 +++---
 src/Dimension.h  |  4 +--
 src/TextMetrics.cpp  | 16 -
 src/frontends/qt/GuiWorkArea.cpp | 18 +-
 src/insets/InsetTabular.cpp  |  4 +--
 src/mathed/InsetMathMacro.cpp|  7 ++--
 src/mathed/InsetMathNest.cpp | 12 +++
 src/mathed/MathData.cpp  |  4 +--
 12 files changed, 97 insertions(+), 98 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 8a4d0b2c20..b55beb34a7 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -511,7 +511,7 @@ bool BufferView::needsFitCursor() const
int const asc = fm.maxAscent();
int const des = fm.maxDescent();
Point const p = getPos(d->cursor_);
-   if (p.y_ - asc >= 0 && p.y_ + des < height_)
+   if (p.y - asc >= 0 && p.y + des < height_)
return false;
}
return true;
@@ -844,7 +844,7 @@ void BufferView::setCursorFromScrollbar()
newy = last;
break;
case CUR_INSIDE:
-   int const y = getPos(oldcur).y_;
+   int const y = getPos(oldcur).y;
newy = min(last, max(y, first));
if (y == newy)
return;
@@ -885,9 +885,9 @@ Change const BufferView::getCurrentChange() const
 CursorStatus BufferView::cursorStatus(DocIterator const & dit) const
 {
Point const p = getPos(dit);
-   if (p.y_ < 0)
+   if (p.y < 0)
return CUR_ABOVE;
-   if (p.y_ > workHeight())
+   if (p.y > workHeight())
return CUR_BELOW;
return CUR_INSIDE;
 }
@@ -1060,7 +1060,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
ScrollType how)
LBUFERR(!pm.rows().empty());
// FIXME: smooth scrolling doesn't work in mathed.
CursorSlice const & cs = dit.innerTextSlice();
-   int const ypos = pm.position() + coordOffset(dit).y_;
+   int const ypos = pm.position() + coordOffset(dit).y;
ParagraphMetrics const & inner_pm =
textMetrics(cs.text()).parMetrics(cs.pit());
Dimension const & row_dim =
@@ -1100,7 +1100,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
ScrollType how)
d->inlineCompletionPos_ = DocIterator();
 
tm.redoParagraph(bot_pit);
-   int const offset = coordOffset(dit).y_;
+   int const offset = coordOffset(dit).y;
pit_type const old_pit = d->anchor_pit_;
d->anchor_pit_ = bot_pit;
 
@@ -2064,7 +2064,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
Point p = getPos(cur);
// This code has been commented out to enable to scroll down a
// document, even if there are large insets in it (see bug 
#5465).
-   /*if (p.y_ < 0 || p.y_ > height_) {
+   /*if (p.y < 0 || p.y > height_) {
// The cursor is off-screen so recenter before 
proceeding.
showCursor();
p = getPos(cur);
@@ -2082,7 +2082,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
if (scrolled)
processUpdateFlags(Update::Force);
 
-   d->text_metrics_[&buffer_.text()].editXY(cur, p.x_, p.y_,
+   d->text_metrics_[&buffer_.text()].editXY(cur, p.x, p.y,
true, act == LFUN_SCREEN_UP);
//FIXME: what to do with cur.x_target()?
bool update = in_texted && cur.bv().checkDepm(cur, old);
@@ -2127,10 +2127,10 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
cur.finishUndo();
break;
}
-   int y = getPos(cur).y_;
+   int y = getPos(cur).y;
int const ymin = y - height_ + defaultRowHeight();
while (y > ymin && cur.up())
-   y = getPos(cur).y_;
+   y = getPos(cur).y;
 
cur.finishUndo();
dr.screenUpdate(Update::SinglePar | Update::FitCursor);
@@ -2145,10 +2145,10 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult &

[LyX/master] Remove useless cursor parameter to global undo actions

2024-06-20 Thread Jean-Marc Lasgouttes
commit f6430577798b604a11616c2191e664d56efa7cfb
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 20 17:25:25 2024 +0200

Remove useless cursor parameter to global undo actions

Add a Cursor-less version of Undo::recordUndoBufferParams (we don't
use an optional arument to avoir #includ'ing Cursor.h).

The version with CursorData parameter has been kept for the case of
local dictionary lfuns that have some kind of locality.

Remove Cursor argument to Undo::recordUndoFullBuffer().
---
 src/Buffer.cpp | 14 +++---
 src/Cursor.cpp |  2 +-
 src/Undo.cpp   | 13 ++---
 src/Undo.h | 10 ++
 4 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 0f7560c8e4..e95d0edcc8 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2865,7 +2865,7 @@ bool Buffer::branchActivationDispatch(FuncCode act, 
docstring const & branch)
"Please make sure to save the master."), branch), true);
 
UndoGroupHelper ugh(buf);
-   buf->undo().recordUndoBufferParams(CursorData());
+   buf->undo().recordUndoBufferParams();
our_branch->setSelected(activate);
// cur.forceBufferUpdate() is not enough)
buf->updateBuffer();
@@ -3029,7 +3029,7 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
msg += ("\n");
msg += bformat(_("Branch \"%1$s\" already 
exists."), branch_name);
} else {
-   undo().recordUndoBufferParams(CursorData());
+   undo().recordUndoBufferParams();
branch_list.add(branch_name);
branch = branch_list.find(branch_name);
if (branch)
@@ -3089,13 +3089,13 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
 
case LFUN_CHANGES_TRACK:
if (params().save_transient_properties)
-   undo().recordUndoBufferParams(CursorData());
+   undo().recordUndoBufferParams();
params().track_changes = !params().track_changes;
break;
 
case LFUN_CHANGES_OUTPUT:
if (params().save_transient_properties)
-   undo().recordUndoBufferParams(CursorData());
+   undo().recordUndoBufferParams();
params().output_changes = !params().output_changes;
if (params().output_changes) {
bool xcolorulem = LaTeXFeatures::isAvailable("ulem") &&
@@ -3113,17 +3113,17 @@ void Buffer::dispatch(FuncRequest const & func, 
DispatchResult & dr)
 
case LFUN_BUFFER_TOGGLE_COMPRESSION:
// turn compression on/off
-   undo().recordUndoBufferParams(CursorData());
+   undo().recordUndoBufferParams();
params().compressed = !params().compressed;
break;
 
case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
-   undo().recordUndoBufferParams(CursorData());
+   undo().recordUndoBufferParams();
params().output_sync = !params().output_sync;
break;
 
case LFUN_BUFFER_ANONYMIZE: {
-   undo().recordUndoFullBuffer(CursorData());
+   undo().recordUndoFullBuffer();
CursorData cur(doc_iterator_begin(this));
for ( ; cur ; cur.forwardPar())
cur.paragraph().anonymize();
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index c1e55954b5..c53a7307bf 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -647,7 +647,7 @@ void CursorData::recordUndoInset(Inset const * inset) const
 
 void CursorData::recordUndoFullBuffer() const
 {
-   buffer()->undo().recordUndoFullBuffer(*this);
+   buffer()->undo().recordUndoFullBuffer();
 }
 
 
diff --git a/src/Undo.cpp b/src/Undo.cpp
index ddc7025e1c..8dc32b 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -672,17 +672,24 @@ void Undo::recordUndoBufferParams(CursorData const & cur)
 }
 
 
-void Undo::recordUndoFullBuffer(CursorData const & cur)
+void Undo::recordUndoBufferParams()
+{
+   d->recordUndoBufferParams(CursorData());
+}
+
+
+void Undo::recordUndoFullBuffer()
 {
// This one may happen outside of the main undo group, so we
// put it in its own subgroup to avoid complaints.
beginUndoGroup();
d->recordUndo(ATOMIC_UNDO, doc_iterator_begin(&d->buffer_),
- 0, d->buffer_.paragraphs().size() - 1, cur);
-   d->recordUndoBufferParams(cur);
+ 0, d->buffer_.paragraphs().size() - 1, CursorData());
+   d->recordUndoBufferParams(CursorData());
endUndoGroup();
 }
 
+
 

[LyX/master] Add a constructor of UndoGroupHelper that uses a CursorData parameter

2024-06-20 Thread Jean-Marc Lasgouttes
commit e7b1ee47eadc35b75862baf6127a5207412bcf36
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 20 17:52:19 2024 +0200

Add a constructor of UndoGroupHelper that uses a CursorData parameter

This aloows to se the the `before' cursor of the undo group.

Not used for now.
---
 src/Undo.cpp | 16 
 src/Undo.h   |  6 ++
 2 files changed, 22 insertions(+)

diff --git a/src/Undo.cpp b/src/Undo.cpp
index 8dc32b..80dff34baa 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -704,6 +704,12 @@ UndoGroupHelper::UndoGroupHelper(Buffer * buf) : d(new 
UndoGroupHelper::Impl)
 }
 
 
+UndoGroupHelper::UndoGroupHelper(CursorData & cur) : d(new 
UndoGroupHelper::Impl)
+{
+   resetBuffer(cur);
+}
+
+
 UndoGroupHelper::~UndoGroupHelper()
 {
for (Buffer * buf : d->buffers_)
@@ -712,6 +718,7 @@ UndoGroupHelper::~UndoGroupHelper()
delete d;
 }
 
+
 void UndoGroupHelper::resetBuffer(Buffer * buf)
 {
if (buf && d->buffers_.count(buf) == 0) {
@@ -721,4 +728,13 @@ void UndoGroupHelper::resetBuffer(Buffer * buf)
 }
 
 
+void UndoGroupHelper::resetBuffer(CursorData & cur)
+{
+   if (!cur.empty() && d->buffers_.count(cur.buffer()) == 0) {
+   d->buffers_.insert(cur.buffer());
+   cur.buffer()->undo().beginUndoGroup(cur);
+   }
+}
+
+
 } // namespace lyx
diff --git a/src/Undo.h b/src/Undo.h
index b6d84569c5..32be7d2ede 100644
--- a/src/Undo.h
+++ b/src/Undo.h
@@ -140,12 +140,18 @@ class UndoGroupHelper {
 public:
// Begin a new undo group for buffer \c buf.
UndoGroupHelper(Buffer * buf);
+   // Begin an undo group for the buffer of \c cur with the the
+   // `before' cursor set to \c cur.
+   UndoGroupHelper(CursorData & cur);
// End all active undo groups.
~UndoGroupHelper();
 
// Begin if needed an undo group for buffer \c buf.
void resetBuffer(Buffer * buf);
 
+   // Begin if needed an undo group for the buffer of \c cur with the
+   // the `before' cursor set to \c cur.
+   void resetBuffer(CursorData & cur);
 private:
class Impl;
Impl * const d;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix cursor when undoing accept/reject all changes

2024-06-20 Thread Jean-Marc Lasgouttes
commit c4531741a9184fa0684d3b1d25c72877bf623da8
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 20 18:00:13 2024 +0200

Fix cursor when undoing accept/reject all changes

Before this change, the whole document would remain selected.

This relies on the new UndoGroupHelper constructor introduced at e7b1ee47.
---
 src/BufferView.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index b55beb34a7..70d81567c1 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1686,6 +1686,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
break;
 
case LFUN_ALL_CHANGES_ACCEPT: {
+   UndoGroupHelper helper(cur);
// select complete document
cur.reset();
cur.selHandle(true);
@@ -1705,6 +1706,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
}
 
case LFUN_ALL_CHANGES_REJECT: {
+   UndoGroupHelper helper(cur);
// select complete document
cur.reset();
cur.selHandle(true);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Rename DocumentCLass:plainInsetLayout() to InsetLayout::undefined()

2024-06-20 Thread Jean-Marc Lasgouttes
commit 608929a857de98c0ca7af4edb79e5c0a017ede35
Author: Jean-Marc Lasgouttes 
Date:   Thu Jun 20 18:26:50 2024 +0200

Rename DocumentCLass:plainInsetLayout() to InsetLayout::undefined()

This makes the code easier to understand.
---
 src/CutAndPaste.cpp| 4 ++--
 src/TextClass.cpp  | 8 +---
 src/TextClass.h| 2 --
 src/insets/Inset.cpp   | 4 ++--
 src/insets/InsetFlex.cpp   | 6 +++---
 src/insets/InsetLayout.cpp | 6 ++
 src/insets/InsetLayout.h   | 3 +++
 7 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp
index abed1567d7..26cfc9bec8 100644
--- a/src/CutAndPaste.cpp
+++ b/src/CutAndPaste.cpp
@@ -883,10 +883,10 @@ void switchBetweenClasses(DocumentClassConstPtr oldone,
docstring const layoutName = iit->layoutName();
docstring const & n = 
newone->insetLayout(layoutName).name();
bool const is_undefined = n.empty() ||
-   n == DocumentClass::plainInsetLayout().name();
+   n == InsetLayout::undefined().name();
docstring const & oldn = 
oldone->insetLayout(layoutName).name();
bool const was_undefined = oldn.empty() ||
-   oldn == 
DocumentClass::plainInsetLayout().name();
+   oldn == InsetLayout::undefined().name();
if (!is_undefined || was_undefined)
continue;
 
diff --git a/src/TextClass.cpp b/src/TextClass.cpp
index b9c75259b4..8816470552 100644
--- a/src/TextClass.cpp
+++ b/src/TextClass.cpp
@@ -1869,13 +1869,7 @@ InsetLayout const & DocumentClass::insetLayout(docstring 
const & name) const
n = n.substr(0, i);
}
// Layout "name" not found.
-   return plainInsetLayout();
-}
-
-
-InsetLayout const & DocumentClass::plainInsetLayout() {
-   static const InsetLayout plain_insetlayout_;
-   return plain_insetlayout_;
+   return InsetLayout::undefined();
 }
 
 
diff --git a/src/TextClass.h b/src/TextClass.h
index 5a7f4c45bd..7626dc329d 100644
--- a/src/TextClass.h
+++ b/src/TextClass.h
@@ -448,8 +448,6 @@ public:
/// If that doesn't work either, an empty object returns (shouldn't
/// happen).  -- Idea JMarc, comment MV
InsetLayout const & insetLayout(docstring const & name) const;
-   /// a plain inset layout for use as a default
-   static InsetLayout const & plainInsetLayout();
/// add a new layout \c name if it does not exist in layoutlist_
/// \return whether we had to add one.
bool addLayoutIfNeeded(docstring const & name) const;
diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp
index 165df39657..b949f9c989 100644
--- a/src/insets/Inset.cpp
+++ b/src/insets/Inset.cpp
@@ -241,7 +241,7 @@ docstring Inset::layoutName() const
 InsetLayout const & Inset::getLayout() const
 {
if (!buffer_)
-   return DocumentClass::plainInsetLayout();
+   return InsetLayout::undefined();
return buffer().params().documentClass().insetLayout(layoutName());
 }
 
@@ -622,7 +622,7 @@ bool Inset::covers(BufferView const & bv, int x, int y) 
const
 bool Inset::undefined() const
 {
docstring const & n = getLayout().name();
-   return n.empty() || n == DocumentClass::plainInsetLayout().name();
+   return n.empty() || n == InsetLayout::undefined().name();
 }
 
 
diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp
index 2a8af67fae..ee7f18b029 100644
--- a/src/insets/InsetFlex.cpp
+++ b/src/insets/InsetFlex.cpp
@@ -49,7 +49,7 @@ InsetFlex::InsetFlex(InsetFlex const & in)
 InsetLayout const & InsetFlex::getLayout() const
 {
if (!buffer_)
-   return DocumentClass::plainInsetLayout();
+   return InsetLayout::undefined();
 
DocumentClass const & dc = buffer().params().documentClass();
docstring const dname = from_utf8(name_);
@@ -102,7 +102,7 @@ bool InsetFlex::getStatus(Cursor & cur, FuncRequest const & 
cmd,
InsetLyXType const type =
translateLyXType(to_utf8(cmd.argument()));
if (il.lyxtype() == type
-   || (il.name() == 
DocumentClass::plainInsetLayout().name()
+   || (il.name() == InsetLayout::undefined().name()
&& type == InsetLyXType::CHARSTYLE)) {
FuncRequest temp_cmd(cmd.action());
return InsetCollapsible::getStatus(cur, 
temp_cmd, flag);
@@ -127,7 +127,7 @@ void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
translateLyXType(to_utf8(cmd.argument())

[LyX/master] redoParagraph: avoid extra cache accesses

2024-06-21 Thread Jean-Marc Lasgouttes
commit 45dce93af73845471ca986731fd31da468a42360
Author: Jean-Marc Lasgouttes 
Date:   Fri Jun 21 17:02:13 2024 +0200

redoParagraph: avoid extra cache accesses

To this end, CoordCacheBase::add returns true when a change was made.
This uses the return value of std::unordered_map::insert.
---
 src/CoordCache.h| 18 +++---
 src/TextMetrics.cpp |  5 +
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/CoordCache.h b/src/CoordCache.h
index 666a3e71c7..fbe91e87c6 100644
--- a/src/CoordCache.h
+++ b/src/CoordCache.h
@@ -75,9 +75,21 @@ public:
data_[thing].pos = Point(x, y);
}
 
-   void add(T const * thing, Dimension const & dim)
-   {
-   data_[thing].dim = dim;
+   // this returns true if a change is done
+   bool add(T const * thing, Dimension const & dim)
+   {
+   Geometry g;
+   g.dim = dim;
+   auto const result = data_.insert(std::make_pair(thing, g));
+   // did a new entry get inserted?
+   if (result.second)
+   return true;
+   // otherwise, if the existing value is different, update it
+   else if (result.first->second.dim != dim) {
+   result.first->second.dim = dim;
+   return true;
+   }
+   return false;
}
 
Geometry & geometry(T const * thing)
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 0ae75f4355..a63adf5ebb 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -605,10 +605,7 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool 
const align_rows)
*/
extrawidths[e.inset] = mi.extrawidth;
 
-   if (!insetCache.has(e.inset) || insetCache.dim(e.inset) != dim) 
{
-   insetCache.add(e.inset, dim);
-   changed = true;
-   }
+   changed |= insetCache.add(e.inset, dim);
}
 
// Transform the paragraph into a single row containing all the 
elements.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] fix comment

2024-06-25 Thread Jean-Marc Lasgouttes
commit e653907b84298d09d18dab330758a0808b148654
Author: Jean-Marc Lasgouttes 
Date:   Tue Jun 25 12:01:05 2024 +0200

fix comment
---
 src/mathed/MathStream.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index ca7543101f..04c7cb507e 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -404,7 +404,7 @@ public:
}
/// Returns the current math style in the stream.
const MathStyle & getFontMathStyle() const { return font_math_style_; }
-   /// Returns the current math style in the stream.
+   /// Sets the current math style in the stream.
void setFontMathStyle(const MathStyle style) { font_math_style_ = 
style; }
 private:
///
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


Re: [LyX/master] Cmake build: Require std >= 17 for compilation of QT6

2024-06-25 Thread Jean-Marc Lasgouttes

Le 25/06/2024 à 13:45, Kornel Benko a écrit :

commit 5ee53450bbef83b60edde401b075f2e1d51ce5b7
Author: Kornel Benko 
Date:   Tue Jun 25 13:50:32 2024 +0200

 Cmake build: Require std >= 17 for compilation of QT6



else()
+   if (CMAKE_CXX_STANDARD LESS 11)
+   message(STATUS "CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
+   message(FATAL_ERROR "QT6 compilation requires at least 
CXX_STANDARD = 11")
+   endif()


I guess you meant QT5 here.

JMarc

--
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Avoid crash when InsetBibitem::updateCommand shows a dialog

2024-07-02 Thread Jean-Marc Lasgouttes
commit c84c59eaecf19b1eb8227f9aadc7f5be187b3856
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 2 14:49:34 2024 +0200

Avoid crash when InsetBibitem::updateCommand shows a dialog

This is one of the places where a dialog is shown (indicating that
some bibtems have been renamed) while the metrics are not up to date.
Then a draw operation can be triggered too early and a crash can ensue.

Use ad-hoc solution for this case and use Buffer::setBusy(). The
Alert::warning helper cannot really do that since it doe snot know the
current buffer.
---
 src/insets/InsetBibitem.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp
index 343770e14d..beb775bc14 100644
--- a/src/insets/InsetBibitem.cpp
+++ b/src/insets/InsetBibitem.cpp
@@ -95,9 +95,11 @@ void InsetBibitem::updateCommand(docstring const & new_key, 
bool)
++i;
key = new_key + '-' + convert(i);
}
+   buffer().setBusy(true);
frontend::Alert::warning(_("Keys must be unique!"),
bformat(_("The key %1$s already exists,\n"
"it will be changed to %2$s."), new_key, key));
+   buffer().setBusy(false);
}
setParam("key", key);
buffer().invalidateBibinfoCache();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Make sure paragraph positions are updated when scrolling

2024-07-02 Thread Jean-Marc Lasgouttes
commit 6e0ea4269ae792225bb4e0d0f0ffcb3236c3c5c9
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 00:22:55 2024 +0200

Make sure paragraph positions are updated when scrolling

Sometimes quick selection-scrolling could cause a crash because the
position of some paragraphs is not computed. To fix that, in
BufferView::showCursor, make sure that the metrics are always kept
clean using updateMetrics(false), which is lighweight.

As a consequence, the 'update' parameter of showCursor and
scrollDocView is not needed anymore. Its removal is mechanical and
accounts for most of this commit.

The only other significant change is that, when creating synthetic
mouse events and relying on scroll() for small moves, the full metrics
recomputation is replaced by the lighter version.

More work is still to come on this code, but this should be going in
the right direction.
---
 src/BufferView.cpp   | 19 +--
 src/BufferView.h |  5 ++---
 src/frontends/qt/GuiWorkArea.cpp |  6 +++---
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 70d81567c1..67aa4944f6 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -763,7 +763,7 @@ Inset const * BufferView::mathContextMenu(InsetMathNest 
const * inset,
 }
 
 
-void BufferView::scrollDocView(int const pixels, bool update)
+void BufferView::scrollDocView(int const pixels)
 {
// The scrollbar values are relative to the top of the screen, 
therefore the
// offset is equal to the target value.
@@ -786,7 +786,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
// cut off at the top
if (pixels <= d->scrollbarParameters_.min) {
DocIterator dit = doc_iterator_begin(&buffer_);
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
LYXERR(Debug::SCROLLING, "scroll to top");
return;
}
@@ -795,7 +795,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
if (pixels >= d->scrollbarParameters_.max) {
DocIterator dit = doc_iterator_end(&buffer_);
dit.backwardPos();
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
LYXERR(Debug::SCROLLING, "scroll to bottom");
return;
}
@@ -814,14 +814,14 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
// It seems we didn't find the correct pit so stay on the safe 
side and
// scroll to bottom.
LYXERR0("scrolling position not found!");
-   scrollDocView(d->scrollbarParameters_.max, update);
+   scrollDocView(d->scrollbarParameters_.max);
return;
}
 
DocIterator dit = doc_iterator_begin(&buffer_);
dit.pit() = i;
LYXERR(Debug::SCROLLING, "pixels = " << pixels << " -> scroll to pit " 
<< i);
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
 }
 
 
@@ -1007,20 +1007,19 @@ int BufferView::workWidth() const
 
 void BufferView::recenter()
 {
-   showCursor(d->cursor_, SCROLL_CENTER, true);
+   showCursor(d->cursor_, SCROLL_CENTER);
 }
 
 
 void BufferView::showCursor()
 {
-   showCursor(d->cursor_, SCROLL_VISIBLE, true);
+   showCursor(d->cursor_, SCROLL_VISIBLE);
 }
 
 
-void BufferView::showCursor(DocIterator const & dit, ScrollType how,
-   bool update)
+void BufferView::showCursor(DocIterator const & dit, ScrollType how)
 {
-   if (scrollToCursor(dit, how) && update)
+   if (scrollToCursor(dit, how))
processUpdateFlags(Update::ForceDraw);
 }
 
diff --git a/src/BufferView.h b/src/BufferView.h
index bfd523aa57..0b9ade2f3b 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -219,8 +219,7 @@ public:
/// This method will automatically scroll and update the BufferView
/// (metrics+drawing) if needed.
/// \param how Use this scroll strategy
-   /// \param force If true, update screen after scrolling
-   void showCursor(DocIterator const & dit, ScrollType how, bool update);
+   void showCursor(DocIterator const & dit, ScrollType how);
/// Scroll to the cursor.
/// \param how Use this scroll strategy
/// \return true if screen was scrolled
@@ -232,7 +231,7 @@ public:
/// scroll document by the given number of pixels.
int scroll(int pixels);
/// Scroll the view by a number of pixels.
-   void scrollDocView(int pixels, bool update);
+   void scrollDocView(int pixels);
/// Set the cursor position based on the scrollbar one.
voi

[LyX/master] fix comment

2024-07-03 Thread Jean-Marc Lasgouttes
commit 29597f600ee84425d2832cc7598752405787c53e
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 15:42:54 2024 +0200

fix comment
---
 src/insets/Inset.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/Inset.h b/src/insets/Inset.h
index 04eb42ce73..ea8f00e38c 100644
--- a/src/insets/Inset.h
+++ b/src/insets/Inset.h
@@ -260,7 +260,7 @@ public:
/// Label font
virtual FontInfo getLabelfont() const;
 
-   /// Where should we go when we press the up or down cursor key?
+   /// Move the cursor vertically into inset; returns false when not 
possible.
virtual bool idxUpDown(Cursor & cur, bool up) const;
/// Move one cell backwards
virtual bool idxBackward(Cursor &) const { return false; }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] comment

2024-07-03 Thread Jean-Marc Lasgouttes
commit a7204098cfd3839110724ed254a73d338e9eb418
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 16:23:30 2024 +0200

comment
---
 src/Cursor.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index c53a7307bf..76f4be407e 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -2000,7 +2000,7 @@ bool Cursor::upDownInMath(bool up)
}
}
 
-   // try to find an inset that knows better then we,
+   // try to find an inset that knows better than we do
if (inset().idxUpDown(*this, up)) {
//lyxerr << "idxUpDown triggered" << endl;
// try to find best position within this inset
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Remove useless SinglePar update when scrolling in text

2024-07-03 Thread Jean-Marc Lasgouttes
commit 2bdd691130e5507fc5cc2ca81e71eef189e90fc5
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 17:31:38 2024 +0200

Remove useless SinglePar update when scrolling in text

Using SinglePar does not majke sense here since the paragraph is not
modified and it might even not have a position yet.

This fixes a crash in BufferView::singleParUpdate, which is not
prepared (yet) to such situations.
---
 src/Text.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 6ffd5f894d..2a5ff9f0b8 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -5344,7 +5344,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
bvcur.setCurrentFont();
if (cur.top() == old) {
// We didn't move one iota, so no need to update the 
screen.
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
//cur.noScreenUpdate();
return;
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Make BufferView::singeParUpdate more robust

2024-07-03 Thread Jean-Marc Lasgouttes
commit 89ab9eb569ec0eea87d9a8c269eb87507934e1c5
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 1 23:56:33 2024 +0200

Make BufferView::singeParUpdate more robust

In some cases, it might happen that this method is called in cases
where no metrics is know for the current paragraph or where its
position is not set.

Take care of these cases to avoid assertions.

Remove setting of inset positions in the method, but make sure that
updateMetrics(false) is always called to get everything right.

In the new code, updateMetrics(bool) os the method that sets
everything right with minimal effort.
---
 src/BufferView.cpp | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 67aa4944f6..ce315a6f49 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -567,7 +567,9 @@ void BufferView::processUpdateFlags(Update::flags flags)
 * correct metrics at cursor position.
 */
else if ((flags & Update::SinglePar) && !(flags & Update::ForceDraw)) {
-   if (!singleParUpdate())
+   if (singleParUpdate())
+   updateMetrics(false);
+   else
updateMetrics(true);
}
else if (flags & Update::ForceDraw)
@@ -3150,6 +3152,10 @@ bool BufferView::singleParUpdate()
if (d->inlineCompletionPos_.fixIfBroken())
d->inlineCompletionPos_ = DocIterator();
 
+   if (!tm.contains(pit)) {
+   LYXERR(Debug::PAINTING, "SinglePar optimization failed: no 
known metrics");
+   return false;
+   }
/* Try to rebreak only the paragraph containing the cursor (if
 * this paragraph contains insets etc., rebreaking will
 * recursively descend). We need a full redraw if either
@@ -3167,18 +3173,19 @@ bool BufferView::singleParUpdate()
tm.redoParagraph(pit);
ParagraphMetrics & pm = tm.parMetrics(pit);
if (pm.height() != old_dim.height()
-   || (pm.width() != old_dim.width() && old_dim.width() == 
tm.width())) {
+|| (pm.width() != old_dim.width() && old_dim.width() == 
tm.width())) {
// Paragraph height or width has changed so we cannot proceed
// to the singlePar optimisation.
-   LYXERR(Debug::PAINTING, "SinglePar optimization failed.");
+   LYXERR(Debug::PAINTING, "SinglePar optimization failed: 
paragraph metrics changed");
return false;
}
// Since position() points to the baseline of the first row, we
// may have to update it. See ticket #11601 for an example where
// the height does not change but the ascent does.
-   pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
-
-   tm.updatePosCache(pit);
+   if (pm.hasPosition())
+   pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
+   else
+   LYXERR0("SinglePar optimization succeeded, but no position to 
update");
 
LYXERR(Debug::PAINTING, "\ny1: " << pm.top() << " y2: " << pm.bottom()
<< " pit: " << pit << " singlepar: 1");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Force a Buffer * argument to math insets constructor

2024-07-05 Thread Jean-Marc Lasgouttes
commit b39fb173167cbe4d5e2c72d0dcdb74adae7c26a6
Author: Jean-Marc Lasgouttes 
Date:   Wed Apr 24 15:07:15 2024 +0200

Force a Buffer * argument to math insets constructor

Make sure that math insets have a proper buffer. To this end, make the
Buffer* parameter of InsetMath mandatory and fix the compilation
errors that ensue.

(cherry picked from commit c013799887eb5c330f3cff4d51542028683fe1bb)
---
 src/Cursor.cpp|  6 ++---
 src/mathed/InsetMath.h|  2 +-
 src/mathed/InsetMathBig.cpp   |  4 ++--
 src/mathed/InsetMathBig.h |  2 +-
 src/mathed/InsetMathBrace.cpp |  4 ++--
 src/mathed/InsetMathBrace.h   |  2 +-
 src/mathed/InsetMathChar.cpp  |  4 ++--
 src/mathed/InsetMathChar.h|  2 +-
 src/mathed/InsetMathDots.cpp  |  4 ++--
 src/mathed/InsetMathDots.h|  2 +-
 src/mathed/InsetMathExInt.cpp |  4 ++--
 src/mathed/InsetMathGrid.cpp  |  6 ++---
 src/mathed/InsetMathHull.cpp  |  2 +-
 src/mathed/InsetMathKern.cpp  | 11 +
 src/mathed/InsetMathKern.h|  6 ++---
 src/mathed/InsetMathMacro.cpp |  6 +++--
 src/mathed/InsetMathMacroArgument.cpp |  4 ++--
 src/mathed/InsetMathMacroArgument.h   |  5 ++--
 src/mathed/InsetMathMacroTemplate.cpp | 43 ++-
 src/mathed/InsetMathNest.cpp  | 36 ++---
 src/mathed/InsetMathNumber.cpp|  4 ++--
 src/mathed/InsetMathNumber.h  |  2 +-
 src/mathed/InsetMathSpace.cpp | 12 +-
 src/mathed/InsetMathSpace.h   |  6 ++---
 src/mathed/InsetMathSpecialChar.cpp   |  4 ++--
 src/mathed/InsetMathSpecialChar.h |  2 +-
 src/mathed/InsetMathString.cpp|  4 ++--
 src/mathed/InsetMathString.h  |  2 +-
 src/mathed/InsetMathSymbol.cpp| 12 +-
 src/mathed/InsetMathSymbol.h  |  6 ++---
 src/mathed/InsetMathUnknown.cpp   |  4 ++--
 src/mathed/InsetMathUnknown.h |  2 +-
 src/mathed/MathData.cpp   |  4 ++--
 src/mathed/MathExtern.cpp |  4 ++--
 src/mathed/MathFactory.cpp| 16 ++---
 src/mathed/MathParser.cpp | 42 +-
 36 files changed, 142 insertions(+), 139 deletions(-)

diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 0e1c3ded55..45ae34c4b2 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -1492,7 +1492,7 @@ void Cursor::insert(char_type c)
LASSERT(!empty(), return);
if (inMathed()) {
cap::selClearOrDel(*this);
-   insert(new InsetMathChar(c));
+   insert(new InsetMathChar(buffer(), c));
} else {
text()->insertChar(*this, c);
}
@@ -1576,7 +1576,7 @@ void Cursor::niceInsert(MathAtom const & t)
docstring const name = t->asMacro()->name();
MacroData const * data = buffer()->getMacro(name);
if (data && data->numargs() - data->optionals() > 0) {
-   plainInsert(MathAtom(new InsetMathBrace(ar)));
+   plainInsert(MathAtom(new InsetMathBrace(buffer(), ar)));
posBackward();
}
}
@@ -1836,7 +1836,7 @@ bool Cursor::macroModeClose(bool cancel)
// finally put the macro argument behind, if needed
if (macroArg) {
if (selection.size() > 1 || selection[0]->asScriptInset())
-   plainInsert(MathAtom(new InsetMathBrace(selection)));
+   plainInsert(MathAtom(new InsetMathBrace(buffer(), 
selection)));
else
insert(selection);
}
diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h
index 7ea8a7cfc1..34484028bb 100644
--- a/src/mathed/InsetMath.h
+++ b/src/mathed/InsetMath.h
@@ -120,7 +120,7 @@ class ReplaceData;
 class InsetMath : public Inset {
 public:
///
-   explicit InsetMath(Buffer * buf = 0) : Inset(buf) {}
+   explicit InsetMath(Buffer * buf) : Inset(buf) {}
/// identification as math inset
InsetMath * asInsetMath() override { return this; }
/// identification as math inset
diff --git a/src/mathed/InsetMathBig.cpp b/src/mathed/InsetMathBig.cpp
index 4972911b75..93661e1f56 100644
--- a/src/mathed/InsetMathBig.cpp
+++ b/src/mathed/InsetMathBig.cpp
@@ -28,8 +28,8 @@
 namespace lyx {
 
 
-InsetMathBig::InsetMathBig(docstring const & name, docstring const & delim)
-   : name_(name), delim_(delim)
+InsetMathBig::InsetMathBig(Buffer * buf, docstring const & name, docstring 
const & delim)
+   : InsetMath(buf), name_(name), delim_(delim)
 {}
 
 
diff --git a/src/mathed/InsetMathBig.h b/src/mathed/InsetMathBig.h
index 09f04a6f78..5f6793 100644
--- a/src/mathed/InsetMathBig.h
+++ b/src/mathed/InsetMathBig.h
@@ -21,7 +21,7 @@ namespace

[LyX/2.4.x] Force a Buffer * argument to MathData constructor

2024-07-05 Thread Jean-Marc Lasgouttes
commit 6b546613173e9b562c7d8648e798d5cfbb44eadb
Author: Jean-Marc Lasgouttes 
Date:   Wed Apr 24 12:04:23 2024 +0200

Force a Buffer * argument to MathData constructor

In order to ensure that MathData objects have a valid buffer, the
default MathData() constructor is deleted. This means that a buffer
shall be specified for each MathData object created.

This is fairly mechanical, actually. In particular, in most
InsetMathXxx cases, in MathData and in MathParser, the available
buffer_ member is used.

More specific cases:
- lyxfind.cpp takes the buffer from the Cursor

- calls to vector::resize take an additional
  MathData(buffer_) parameter. There are cases where resize actually
  remove cells, and in this case clear() or even erase() have been
  used.

- in InsetMathMacroTemplate, the optional parameters of the
  constructors cannot be allowed anymore (a default value cannot
  depend on another parameter). Therefore there a now two constructors
  instead.

- in MathAutoCorrect.cpp, the MathData objects are not bound to a
  buffer, so that std::nullptr is used instead.

- in MathExtern, use a buffer when one is specified, std::nulptr
  instead.

(cherry picked from commit 57d713065545ac53a62a641d12a8b8c2c62c22fc)
---
 src/lyxfind.cpp   |  6 ++--
 src/mathed/InsetMath.cpp  |  2 +-
 src/mathed/InsetMathGrid.cpp  |  2 +-
 src/mathed/InsetMathHull.cpp  |  8 +++---
 src/mathed/InsetMathMacro.cpp | 22 +++---
 src/mathed/InsetMathMacroTemplate.cpp | 12 ++--
 src/mathed/InsetMathMacroTemplate.h   |  8 --
 src/mathed/InsetMathNest.cpp  | 10 +++
 src/mathed/InsetMathRef.cpp   |  6 ++--
 src/mathed/InsetMathScript.cpp|  4 +--
 src/mathed/InsetMathSpace.cpp |  2 +-
 src/mathed/MathAutoCorrect.cpp|  4 +--
 src/mathed/MathData.cpp   |  8 +++---
 src/mathed/MathData.h |  2 +-
 src/mathed/MathExtern.cpp | 20 ++---
 src/mathed/MathParser.cpp | 54 +--
 16 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index fd08a596c4..aae8b30bff 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -4162,7 +4162,7 @@ docstring stringifyFromCursor(DocIterator const & cur, 
int len)
(( len == -1 || cs.pos() + len > int(md.size()))
 ? md.end()
 : md.begin() + cs.pos() + len );
-   MathData md2;
+   MathData md2(cur.buffer());
for (MathData::const_iterator it = md.begin() + cs.pos(); it != 
it_end; ++it)
md2.push_back(*it);
docstring res = from_utf8(latexNamesToUtf8(asString(md2), 
false));
@@ -4228,7 +4228,7 @@ docstring latexifyFromCursor(DocIterator const & cur, int 
len)
((len == -1 || cs.pos() + len > int(md.size()))
 ? md.end()
 : md.begin() + cs.pos() + len);
-   MathData md2;
+   MathData md2(cur.buffer());
for (MathData::const_iterator it = md.begin() + cs.pos();
 it != it_end; ++it)
md2.push_back(*it);
@@ -4892,7 +4892,7 @@ bool findAdv(BufferView * bv, FindAndReplaceOptions & opt)
MathData md = cs.cell();
int len = -1;
MathData::const_iterator it_end 
= md.end();
-   MathData md2;
+   MathData md2(cur.buffer());
// Start the check with one 
character before actual cursor position
for (MathData::const_iterator 
it = md.begin() + cs.pos() - 1;
it != it_end; ++it)
diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index e072b487a0..5aea5716ce 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -88,7 +88,7 @@ MathData & InsetMath::cell(idx_type)
 
 MathData const & InsetMath::cell(idx_type) const
 {
-   static MathData dummyCell;
+   static MathData dummyCell(const_cast(&buffer()));
LYXERR0("I don't have any cell");
return dummyCell;
 }
diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 3adec0ca2b..05242aca00 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -835,7 +835,7 @@ void InsetMathGrid::addCol(col_type newcol)
 {
const col_type nc = ncols();
const row_type n

[LyX/2.4.x] Remove setBuffer call in Cursor::push.

2024-07-05 Thread Jean-Marc Lasgouttes
commit 46d1d6e0d384bea969a55426bef22e03bc231bf8
Author: Richard Kimberly Heck 
Date:   Sat Jun 1 12:06:13 2024 -0400

Remove setBuffer call in Cursor::push.

This is potentially slow. It also should be unnecessary after
some of JMarc's recent commits. See bug #13050.

(cherry picked from commit 66cfc6af3c764b6923aae6c134c43c2155317c6a)
---
 src/Cursor.cpp | 3 ++-
 status.24x | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 45ae34c4b2..b235200db9 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -903,7 +903,8 @@ void Cursor::pop()
 void Cursor::push(Inset & inset)
 {
push_back(CursorSlice(inset));
-   inset.setBuffer(*buffer());
+   // See bug #13050
+   // inset.setBuffer(*buffer());
 }
 
 
diff --git a/status.24x b/status.24x
index e982adeca2..b6304efe40 100644
--- a/status.24x
+++ b/status.24x
@@ -52,6 +52,8 @@ What's new
 - Fix bug where the dialog asking for saving unapplied changes on buffer change
   popped up twice, or sometimes not at all (bug 12954).
 
+- Improve performance when selecting text on less powerful systems (bug 13050).
+
 
 * INTERNALS
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix display of page references when language is not specified

2024-07-05 Thread Jean-Marc Lasgouttes
commit 6f6d9b631d110fb71fcd99351b4f40d58451700a
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 5 16:10:17 2024 +0200

Fix display of page references when language is not specified

Using translateIfPossible with null language does not make sense (and
gives an error on console).

Using translateIfPossible there actually does not make sense at all: it
is only for string from layout files that may already be translated.

We use the buffer language when no language has been specified. It
might have been better to use the GUI language.

A consequence of the commit is that "elsewhere" will be in the po
files and now really translatable ;)
---
 src/insets/InsetRef.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index c1ea8e4a93..11ab35e219 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -32,6 +32,7 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
+#include "support/Messages.h"
 #include "support/textutils.h"
 
 using namespace lyx::support;
@@ -399,8 +400,8 @@ docstring InsetRef::displayString(docstring const & ref, 
string const & cmd,
display_string = value;
else if (cmd == "pageref" || cmd == "vpageref") {
// normally would be "on page #", but we have no pages.
-   display_string =
-   translateIfPossible(from_ascii("elsewhere"), 
language);
+   display_string = language.empty() ? 
buffer().B_("elsewhere")
+   : getMessages(language).get("elsewhere");
} else if (cmd == "eqref")
display_string = '(' + value + ')';
else if (cmd == "formatted") {
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 145af7c2: remove unused method

2024-07-10 Thread Jean-Marc Lasgouttes
commit 8bc3799b354908f22270f9d96b2cce43ebd96d66
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 10 13:42:57 2024 +0200

Fixup 145af7c2: remove unused method

TextMetrics::firstVisible(), introduced in this commit, is actually unused.
---
 src/TextMetrics.cpp | 11 ---
 src/TextMetrics.h   |  2 --
 2 files changed, 13 deletions(-)

diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index a63adf5ebb..6ba15b0251 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -131,17 +131,6 @@ pair 
TextMetrics::first() const
 }
 
 
-pair TextMetrics::firstVisible() const
-{
-   // This only works in the main text, I think (bottom > 0)
-   LASSERT(text_->isMainText(), return first());
-   auto it = find_if(par_metrics_.begin(), par_metrics_.end(),
- [] (ParMetricsCache::value_type const & p) {
- return p.second.hasPosition() && 
p.second.bottom() > 0;
- });
-   return make_pair(it->first, &it->second);
-}
-
 pair TextMetrics::last() const
 {
LBUFERR(!par_metrics_.empty());
diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index 1a19b42939..d5606b610a 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -50,8 +50,6 @@ public:
///
std::pair first() const;
///
-   std::pair firstVisible() const;
-   ///
std::pair last() const;
/// is this row the last in the text?
bool isLastRow(Row const & row) const;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fix display of page references when language is not specified

2024-07-10 Thread Jean-Marc Lasgouttes
commit f64349db8d544bbce835d958371a39acf67adf41
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 5 16:10:17 2024 +0200

Fix display of page references when language is not specified

Using translateIfPossible with null language does not make sense (and
gives an error on console).

Using translateIfPossible there actually does not make sense at all: it
is only for string from layout files that may already be translated.

We use the GUI language when no language has been specified (this is
different and probably safer than what is done in master).

A consequence of the commit is that "elsewhere" will be in the po
files and now really translatable ;)

(cherry picked from commit 6f6d9b631d110fb71fcd99351b4f40d58451700a)
---
 src/insets/InsetRef.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index c1ea8e4a93..6021a239d2 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -32,6 +32,7 @@
 #include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
+#include "support/Messages.h"
 #include "support/textutils.h"
 
 using namespace lyx::support;
@@ -399,8 +400,8 @@ docstring InsetRef::displayString(docstring const & ref, 
string const & cmd,
display_string = value;
else if (cmd == "pageref" || cmd == "vpageref") {
// normally would be "on page #", but we have no pages.
-   display_string =
-   translateIfPossible(from_ascii("elsewhere"), 
language);
+   display_string = language.empty() ? _("elsewhere")
+   : getMessages(language).get("elsewhere");
} else if (cmd == "eqref")
display_string = '(' + value + ')';
else if (cmd == "formatted") {
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Handle metrics of not visible paragraphs

2024-07-10 Thread Jean-Marc Lasgouttes
commit 10b8861d103490e4598582608ac60407d6b0b711
Author: Jean-Marc Lasgouttes 
Date:   Fri May 17 15:42:08 2024 +0200

Handle metrics of not visible paragraphs

The code is not ready for situations where some paragraphs that are
not visible have metrics available.

In PararagraphMetrics, some methods are added to be able to handle the
fact that paragraphs have or do not have a position.

In TextMetrics, a new method returns the first visible paragraph.

Finally, in BufferView::updateMetrics, the paragraphs' positions are
reset (in the case where everything is not cleared) and some care is
taken to skip the ones that are not relevant.

The assumption outside of this method is that all the paragraphs that
are in the TextMetrics are visible (we are talking about top-level
TextMetrics here). This could be changed (in order to avoid
recomputing paragraph metrics), but the cost is high in terms of
complexity and it is not clear that the gain in terms of performance
would be important.

NOTE: contrary to the code in master which returns npos = -1, this
code still returns -1 when the position of a paragraph is unknown.

(cherry picked from commit 145af7c2ac1eb2c5ec5102a7a11cb740be7b3c43)
(cherry picked from commit 05bb851adfb733c942d243800d7151c6b9194645)
(cherry picked from commit 8bc3799b354908f22270f9d96b2cce43ebd96d66)
---
 src/BufferView.cpp   | 11 +++
 src/ParagraphMetrics.cpp | 24 ++--
 src/ParagraphMetrics.h   |  6 +-
 src/TextMetrics.cpp  |  6 +-
 4 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 1b2752e638..ec77a81c46 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3197,6 +3197,7 @@ void BufferView::updateMetrics(bool force)
d->text_metrics_.clear();
}
 
+   // This should not be moved earlier
TextMetrics & tm = textMetrics(&buftext);
 
// make sure inline completion pointer is ok
@@ -3212,14 +3213,16 @@ void BufferView::updateMetrics(bool force)
 
// Check that the end of the document is not too high
int const min_visible = lyxrc.scroll_below_document ? minVisiblePart() 
: height_;
-   if (tm.last().first == lastpit && tm.last().second->bottom() < 
min_visible) {
+   if (tm.last().first == lastpit && tm.last().second->hasPosition()
+&& tm.last().second->bottom() < min_visible) {
d->anchor_ypos_ += min_visible - tm.last().second->bottom();
LYXERR(Debug::SCROLLING, "Too high, adjusting anchor ypos to " 
<< d->anchor_ypos_);
tm.updateMetrics(d->anchor_pit_, d->anchor_ypos_, height_);
}
 
// Check that the start of the document is not too low
-   if (tm.first().first == 0 && tm.first().second->top() > 0) {
+   if (tm.first().first == 0 && tm.first().second->hasPosition()
+&& tm.first().second->top() > 0) {
d->anchor_ypos_ -= tm.first().second->top();
LYXERR(Debug::SCROLLING, "Too low, adjusting anchor ypos to " 
<< d->anchor_ypos_);
tm.updateMetrics(d->anchor_pit_, d->anchor_ypos_, height_);
@@ -3232,11 +3235,11 @@ void BufferView::updateMetrics(bool force)
 * extra paragraphs are removed
 */
// Remove paragraphs that are outside of screen
-   while(tm.first().second->bottom() <= 0) {
+   while(!tm.first().second->hasPosition() || tm.first().second->bottom() 
<= 0) {
//LYXERR0("Forget pit: " << tm.first().first);
tm.forget(tm.first().first);
}
-   while(tm.last().second->top() > height_) {
+   while(!tm.last().second->hasPosition() || tm.last().second->top() > 
height_) {
//LYXERR0("Forget pit: " << tm.first().first);
tm.forget(tm.last().first);
}
diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp
index 31b31a2d01..5bf7cb1d43 100644
--- a/src/ParagraphMetrics.cpp
+++ b/src/ParagraphMetrics.cpp
@@ -40,9 +40,10 @@ using namespace lyx::support;
 
 namespace lyx {
 
+const int pm_npos = -1;
 
 ParagraphMetrics::ParagraphMetrics(Paragraph const & par) :
-   position_(-1), id_(par.id()), par_(&par)
+   position_(pm_npos), id_(par.id()), par_(&par)
 {}
 
 
@@ -61,7 +62,14 @@ void ParagraphMetrics::reset(Paragraph const & par)
 {
par_ = ∥
dim_ = Dimension();
-   //position_ = -1;
+   //position_ = pm_npos;
+}
+
+
+int ParagraphMetrics::position() const
+{
+   LASSERT(hasPosition(), return -1);
+   return position_;
 }
 
 
@@ -71,6 +79,18 @@ void ParagraphMetrics::setPosition(int

[LyX/2.4.x] Make sure paragraph positions are updated when scrolling

2024-07-10 Thread Jean-Marc Lasgouttes
commit 288684356016f5cca7959462735f6153cd1adab2
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 00:22:55 2024 +0200

Make sure paragraph positions are updated when scrolling

Sometimes quick selection-scrolling could cause a crash because the
position of some paragraphs is not computed. To fix that, in
BufferView::showCursor, make sure that the metrics are always kept
clean using updateMetrics(false), which is lighweight.

As a consequence, the 'update' parameter of showCursor and
scrollDocView is not needed anymore. Its removal is mechanical and
accounts for most of this commit.

The only other significant change is that, when creating synthetic
mouse events and relying on scroll() for small moves, the full metrics
recomputation is replaced by the lighter version.

More work is still to come on this code, but this should be going in
the right direction.

(cherry picked from commit 6e0ea4269ae792225bb4e0d0f0ffcb3236c3c5c9)
---
 src/BufferView.cpp   | 21 ++---
 src/BufferView.h |  5 ++---
 src/frontends/qt/GuiWorkArea.cpp |  6 +++---
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index ec77a81c46..428c03299f 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -755,7 +755,7 @@ Inset const * BufferView::mathContextMenu(InsetMathNest 
const * inset,
 }
 
 
-void BufferView::scrollDocView(int const pixels, bool update)
+void BufferView::scrollDocView(int const pixels)
 {
// The scrollbar values are relative to the top of the screen, 
therefore the
// offset is equal to the target value.
@@ -778,7 +778,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
// cut off at the top
if (pixels <= d->scrollbarParameters_.min) {
DocIterator dit = doc_iterator_begin(&buffer_);
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
LYXERR(Debug::SCROLLING, "scroll to top");
return;
}
@@ -787,7 +787,7 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
if (pixels >= d->scrollbarParameters_.max) {
DocIterator dit = doc_iterator_end(&buffer_);
dit.backwardPos();
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
LYXERR(Debug::SCROLLING, "scroll to bottom");
return;
}
@@ -806,14 +806,14 @@ void BufferView::scrollDocView(int const pixels, bool 
update)
// It seems we didn't find the correct pit so stay on the safe 
side and
// scroll to bottom.
LYXERR0("scrolling position not found!");
-   scrollDocView(d->scrollbarParameters_.max, update);
+   scrollDocView(d->scrollbarParameters_.max);
return;
}
 
DocIterator dit = doc_iterator_begin(&buffer_);
dit.pit() = i;
LYXERR(Debug::SCROLLING, "pixels = " << pixels << " -> scroll to pit " 
<< i);
-   showCursor(dit, SCROLL_VISIBLE, update);
+   showCursor(dit, SCROLL_VISIBLE);
 }
 
 
@@ -999,21 +999,20 @@ int BufferView::workWidth() const
 
 void BufferView::recenter()
 {
-   showCursor(d->cursor_, SCROLL_CENTER, true);
+   showCursor(d->cursor_, SCROLL_CENTER);
 }
 
 
 void BufferView::showCursor()
 {
-   showCursor(d->cursor_, SCROLL_VISIBLE, true);
+   showCursor(d->cursor_, SCROLL_VISIBLE);
 }
 
 
-void BufferView::showCursor(DocIterator const & dit, ScrollType how,
-   bool update)
+void BufferView::showCursor(DocIterator const & dit, ScrollType how)
 {
-   if (scrollToCursor(dit, how) && update)
-   processUpdateFlags(Update::Force);
+   if (scrollToCursor(dit, how))
+   processUpdateFlags(Update::ForceDraw);
 }
 
 
diff --git a/src/BufferView.h b/src/BufferView.h
index b5439b7036..ca2d7bee77 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -219,8 +219,7 @@ public:
/// This method will automatically scroll and update the BufferView
/// (metrics+drawing) if needed.
/// \param how Use this scroll strategy
-   /// \param force If true, update screen after scrolling
-   void showCursor(DocIterator const & dit, ScrollType how, bool update);
+   void showCursor(DocIterator const & dit, ScrollType how);
/// Scroll to the cursor.
/// \param how Use this scroll strategy
/// \return true if screen was scrolled
@@ -232,7 +231,7 @@ public:
/// scroll document by the given number of pixels.
int scroll(int pixels);
/// Scroll the view by a number of pixels.
-   void scrollDocView(int pixels, b

[LyX/2.4.x] Remove useless SinglePar update when scrolling in text

2024-07-10 Thread Jean-Marc Lasgouttes
commit f4364c7593a66c63a7a2b588ff60c3350353d89c
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 3 17:31:38 2024 +0200

Remove useless SinglePar update when scrolling in text

Using SinglePar does not majke sense here since the paragraph is not
modified and it might even not have a position yet.

This fixes a crash in BufferView::singleParUpdate, which is not
prepared (yet) to such situations.

(cherry picked from commit 2bdd691130e5507fc5cc2ca81e71eef189e90fc5)
---
 src/Text.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 687144ce50..d314c251ae 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -5343,7 +5343,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
bvcur.setCurrentFont();
if (cur.top() == old) {
// We didn't move one iota, so no need to update the 
screen.
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
//cur.noScreenUpdate();
return;
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Make BufferView::singeParUpdate more robust

2024-07-10 Thread Jean-Marc Lasgouttes
commit aadf3d8a5da69a5a0a21f4f4420407ce0da37691
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 1 23:56:33 2024 +0200

Make BufferView::singeParUpdate more robust

In some cases, it might happen that this method is called with no
metrics or position known for the current paragraph.

Take care of these cases to avoid assertions.

Remove setting of inset positions in the method, but make sure that
updateMetrics(false) is always called to get everything right.

In the new code, updateMetrics(bool) is the method that sets
everything right with minimal effort.

(cherry picked from commit 89ab9eb569ec0eea87d9a8c269eb87507934e1c5)
---
 src/BufferView.cpp | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 428c03299f..1fdfa78e2a 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -564,10 +564,12 @@ void BufferView::processUpdateFlags(Update::flags flags)
// are not already redrawing all).
// We handle this before FitCursor because the later will require
// correct metrics at cursor position.
-   if (!(flags & Update::ForceDraw)
-   && (flags & Update::SinglePar)
-   && !singleParUpdate())
-   updateMetrics(true);
+   if (!(flags & Update::ForceDraw) && (flags & Update::SinglePar)) {
+   if (singleParUpdate())
+   updateMetrics(false);
+   else
+   updateMetrics(true);
+   }
 
// Then make sure that the screen contains the cursor if needed
if (flags & Update::FitCursor) {
@@ -3132,6 +3134,10 @@ bool BufferView::singleParUpdate()
if (d->inlineCompletionPos_.fixIfBroken())
d->inlineCompletionPos_ = DocIterator();
 
+   if (!tm.contains(pit)) {
+   LYXERR(Debug::PAINTING, "SinglePar optimization failed: no 
known metrics");
+   return false;
+   }
/* Try to rebreak only the paragraph containing the cursor (if
 * this paragraph contains insets etc., rebreaking will
 * recursively descend). We need a full redraw if either
@@ -3149,18 +3155,19 @@ bool BufferView::singleParUpdate()
tm.redoParagraph(pit);
ParagraphMetrics & pm = tm.parMetrics(pit);
if (pm.height() != old_dim.height()
-   || (pm.width() != old_dim.width() && old_dim.width() == 
tm.width())) {
+|| (pm.width() != old_dim.width() && old_dim.width() == 
tm.width())) {
// Paragraph height or width has changed so we cannot proceed
// to the singlePar optimisation.
-   LYXERR(Debug::PAINTING, "SinglePar optimization failed.");
+   LYXERR(Debug::PAINTING, "SinglePar optimization failed: 
paragraph metrics changed");
return false;
}
// Since position() points to the baseline of the first row, we
// may have to update it. See ticket #11601 for an example where
// the height does not change but the ascent does.
-   pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
-
-   tm.updatePosCache(pit);
+   if (pm.hasPosition())
+   pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent());
+   else
+   LYXERR0("SinglePar optimization succeeded, but no position to 
update");
 
LYXERR(Debug::PAINTING, "\ny1: " << pm.top() << " y2: " << pm.bottom()
<< " pit: " << pit << " singlepar: 1");
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Add explicit check for EGREP in configure.ac

2024-07-12 Thread Jean-Marc Lasgouttes
commit 31cde7247638a50c2302744984732064505b7d85
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 12 16:02:53 2024 +0200

Add explicit check for EGREP in configure.ac

It is used in lib/Makefile.am and we were relying some autoconf macros
to define it as a side-effect. This is not the case anymore as of
autoconf 2.72.
---
 configure.ac | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4be32fa9c0..c796b60f9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,6 +122,9 @@ AC_SUBST([HAVE_WCHAR_T])
 # Needed for Mingw-w64
 AC_TYPE_LONG_LONG_INT
 
+# egrep is used in lib/Makefile.am
+AC_PROG_EGREP
+
 ### We need iconv for unicode support (Qt frontend requires it too)
 LYX_USE_INCLUDED_ICONV
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] missing quote in message

2024-07-12 Thread Jean-Marc Lasgouttes
commit ed2e5554d8a1165d284ca75bf6ed191b2427c047
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 12 19:04:18 2024 +0200

missing quote in message
---
 src/LyXRC.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index feda5110c0..fb9eb8f303 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -1150,7 +1150,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool 
check_format)
else if (tmp == "full")
draw_strategy = DrawStrategy::Full;
else {
-   LYXERR0("Unrecognized draw strategy " 
<< tmp <<'"');
+   LYXERR0("Unrecognized draw strategy \"" 
<< tmp <<'"');
}
}
break;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Sort entries in src/Makefile.am

2024-07-15 Thread Jean-Marc Lasgouttes
commit 281744d24f999eb8896a88c5c0829469a0afa13c
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 15 12:10:08 2024 +0200

Sort entries in src/Makefile.am

Remove also STANDALONEFILES variable, which is a remain of monolithic
builds.
---
 src/Makefile.am | 111 +++-
 1 file changed, 54 insertions(+), 57 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 44ddf66491..d6c9a0cb18 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -103,6 +103,7 @@ SOURCEFILESCORE = \
BranchList.cpp \
Buffer.cpp \
buffer_funcs.cpp \
+   BufferEncodings.cpp \
BufferList.cpp \
BufferParams.cpp \
BufferView.cpp \
@@ -112,8 +113,8 @@ SOURCEFILESCORE = \
CiteEnginesList.cpp \
CmdDef.cpp \
Color.cpp \
-   ConverterCache.cpp \
Converter.cpp \
+   ConverterCache.cpp \
CoordCache.cpp \
Counters.cpp \
Cursor.cpp \
@@ -122,15 +123,14 @@ SOURCEFILESCORE = \
DepTable.cpp \
DocIterator.cpp \
Encoding.cpp \
-   BufferEncodings.cpp \
ErrorList.cpp \
Exporter.cpp \
factory.cpp \
Floating.cpp \
FloatList.cpp \
+   Font.cpp \
FontInfo.cpp \
FontList.cpp \
-   Font.cpp \
Format.cpp \
FuncRequest.cpp \
FuncStatus.cpp \
@@ -145,6 +145,7 @@ SOURCEFILESCORE = \
LaTeX.cpp \
LaTeXFeatures.cpp \
LaTeXPackages.cpp \
+   Layout.cpp \
LayoutFile.cpp \
LayoutModuleList.cpp \
LyX.cpp \
@@ -155,12 +156,12 @@ SOURCEFILESCORE = \
MetricsInfo.cpp \
ModuleList.cpp \
Mover.cpp \
-   output_docbook.cpp \
output.cpp \
+   output_docbook.cpp \
output_latex.cpp \
+   output_plaintext.cpp \
output_xhtml.cpp \
OutputParams.cpp \
-   output_plaintext.cpp \
Paragraph.cpp \
ParagraphMetrics.cpp \
ParagraphParameters.cpp \
@@ -170,7 +171,6 @@ SOURCEFILESCORE = \
RowPainter.cpp \
Server.cpp \
ServerSocket.cpp \
-   xml.cpp \
Session.cpp \
Spacing.cpp \
TexRow.cpp \
@@ -185,29 +185,30 @@ SOURCEFILESCORE = \
VCBackend.cpp \
version.cpp \
VSpace.cpp \
-   WordList.cpp
+   WordList.cpp \
+   xml.cpp
 
 HEADERFILESCORE = \
Author.h \
BranchList.h \
-   buffer_funcs.h \
Buffer.h \
+   buffer_funcs.h \
BufferEncodings.h \
BufferList.h \
BufferParams.h \
BufferView.h \
Bullet.h \
-   Citation.h \
-   CiteEnginesList.h \
Changes.h \
Chktex.h \
+   Citation.h \
+   CiteEnginesList.h \
CmdDef.h \
-   ColorCode.h \
Color.h \
+   ColorCode.h \
ColorSet.h \
CompletionList.h \
-   ConverterCache.h \
Converter.h \
+   ConverterCache.h \
CoordCache.h \
Counters.h \
Cursor.h \
@@ -239,28 +240,28 @@ HEADERFILESCORE = \
KeyMap.h \
KeySequence.h \
Language.h \
+   LaTeX.h \
LaTeXFeatures.h \
LaTeXPackages.h \
-   LaTeX.h \
Layout.h \
LayoutEnums.h \
LayoutFile.h \
LayoutModuleList.h \
+   LyX.h \
LyXAction.h \
lyxfind.h \
-   LyX.h \
LyXRC.h \
LyXVC.h \
MetricsInfo.h \
ModuleList.h \
Mover.h \
-   output_docbook.h \
output.h \
-   OutputEnums.h \
+   output_docbook.h \
output_latex.h \
+   output_plaintext.h \
output_xhtml.h \
+   OutputEnums.h \
OutputParams.h \
-   output_plaintext.h \
paper.h \
Paragraph.h \
ParagraphList.h \
@@ -274,7 +275,6 @@ HEADERFILESCORE = \
Server.h \
ServerSocket.h \
Session.h \
-   xml.h \
Spacing.h \
SpellChecker.h \
TexRow.h \
@@ -292,11 +292,8 @@ HEADERFILESCORE = \
version.h \
VSpace.h \
WordLangTuple.h \
-   WordList.h
-
-STANDALONEFILES = \
-   Layout.cpp
-
+   WordList.h \
+   xml.h
 
 .PHONY: update_commit_hash
 
@@ -317,7 +314,7 @@ lyx_commit_hash.h: update_commit_hash
 BUILT_SOURCES = lyx_commit_hash.h
 CLEANFILES = lyx_commit_hash.h
 
-liblyxcore_a_SOURCES = $(SOURCEFILESCORE) $(STANDALONEFILES) $(HEADERFILESCORE)
+liblyxcore_a_SOURCES = $(SOURCEFILESCORE) $(HEADERFILESCORE)
 
 
 #  Qt stuff  ##
@@ -374,13 +371,13 @@ liblyxgraphics_a_SOURCES = \
 noinst_LIBRARIES += liblyxmathed.a
 
 SOURCEFILESMATHED = \
+   mathed/InsetMath.cpp \
mathed/InsetMathAMSArray.cpp \
mathed/InsetMathArray.cpp \
mathed/InsetMathBig.cpp \
mathed/InsetMathBoldSymbol.cpp \
mathed/InsetMathBox.cpp \
mathed/InsetMathBrace.cpp \
-   mathed

[LyX/2.4.x] Add explicit check for EGREP in configure.ac

2024-07-15 Thread Jean-Marc Lasgouttes
commit 2882bed1abcce146107b936f81d77ecd0f051bc0
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 12 16:02:53 2024 +0200

Add explicit check for EGREP in configure.ac

It is used in lib/Makefile.am and we were relying some autoconf macros
to define it as a side-effect. This is not the case anymore as of
autoconf 2.72.

(cherry picked from commit 31cde7247638a50c2302744984732064505b7d85)
---
 configure.ac | 3 +++
 status.24x   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d05e633a78..fc6a3f6319 100644
--- a/configure.ac
+++ b/configure.ac
@@ -124,6 +124,9 @@ AC_SUBST([HAVE_WCHAR_T])
 # Needed for Mingw-w64
 AC_TYPE_LONG_LONG_INT
 
+# egrep is used in lib/Makefile.am
+AC_PROG_EGREP
+
 ### We need iconv for unicode support (Qt frontend requires it too)
 LYX_USE_INCLUDED_ICONV
 
diff --git a/status.24x b/status.24x
index 538c881b43..6414a40abb 100644
--- a/status.24x
+++ b/status.24x
@@ -86,4 +86,4 @@ What's new
 
 * BUILD/INSTALLATION
 
-
+- Fix 'make install' target for autotools builds with autoconf >= 2.72.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix faulty undo recording

2024-07-16 Thread Jean-Marc Lasgouttes
commit 82f387dabc2b18de6a9917192f4304e92bff8bc1
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 16 15:43:11 2024 +0200

Fix faulty undo recording

The recordUndo() call is very wrong, since we may be inserting over a
selection covering several paragraphs (undo itself works at paragraph
granularity).

recordUndoSelection() is the right operation in this case. It is
equivalent to recordUndo() when there is no selection.
---
 src/Text.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 2a5ff9f0b8..d56cd10268 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -3600,7 +3600,7 @@ bool doInsertInset(Cursor & cur, Text * text,
if (InsetCollapsible * ci = inset->asInsetCollapsible())
ci->setButtonLabel();
 
-   cur.recordUndo();
+   cur.recordUndoSelection();
if (cmd.action() == LFUN_ARGUMENT_INSERT) {
bool cotextinsert = false;
InsetArgument * const ia = static_cast(inset);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fix faulty undo recording

2024-07-18 Thread Jean-Marc Lasgouttes
commit e57ccede186fa3705578a4908cbf8f96f5b9f5b5
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 16 15:43:11 2024 +0200

Fix faulty undo recording

The recordUndo() call is very wrong, since we may be inserting over a
selection covering several paragraphs (undo itself works at paragraph
granularity).

recordUndoSelection() is the right operation in this case. It is
equivalent to recordUndo() when there is no selection.

(cherry picked from commit 82f387dabc2b18de6a9917192f4304e92bff8bc1)
---
 src/Text.cpp | 2 +-
 status.24x   | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index d314c251ae..767117a33a 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -3600,7 +3600,7 @@ bool doInsertInset(Cursor & cur, Text * text,
if (InsetCollapsible * ci = inset->asInsetCollapsible())
ci->setButtonLabel();
 
-   cur.recordUndo();
+   cur.recordUndoSelection();
if (cmd.action() == LFUN_ARGUMENT_INSERT) {
bool cotextinsert = false;
InsetArgument * const ia = static_cast(inset);
diff --git a/status.24x b/status.24x
index 8e6a63cb9c..42df3bb1fe 100644
--- a/status.24x
+++ b/status.24x
@@ -67,6 +67,8 @@ What's new
 
 * INTERNALS
 
+- Fix possible crash in undo code after inserting note inset over a 
multi-paragraph
+  selection.
 
 
 * DOCUMENTATION AND LOCALIZATION
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 2bdd691130: remove two more Update::SinglePar instances

2024-07-20 Thread Jean-Marc Lasgouttes
commit 485f5afc21ba553fd16465231de7570b0c631298
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 17:12:09 2024 +0200

Fixup 2bdd691130: remove two more Update::SinglePar instances

They do not do what the author(s) of these lines thought it would do,
and can create crashes.
---
 src/Text.cpp | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index d56cd10268..c61bb8f812 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -5267,7 +5267,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Set the cursor
bvcur.resetAnchor();
if (!bv->mouseSetCursor(cur, cmd.modifier() == 
ShiftModifier))
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
// FIXME: move this to mouseSetCursor?
if (bvcur.wordSelection() && bvcur.inTexted())
expandWordSel(bvcur);
@@ -5366,9 +5366,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// selectWord but bvcur is current
// mouse position.
cur.bv().cursor().setSelection();
-   // We might have removed an empty but drawn 
selection
-   // (probably a margin)
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
} else
cur.noScreenUpdate();
// FIXME: We could try to handle drag and drop of 
selection here.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Use background to make math comments more visible

2024-07-20 Thread Jean-Marc Lasgouttes
commit 3040eb0fa2930ae117b9166217ddb8089997c5aa
Author: Jean-Marc Lasgouttes 
Date:   Wed Jun 5 10:41:47 2024 +0200

Use background to make math comments more visible
---
 src/mathed/InsetMathComment.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mathed/InsetMathComment.cpp b/src/mathed/InsetMathComment.cpp
index 273253ec0e..2fdcde369e 100644
--- a/src/mathed/InsetMathComment.cpp
+++ b/src/mathed/InsetMathComment.cpp
@@ -16,6 +16,10 @@
 #include "MathStream.h"
 #include "MathSupport.h"
 
+#include "frontends/Painter.h"
+
+#include "MetricsInfo.h"
+
 #include 
 
 
@@ -55,6 +59,8 @@ void InsetMathComment::metrics(MetricsInfo & mi, Dimension & 
dim) const
 
 void InsetMathComment::draw(PainterInfo & pi, int x, int y) const
 {
+   Dimension const & dim = dimension(*pi.base.bv);
+   pi.pain.fillRectangle(x, y - dim.asc, dim.wid, dim.height(), 
Color_notebg);
cell(0).draw(pi, x, y);
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fixup f4364c75: remove two more Update::SinglePar instances

2024-07-20 Thread Jean-Marc Lasgouttes
commit 0867aaf5c59ee91871dca51bd1c46942ea6c3379
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 17:12:09 2024 +0200

Fixup f4364c75: remove two more Update::SinglePar instances

They do not do what the author(s) of these lines thought it would do,
and can create crashes.

(cherry picked from commit 485f5afc21ba553fd16465231de7570b0c631298)
---
 src/Text.cpp | 6 ++
 status.24x   | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 767117a33a..1e55600a80 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -5266,7 +5266,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// Set the cursor
bvcur.resetAnchor();
if (!bv->mouseSetCursor(cur, cmd.modifier() == 
ShiftModifier))
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
// FIXME: move this to mouseSetCursor?
if (bvcur.wordSelection() && bvcur.inTexted())
expandWordSel(bvcur);
@@ -5365,9 +5365,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// selectWord but bvcur is current
// mouse position.
cur.bv().cursor().setSelection();
-   // We might have removed an empty but drawn 
selection
-   // (probably a margin)
-   cur.screenUpdateFlags(Update::SinglePar | 
Update::FitCursor);
+   cur.screenUpdateFlags(Update::FitCursor);
} else
cur.noScreenUpdate();
// FIXME: We could try to handle drag and drop of 
selection here.
diff --git a/status.24x b/status.24x
index b30028e775..2be245c92d 100644
--- a/status.24x
+++ b/status.24x
@@ -55,6 +55,8 @@ What's new
 
 - Fix crash when attempting to search in selection that contains only math.
 
+- Fix potential crashes when scrolling documents.
+
 - Fix bug where the dialog asking for saving unapplied changes on buffer change
   popped up twice, or sometimes not at all (bug 12954).
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Store spellchecker_esc_chars as a docstring

2024-07-21 Thread Jean-Marc Lasgouttes
commit 23379bb1d596359a0922b9d14e6f83c003ecd14d
Author: Jean-Marc Lasgouttes 
Date:   Sun Jul 21 21:33:01 2024 +0200

Store spellchecker_esc_chars as a docstring

This is a minor optimization to avoid calling from_utf8() repeatedly
on a hot path.
---
 src/LyXRC.cpp | 2 +-
 src/LyXRC.h   | 2 +-
 src/Paragraph.cpp | 4 ++--
 src/frontends/qt/GuiPrefs.cpp | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
index fb9eb8f303..ce0d4ee92a 100644
--- a/src/LyXRC.cpp
+++ b/src/LyXRC.cpp
@@ -2419,7 +2419,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, 
string const & name) c
case RC_ESC_CHARS:
if (ignore_system_lyxrc ||
spellchecker_esc_chars != 
system_lyxrc.spellchecker_esc_chars) {
-   os << "\\escape_chars \"" << spellchecker_esc_chars << 
"\"\n";
+   os << "\\escape_chars \"" << 
to_utf8(spellchecker_esc_chars) << "\"\n";
}
if (tag != RC_LAST)
break;
diff --git a/src/LyXRC.h b/src/LyXRC.h
index e0c2da3178..a8b4b04452 100644
--- a/src/LyXRC.h
+++ b/src/LyXRC.h
@@ -372,7 +372,7 @@ public:
/// Alternate language for spellchecker
std::string spellchecker_alt_lang;
/// Escape characters
-   std::string spellchecker_esc_chars;
+   docstring spellchecker_esc_chars;
/// Accept compound words in spellchecker?
bool spellchecker_accept_compound = false;
/// spellcheck continuously?
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 369d03ee83..d21e86ebbf 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4275,8 +4275,8 @@ bool Paragraph::isWordSeparator(pos_type pos, bool const 
ignore_deleted) const
return false;
char_type const c = d->text_[pos];
// We want to pass the escape chars to the spellchecker
-   docstring const escape_chars = from_utf8(lyxrc.spellchecker_esc_chars);
-   return !isLetterChar(c) && !isDigitASCII(c) && !contains(escape_chars, 
c);
+   return !isLetterChar(c) && !isDigitASCII(c)
+  && !contains(lyxrc.spellchecker_esc_chars, c);
 }
 
 
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index 230d377a2b..6eac7d9fab 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -1515,7 +1515,7 @@ void PrefSpellchecker::applyRC(LyXRC & rc) const
if (!speller.empty())
rc.spellchecker = speller;
rc.spellchecker_alt_lang = fromqstr(altLanguageED->text());
-   rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text());
+   rc.spellchecker_esc_chars = qstring_to_ucs4(escapeCharactersED->text());
rc.spellchecker_accept_compound = compoundWordCB->isChecked();
rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked();
rc.spellcheck_notes = spellcheckNotesCB->isChecked();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Remove alpha component of system colors

2024-07-22 Thread Jean-Marc Lasgouttes
commit 095bb18331f8eb4653691a64520d89d4a2d60fc4
Author: Jean-Marc Lasgouttes 
Date:   Mon Jul 22 20:36:20 2024 +0200

Remove alpha component of system colors

When using system colors it may happen (on windows 11 in particular)
that the background color is actually translucid. This is not
something we are prepared to handle and it creates ghosts on screen.

The fix is easy: the alpha channel of the colors is set to 255.

Fixes bug #13084.
---
 src/frontends/qt/ColorCache.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/frontends/qt/ColorCache.cpp b/src/frontends/qt/ColorCache.cpp
index 1c3d68e548..2566b75025 100644
--- a/src/frontends/qt/ColorCache.cpp
+++ b/src/frontends/qt/ColorCache.cpp
@@ -86,7 +86,9 @@ QColor ColorCache::get(Color const & color, bool syscolors) 
const
QPalette::ColorRole const cr = role(color.baseColor);
if (syscolors && cr != QPalette::NoRole) {
static QColor const white = Qt::white;
-   QColor const c = pal_.brush(QPalette::Active, 
cr).color();
+   QColor c = pal_.brush(QPalette::Active, cr).color();
+   // Change to fully opaque color
+   c.setAlpha(255);
if (cr == QPalette::Base && c == white)
return lcolors_[color.baseColor];
else
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Revert "Fix bug #13069."

2024-07-22 Thread Jean-Marc Lasgouttes
commit d7ba7bceb300c49ed1c3edb9b129810bb8a5160b
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 19 14:22:10 2024 +0200

Revert "Fix bug #13069."

This reverts commit fafe3ea5d7be1c06fb734e3bc621c551d617a6f7.
---
 config/qt.m4| 13 +++
 src/mathed/InsetMathBox.cpp | 95 ++---
 2 files changed, 53 insertions(+), 55 deletions(-)

diff --git a/config/qt.m4 b/config/qt.m4
index 64ffcd1213..6a455f9134 100644
--- a/config/qt.m4
+++ b/config/qt.m4
@@ -28,10 +28,10 @@ AC_DEFUN([QT_CHECK_COMPILE],
qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
if test $USE_QT6 = "yes" ; then
qt_corelibs="-lQt6Core"
-   qt_guilibs="-lQt6Core -lQt6Concurrent -lQt6Gui -lQt6Svg 
-lQt6Xml -lQt6Widgets"
+   qt_guilibs="-lQt6Core -lQt6Concurrent -lQt6Gui -lQt6Svg 
-lQt6Widgets"
else
qt_corelibs="-lQt5Core"
-   qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg 
-lQt5Xml -lQt5Widgets"
+   qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg 
-lQt5Widgets"
fi
for libname in $qt_corelibs '-framework QtCore'
do
@@ -43,8 +43,8 @@ AC_DEFUN([QT_CHECK_COMPILE],
done
qt_cv_libname=
for libname in $qt_guilibs \
-  '-framework QtCore -framework QtConcurrent 
-framework QtSvg -framework QtXml -framework QtWidgets -framework QtMacExtras 
-framework QtGui'\
-  '-framework QtCore -framework QtConcurrent 
-framework QtSvg -framework QtSvgWidgets -framework QtXml -framework QtWidgets 
-framework QtGui'\
+  '-framework QtCore -framework QtConcurrent 
-framework QtSvg -framework QtWidgets -framework QtMacExtras -framework QtGui'\
+  '-framework QtCore -framework QtConcurrent 
-framework QtSvg -framework QtSvgWidgets -framework QtWidgets -framework QtGui'\
   '-framework QtCore -framework QtGui'
do
QT_TRY_LINK($libname)
@@ -264,7 +264,7 @@ AC_DEFUN([QT_DO_PKG_CONFIG],
  export PKG_CONFIG_PATH
fi
qt_corelibs="Qt5Core"
-   qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets Qt5Xml"
+   qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets"
lyx_use_x11extras=false
PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], [])
if $lyx_use_x11extras; then
@@ -339,7 +339,7 @@ AC_DEFUN([QT_DO_MANUAL_CONFIG],
QT_CORE_LDFLAGS=
if test -n "$qt_cv_includes"; then
QT_INCLUDES="-I$qt_cv_includes"
-   for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent 
QtSvgWidgets QtXml QtMacExtras; do
+   for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent 
QtSvgWidgets QtMacExtras; do
QT_INCLUDES="$QT_INCLUDES -I$qt_cv_includes/$i"
if test "$lyx_use_packaging" = "macosx" ; then
QT_INCLUDES="$QT_INCLUDES 
-I$qt_cv_libraries/${i}.framework/Headers"
@@ -435,7 +435,6 @@ qtHaveModule(concurrent){QT += concurrent} else 
{MISSING += concurrent}
 qtHaveModule(gui)  {QT += gui} else {MISSING += gui}
 qtHaveModule(gui-private)  {QT += gui-private} else {MISSING += 
gui-private}
 qtHaveModule(svg)  {QT += svg} else {MISSING += svg}
-qtHaveModule(xml)  {QT += xml} else {MISSING += xml}
 qtHaveModule(widgets)  {QT += widgets} else {MISSING += widgets}
 EOF2
if test "$qt_major" = 6; then
diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index 09a0a0f351..6feddf9cdd 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -28,10 +28,6 @@
 #include 
 #include 
 
-#include 
-#include 
-#include "support/qstring_helpers.h"
-
 using namespace lyx::support;
 
 namespace lyx {
@@ -66,10 +62,6 @@ namespace {
 void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
 const std::string & attributes)
 {
-// The goal of this function is to take an XML fragment and wrap
-// anything that is outside of any tag in  tags,
-// then wrap the whole thing in an  tag with attributes
-
// First, generate the inset into a string of its own.
docstring inset_contents;
{
@@ -82,46 +74,53 @@ void splitAndWrapInMText(MathMLStream & ms, MathData const 
& cell,
inset_contents = ostmp.str();
}

[LyX/master] Revert "Cmake build: Add Qt?Xml modules to build."

2024-07-22 Thread Jean-Marc Lasgouttes
commit cd4d54f76af59b3fba9e1d5565e463c28493f8cb
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 19 14:20:53 2024 +0200

Revert "Cmake build: Add Qt?Xml modules to build."

This reverts commit 01160486974a69e62e0b21490454e8dc2e0a4c8e.
---
 src/frontends/qt/CMakeLists.txt | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/frontends/qt/CMakeLists.txt b/src/frontends/qt/CMakeLists.txt
index 65ed992c94..a007c2f492 100644
--- a/src/frontends/qt/CMakeLists.txt
+++ b/src/frontends/qt/CMakeLists.txt
@@ -47,14 +47,14 @@ endif()
 set_target_properties(frontend_qt PROPERTIES FOLDER "applications/LyX" 
QT_NO_UNICODE_DEFINES TRUE)
 
 if(Qt6Core_FOUND)
-   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg Xml 
SvgWidgets)
+   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg SvgWidgets)
 elseif(Qt5Core_FOUND AND APPLE)
-   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg Xml 
MacExtras)
+   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg MacExtras)
 else()
if (Qt5WinExtras_FOUND)
-   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg Xml 
WinExtras)
+   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg 
WinExtras)
else()
-  qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg Xml)
+   qt_use_modules(frontend_qt Core Gui Widgets Concurrent Svg)
endif()
 endif()
 target_link_libraries(frontend_qt
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Cleanup MathMLStream

2024-07-22 Thread Jean-Marc Lasgouttes
commit fbd4b0a13fae4263cc88aa76bc4fbba5178b15fa
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 19 14:57:58 2024 +0200

Cleanup MathMLStream

This is preparatory work for fixing ticket #13069.

Remove direct accesses to the underlying stream of MathMLStream in
InsetMathChar, InsetMathSpecialChar, and in all << operators other
than MathMLStream << docstring. This will allow to add a hook later in
this operator.

Move default values of MathMLStream private members to their definition.

Get rid of line_ member, which is not used.
---
 src/mathed/InsetMathChar.cpp|  2 +-
 src/mathed/InsetMathSpecialChar.cpp |  2 +-
 src/mathed/MathStream.cpp   | 22 +++---
 src/mathed/MathStream.h | 16 +---
 4 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 199982a5f7..82d0b63f1e 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -248,7 +248,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 
if (ms.inText()) {
if (entity.empty())
-   ms.os().put(char_);
+   ms << char_;
else
ms << from_ascii(entity);
return;
diff --git a/src/mathed/InsetMathSpecialChar.cpp 
b/src/mathed/InsetMathSpecialChar.cpp
index 746cec5bda..12c9a4c111 100644
--- a/src/mathed/InsetMathSpecialChar.cpp
+++ b/src/mathed/InsetMathSpecialChar.cpp
@@ -139,7 +139,7 @@ void InsetMathSpecialChar::mathmlize(MathMLStream & ms) 
const
ms << "&";
break;
default:
-   ms.os().put(char_);
+   ms << char_;
break;
}
 }
diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 4a006e4809..dc4aa05df9 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -289,7 +289,7 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int 
i)
 
 
 MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns)
-   : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
+   : os_(os), xmlns_(xmlns)
 {
if (in_text_)
font_math_style_ = TEXT_STYLE;
@@ -338,23 +338,30 @@ MathMLStream & operator<<(MathMLStream & ms, MathData 
const & ar)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, char const * s)
+MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
 {
ms.os() << s;
return ms;
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, char const * s)
+{
+   ms << from_utf8(s);
+   return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, char c)
 {
-   ms.os() << c;
+   ms << docstring(1,c);
return ms;
 }
 
 
 MathMLStream & operator<<(MathMLStream & ms, char_type c)
 {
-   ms.os().put(c);
+   ms << docstring(1,c);
return ms;
 }
 
@@ -410,13 +417,6 @@ MathMLStream & operator<<(MathMLStream & ms, CTag const & 
t)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
-{
-   ms.os() << s;
-   return ms;
-}
-
-
 //
 
 
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 04c7cb507e..c8d684bc38 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -9,8 +9,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef MATH_MATHMLSTREAM_H
-#define MATH_MATHMLSTREAM_H
+#ifndef MATH_MATHSTREAM_H
+#define MATH_MATHSTREAM_H
 
 #include "InsetMath.h"
 #include "FontInfo.h"
@@ -382,13 +382,9 @@ public:
void cr();
///
odocstream & os() { return os_; }
-   ///
-   int line() const { return line_; }
-   ///
+   /// Indentation when nesting tags
int & tab() { return tab_; }
///
-   friend MathMLStream & operator<<(MathMLStream &, char const *);
-   ///
void defer(docstring const &);
///
void defer(std::string const &);
@@ -412,11 +408,9 @@ private:
///
odocstream & os_;
///
-   int tab_;
-   ///
-   int line_;
+   int tab_ = 0;
///
-   bool in_text_;
+   bool in_text_ = false;
///
odocstringstream deferred_;
///
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix crash when generating MathML with InsetMathBox

2024-07-22 Thread Jean-Marc Lasgouttes
commit 216a6fb348dedac3230f651287a0ccfb48b88818
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 12:15:32 2024 +0200

Fix crash when generating MathML with InsetMathBox

Instead of generating code and parsing it to add ... at
the right spots, this commit honors the text mode setting that was
already present in the codebase to generate it automatically.

This is the work of two helper methods in MathMLStream:

* beforeText() notices when the stream is in text mode and that a
   has not yet been generated. In this case it inserts it, so
  that raw text can be emitted afterwards.

* beforeTag() checks whether a  needs to be closed at this
  point, and does it if needed.

To make this work, the code now tracks the nesting level in the
stream, and compares it the what the level was when text mode has been
enabled using the SetMode helper function.

In order to avoid later bugs, member os() that allows to access the
underlying stream of MathMLStream is removed. This required many <<
operators to become friends of MathMLStream.

In InsetMathBox, rename splitAndWrapInMText() to mathmlizeHelper(),
which is not just a method that sets text mode inside a 
element.

In InsetMathFont and InsetMathHull, the explicit generation of nesting
in ... can be removed now.

Fixes bug #13069.
---
 src/mathed/InsetMath.cpp |  5 ++-
 src/mathed/InsetMathBox.cpp  | 74 +++-
 src/mathed/InsetMathFont.cpp |  2 --
 src/mathed/InsetMathHull.cpp |  6 ++--
 src/mathed/MathStream.cpp| 64 --
 src/mathed/MathStream.h  | 27 +++-
 6 files changed, 88 insertions(+), 90 deletions(-)

diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 5aea5716ce..5dee0c31ba 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -204,10 +204,13 @@ void InsetMath::mathematica(MathematicaStream & os) const
 
 void InsetMath::mathmlize(MathMLStream & ms) const
 {
+   SetMode rawmode(ms, false);
ms << "";
ms << MTagInline("mi");
-   NormalStream ns(ms.os());
+   odocstringstream ods;
+   NormalStream ns(ods);
normalize(ns);
+   ms << ods.str();
ms << ETagInline("mi");
 }
 
diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index 6feddf9cdd..f06ffcf95d 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -59,69 +59,19 @@ void InsetMathBox::normalize(NormalStream & os) const
 
 
 namespace {
-void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
-const std::string & attributes)
+// Generate the MathML, making sure that anything that is outside of
+// any tag is wrapped in  tags, then wrap the whole thing in an
+//  tag with attributes
+void mathmlizeHelper(MathMLStream & ms, MathData const & cell, const 
std::string & attributes)
 {
-   // First, generate the inset into a string of its own.
-   docstring inset_contents;
-   {
-   odocstringstream ostmp;
-   MathMLStream mstmp(ostmp, ms.xmlns());
-
-   SetMode textmode(mstmp, true);
-   mstmp << cell;
-
-   inset_contents = ostmp.str();
-   }
-
-   // No tags are allowed within : split the string if there are 
tags.
-   std::vector parts;
-   while (true) {
-   std::size_t angle_pos = inset_contents.find('<');
-   if (angle_pos == docstring::npos)
-   break;
-
-   // String structure:
-   // - prefix: pure text, no tag
-   // - tag to split: something like 1 or more 
complicated
-   //   (like nested tags), with or without name space
-   // - rest to be taken care of in the next iteration
-
-   // Push the part before the tag.
-   parts.emplace_back(inset_contents.substr(0, angle_pos));
-   inset_contents = inset_contents.substr(angle_pos);
-   // Now, inset_contents starts with the tag to isolate, so that
-   // inset_contents[0] == '<'
-
-   // Push the tag, up to its end. Process: find the tag name 
(either
-   // before > or the first attribute of the tag), then the 
matching end
-   // tag, then proceed with pushing.
-   const std::size_t tag_name_end =
-   std::min(inset_contents.find(' ', 1), 
inset_contents.find('>', 1));
-   const std::size_t tag_name_length = tag_name_end - 1;
-   const docstring tag_name = inset_contents.substr(1, 
tag_name_length);
-
-   const std::size_t end_ta

[LyX/master] Make scrolling-by-selection smoother

2024-07-22 Thread Jean-Marc Lasgouttes
commit 1cc1f0ba27d1846ba244507529d4795ecfa29a39
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 19:47:32 2024 +0200

Make scrolling-by-selection smoother

This trivial patch makes scrolling-by-selection smoother by dividing
the step size and the time between steps by 8 when generating
synthetic events in work area.

The scrolling speed is unchanged, but the result is visually better.
---
 src/frontends/qt/GuiWorkArea.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 462fabda1e..4dfd365d79 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -943,6 +943,8 @@ void GuiWorkArea::generateSyntheticMouseEvent()
step = 8 / (time * time);
time = 40;
}
+   step /= 8;
+   time /= 8;
}
d->synthetic_mouse_event_.timeout.setTimeout(time);
d->synthetic_mouse_event_.timeout.start();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Cleanup MathMLStream

2024-07-22 Thread Jean-Marc Lasgouttes
commit 17bc6d05b327034c2034087978c2ebf9f8d9e469
Author: Jean-Marc Lasgouttes 
Date:   Fri Jul 19 14:57:58 2024 +0200

Cleanup MathMLStream

This is preparatory work for fixing ticket #13069.

Remove direct accesses to the underlying stream of MathMLStream in
InsetMathChar, InsetMathSpecialChar, and in all << operators other
than MathMLStream << docstring. This will allow to add a hook later in
this operator.

Move default values of MathMLStream private members to their definition.

Get rid of line_ member, which is not used.

(cherry picked from commit fbd4b0a13fae4263cc88aa76bc4fbba5178b15fa)
---
 src/mathed/InsetMathChar.cpp|  2 +-
 src/mathed/InsetMathSpecialChar.cpp |  2 +-
 src/mathed/MathStream.cpp   | 22 +++---
 src/mathed/MathStream.h | 16 +---
 4 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp
index 199982a5f7..82d0b63f1e 100644
--- a/src/mathed/InsetMathChar.cpp
+++ b/src/mathed/InsetMathChar.cpp
@@ -248,7 +248,7 @@ void InsetMathChar::mathmlize(MathMLStream & ms) const
 
if (ms.inText()) {
if (entity.empty())
-   ms.os().put(char_);
+   ms << char_;
else
ms << from_ascii(entity);
return;
diff --git a/src/mathed/InsetMathSpecialChar.cpp 
b/src/mathed/InsetMathSpecialChar.cpp
index 746cec5bda..12c9a4c111 100644
--- a/src/mathed/InsetMathSpecialChar.cpp
+++ b/src/mathed/InsetMathSpecialChar.cpp
@@ -139,7 +139,7 @@ void InsetMathSpecialChar::mathmlize(MathMLStream & ms) 
const
ms << "&";
break;
default:
-   ms.os().put(char_);
+   ms << char_;
break;
}
 }
diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 4a006e4809..dc4aa05df9 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -289,7 +289,7 @@ TeXMathStream & operator<<(TeXMathStream & ws, unsigned int 
i)
 
 
 MathMLStream::MathMLStream(odocstream & os, std::string const & xmlns)
-   : os_(os), tab_(0), line_(0), in_text_(false), xmlns_(xmlns)
+   : os_(os), xmlns_(xmlns)
 {
if (in_text_)
font_math_style_ = TEXT_STYLE;
@@ -338,23 +338,30 @@ MathMLStream & operator<<(MathMLStream & ms, MathData 
const & ar)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, char const * s)
+MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
 {
ms.os() << s;
return ms;
 }
 
 
+MathMLStream & operator<<(MathMLStream & ms, char const * s)
+{
+   ms << from_utf8(s);
+   return ms;
+}
+
+
 MathMLStream & operator<<(MathMLStream & ms, char c)
 {
-   ms.os() << c;
+   ms << docstring(1,c);
return ms;
 }
 
 
 MathMLStream & operator<<(MathMLStream & ms, char_type c)
 {
-   ms.os().put(c);
+   ms << docstring(1,c);
return ms;
 }
 
@@ -410,13 +417,6 @@ MathMLStream & operator<<(MathMLStream & ms, CTag const & 
t)
 }
 
 
-MathMLStream & operator<<(MathMLStream & ms, docstring const & s)
-{
-   ms.os() << s;
-   return ms;
-}
-
-
 //
 
 
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index ca7543101f..f46c9878ef 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -9,8 +9,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef MATH_MATHMLSTREAM_H
-#define MATH_MATHMLSTREAM_H
+#ifndef MATH_MATHSTREAM_H
+#define MATH_MATHSTREAM_H
 
 #include "InsetMath.h"
 #include "FontInfo.h"
@@ -382,13 +382,9 @@ public:
void cr();
///
odocstream & os() { return os_; }
-   ///
-   int line() const { return line_; }
-   ///
+   /// Indentation when nesting tags
int & tab() { return tab_; }
///
-   friend MathMLStream & operator<<(MathMLStream &, char const *);
-   ///
void defer(docstring const &);
///
void defer(std::string const &);
@@ -412,11 +408,9 @@ private:
///
odocstream & os_;
///
-   int tab_;
-   ///
-   int line_;
+   int tab_ = 0;
///
-   bool in_text_;
+   bool in_text_ = false;
///
odocstringstream deferred_;
///
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fix crash when generating MathML with InsetMathBox

2024-07-22 Thread Jean-Marc Lasgouttes
commit b29b3eb1fcbc30aad3c5e2800a9db61b823f65ae
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 12:15:32 2024 +0200

Fix crash when generating MathML with InsetMathBox

Instead of generating code and parsing it to add ... at
the right spots, this commit honors the text mode setting that was
already present in the codebase to generate it automatically.

This is the work of two helper methods in MathMLStream:

* beforeText() notices when the stream is in text mode and that a
   has not yet been generated. In this case it inserts it, so
  that raw text can be emitted afterwards.

* beforeTag() checks whether a  needs to be closed at this
  point, and does it if needed.

To make this work, the code now tracks the nesting level in the
stream, and compares it the what the level was when text mode has been
enabled using the SetMode helper function.

In order to avoid later bugs, member os() that allows to access the
underlying stream of MathMLStream is removed. This required many <<
operators to become friends of MathMLStream.

In InsetMathBox, rename splitAndWrapInMText() to mathmlizeHelper(),
which is not just a method that sets text mode inside a 
element.

In InsetMathFont and InsetMathHull, the explicit generation of nesting
in ... can be removed now.

Fixes bug #13069.

(cherry picked from commit 216a6fb348dedac3230f651287a0ccfb48b88818)
---
 src/mathed/InsetMath.cpp |  5 ++-
 src/mathed/InsetMathBox.cpp  | 74 +++-
 src/mathed/InsetMathFont.cpp |  2 --
 src/mathed/InsetMathHull.cpp |  6 ++--
 src/mathed/MathStream.cpp| 64 --
 src/mathed/MathStream.h  | 27 +++-
 status.24x   |  7 +++--
 7 files changed, 93 insertions(+), 92 deletions(-)

diff --git a/src/mathed/InsetMath.cpp b/src/mathed/InsetMath.cpp
index 5aea5716ce..5dee0c31ba 100644
--- a/src/mathed/InsetMath.cpp
+++ b/src/mathed/InsetMath.cpp
@@ -204,10 +204,13 @@ void InsetMath::mathematica(MathematicaStream & os) const
 
 void InsetMath::mathmlize(MathMLStream & ms) const
 {
+   SetMode rawmode(ms, false);
ms << "";
ms << MTagInline("mi");
-   NormalStream ns(ms.os());
+   odocstringstream ods;
+   NormalStream ns(ods);
normalize(ns);
+   ms << ods.str();
ms << ETagInline("mi");
 }
 
diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index 6feddf9cdd..f06ffcf95d 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -59,69 +59,19 @@ void InsetMathBox::normalize(NormalStream & os) const
 
 
 namespace {
-void splitAndWrapInMText(MathMLStream & ms, MathData const & cell,
-const std::string & attributes)
+// Generate the MathML, making sure that anything that is outside of
+// any tag is wrapped in  tags, then wrap the whole thing in an
+//  tag with attributes
+void mathmlizeHelper(MathMLStream & ms, MathData const & cell, const 
std::string & attributes)
 {
-   // First, generate the inset into a string of its own.
-   docstring inset_contents;
-   {
-   odocstringstream ostmp;
-   MathMLStream mstmp(ostmp, ms.xmlns());
-
-   SetMode textmode(mstmp, true);
-   mstmp << cell;
-
-   inset_contents = ostmp.str();
-   }
-
-   // No tags are allowed within : split the string if there are 
tags.
-   std::vector parts;
-   while (true) {
-   std::size_t angle_pos = inset_contents.find('<');
-   if (angle_pos == docstring::npos)
-   break;
-
-   // String structure:
-   // - prefix: pure text, no tag
-   // - tag to split: something like 1 or more 
complicated
-   //   (like nested tags), with or without name space
-   // - rest to be taken care of in the next iteration
-
-   // Push the part before the tag.
-   parts.emplace_back(inset_contents.substr(0, angle_pos));
-   inset_contents = inset_contents.substr(angle_pos);
-   // Now, inset_contents starts with the tag to isolate, so that
-   // inset_contents[0] == '<'
-
-   // Push the tag, up to its end. Process: find the tag name 
(either
-   // before > or the first attribute of the tag), then the 
matching end
-   // tag, then proceed with pushing.
-   const std::size_t tag_name_end =
-   std::min(inset_contents.find(' ', 1), 
inset_contents.find('>', 1));
-   const std::size_t tag_name_length = 

[LyX/master] Fixup 216a6fb3: fix broken xml syntax

2024-07-23 Thread Jean-Marc Lasgouttes
commit a268fe096a58a7818554a7da4da85896bb289c81
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 15:04:49 2024 +0200

Fixup 216a6fb3: fix broken xml syntax

This commit addresses two issues:

1/ the embarassing one: the member SetMode::old_text_level_ was
   declared as bool instead of int. This means that is was definitely
   not a proper backup variable!

2/ a robustness issue: replace two consecutive test for isTest() by a
   boolean veriable that is used twice. This makes sure that 
   cannot be output without the corresponding .

Part of bug #13069.
---
 src/mathed/MathExtern.cpp | 6 --
 src/mathed/MathStream.h   | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 1f9356f8f2..990d35e9d2 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1646,11 +1646,13 @@ void mathmlize(MathData const & dat, MathMLStream & ms)
} else if (ar.size() == 1) {
ms << ar.front();
} else {
-   if (!ms.inText())
+   // protect against the value changing in the second test.
+   bool const intext = ms.inText();
+   if (!intext)
ms << MTag("mrow");
for (MathData::const_iterator it = ar.begin(); it != ar.end(); 
++it)
(*it)->mathmlize(ms);
-   if (!ms.inText())
+   if (!intext)
ms << ETag("mrow");
}
 }
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index a9edae08c0..40bb7d3bfb 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -469,7 +469,7 @@ private:
///
MathMLStream & ms_;
///
-   bool old_text_level_;
+   int old_text_level_;
 };
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 216a6fb348: close when quitting text mode

2024-07-23 Thread Jean-Marc Lasgouttes
commit 1385f0fddd0229770496b1e50b76782892032d18
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 22:02:50 2024 +0200

Fixup 216a6fb348: close  when quitting text mode

This fixes malformed documents on UserGuide export.

Related to bug #13069.
---
 src/mathed/MathStream.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 2951aeeefd..665b3fcbf4 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -547,6 +547,7 @@ SetMode::SetMode(MathMLStream & ms, bool text)
 
 SetMode::~SetMode()
 {
+   ms_.beforeTag();
ms_.text_level_ = old_text_level_;
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Do not export the content of InsetMathBoxed as text in MathML

2024-07-23 Thread Jean-Marc Lasgouttes
commit 1186d90edf9a6702573f296d5642c5e61ceaaedf
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 23:44:58 2024 +0200

Do not export the content of InsetMathBoxed as text in MathML

\boxed{} is the only box in LaTeX that contains math. It is amusing
that the example file that we had for ticket #13609 should not have
been a problem since there is no reason to force  there.
---
 src/mathed/InsetMathBox.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index f06ffcf95d..62a11a15aa 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -402,7 +402,9 @@ void InsetMathBoxed::infoize(odocstream & os) const
 
 void InsetMathBoxed::mathmlize(MathMLStream & ms) const
 {
-   mathmlizeHelper(ms, cell(0), "class='boxed'");
+   ms << MTag("mrow", "class='boxed'");
+   ms << cell(0);
+   ms << ETag("mrow");
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Rewrite statistics code

2024-07-24 Thread Jean-Marc Lasgouttes
commit 6e81f317229a585e4d74b68af967873acd1f74ae
Author: Jean-Marc Lasgouttes 
Date:   Sun Jul 21 22:09:28 2024 +0200

Rewrite statistics code

The statistics code is known to be very slow, because it relies on
DocIterator to go through the buffer.

This commit introduces a new Statistics class that encapsulates the
main code, along a virtual method Inset::updateStatistics() that
allows to fine-tune how counting is done inset by inset.

This is a faithful bug-for-bug reimplementation.

The new code appears to be 3x faster than the old one.

See bug #12929 for a discussion about statistics update woes.
---
 src/Buffer.cpp| 106 +++--
 src/Buffer.h  |  12 ++---
 src/BufferView.cpp|  34 +---
 src/Makefile.am   |   2 +
 src/Statistics.cpp| 120 ++
 src/Statistics.h  |  64 ++
 src/Text.cpp  |  24 -
 src/frontends/qt/GuiView.cpp  |  23 +++-
 src/insets/Inset.cpp  |  14 -
 src/insets/Inset.h|   6 +--
 src/insets/InsetCitation.cpp  |   6 +--
 src/insets/InsetCitation.h|   2 +-
 src/insets/InsetHyperlink.cpp |   8 +--
 src/insets/InsetHyperlink.h   |   2 +-
 src/insets/InsetQuotes.cpp|   5 +-
 src/insets/InsetQuotes.h  |   2 +-
 src/insets/InsetTabular.cpp   |   8 +++
 src/insets/InsetTabular.h |   3 ++
 src/insets/InsetText.cpp  |   7 +++
 src/insets/InsetText.h|   3 ++
 20 files changed, 275 insertions(+), 176 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index e95d0edcc8..6c1619151c 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -56,7 +56,7 @@
 #include "PDFOptions.h"
 #include "Session.h"
 #include "SpellChecker.h"
-#include "xml.h"
+#include "Statistics.h"
 #include "texstream.h"
 #include "TexRow.h"
 #include "Text.h"
@@ -66,6 +66,7 @@
 #include "VCBackend.h"
 #include "version.h"
 #include "WordLangTuple.h"
+#include "xml.h"
 
 #include "insets/InsetBranch.h"
 #include "insets/InsetInclude.h"
@@ -357,10 +358,8 @@ public:
///
mutable bool need_update;
 
-private:
-   int word_count_;
-   int char_count_;
-   int blank_count_;
+   ///
+   Statistics statistics_;
 
 public:
/// This is here to force the test to be done whenever parent_buffer
@@ -395,22 +394,6 @@ public:
parent_buffer->invalidateBibinfoCache();
}
 
-   /// compute statistics
-   /// \p from initial position
-   /// \p to points to the end position
-   void updateStatistics(DocIterator & from, DocIterator & to,
- bool skipNoOutput = true);
-   /// statistics accessor functions
-   int wordCount() const
-   {
-   return word_count_;
-   }
-   int charCount(bool with_blanks) const
-   {
-   return char_count_
-   + (with_blanks ? blank_count_ : 0);
-   }
-
// Make sure the file monitor monitors the good file.
void refreshFileMonitor();
 
@@ -462,8 +445,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, 
bool readonly_,
  have_bibitems_(false), lyx_clean(true), bak_clean(true), 
unnamed(false),
  internal_buffer(false), read_only(readonly_), 
file_fully_loaded(false),
  need_format_backup(false), ignore_parent(false), macro_lock(false),
- externally_modified_(false), bibinfo_cache_valid_(false),
- need_update(false), word_count_(0), char_count_(0), blank_count_(0)
+ externally_modified_(false), bibinfo_cache_valid_(false), 
need_update(false)
 {
refreshFileMonitor();
if (!cloned_buffer_) {
@@ -5464,83 +5446,9 @@ void Buffer::requestSpellcheck()
 }
 
 
-void Buffer::Impl::updateStatistics(DocIterator & from, DocIterator & to, bool 
skipNoOutput)
-{
-   bool inword = false;
-   word_count_ = 0;
-   char_count_ = 0;
-   blank_count_ = 0;
-
-   for (DocIterator dit = from ; dit != to && !dit.atEnd(); ) {
-   if (!dit.inTexted()) {
-   dit.forwardPos();
-   continue;
-   }
-
-   Paragraph const & par = dit.paragraph();
-   pos_type const pos = dit.pos();
-
-   // Copied and adapted from isWordSeparator() in Paragraph
-   if (pos == dit.lastpos()) {
-   inword = false;
-   } else {
-   Inset const * ins = par.getInset(pos);
-   if (ins && skipNoOutput && !ins->producesOutput()) {
-   // skip this inset
-   

[LyX/2.4.x] Fixup b29b3eb1: fix broken xml syntax

2024-07-24 Thread Jean-Marc Lasgouttes
commit 8ea0987644eae6f6ec2e5eff308feded4ef51f3e
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 15:04:49 2024 +0200

Fixup b29b3eb1: fix broken xml syntax

This commit addresses two issues:

1/ the embarassing one: the member SetMode::old_text_level_ was
   declared as bool instead of int. This means that is was definitely
   not a proper backup variable!

2/ a robustness issue: replace two consecutive test for isTest() by a
   boolean veriable that is used twice. This makes sure that 
   cannot be output without the corresponding .

Part of bug #13069.

(cherry picked from commit a268fe096a58a7818554a7da4da85896bb289c81)
---
 src/mathed/MathExtern.cpp | 6 --
 src/mathed/MathStream.h   | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp
index 1f9356f8f2..990d35e9d2 100644
--- a/src/mathed/MathExtern.cpp
+++ b/src/mathed/MathExtern.cpp
@@ -1646,11 +1646,13 @@ void mathmlize(MathData const & dat, MathMLStream & ms)
} else if (ar.size() == 1) {
ms << ar.front();
} else {
-   if (!ms.inText())
+   // protect against the value changing in the second test.
+   bool const intext = ms.inText();
+   if (!intext)
ms << MTag("mrow");
for (MathData::const_iterator it = ar.begin(); it != ar.end(); 
++it)
(*it)->mathmlize(ms);
-   if (!ms.inText())
+   if (!intext)
ms << ETag("mrow");
}
 }
diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h
index 0cf10f0061..ffa14a7b59 100644
--- a/src/mathed/MathStream.h
+++ b/src/mathed/MathStream.h
@@ -469,7 +469,7 @@ private:
///
MathMLStream & ms_;
///
-   bool old_text_level_;
+   int old_text_level_;
 };
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fixup b29b3eb1: close when quitting text mode

2024-07-24 Thread Jean-Marc Lasgouttes
commit 458ce0fdba19094f97b96b7747a2d7b82d4d7087
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 22:02:50 2024 +0200

Fixup b29b3eb1: close  when quitting text mode

This fixes malformed documents on UserGuide export.

Related to bug #13069.

(cherry picked from commit 1385f0fddd0229770496b1e50b76782892032d18)
---
 src/mathed/MathStream.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mathed/MathStream.cpp b/src/mathed/MathStream.cpp
index 2951aeeefd..665b3fcbf4 100644
--- a/src/mathed/MathStream.cpp
+++ b/src/mathed/MathStream.cpp
@@ -547,6 +547,7 @@ SetMode::SetMode(MathMLStream & ms, bool text)
 
 SetMode::~SetMode()
 {
+   ms_.beforeTag();
ms_.text_level_ = old_text_level_;
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Do not export the content of InsetMathBoxed as text in MathML

2024-07-24 Thread Jean-Marc Lasgouttes
commit 2baa292314cad5255f6779339de3f646dc9d8a2a
Author: Jean-Marc Lasgouttes 
Date:   Tue Jul 23 23:44:58 2024 +0200

Do not export the content of InsetMathBoxed as text in MathML

\boxed{} is the only box in LaTeX that contains math. It is amusing
that the example file that we had for ticket #13609 should not have
been a problem since there is no reason to force  there.

(cherry picked from commit 1186d90edf9a6702573f296d5642c5e61ceaaedf)
---
 src/mathed/InsetMathBox.cpp | 4 +++-
 status.24x  | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp
index f06ffcf95d..62a11a15aa 100644
--- a/src/mathed/InsetMathBox.cpp
+++ b/src/mathed/InsetMathBox.cpp
@@ -402,7 +402,9 @@ void InsetMathBoxed::infoize(odocstream & os) const
 
 void InsetMathBoxed::mathmlize(MathMLStream & ms) const
 {
-   mathmlizeHelper(ms, cell(0), "class='boxed'");
+   ms << MTag("mrow", "class='boxed'");
+   ms << cell(0);
+   ms << ETag("mrow");
 }
 
 
diff --git a/status.24x b/status.24x
index f4186c577c..8a9d1ea3ec 100644
--- a/status.24x
+++ b/status.24x
@@ -49,6 +49,8 @@ What's new
 
 * DOCUMENT INPUT/OUTPUT
 
+- When exporting to MathML, the argument of the \boxed{} macro is now
+  correctly treated as math.
 
 
 * USER INTERFACE
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Do not run updateMacros if the buffer has not changed

2024-07-24 Thread Jean-Marc Lasgouttes
commit 999fb37ebb1aecfda9889fa6a2b2fbb15133f2aa
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 22:31:34 2024 +0200

Do not run updateMacros if the buffer has not changed

Each buffer now has an id which is increased when it is marked dirty
(or when one of its relatives is marked dirty).

This can be a big win since updateMacros is very expensive.
---
 src/Buffer.cpp | 27 +++
 src/Buffer.h   |  6 ++
 src/Undo.cpp   |  6 --
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 6c1619151c..59733d852e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -254,6 +254,11 @@ public:
///
Undo undo_;
 
+   /// This is increased every time the buffer or one of its relatives is 
marked dirty
+   int id_ = 0;
+   /// The buffer id at last updateMacros invokation
+   int update_macros_id_ = -1;
+
/// A cache for the bibfiles (including bibfiles of loaded child
/// documents), needed for appropriate update of natbib labels.
mutable docstring_list bibfiles_cache_;
@@ -790,6 +795,20 @@ Undo const & Buffer::undo() const
 }
 
 
+int Buffer::id() const
+{
+   return d->id_;
+}
+
+
+void Buffer::updateId()
+{
+   ++d->id_;
+   for(Buffer * b : allRelatives())
+   ++(b->d->id_);
+}
+
+
 void Buffer::setChild(DocIterator const & dit, Buffer * child)
 {
d->children_positions[child] = dit;
@@ -3305,6 +3324,9 @@ void Buffer::markDirty()
 
for (auto & depit : d->dep_clean)
depit.second = false;
+
+   // Update the buffer and its relatives' ids.
+   updateId();
 }
 
 
@@ -3899,6 +3921,11 @@ void Buffer::updateMacros() const
if (d->macro_lock)
return;
 
+   // early exit if the buffer has not changed since last time
+   if (d->update_macros_id_ == d->id_)
+   return;
+   d->update_macros_id_ = d->id_;
+
LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName());
 
// start with empty table
diff --git a/src/Buffer.h b/src/Buffer.h
index fd4d8bc8e3..2cd1495796 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -661,6 +661,12 @@ public:
///
Undo const & undo() const;
 
+   /// poor man versioning of the buffer (and its relatives).
+   int id() const;
+   /// change the id of this buffer and its relatives (indicating
+   /// something has changed). This is currently used by updateMacros().
+   void updateId();
+
/// This function is called when the buffer is changed.
void changed(bool update_metrics) const;
///
diff --git a/src/Undo.cpp b/src/Undo.cpp
index 80dff34baa..5eb29bf7a0 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -529,9 +529,11 @@ void Undo::Private::doUndoRedoAction(CursorData & cur, 
UndoElementStack & stack,
 
if (!undo.cur_before.empty())
cur = undo.cur_before;
-   if (undo.lyx_clean)
+   if (undo.lyx_clean) {
buffer_.markClean();
-   else
+   // since we have changed the buffer, update its id.
+   buffer_.updateId();
+   } else
buffer_.markDirty();
// Now that we're done with undo, we pop it off the stack.
stack.pop();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 6e81f317: cut and paste error

2024-07-24 Thread Jean-Marc Lasgouttes
commit 393f65c737b7857ba2cc610b15fe085d34dfb231
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 24 18:51:35 2024 +0200

Fixup 6e81f317: cut and paste error
---
 src/BufferView.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index f754186d07..4c2a49546c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2048,7 +2048,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
Statistics & stats = buffer_.statistics();
stats.update(cur);
d->stats_ref_value_w_ = stats.word_count;
-   d->stats_ref_value_c_ = stats.char_count; + stats.blank_count;
+   d->stats_ref_value_c_ = stats.char_count + stats.blank_count;
d->stats_ref_value_nb_ = stats.char_count;
break;
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] fix warning

2024-07-24 Thread Jean-Marc Lasgouttes
commit a042d6a9d2a2762f78c51891dc3e6263bc28a126
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 24 21:08:53 2024 +0200

fix warning
---
 src/insets/InsetTabular.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 8b052c5d73..f4906cc70f 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -1117,7 +1117,7 @@ public:
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType, bool const deleted = 
false) override;
///
-   void updateStatistics(Statistics & stats) const;
+   void updateStatistics(Statistics & stats) const override;
///
void addToToc(DocIterator const & di, bool output_active,
  UpdateType utype, TocBackend & backend) const 
override;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Do not update statisitics if buffer has not changed

2024-07-24 Thread Jean-Marc Lasgouttes
commit 0d50a8417f059f7bffc86b562817042564970c05
Author: Jean-Marc Lasgouttes 
Date:   Wed Jul 24 22:19:32 2024 +0200

Do not update statisitics if buffer has not changed

Rely on the newly-introduced Buffer::id() to skip statistics
computation if the id is the same as last time. This will reduce the
annoyance of updates triggering at random times.

Take this occasion to clean code up:

- add 'skip' parameter (true by default) to Statistics::update to indicate
  that the insets that do not produce output should be skipped.

- use a trailing underscrore for private members
---
 src/Statistics.cpp | 21 +++--
 src/Statistics.h   | 25 ++---
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/src/Statistics.cpp b/src/Statistics.cpp
index eabae8f399..b0e109b584 100644
--- a/src/Statistics.cpp
+++ b/src/Statistics.cpp
@@ -13,11 +13,13 @@
 
 #include "Statistics.h"
 
+#include "Buffer.h"
 #include "Paragraph.h"
 #include "Text.h"
 #include "Cursor.h"
 
 #include "support/lassert.h"
+#include "support/debug.h"
 #include "support/lstrings.h"
 #include "support/textutils.h"
 
@@ -27,10 +29,17 @@ namespace lyx {
 using namespace support;
 
 
-void Statistics::update(CursorData const & cur)
+void Statistics::update(CursorData const & cur, bool skip)
 {
+   // early exit if the buffer has not changed since last time
+   if (stats_id_ == cur.buffer()->id())
+   return;
+
// reset counts
*this = Statistics();
+   skip_no_output_ = skip;
+   stats_id_ = cur.buffer()->id();
+
if (cur.selection()) {
if (cur.inMathed())
return;
@@ -91,15 +100,15 @@ void Statistics::update(Paragraph const & par, pos_type 
from, pos_type to)
// Stuff that we skip
if (par.isDeleted(pos))
continue;
-   if (ins && skip_no_output && !ins->producesOutput())
+   if (ins && skip_no_output_ && !ins->producesOutput())
continue;
 
// words
if (par.isWordSeparator(pos))
-   inword = false;
-   else if (!inword) {
+   inword_ = false;
+   else if (!inword_) {
++word_count;
-   inword = true;
+   inword_ = true;
}
 
if (ins)
@@ -112,7 +121,7 @@ void Statistics::update(Paragraph const & par, pos_type 
from, pos_type to)
++blank_count;
}
}
-   inword = false;
+   inword_ = false;
 }
 
 
diff --git a/src/Statistics.h b/src/Statistics.h
index 7439de06cf..e91e9fc340 100644
--- a/src/Statistics.h
+++ b/src/Statistics.h
@@ -25,22 +25,21 @@ class Paragraph;
 // Class used to compute letters/words statistics on buffer or selection
 class Statistics {
 public:
+   /// Count characters in the whole document, or in the selection if
+   /// there is one. This is the main entry point.
+   void update(CursorData const & cur, bool skip = true);
+
+   /// Helper: count chars and words in this string
+   void update(docstring const & s);
+   /// Helper: count chars and words in the paragraphs of \c text
+   void update(Text const & text);
+
// Number of words
int word_count = 0;
// Number of non blank characters
int char_count = 0;
// Number of blank characters
int blank_count = 0;
-   // Indicate whether parts that are not output should be counted.
-   bool skip_no_output = true;
-
-   /// Count characters in the whole document, or in the selection if
-   /// there is one. This is the main entry point.
-   void update(CursorData const & cur);
-   ///  Count chars and words in this string
-   void update(docstring const & s);
-   /// Count chars and words in the paragraphs of \c text
-   void update(Text const & text);
 
 private:
 
@@ -55,8 +54,12 @@ private:
 */
void update(Paragraph const & par, pos_type from = 0, pos_type to = -1);
 
+   // Indicate whether parts that produce no output should be counted.
+   bool skip_no_output_;
// Used in the code to track status
-   bool inword = false;
+   bool inword_ = false;
+   // The buffer id at last statistics computation.
+   int stats_id_ = -1;
 };
 
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Make scrolling-by-selection smoother

2024-07-25 Thread Jean-Marc Lasgouttes
commit 73bfef16f3d5a9fe1064dfb8b2782bf82111e4c0
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 19:47:32 2024 +0200

Make scrolling-by-selection smoother

This trivial patch makes scrolling-by-selection smoother by dividing
the step size and the time between steps by 8 when generating
synthetic events in work area.

The scrolling speed is unchanged, but the result is visually better.

(cherry picked from commit 1cc1f0ba27d1846ba244507529d4795ecfa29a39)
---
 src/frontends/qt/GuiWorkArea.cpp | 2 ++
 status.24x   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 7f5cb22127..3f7c34dc4d 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -945,6 +945,8 @@ void GuiWorkArea::generateSyntheticMouseEvent()
step = 8 / (time * time);
time = 40;
}
+   step /= 8;
+   time /= 8;
}
d->synthetic_mouse_event_.timeout.setTimeout(time);
d->synthetic_mouse_event_.timeout.start();
diff --git a/status.24x b/status.24x
index 8a9d1ea3ec..ae1989d85f 100644
--- a/status.24x
+++ b/status.24x
@@ -33,6 +33,8 @@ What's new
 
 - Show font info in status line again.
 
+- Make scrolling smoother when using selection.
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 999fb37e: always run updateMacros when in batch mode

2024-07-25 Thread Jean-Marc Lasgouttes
commit fe1a3b57df2cd6adf1bd4752d05b1aae40a4e5b7
Author: Jean-Marc Lasgouttes 
Date:   Thu Jul 25 18:30:38 2024 +0200

Fixup 999fb37e: always run updateMacros when in batch mode

The optimization is useful in GUI mode only, and it turns out that it
creates weird crashes otherwise.

Thanks to Juergen Spitzmuller for the idea.
---
 src/Buffer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 59733d852e..a13c8e5f9f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -3922,7 +3922,7 @@ void Buffer::updateMacros() const
return;
 
// early exit if the buffer has not changed since last time
-   if (d->update_macros_id_ == d->id_)
+   if (d->gui_ && d->update_macros_id_ == d->id_)
return;
d->update_macros_id_ = d->id_;
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


Re: [LyX/master] Transform InsetNomenclature to a collapsible

2024-08-12 Thread Jean-Marc Lasgouttes

Le 12/08/2024 à 12:35, Juergen Spitzmueller a écrit :

commit a5841b3312d549bb7984ea8382afe490129c0750
Author: Juergen Spitzmueller 
Date:   Mon Aug 12 12:33:16 2024 +0200

 Transform InsetNomenclature to a collapsible


Looks like a good move!

JMarc

 
 Fixes: #10460, #12595, #6353


  development/FORMAT |   4 +
  lib/doc/UserGuide.lyx  | 101 --
  lib/doc/de/UserGuide.lyx   | 233 +++--
  lib/layouts/stdinsets.inc  |  31 +
  lib/lyx2lyx/lyx2lyx_tools.py   |   2 +-
  lib/lyx2lyx/lyx_2_5.py | 149 -
  lib/ui/stdmenus.inc|   2 +-
  src/Color.cpp  |   1 +
  src/ColorCode.h|   2 +
  src/Text.cpp   | 110 +++-
  src/factory.cpp|  19 +--
  src/frontends/qt/DialogFactory.cpp |   4 -
  src/frontends/qt/GuiNomenclature.cpp   |  91 -
  src/frontends/qt/GuiNomenclature.h |  47 ---
  src/frontends/qt/GuiPrintNomencl.cpp   |   4 +-
  src/frontends/qt/InsetParamsDialog.cpp |   1 -
  src/frontends/qt/Makefile.am   |   3 -
  src/frontends/qt/ui/NomenclUi.ui   |  91 -
  src/insets/Inset.h |   3 +
  src/insets/InsetCommandParams.cpp  |   6 -
  src/insets/InsetNomencl.cpp| 118 ++---
  src/insets/InsetNomencl.h  |  27 ++--
  src/tex2lyx/text.cpp   |  37 +-
  src/version.h  |   4 +-
  24 files changed, 442 insertions(+), 648 deletions(-)


--
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Force a metrics update of buffer after reload

2024-08-26 Thread Jean-Marc Lasgouttes
commit 52ec69a1af7f8c860d6f1d6ed6337db58d5ce163
Author: Jean-Marc Lasgouttes 
Date:   Tue Aug 27 00:09:04 2024 +0200

Force a metrics update of buffer after reload

It makes reload more robust and is in any case good enough to avoid
crash in #139091.

Fixes bug #13091.
---
 src/Buffer.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index fe259df8d7..6c5713b9c2 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5527,6 +5527,7 @@ Buffer::ReadStatus Buffer::reload()
removePreviews();
updatePreviews();
errors("Parse");
+   changed(true);
return status;
 }
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Force a metrics update of buffer after reload

2024-08-27 Thread Jean-Marc Lasgouttes
commit f06de64047f5b9d3e3033ed208c832c263779497
Author: Jean-Marc Lasgouttes 
Date:   Tue Aug 27 00:09:04 2024 +0200

Force a metrics update of buffer after reload

It makes reload more robust and is in any case good enough to avoid
crash in #139091.

Fixes bug #13091.

(cherry picked from commit 52ec69a1af7f8c860d6f1d6ed6337db58d5ce163)
---
 src/Buffer.cpp | 1 +
 status.24x | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 1dc29d9568..ef7367ca23 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5585,6 +5585,7 @@ Buffer::ReadStatus Buffer::reload()
removePreviews();
updatePreviews();
errors("Parse");
+   changed(true);
return status;
 }
 
diff --git a/status.24x b/status.24x
index a5db20964d..9d1b1a3f5e 100644
--- a/status.24x
+++ b/status.24x
@@ -52,6 +52,8 @@ What's new
   modification. Only file deletion will trigger the modification
   flag now (see bug 12819).
 
+- fix crash when using Save As... with previews enabled (bug 13091).
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Do not run updateMacros if the buffer has not changed

2024-08-30 Thread Jean-Marc Lasgouttes
commit e2cf6731c0ca3a3d4edec19a24754a8ddcbd3284
Author: Jean-Marc Lasgouttes 
Date:   Sat Jul 20 22:31:34 2024 +0200

Do not run updateMacros if the buffer has not changed

Each buffer now has an id which is increased when it is marked dirty
(or when one of its relatives is marked dirty).

This can be a big win since updateMacros is very expensive.

(cherry picked from commit 999fb37ebb1aecfda9889fa6a2b2fbb15133f2aa)
(cherry picked from commit fe1a3b57df2cd6adf1bd4752d05b1aae40a4e5b7)
---
 src/Buffer.cpp | 27 +++
 src/Buffer.h   |  6 ++
 src/Undo.cpp   |  6 --
 status.24x |  3 +++
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index ef7367ca23..b32dff040e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -253,6 +253,11 @@ public:
///
Undo undo_;
 
+   /// This is increased every time the buffer or one of its relatives is 
marked dirty
+   int id_ = 0;
+   /// The buffer id at last updateMacros invokation
+   int update_macros_id_ = -1;
+
/// A cache for the bibfiles (including bibfiles of loaded child
/// documents), needed for appropriate update of natbib labels.
mutable docstring_list bibfiles_cache_;
@@ -808,6 +813,20 @@ Undo const & Buffer::undo() const
 }
 
 
+int Buffer::id() const
+{
+   return d->id_;
+}
+
+
+void Buffer::updateId()
+{
+   ++d->id_;
+   for(Buffer * b : allRelatives())
+   ++(b->d->id_);
+}
+
+
 void Buffer::setChild(DocIterator const & dit, Buffer * child)
 {
d->children_positions[child] = dit;
@@ -3322,6 +3341,9 @@ void Buffer::markDirty()
 
for (auto & depit : d->dep_clean)
depit.second = false;
+
+   // Update the buffer and its relatives' ids.
+   updateId();
 }
 
 
@@ -3916,6 +3938,11 @@ void Buffer::updateMacros() const
if (d->macro_lock)
return;
 
+   // early exit if the buffer has not changed since last time
+   if (d->gui_ && d->update_macros_id_ == d->id_)
+   return;
+   d->update_macros_id_ = d->id_;
+
LYXERR(Debug::MACROS, "updateMacro of " << d->filename.onlyFileName());
 
// start with empty table
diff --git a/src/Buffer.h b/src/Buffer.h
index ee37098055..824e10c890 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -660,6 +660,12 @@ public:
///
Undo const & undo() const;
 
+   /// poor man versioning of the buffer (and its relatives).
+   int id() const;
+   /// change the id of this buffer and its relatives (indicating
+   /// something has changed). This is currently used by updateMacros().
+   void updateId();
+
/// This function is called when the buffer is changed.
void changed(bool update_metrics) const;
///
diff --git a/src/Undo.cpp b/src/Undo.cpp
index 4e970df5a0..ef149631a3 100644
--- a/src/Undo.cpp
+++ b/src/Undo.cpp
@@ -512,9 +512,11 @@ void Undo::Private::doUndoRedoAction(CursorData & cur, 
UndoElementStack & stack,
 
if (!undo.cur_before.empty())
cur = undo.cur_before;
-   if (undo.lyx_clean)
+   if (undo.lyx_clean) {
buffer_.markClean();
-   else
+   // since we have changed the buffer, update its id.
+   buffer_.updateId();
+   } else
buffer_.markDirty();
// Now that we're done with undo, we pop it off the stack.
stack.pop();
diff --git a/status.24x b/status.24x
index c826469b85..5ad6c0e865 100644
--- a/status.24x
+++ b/status.24x
@@ -54,6 +54,9 @@ What's new
 
 - fix crash when using Save As... with previews enabled (bug 13091).
 
+- Speedup interactive use by avoiding expensive math macros bookkeeping
+  when possible.
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Streamline -geometry command-line option support

2024-08-30 Thread Jean-Marc Lasgouttes
commit ce9de28f06eb770ae440992fb8ca8b98a07c1cfd
Author: Jean-Marc Lasgouttes 
Date:   Thu Aug 29 11:10:31 2024 +0200

Streamline -geometry command-line option support

Instead of baking our own support for -geometry command line option on
Windows (Qt only does that for Xcb), use the fact that Qt 5 provides
the equivalent -qwindowgeometry flag.

All we need to do is to replace the -geometry option with -qwindowgeometry.

This is part of the effort in ticket #13086 to get rid of the
compile-time QPA_XCB define.
---
 src/LyX.cpp | 23 +--
 src/frontends/qt/GuiApplication.cpp | 14 --
 2 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/src/LyX.cpp b/src/LyX.cpp
index c0dbd019b9..8f13f83713 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -127,8 +127,6 @@ namespace {
 string cl_system_support;
 string cl_user_support;
 
-string geometryArg;
-
 LyX * singleton_ = nullptr;
 
 void showFileError(string const & error)
@@ -611,7 +609,7 @@ void LyX::execCommands()
}
 
// create the first main window
-   lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW, geometryArg));
+   lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
 
if (!pimpl_->files_to_load_.empty()) {
// if some files were specified at command-line we assume that 
the
@@ -1342,20 +1340,6 @@ int parse_import(string const & type, string const & 
file, string & batch)
 }
 
 
-int parse_geometry(string const & arg1, string const &, string &)
-{
-   geometryArg = arg1;
-#if !defined(QPA_XCB)
-   // don't remove "-geometry", it will be pruned out later in the
-   // frontend if need be.
-   return -1;
-#else
-   // but that is only done if QPA_XCB is not defined.
-   return 1;
-#endif
-}
-
-
 int parse_batch(string const &, string const &, string &)
 {
use_gui = false;
@@ -1433,7 +1417,6 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--export-to"] = parse_export_to;
cmdmap["-i"] = parse_import;
cmdmap["--import"] = parse_import;
-   cmdmap["-geometry"] = parse_geometry;
cmdmap["-batch"] = parse_batch;
cmdmap["-f"] = parse_force;
cmdmap["--force-overwrite"] = parse_force;
@@ -1446,6 +1429,10 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--ignore-error-message"] = parse_ignore_error_message;
 
for (int i = 1; i < argc; ++i) {
+   // Let Qt handle -geometry even when not on X11.
+   if (from_utf8(argv[i]) == "-geometry")
+   argv[i] = const_cast("-qwindowgeometry");
+
map::const_iterator it
= cmdmap.find(argv[i]);
 
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index 6665631d31..f7eabe276c 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -172,20 +172,6 @@ namespace lyx {
 
 frontend::Application * createApplication(int & argc, char * argv[])
 {
-#if !defined(QPA_XCB)
-   // prune -geometry argument(s) by shifting
-   // the following ones 2 places down.
-   for (int i = 0 ; i < argc ; ++i) {
-   if (strcmp(argv[i], "-geometry") == 0) {
-   int const remove = (i+1) < argc ? 2 : 1;
-   argc -= remove;
-   for (int j = i; j < argc; ++j)
-   argv[j] = argv[j + remove];
-   --i;
-   }
-   }
-#endif
-
 #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
// On Windows, allow bringing the LyX window to top
AllowSetForegroundWindow(ASFW_ANY);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Get rid of QPA_XCB define

2024-08-30 Thread Jean-Marc Lasgouttes
commit 18c310a8cf60ebc8cab27aeea6fc0a6e1fcc7fcc
Author: Jean-Marc Lasgouttes 
Date:   Thu Aug 29 11:15:26 2024 +0200

Get rid of QPA_XCB define

Since the platform is selected at run time (e.g. xcb vs. Wayland), it
is not a good idea to decide at compile time what code is run. Another
example is on macOS, where having xcb libraries available will lead to
lauching the Xquartz whenever LyX is running.

With this patch, things are separated:
- the code is run when run-time platform is "xcb".
- the support code is compiled in when xcb header and libraries are
  available.

Fixes ticket #13086.
---
 config/qt.m4| 22 +++---
 src/frontends/qt/GuiApplication.cpp | 28 
 src/frontends/qt/GuiApplication.h   |  6 +++---
 3 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/config/qt.m4 b/config/qt.m4
index 6a455f9134..93b8575ad3 100644
--- a/config/qt.m4
+++ b/config/qt.m4
@@ -217,31 +217,15 @@ AC_DEFUN([QT_DO_IT_ALL],
 fi;;
esac
 
+   dnl Specific support for X11 will be built if these are available
+   AC_CHECK_HEADERS([xcb/xcb.h])
+   AC_CHECK_LIB([xcb], [xcb_send_event])
 
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
AC_CHECK_HEADER(QtGui/qtgui-config.h,
  [lyx_qt_config=QtGui/qtgui-config.h],
  [lyx_qt_config=qconfig.h])
-   AC_MSG_CHECKING([whether Qt uses the X Window system])
-   if test x$USE_QT6 = xyes ; then
- dnl FIXME: Check whether defining QPA_XCB makes sense with Qt6
- AC_PREPROC_IFELSE([AC_LANG_SOURCE([
-   [#include <$lyx_qt_config>]
-   [#if !defined(QT_FEATURE_xcb) || QT_FEATURE_xcb < 0]
-   [#error Fail]
-   [#endif]])],
-   [AC_MSG_RESULT(yes)
-AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
-   [AC_MSG_RESULT(no)])
-   else
- AC_EGREP_CPP(xcb,
-   [#include <$lyx_qt_config>
-   QT_QPA_DEFAULT_PLATFORM_NAME],
-   [AC_MSG_RESULT(yes)
-AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
-   [AC_MSG_RESULT(no)])
-   fi
CPPFLAGS=$save_CPPFLAGS
 
QT_FIND_TOOL([QT_MOC], [moc])
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index f7eabe276c..00648c1561 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -121,7 +121,7 @@
 #include 
 #include 
 
-#if defined(QPA_XCB)
+#ifdef HAVE_XCB_XCB_H
 #include 
 #ifdef HAVE_QT5_X11_EXTRAS
 #include 
@@ -1157,10 +1157,14 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
// Install Qt native translator for GUI elements.
installTranslator(&d->qt_trans_);
 
-#ifdef QPA_XCB
-   // Enable reception of XCB events.
-   installNativeEventFilter(this);
+   if (platformName() == "xcb") {
+#if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
+   // Enable reception of XCB events.
+   installNativeEventFilter(this);
+#else
+   LYXERR0("Warning: X11 support is incomplete in this LyX 
binary.");
 #endif
+   }
 
// FIXME: quitOnLastWindowClosed is true by default. We should have a
// lyxrc setting for this in order to let the application stay resident.
@@ -1181,13 +1185,13 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
this, 
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
 #endif
 
-#if defined(QPA_XCB)
-   // doubleClickInterval() is 400 ms on X11 which is just too long.
-   // On Windows and Mac OS X, the operating system's value is used.
-   // On Microsoft Windows, calling this function sets the double
-   // click interval for all applications. So we don't!
-   QApplication::setDoubleClickInterval(300);
-#endif
+   if (platformName() == "xcb") {
+   // doubleClickInterval() is 400 ms on X11 which is just too 
long.
+   // On Windows and Mac OS X, the operating system's value is 
used.
+   // On Microsoft Windows, calling this function sets the double
+   // click interval for all applications. So we don't!
+   QApplication::setDoubleClickInterval(300);
+   }
 
connect(this, SIGNAL(lastWindowClosed()), this, 
SLOT(onLastWindowClosed()));
 
@@ -3498,7 +3502,7 @@ bool GuiApplication::longOperationStarted() {
 //
 // X11 specific stuff goes here...
 
-#if defined(QPA_XCB)
+#if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
 bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
   void * message, QINTPTR *)
 {
diff --git a/src/frontends/qt/GuiApplication.h 
b/src/frontends/qt/GuiApplicati

[LyX/master] Remove legacy code to compute geometry

2024-08-30 Thread Jean-Marc Lasgouttes
commit 3c59a9a23cdcae77fd0b85dc2d66d86fe611d051
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 14:31:47 2024 +0200

Remove legacy code to compute geometry

This code is not necessary anymore after the fix to #13069.

Remove the first QString argument to createView(). Set the autoShow
parameter to false by default and rename createView(id) to
createAndShowView(id) to avoid member function overloading issues.

Remove optional  argument of window-new lfun.
Document the removal of the argument in release notes.
---
 lib/RELEASE-NOTES   |  4 +++
 src/LyXAction.cpp   |  4 +--
 src/frontends/qt/GuiApplication.cpp | 61 +++--
 src/frontends/qt/GuiApplication.h   | 13 
 4 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index e7c4b9feca..64191591aa 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -15,6 +15,10 @@
 
 !!!The following LyX functions have been changed in 2.5:
 
+- The funcion window_new does not take an optional 
+  parameter anymore. This only worked in windows and existed for
+  internal reasons.
+
 !!!The following LyX functions have been removed in 2.5:
 
 !!!The following LyX function has been added and then removed in 2.5 
development cycle:
diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp
index e07f260b25..489002364c 100644
--- a/src/LyXAction.cpp
+++ b/src/LyXAction.cpp
@@ -4417,9 +4417,7 @@ void LyXAction::init()
  * \var lyx::FuncCode lyx::LFUN_WINDOW_NEW
  * \li Action: Creates new empty LyX window.
  * \li Notion: Already opened documents from the previous window can be found 
under View menu.
- * \li Syntax: window-new []
- * \li Params: : pass the geometry of the window. This parameter is 
currently
-   accepted only on Windows platform.
+ * \li Syntax: window-new
  * \li Origin: Abdel, 21 Oct 2006
  * \endvar
  */
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index 00648c1561..a4c8b328b3 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -1771,7 +1771,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
switch (cmd.action()) {
 
case LFUN_WINDOW_NEW:
-   createView(toqstr(cmd.argument()));
+   createAndShowView();
break;
 
case LFUN_WINDOW_CLOSE:
@@ -1811,7 +1811,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
validateCurrentView();
if (!current_view_
   || (!lyxrc.open_buffers_in_tabs && 
current_view_->documentBufferView() != nullptr)) {
-   createView(QString(), false); // keep hidden
+   createView(); // keep hidden
current_view_->newDocument(to_utf8(cmd.argument()));
current_view_->show();
current_view_->activateWindow();
@@ -1826,7 +1826,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
validateCurrentView();
if (!current_view_
   || (!lyxrc.open_buffers_in_tabs && 
current_view_->documentBufferView() != nullptr)) {
-   createView();
+   createAndShowView();
current_view_->newDocument(file, temp, true);
if (!current_view_->documentBufferView())
current_view_->close();
@@ -1850,7 +1850,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
&& !is_open)) {
// We want the ui session to be saved per document and 
not per
// window number. The filename crc is a good enough 
identifier.
-   createView(support::checksum(fname));
+   createAndShowView(support::checksum(fname));
current_view_->openDocuments(fname, cmd.origin());
if (!current_view_->documentBufferView())
current_view_->close();
@@ -1873,7 +1873,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
case LFUN_HELP_OPEN: {
// FIXME: create a new method shared with LFUN_FILE_OPEN.
if (current_view_ == nullptr)
-   createView();
+   createAndShowView();
string const arg = to_utf8(cmd.argument());
if (arg.empty()) {
current_view_->message(_("Missing argument"));
@@ -2263,7 +2263,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)

[LyX/master] update comments

2024-08-30 Thread Jean-Marc Lasgouttes
commit 53c8e0b77d2fbc62bf7d895714977d906122657f
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 14:53:07 2024 +0200

update comments
---
 src/Buffer.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Buffer.h b/src/Buffer.h
index 2cd1495796..d4e8db8748 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -661,10 +661,11 @@ public:
///
Undo const & undo() const;
 
-   /// poor man versioning of the buffer (and its relatives).
+   /// Poor man versioning of the buffer (and its relatives).
+   ///  This is currently used by updateMacros() and Statistics::update().
int id() const;
/// change the id of this buffer and its relatives (indicating
-   /// something has changed). This is currently used by updateMacros().
+   /// something has changed).
void updateId();
 
/// This function is called when the buffer is changed.
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 999fb37e: fix thinko

2024-08-30 Thread Jean-Marc Lasgouttes
commit 2eb4e3d3ca063d12371695282ae0bc3d9609ab06
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 15:07:03 2024 +0200

Fixup 999fb37e: fix thinko

The current buffer is part of allRelatives(), contrary to what I
thought. Therefore updateId() increased the buffer id by two.
---
 src/Buffer.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 6c5713b9c2..f473f3dc6f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -803,7 +803,6 @@ int Buffer::id() const
 
 void Buffer::updateId()
 {
-   ++d->id_;
for(Buffer * b : allRelatives())
++(b->d->id_);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fixup e2cf6731: fix thinko

2024-08-30 Thread Jean-Marc Lasgouttes
commit 76ef192214237a5ac11edfd9c09062131eabde12
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 15:07:03 2024 +0200

Fixup e2cf6731: fix thinko

The current buffer is part of allRelatives(), contrary to what I
thought. Therefore updateId() increased the buffer id by two.

(cherry picked from commit 2eb4e3d3ca063d12371695282ae0bc3d9609ab06)
---
 src/Buffer.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index b32dff040e..79f41cb13f 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -821,7 +821,6 @@ int Buffer::id() const
 
 void Buffer::updateId()
 {
-   ++d->id_;
for(Buffer * b : allRelatives())
++(b->d->id_);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix update of cursor in tab-delete when there is a selection

2024-08-30 Thread Jean-Marc Lasgouttes
commit 16be88ca18719a98a555ced268431ca1040658b7
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 16:56:16 2024 +0200

Fix update of cursor in tab-delete when there is a selection

The position of the cursor should not be decreased if it is already at
the start of the paragraph. This can lead to a crash when trying to
display the caret.
---
 src/Text.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 7c0b18cbfd..327e3949ee 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -4629,10 +4629,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
int const n = (c == ' ' ? 4 : 1);
for (int i = 0; i < n
  && !par.empty() && 
par.getChar(0) == c; ++i) {
-   if (cur.pit() == pit)
+   if (cur.pit() == pit && 
cur.pos() > 0)
cur.posBackward();
-   if (cur.realAnchor().pit() == 
pit
- && 
cur.realAnchor().pos() > 0 )
+   if (cur.realAnchor().pit() == 
pit && cur.realAnchor().pos() > 0)

cur.realAnchor().backwardPos();
par.eraseChar(0, tc);
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Avoid missing updates after some operations on selection

2024-08-31 Thread Jean-Marc Lasgouttes
commit 4d46f766ea3f24608b8b7b418893054bfa7495dd
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 17:26:48 2024 +0200

Avoid missing updates after some operations on selection

The logic at the end of Text::dispatch failed when needsUpdate and
singleParUpdate were true at the same time.
---
 src/Text.cpp | 2 +-
 status.24x   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index e96c9a1e81..f63a6ede4b 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -6386,7 +6386,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
// FIXME: the following code should go in favor of fine grained
// update flag treatment.
-   if (singleParUpdate) {
+   if (singleParUpdate && !needsUpdate) {
// Inserting characters does not change par height in general. 
So, try
// to update _only_ this paragraph. BufferView will detect if a 
full
// metrics update is needed anyway.
diff --git a/status.24x b/status.24x
index 4ad8487467..2e789c7a5c 100644
--- a/status.24x
+++ b/status.24x
@@ -126,6 +126,7 @@ What's new
 - Fix crash when deleting tabs in a selection (with S-BackTab) in a
   text-only inset (ERT, Listings...).
 
+- Fix display glitches when applying some operations to a selection.
 
 * INTERNALS
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Fix update of cursor in tab-delete when there is a selection

2024-08-31 Thread Jean-Marc Lasgouttes
commit 5ca48a7a39e7211bf9f55487d8de38821c8613e6
Author: Jean-Marc Lasgouttes 
Date:   Fri Aug 30 16:56:16 2024 +0200

Fix update of cursor in tab-delete when there is a selection

The position of the cursor should not be decreased if it is already at
the start of the paragraph. This can lead to a crash when trying to
display the caret.

(cherry picked from commit 16be88ca18719a98a555ced268431ca1040658b7)
---
 src/Text.cpp | 5 ++---
 status.24x   | 5 -
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 1e55600a80..e96c9a1e81 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -4594,10 +4594,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
int const n = (c == ' ' ? 4 : 1);
for (int i = 0; i < n
  && !par.empty() && 
par.getChar(0) == c; ++i) {
-   if (cur.pit() == pit)
+   if (cur.pit() == pit && 
cur.pos() > 0)
cur.posBackward();
-   if (cur.realAnchor().pit() == 
pit
- && 
cur.realAnchor().pos() > 0 )
+   if (cur.realAnchor().pit() == 
pit && cur.realAnchor().pos() > 0)

cur.realAnchor().backwardPos();
par.eraseChar(0, tc);
}
diff --git a/status.24x b/status.24x
index 77034ea06f..4ad8487467 100644
--- a/status.24x
+++ b/status.24x
@@ -121,7 +121,10 @@ What's new
   and xltable), as this is not supported by the packages. Also fix the
   disabling mechanism in the table dialog.
 
-- Fix display of integral limits on Windows (bug 13087)
+- Fix display of integral limits on Windows (bug 13087).
+
+- Fix crash when deleting tabs in a selection (with S-BackTab) in a
+  text-only inset (ERT, Listings...).
 
 
 * INTERNALS
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/2.4.x] Get rid of QPA_XCB define

2024-08-31 Thread Jean-Marc Lasgouttes
commit d7e2ca377f9fab169431e41e820973fad49224b5
Author: Jean-Marc Lasgouttes 
Date:   Thu Aug 29 11:15:26 2024 +0200

Get rid of QPA_XCB define

Since the platform is selected at run time (e.g. xcb vs. Wayland), it
is not a good idea to decide at compile time what code is run. Another
example is on macOS, where having xcb libraries available will lead to
lauching the Xquartz whenever LyX is running.

With this patch, things are separated:
- the code is run when run-time platform is "xcb".
- the support code is compiled in when xcb header and libraries are
  available.

The cmake code is courtesy of Kornel Benko.

Fixes ticket #13086.

(cherry picked from commit 18c310a8cf60ebc8cab27aeea6fc0a6e1fcc7fcc)
(cherry picked from commit f1fddd86efa22ac9342de723f5ca724f252f8cbe)
(cherry picked from commit 3bc4554e5762c3484477e1c590632756e3f310ad)
(cherry picked from commit 8c14748e782d93870a7328df383403fb37da936f)
---
 CMakeLists.txt  |  8 +++-
 config/qt.m4| 22 +++---
 development/cmake/ConfigureChecks.cmake |  7 +--
 development/cmake/config.h.cmake|  8 
 src/CMakeLists.txt  |  1 -
 src/frontends/qt/GuiApplication.cpp | 28 
 src/frontends/qt/GuiApplication.h   |  6 +++---
 status.24x  |  3 +++
 8 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58c6b1eb52..a1f3f8efc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -805,7 +805,6 @@ if(LYX_USE_QT MATCHES "QT6|QT5")
Qt5_wrap_ui(${ARGN})
endmacro()
endif()
-   # set QPA_XCB if QT uses X11
find_package(${QtVal}Core CONFIG REQUIRED)
if (${QtVal}Core_FOUND)
find_package(${QtVal}Widgets CONFIG REQUIRED)
@@ -1188,6 +1187,13 @@ get_data_destination(dest_data)
 list(APPEND tmp_vi "  LyX files dir:   
${CMAKE_INSTALL_PREFIX}/${dest_data}")
 string(REPLACE ";" "\\n" VERSION_INFO "${tmp_vi}")
 
+# the result XCB_LIBRARY will be used in src/CMakeLists.txt and also in 
configuring config.h
+find_library(XCB_LIBRARY NAMES xcb)
+if (XCB_LIBRARY)
+  set(HAVE_LIBXCB 1 CACHE BOOL "" FORCE)
+else()
+  set(HAVE_LIBXCB 0 CACHE BOOL "" FORCE)
+endif()
 configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
 unset(opts)
 unset(tmp_vi)
diff --git a/config/qt.m4 b/config/qt.m4
index 96810bfc9b..1f57441845 100644
--- a/config/qt.m4
+++ b/config/qt.m4
@@ -214,31 +214,15 @@ AC_DEFUN([QT_DO_IT_ALL],
 fi;;
esac
 
+   dnl Specific support for X11 will be built if these are available
+   AC_CHECK_HEADERS([xcb/xcb.h])
+   AC_CHECK_LIB([xcb], [xcb_send_event])
 
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
AC_CHECK_HEADER(QtGui/qtgui-config.h,
  [lyx_qt_config=QtGui/qtgui-config.h],
  [lyx_qt_config=qconfig.h])
-   AC_MSG_CHECKING([whether Qt uses the X Window system])
-   if test x$USE_QT6 = xyes ; then
- dnl FIXME: Check whether defining QPA_XCB makes sense with Qt6
- AC_PREPROC_IFELSE([AC_LANG_SOURCE([
-   [#include <$lyx_qt_config>]
-   [#if !defined(QT_FEATURE_xcb) || QT_FEATURE_xcb < 0]
-   [#error Fail]
-   [#endif]])],
-   [AC_MSG_RESULT(yes)
-AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
-   [AC_MSG_RESULT(no)])
-   else
- AC_EGREP_CPP(xcb,
-   [#include <$lyx_qt_config>
-   QT_QPA_DEFAULT_PLATFORM_NAME],
-   [AC_MSG_RESULT(yes)
-AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
-   [AC_MSG_RESULT(no)])
-   fi
CPPFLAGS=$save_CPPFLAGS
 
QT_FIND_TOOL([QT_MOC], [moc])
diff --git a/development/cmake/ConfigureChecks.cmake 
b/development/cmake/ConfigureChecks.cmake
index 9062372c38..7e6707ca59 100644
--- a/development/cmake/ConfigureChecks.cmake
+++ b/development/cmake/ConfigureChecks.cmake
@@ -28,7 +28,7 @@ test_big_endian(WORDS_BIGENDIAN)
 set(Include_Defines)
 foreach(_h_file aspell.h aspell/aspell.h limits.h locale.h
stdlib.h sys/stat.h sys/time.h sys/types.h sys/utime.h
-   sys/socket.h unistd.h inttypes.h utime.h string.h argz.h)
+   sys/socket.h unistd.h inttypes.h utime.h string.h argz.h xcb/xcb.h)
string(REGEX REPLACE "[/\\.]" "_" _hf ${_h_file})
string(TOUPPER ${_hf} _HF)
check_include_files(${_h_file} HAVE_${_HF})
@@ -275,7 +275,6 @@ else()
   endif()
 endif()
 
-set(QPA_XCB)
 set(HAVE_QT5_X11_EXTRAS)
 set(HAVE_QT6_X11_EXTRAS)
 if (LYX_USE_QT MATCHES "QT5|QT6")
@@ -312,10 +311,6 @@ if (LYX_USE_QT MATCHES 

[LyX/2.4.x] Streamline -geometry command-line option support

2024-08-31 Thread Jean-Marc Lasgouttes
commit 390f45812202a80d80b27a2191c1b8e1ce5f0190
Author: Jean-Marc Lasgouttes 
Date:   Thu Aug 29 11:10:31 2024 +0200

Streamline -geometry command-line option support

Instead of baking our own support for -geometry command line option on
Windows (Qt only does that for Xcb), use the fact that Qt 5 provides
the equivalent -qwindowgeometry flag.

All we need to do is to replace the -geometry option with -qwindowgeometry.

This is part of the effort in ticket #13086 to get rid of the
compile-time QPA_XCB define.

(cherry picked from commit ce9de28f06eb770ae440992fb8ca8b98a07c1cfd)
---
 src/LyX.cpp | 23 +--
 src/frontends/qt/GuiApplication.cpp | 14 --
 status.24x  |  2 ++
 3 files changed, 7 insertions(+), 32 deletions(-)

diff --git a/src/LyX.cpp b/src/LyX.cpp
index c0dbd019b9..8f13f83713 100644
--- a/src/LyX.cpp
+++ b/src/LyX.cpp
@@ -127,8 +127,6 @@ namespace {
 string cl_system_support;
 string cl_user_support;
 
-string geometryArg;
-
 LyX * singleton_ = nullptr;
 
 void showFileError(string const & error)
@@ -611,7 +609,7 @@ void LyX::execCommands()
}
 
// create the first main window
-   lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW, geometryArg));
+   lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
 
if (!pimpl_->files_to_load_.empty()) {
// if some files were specified at command-line we assume that 
the
@@ -1342,20 +1340,6 @@ int parse_import(string const & type, string const & 
file, string & batch)
 }
 
 
-int parse_geometry(string const & arg1, string const &, string &)
-{
-   geometryArg = arg1;
-#if !defined(QPA_XCB)
-   // don't remove "-geometry", it will be pruned out later in the
-   // frontend if need be.
-   return -1;
-#else
-   // but that is only done if QPA_XCB is not defined.
-   return 1;
-#endif
-}
-
-
 int parse_batch(string const &, string const &, string &)
 {
use_gui = false;
@@ -1433,7 +1417,6 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--export-to"] = parse_export_to;
cmdmap["-i"] = parse_import;
cmdmap["--import"] = parse_import;
-   cmdmap["-geometry"] = parse_geometry;
cmdmap["-batch"] = parse_batch;
cmdmap["-f"] = parse_force;
cmdmap["--force-overwrite"] = parse_force;
@@ -1446,6 +1429,10 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--ignore-error-message"] = parse_ignore_error_message;
 
for (int i = 1; i < argc; ++i) {
+   // Let Qt handle -geometry even when not on X11.
+   if (from_utf8(argv[i]) == "-geometry")
+   argv[i] = const_cast("-qwindowgeometry");
+
map::const_iterator it
= cmdmap.find(argv[i]);
 
diff --git a/src/frontends/qt/GuiApplication.cpp 
b/src/frontends/qt/GuiApplication.cpp
index a70ed358c5..9a94fa53cd 100644
--- a/src/frontends/qt/GuiApplication.cpp
+++ b/src/frontends/qt/GuiApplication.cpp
@@ -172,20 +172,6 @@ namespace lyx {
 
 frontend::Application * createApplication(int & argc, char * argv[])
 {
-#if !defined(QPA_XCB)
-   // prune -geometry argument(s) by shifting
-   // the following ones 2 places down.
-   for (int i = 0 ; i < argc ; ++i) {
-   if (strcmp(argv[i], "-geometry") == 0) {
-   int const remove = (i+1) < argc ? 2 : 1;
-   argc -= remove;
-   for (int j = i; j < argc; ++j)
-   argv[j] = argv[j + remove];
-   --i;
-   }
-   }
-#endif
-
 #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
// On Windows, allow bringing the LyX window to top
AllowSetForegroundWindow(ASFW_ANY);
diff --git a/status.24x b/status.24x
index 5ad6c0e865..64b9892a13 100644
--- a/status.24x
+++ b/status.24x
@@ -57,6 +57,8 @@ What's new
 - Speedup interactive use by avoiding expensive math macros bookkeeping
   when possible.
 
+- Make -geometry command-line option work on all platforms.
+
 
 * DOCUMENTATION AND LOCALIZATION
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Simplify greatly Buffer::scroll/Up/Down methods

2024-09-03 Thread Jean-Marc Lasgouttes
commit 86d2313ce323fd20fadd63f103625e15704ae527
Author: Jean-Marc Lasgouttes 
Date:   Tue Sep 3 15:55:34 2024 +0200

Simplify greatly Buffer::scroll/Up/Down methods

The code there that checks whether we scroll beyond the top/bottom of
document is not needed anymore, this is handled later by
BufferView::update(bool).

Note that this methods may disappear with time.

No change intended.
---
 src/BufferView.cpp | 41 ++---
 1 file changed, 2 insertions(+), 39 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 2a3a9c58c4..0985f6f7f6 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2848,34 +2848,13 @@ int BufferView::minVisiblePart()
 
 int BufferView::scroll(int pixels)
 {
-   if (pixels > 0)
-   return scrollDown(pixels);
-   if (pixels < 0)
-   return scrollUp(-pixels);
-   return 0;
+   d->anchor_ypos_ -= pixels;
+   return -pixels;
 }
 
 
 int BufferView::scrollDown(int pixels)
 {
-   Text * text = &buffer_.text();
-   TextMetrics & tm = d->text_metrics_[text];
-   int const ymax = height_ + pixels;
-   while (true) {
-   pair last = tm.last();
-   int bottom_pos = last.second->bottom();
-   if (lyxrc.scroll_below_document)
-   bottom_pos += height_ - minVisiblePart();
-   if (last.first + 1 == int(text->paragraphs().size())) {
-   if (bottom_pos <= height_)
-   return 0;
-   pixels = min(pixels, bottom_pos - height_);
-   break;
-   }
-   if (bottom_pos > ymax)
-   break;
-   tm.newParMetricsDown();
-   }
d->anchor_ypos_ -= pixels;
return -pixels;
 }
@@ -2883,22 +2862,6 @@ int BufferView::scrollDown(int pixels)
 
 int BufferView::scrollUp(int pixels)
 {
-   Text * text = &buffer_.text();
-   TextMetrics & tm = d->text_metrics_[text];
-   int ymin = - pixels;
-   while (true) {
-   pair first = tm.first();
-   int top_pos = first.second->top();
-   if (first.first == 0) {
-   if (top_pos >= 0)
-   return 0;
-   pixels = min(pixels, - top_pos);
-   break;
-   }
-   if (top_pos < ymin)
-   break;
-   tm.newParMetricsUp();
-   }
d->anchor_ypos_ += pixels;
return pixels;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Streamline BufferView::scrollToCursor

2024-09-03 Thread Jean-Marc Lasgouttes
commit f52842d289d1434c44ffb4c9971279a8e56af612
Author: Jean-Marc Lasgouttes 
Date:   Tue Sep 3 16:21:32 2024 +0200

Streamline BufferView::scrollToCursor

There are two parts in this patch :

1/ in the part where the cursor is already visible, replace calls to
scroll/scrollUp/scrollDown by direct manipulation of the anchor
vertical position. Reasoning in terms of new position rather than
amount of pixels to scroll makes work easier.

2/ in the part where the cursor is set to a new TOP or CENTER
position, move the code around in order to prepare for new ScrollType
enums.

No change intended, except that CENTER now relies on the contents
dimension of the row that holds the iterator, that is without spacing
and labels.
---
 src/BufferView.cpp | 62 ++
 1 file changed, 34 insertions(+), 28 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 0985f6f7f6..485daf4f31 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1053,6 +1053,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
ScrollType how)
bot_pit = max_pit;
}
 
+   // Add surrounding paragraph metrics to scroll properly with cursor 
up/down
if (bot_pit == tm.first().first - 1)
tm.newParMetricsUp();
else if (bot_pit == tm.last().first + 1)
@@ -1068,7 +1069,8 @@ bool BufferView::scrollToCursor(DocIterator const & dit, 
ScrollType how)
textMetrics(cs.text()).parMetrics(cs.pit());
Dimension const & row_dim =
inner_pm.getRow(cs.pos(), dit.boundary()).dim();
-   int scrolled = 0;
+   // Assume first that we do not have to scroll anything
+   int ynew = ypos;
 
// We try to visualize the whole row, if the row height is 
larger than
// the screen height, we scroll to a heuristic value of height_ 
/ 4.
@@ -1076,51 +1078,55 @@ bool BufferView::scrollToCursor(DocIterator const & 
dit, ScrollType how)
// for a row in the inset that can be visualized completely.
if (row_dim.height() > height_) {
if (ypos < defaultRowHeight())
-   scrolled = scroll(ypos - height_ / 4);
+   ynew = height_ / 4;
else if (ypos > height_ - defaultRowHeight())
-   scrolled = scroll(ypos - 3 * height_ / 4);
+   ynew = 3 * height_ / 4;
}
-
// If the top part of the row falls of the screen, we scroll
// up to align the top of the row with the top of the screen.
-   else if (ypos - row_dim.ascent() < 0 && ypos < height_) {
-   int const ynew = row_dim.ascent();
-   scrolled = scrollUp(ynew - ypos);
-   }
-
+   else if (ypos - row_dim.ascent() < 0 && ypos < height_)
+   ynew = row_dim.ascent();
// If the bottom of the row falls of the screen, we scroll down.
-   else if (ypos + row_dim.descent() > height_ && ypos > 0) {
-   int const ynew = height_ - row_dim.descent();
-   scrolled = scrollDown(ypos - ynew);
-   }
+   else if (ypos + row_dim.descent() > height_ && ypos > 0)
+   ynew = height_ - row_dim.descent();
 
-   // else, nothing to do, the cursor is already visible so we 
just return.
-   return scrolled != 0;
+   d->anchor_ypos_ += ynew - ypos;
+   return ynew != ypos;
}
 
// fix inline completion position
if (d->inlineCompletionPos_.fixIfBroken())
d->inlineCompletionPos_ = DocIterator();
 
-   tm.redoParagraph(bot_pit);
-   int const offset = coordOffset(dit).y;
pit_type const old_pit = d->anchor_pit_;
-   d->anchor_pit_ = bot_pit;
+   int const old_ypos = d->anchor_ypos_;
+
+   if (!tm.contains(bot_pit))
+   tm.redoParagraph(bot_pit);
+   int const offset = coordOffset(dit).y;
 
CursorSlice const & cs = dit.innerTextSlice();
ParagraphMetrics const & inner_pm =
textMetrics(cs.text()).parMetrics(cs.pit());
-   Dimension const & row_dim =
-   inner_pm.getRow(cs.pos(), dit.boundary()).dim();
+   // dimension of the contents of the text row that holds dit
+   Dimension const & row_dim = inner_pm.getRow(cs.pos(), 
dit.boundary()).contents_dim();
 
-   int const old_ypos = d->anchor_ypos_;
-   d->anchor_ypos_ = - offset + row_dim.ascent();
-   if (how == SCROLL_CENTER)
-   d->an

[LyX/master] Get rid of BufferView::scrollUp/Down

2024-09-05 Thread Jean-Marc Lasgouttes
commit 439b7bb9c97ba2f267a4ccc9ae3d9af5eab100f9
Author: Jean-Marc Lasgouttes 
Date:   Tue Sep 3 18:13:02 2024 +0200

Get rid of BufferView::scrollUp/Down

LFUN_SCROLL was the last user, change it to use only scroll(). Take
this opportunity to improve a bit this dispatch code.

Also improve somewhat the methods documentation.
---
 src/BufferView.cpp | 32 
 src/BufferView.h   | 14 +++---
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 485daf4f31..75d145fa75 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2168,18 +2168,24 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
scroll_step = d->scrollbarParameters_.single_step;
else if (scroll_type == "page")
scroll_step = d->scrollbarParameters_.page_step;
-   else
+   else {
+   dispatched = false;
return;
+   }
+
string const scroll_quantity = cmd.getArg(1);
+
if (scroll_quantity == "up")
-   scrollUp(scroll_step);
+   scroll(-scroll_step);
else if (scroll_quantity == "down")
-   scrollDown(scroll_step);
+   scroll(scroll_step);
+   else if (isStrInt(scroll_quantity))
+   scroll(scroll_step * convert(scroll_quantity));
else {
-   int const scroll_value = convert(scroll_quantity);
-   if (scroll_value)
-   scroll(scroll_step * scroll_value);
+   dispatched = false;
+   return;
}
+
dr.screenUpdate(Update::ForceDraw);
dr.forceBufferUpdate();
break;
@@ -2859,20 +2865,6 @@ int BufferView::scroll(int pixels)
 }
 
 
-int BufferView::scrollDown(int pixels)
-{
-   d->anchor_ypos_ -= pixels;
-   return -pixels;
-}
-
-
-int BufferView::scrollUp(int pixels)
-{
-   d->anchor_ypos_ += pixels;
-   return pixels;
-}
-
-
 bool BufferView::setCursorFromRow(int row)
 {
TexRow::TextEntry start, end;
diff --git a/src/BufferView.h b/src/BufferView.h
index 0b9ade2f3b..57d602de7f 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -218,17 +218,17 @@ public:
/// Ensure the passed cursor \p dit is visible.
/// This method will automatically scroll and update the BufferView
/// (metrics+drawing) if needed.
-   /// \param how Use this scroll strategy
+   /// \param how: where the cursor should appear (visible/top/center)
void showCursor(DocIterator const & dit, ScrollType how);
/// Scroll to the cursor.
-   /// \param how Use this scroll strategy
+   /// This only updates the anchor vertical position, but does not
+   /// recompute metrics nor trigger a screen refresh.
+   /// \param how: where the cursor should appear (visible/top/center)
/// \return true if screen was scrolled
bool scrollToCursor(DocIterator const & dit, ScrollType how);
-   /// scroll down document by the given number of pixels.
-   int scrollDown(int pixels);
-   /// scroll up document by the given number of pixels.
-   int scrollUp(int pixels);
-   /// scroll document by the given number of pixels.
+   /// scroll the view by the given number of pixels. This only
+   /// updates the anchor vertical position, but does not recompute
+   /// metrics nor trigger a screen refresh.
int scroll(int pixels);
/// Scroll the view by a number of pixels.
void scrollDocView(int pixels);
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Cleanup Page Up/Down code

2024-09-05 Thread Jean-Marc Lasgouttes
commit 9c443d965114318dacbb67db68f5a3fd9b1b8fc2
Author: Jean-Marc Lasgouttes 
Date:   Wed Sep 4 15:48:38 2024 +0200

Cleanup Page Up/Down code

Since BufferView::scroll() does not correct scrolling amount at
top/bottom anymore, remove its return value and add a new one to
BufferView::updateMetrics(bool) that returns this correction.

Rely on updateMetrics(false) to set the metrics straight after moving
the anchor y position.

Use assert_in_view = false when calling TextMetrics::editXY() because
this parameter does not work as advertised: if an inset not totally
visible, the code will not try to go inside it to look for a smaller
row that is totally visible.

Two small (hopfully useful) modifications:
- take into account the cursor X target instead of its screen position
- adapt the cursor position depending on
  lyxrc.mac_like_cursor_movement when hitting start or end of
  document.
---
 src/BufferView.cpp | 37 +
 src/BufferView.h   | 18 +-
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 75d145fa75..e58612ef49 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -2128,6 +2128,8 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN: {
Point p = getPos(cur);
+   // replace x by the cursor target
+   p.x = cur.targetX();
// This code has been commented out to enable to scroll down a
// document, even if there are large insets in it (see bug 
#5465).
/*if (p.y < 0 || p.y > height_) {
@@ -2135,29 +2137,28 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
showCursor();
p = getPos(cur);
}*/
-   int const scrolled = scroll(act == LFUN_SCREEN_UP
-   ? -height_ : height_);
-   if (act == LFUN_SCREEN_UP && scrolled > -height_)
-   p = Point(0, 0);
-   if (act == LFUN_SCREEN_DOWN && scrolled < height_)
-   p = Point(width_, height_);
+   scroll(act == LFUN_SCREEN_UP ? -height_ : height_);
+   // update metrics
+   int const correction = updateMetrics(false);
+   if (act == LFUN_SCREEN_UP && correction < 0)
+   p = Point(lyxrc.mac_like_cursor_movement ? 0 : p.x, 0);
+   if (act == LFUN_SCREEN_DOWN && correction > 0)
+   p = Point(lyxrc.mac_like_cursor_movement ? width_ : 
p.x, height_);
bool const in_texted = cur.inTexted();
cur.setCursor(doc_iterator_begin(cur.buffer()));
cur.selHandle(false);
-   // Force an immediate computation of metrics because we need it 
below
-   if (scrolled)
-   processUpdateFlags(Update::Force);
 
d->text_metrics_[&buffer_.text()].editXY(cur, p.x, p.y,
-   true, act == LFUN_SCREEN_UP);
+   false, act == LFUN_SCREEN_UP);
//FIXME: what to do with cur.x_target()?
bool update = in_texted && cur.bv().checkDepm(cur, old);
cur.finishUndo();
 
-   if (update || cur.mark())
+   if (update) {
dr.screenUpdate(Update::Force | Update::FitCursor);
-   if (update)
dr.forceBufferUpdate();
+   } else
+   dr.screenUpdate(Update::ForceDraw | Update::FitCursor);
break;
}
 
@@ -2858,10 +2859,9 @@ int BufferView::minVisiblePart()
 }
 
 
-int BufferView::scroll(int pixels)
+void BufferView::scroll(int pixels)
 {
d->anchor_ypos_ -= pixels;
-   return -pixels;
 }
 
 
@@ -3220,10 +3220,10 @@ void BufferView::updateMetrics()
 }
 
 
-void BufferView::updateMetrics(bool force)
+int BufferView::updateMetrics(bool force)
 {
if (!ready())
-   return;
+   return 0;
 
//LYXERR0("updateMetrics " << _v_(force));
 
@@ -3256,6 +3256,7 @@ void BufferView::updateMetrics(bool force)
tm.updateMetrics(d->anchor_pit_, d->anchor_ypos_, height_);
 
// Check that the end of the document is not too high
+   int const old_ypos = d->anchor_ypos_;
int const min_visible = lyxrc.scroll_below_document ? minVisiblePart() 
: height_;
if (tm.last().first == lastpit && tm.last().second->hasPosition()
 && tm.last().second->bottom() < min_visible) {
@@ -3272,6 +3273,9 @@ void BufferView::updateMetrics(bool force)
tm.updateMetri

[LyX/master] Add ScrollType BOTTOM and TOGGLE for BufferView::scrollToCursor()

2024-09-06 Thread Jean-Marc Lasgouttes
commit 6c20e5db7db662239e8c2bd47fe28d18b27bd729
Author: Jean-Marc Lasgouttes 
Date:   Thu Sep 5 22:05:38 2024 +0200

Add ScrollType BOTTOM and TOGGLE for BufferView::scrollToCursor()

BOTTOM shows the paragraph containing the cursor at the bottom of the
work area.

TOGGLE does CENTER, then TOP, BOTTOM and finally cycles to CENTER.
This is a feature copied from emacs's C-l binding.

Add new argument "caret" to lfun "scroll" that can be used like
  scroll caret center

Change the keys (either C-l, M-l or F5) bound to screen-recenter to
"scroll caret toggle".

As an experiment, change paragraph-goto to use this scrolling method.
This can be tested when going to a heading in the outline pane.
---
 lib/bind/cua.bind |  2 +-
 lib/bind/emacs.bind   |  2 +-
 lib/bind/mac.bind |  4 ++--
 lib/bind/sciword.bind |  2 +-
 lib/bind/xemacs.bind  |  2 +-
 src/BufferView.cpp| 55 +--
 src/BufferView.h  | 18 ++---
 src/LyXAction.cpp |  5 +++--
 8 files changed, 69 insertions(+), 21 deletions(-)

diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind
index 9d3f386091..d0fb3edebe 100644
--- a/lib/bind/cua.bind
+++ b/lib/bind/cua.bind
@@ -120,7 +120,7 @@ Format 5
 \bind "C-F3"   "search-string-set"
 \bind "C-F4"   "buffer-close"
 \bind "M-F4"   "lyx-quit"
-\bind "F5" "screen-recenter"
+\bind "F5" "scroll caret toggle"
 \bind "C-M-Up" "scroll line up"
 \bind "C-M-Down"   "scroll line down"
 \bind "C-M-Prior"  "scroll page up"
diff --git a/lib/bind/emacs.bind b/lib/bind/emacs.bind
index b463cabb36..c5bae46104 100644
--- a/lib/bind/emacs.bind
+++ b/lib/bind/emacs.bind
@@ -42,7 +42,7 @@ Format 5
 \bind "C-i""space-insert hfill"
 \bind "C-j""paragraph-break"
 \bind "C-k""line-delete-forward"
-\bind "C-l""screen-recenter"
+\bind "C-l""scroll caret toggle"
 \bind "C-m""mark-toggle"
 \bind "C-n""down"
 \bind "C-o""inset-toggle"
diff --git a/lib/bind/mac.bind b/lib/bind/mac.bind
index 8fbe012bbd..f2b91235d8 100644
--- a/lib/bind/mac.bind
+++ b/lib/bind/mac.bind
@@ -63,8 +63,8 @@ Format 5
 #  -: "Control-K"# Delete from the character in front of 
the cursor to the end of the line/paragraph
 # used by menu.bind - keymap
 #  +: "Control-L"# Center the cursor/selection in the 
visible area
-\bind "M-l"  "screen-recenter"
-\bind "F5"   "screen-recenter"
+\bind "M-l"  "scroll caret toggle"
+\bind "F5"   "scroll caret toggle"
 #  +: "Control-N"# Move down one line
 \bind "M-n"  "down"
 #  +: "Control-O"# Insert a new line after the cursor
diff --git a/lib/bind/sciword.bind b/lib/bind/sciword.bind
index 55a146bc9b..78508b9256 100644
--- a/lib/bind/sciword.bind
+++ b/lib/bind/sciword.bind
@@ -79,7 +79,7 @@ Format 5
 #\bind "C-j"   "--"
 
 \bind "C-k""line-delete-forward"
-\bind "C-j""screen-recenter"
+\bind "C-j""scroll caret toggle"
 \bind "C-S-I"  "info-insert"
 
 # Toggle: in text mode, switch to math, and vice versa. Also C-t.
diff --git a/lib/bind/xemacs.bind b/lib/bind/xemacs.bind
index ad36a4f2d6..d130e660fa 100644
--- a/lib/bind/xemacs.bind
+++ b/lib/bind/xemacs.bind
@@ -44,7 +44,7 @@ Format 5
 \bind "C-i""space-insert hfill"
 #bind "C-j""--"
 \bind "C-k""line-delete-forward"
-\bind "C-l""screen-recenter"
+\bind "C-l""scroll caret toggle"
 \bind "C-m""mark-toggle"
 \bind "C-n""down"
 \bind "C-o""inset-toggle"
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index e58612ef49..665f4673d5 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1015

[LyX/master] Remove handling of dispatched() property in BufferView::dispatch

2024-09-06 Thread Jean-Marc Lasgouttes
commit e5c31699b4d8fd13c71212158d835c7fa750100f
Author: Jean-Marc Lasgouttes 
Date:   Fri Sep 6 16:21:47 2024 +0200

Remove handling of dispatched() property in BufferView::dispatch

As indicated in DispatchResult.h, this is only needed in insets'
doDispatch() methods, where lfuns can be delegated to a higher lever.
---
 src/BufferView.cpp | 31 ++-
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 665f4673d5..b1ac2da82c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1450,8 +1450,6 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
&& lyxaction.funcHasFlag(cmd.action(), LyXAction::NoInternal))
return;
 
-   // We'll set this back to false if need be.
-   bool dispatched = true;
buffer_.undo().beginUndoGroup();
 
FuncCode const act = cmd.action();
@@ -1638,8 +1636,7 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
InsetMathRef * minset =
getInsetByCode(cur, 
MATH_REF_CODE);
if (minset)
-   lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO,
-   minset->getTarget()));
+   lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, 
minset->getTarget()));
}
break;
}
@@ -1898,14 +1895,8 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
FindAndReplaceOptions opt;
istringstream iss(to_utf8(cmd.argument()));
iss >> opt;
-   if (findAdv(this, opt)) {
+   if (findAdv(this, opt))
dr.screenUpdate(Update::Force | Update::FitCursor);
-   cur.dispatched();
-   dispatched = true;
-   } else {
-   cur.undispatched();
-   dispatched = false;
-   }
break;
}
 
@@ -2199,10 +2190,8 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
how = SCROLL_TOGGLE;
else if (where == "visible")
how = SCROLL_VISIBLE;
-   else {
-   dispatched = false;
+   else
break;
-   }
showCursor(how);
break;
}
@@ -2212,10 +2201,8 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
scroll_step = d->scrollbarParameters_.single_step;
else if (scroll_type == "page")
scroll_step = d->scrollbarParameters_.page_step;
-   else {
-   dispatched = false;
+   else
break;
-   }
 
string const scroll_quantity = cmd.getArg(1);
 
@@ -2225,10 +2212,8 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
scroll(scroll_step);
else if (isStrInt(scroll_quantity))
scroll(scroll_step * convert(scroll_quantity));
-   else {
-   dispatched = false;
+   else
break;
-   }
 
dr.screenUpdate(Update::ForceDraw);
dr.forceBufferUpdate();
@@ -2478,14 +2463,13 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
if (!opt1.empty())
LYXERR0("Discarding optional argument 
to citation-insert.");
}
-   dispatched = true;
break;
}
InsetCommandParams icp(CITE_CODE);
icp["key"] = from_utf8(arg);
if (!opt1.empty())
icp["before"] = from_utf8(opt1);
-   icp["literal"] = 
+   icp["literal"] =
from_ascii(InsetCitation::last_literal ? "true" : 
"false");
string icstr = InsetCommand::params2string(icp);
FuncRequest fr(LFUN_INSET_INSERT, icstr);
@@ -2571,7 +2555,6 @@ void BufferView::dispatch(FuncRequest const & cmd, 
DispatchResult & dr)
if (cur.inTexted() && cur.selection()
&& cur.selectionBegin().idx() != cur.selectionEnd().idx()) {
buffer_.dispatch(cmd, dr);
-  

<    3   4   5   6   7   8   9   10   11   12   >