commit 67ffe3518f16c1bbaa1183d34fbe46b47b1fd5c7
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Tue Jul 8 11:59:16 2025 +0200
Small code cleanup
Move code around, document function, rename parameter.
No change intended.
---
src/Row.cpp | 42 +++++++++++++++++++++---------------------
src/Row.h | 10 ++++++----
2 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/src/Row.cpp b/src/Row.cpp
index 474b134c9b..2e89434924 100644
--- a/src/Row.cpp
+++ b/src/Row.cpp
@@ -242,11 +242,11 @@ void Row::Element::rtrim()
}
-bool Row::isMarginSelected(bool left, DocIterator const & beg,
+bool Row::isMarginSelected(bool margin_begin, DocIterator const & beg,
DocIterator const & end) const
{
- pos_type const sel_pos = left ? sel_beg : sel_end;
- pos_type const margin_pos = left ? pos_ : end_;
+ pos_type const sel_pos = margin_begin ? sel_beg : sel_end;
+ pos_type const margin_pos = margin_begin ? pos_ : end_;
// Is there a selection and is the chosen margin selected ?
if (!selection() || sel_pos != margin_pos)
@@ -269,6 +269,24 @@ bool Row::isMarginSelected(bool left, DocIterator const &
beg,
}
+void Row::setSelection(pos_type beg, pos_type end) const
+{
+ if (pos_ >= beg && pos_ <= end)
+ change(sel_beg, pos_);
+ else if (beg > pos_ && beg <= end_)
+ change(sel_beg, beg);
+ else
+ change(sel_beg, -1);
+
+ if (end_ >= beg && end_ <= end)
+ change(sel_end,end_);
+ else if (end < end_ && end >= pos_)
+ change(sel_end, end);
+ else
+ change(sel_end, -1);
+}
+
+
void Row::setSelectionAndMargins(DocIterator const & beg,
DocIterator const & end) const
{
@@ -288,24 +306,6 @@ void Row::clearSelectionAndMargins() const
}
-void Row::setSelection(pos_type beg, pos_type end) const
-{
- if (pos_ >= beg && pos_ <= end)
- change(sel_beg, pos_);
- else if (beg > pos_ && beg <= end_)
- change(sel_beg, beg);
- else
- change(sel_beg, -1);
-
- if (end_ >= beg && end_ <= end)
- change(sel_end,end_);
- else if (end < end_ && end >= pos_)
- change(sel_end, end);
- else
- change(sel_end, -1);
-}
-
-
bool Row::selection() const
{
return sel_beg != -1 && sel_end != -1;
diff --git a/src/Row.h b/src/Row.h
index 8dbec9474b..997163303a 100644
--- a/src/Row.h
+++ b/src/Row.h
@@ -377,11 +377,13 @@ public:
private:
/// Decides whether the margin is selected.
/**
- * \param margin_begin
- * \param beg
- * \param end
+ * \param margin_begin: if true check the margin at the beginning
+ * of text (left or right depending on bidi status).
+ * \param beg: the beginning of selection, preprocessed in
+ * TextMetrics::drawParagraph.
+ * \param end: same for end of selection.
*/
- bool isMarginSelected(bool left, DocIterator const & beg,
+ bool isMarginSelected(bool margin_begin, DocIterator const & beg,
DocIterator const & end) const;
/// Set the selection begin and end.
void setSelection(pos_type sel_beg, pos_type sel_end) const;
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs