Commit Graph

667 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
776807a536 Constification 2021-03-10 10:43:45 +01:00
Jean-Marc Lasgouttes
9a2b8c87cd Code reformatting. 2021-03-10 10:43:45 +01:00
Enrico Forestieri
7545698380 Fix bug #12181
The context menu for InsetMathRef is now usable.
InsetMathRef still misses support for RefStyle and thus the
corresponding entries are omitted from the menu. But this would
be a different bug.
2021-03-06 23:36:58 +01:00
Enrico Forestieri
5a43b86141 Allow context menus in mathed
It is now possible to get a context menu for math insets.
InsetMathSpace was already providing a specific context menu,
but it was never triggered because the math hull inset is not
descendable. It is still so, but now when a context menu is
requested all the insets inside the math hull are examined.
If the inset under the cursor provides a context menu, it
is shown instead of the general math one.

Fixes #12100.
2021-03-05 21:21:41 +01:00
Jean-Marc Lasgouttes
fbf22bb3f3 Fix random scrolling inside nested insets
Happened when the BufferView was resized (e.g. math toolbars were
displayed/hidden).

Backported from gadmm's lyx-unstable tree
https://gitlab.com/gadmm/lyx-unstable/-/commit/a868bc034cea4c

Possible fix to bug #7457.
2021-03-02 18:10:12 +01:00
Jean-Marc Lasgouttes
42b23f3fb2 Display bookmarks in the workarea (take 2).
The bookmarks are shown with circled numbers in the right margin (or
the left margin in RTL mode). A new color "bookmarks" has been added.
Currently bookmark 0 (the return position) is not displayed because it
is very disturbing in practice.

To make this work, a new method BookmarksSection::bookmarksInPar
retuns the list of bookmarks in a paragraph along with their position.

Force redraw when using bookmark-save and bookmark-clear.

Caveats:

- this solution does not show the precise position of the bookmark
  (this is supposedly not a problem).

- if several bookmarks are on the same row, they will currently be
  garbled. It would be easy to make sure that only one is shown ; what
  would be more difficult would be to move the second bookmark lower.

- it is possible to make sure that the markers are correctly centered
  in the margin, and that the margin size is large enough to hold the
  marker (I did not try all fonts).

Fixes bug #2496.
2021-02-26 19:09:25 +01:00
Jean-Marc Lasgouttes
e4ab91d802 Revert "Display bookmarks in the workarea."
This will be replaced by a different version.

This reverts commit 99e636ae7b.
2021-02-26 18:07:39 +01:00
Jean-Marc Lasgouttes
090e9a6c36 Keep the useful parts of reverted commits
Keep from 907f0207 the introduction of BufferView::top/bottomMargin()
and the setting of the top/bottom margin of the document. The
difference is that the extra height is still added to the relevant
rows, and not only to the paragraph metrics.

Keep from f41ca959 the reduction of top/bottom margin for Adv F&R
workareas.
2021-02-16 12:29:40 +01:00
Jean-Marc Lasgouttes
a40ca1430e Revert "Improve handling of top and bottom margin"
This reverts commit 907f020724.
2021-02-16 12:29:40 +01:00
Jean-Marc Lasgouttes
810b86560a Revert "Reduce top/bottom margin for Adv F&R workareas"
This reverts commit f41ca959fd.
2021-02-16 12:29:40 +01:00
Jean-Marc Lasgouttes
f6c87c63c1 Revert "Make sure that top/bottom margins are visible when needed"
This reverts commit a78eb4471f.
2021-02-16 12:29:40 +01:00
Juergen Spitzmueller
5980afaee0 Add support for search/replace within selection (#2548) 2021-02-16 08:11:09 +01:00
Juergen Spitzmueller
958213ee52 Improve instant search 2021-02-15 14:12:07 +01:00
Juergen Spitzmueller
f59b8cb657 GuiSearch: Add auto-wrap option 2021-02-15 11:30:03 +01:00
Stephan Witt
a476cc4839 #8055 add support for system-wide find buffer on Mac
Command-E is standard for paste to find buffer on Mac. That's why the key binding is changed appropriately.
2021-02-14 18:56:25 +01:00
Stephan Witt
46bb8f22c9 #8055 correct processing of LFUN_WORD_FIND option flags for repeated search operations 2021-02-13 04:47:44 +01:00
Jean-Marc Lasgouttes
1cbbe5c3aa Do not redraw cursor twice with Page Up/Down
Just recompute metrics instead of triggering a full redraw. The old
behavior was that, when the document was less that one page long, the
cursor would blink to the top of the document before going to its
correct position.
2021-02-12 18:35:07 +01:00
Jean-Marc Lasgouttes
a78eb4471f Make sure that top/bottom margins are visible when needed
When the cursor is at the top, it is important to make sure that, not
only its row is visible, but also the extra margin at the beginning of
the document, that was added at 907f0207.

Fixes part of bug #12123.
2021-02-12 18:35:07 +01:00
Juergen Spitzmueller
b75fc70561 Adapt comment 2021-02-12 14:43:56 +01:00
Juergen Spitzmueller
7f90e3b7d2 Introduce search-string-set (#8055)
This stores its argument, the currently selected text or the word under
cursor in the search cache that is used by word-find[-backward|-forward]
if no argument is given to those.

Prerequisite for a feature apparently expected on the Mac.
2021-02-12 14:30:50 +01:00
Juergen Spitzmueller
e35574b3ce Store the AuthorList in the cut stack
Otherwise we crash when we paste text with markup into a different buffer
that has change tracking disabled (in this case, markup is now kept).
2021-02-09 16:54:21 +01:00
Jean-Marc Lasgouttes
f3a0e8ff9a Run updateBuffer when adding/merging changes
Following 4a4ded22, the enabling of some change-related functions is
handled in updateBuffer. However, this method is not ran at every
document change for performance reasons.

This patch adds code to every place that modifies
Paragraph::Private::changes_ that checks whether the `changedness' of
the paragraph, err... changes.

To this end, a new helper struct is introduced that remembers
paragraph state at contruction time, and compares it to new state in
the destructor.

New forceUpdate/needUpdate methods are added to Buffer class, since
the cursor is in general not available in the places where these
changes are made.

Fixes bug #12074.
2021-01-28 11:30:05 +01:00
Richard Kimberly Heck
1582a2afe1 Fix bug #12068 2021-01-14 01:15:19 -05:00
Juergen Spitzmueller
1b2a56e2d2 Ignore tracked deletions in simple replace (#11194) 2021-01-12 16:13:47 +01:00
Jean-Marc Lasgouttes
9e1db65932 Move handling of LFUN_COPY to BufferView
It turns out that the code is the same in texted ans mathed and that
whatever is done in InsetTabular is not useful.

This means that we do not need to deal Text::dispatch idiosyncrasies
(in particular forcing the cursor to be visible).

Fix bug #11225.
2021-01-08 19:31:42 +01:00
Jean-Marc Lasgouttes
99e636ae7b Display bookmarks in the workarea.
The bookmarks are added as virtual elements in display Rows. Bookmarks
are shown with circled numbers. A new color "bookmarks" has been
added. Currently bookmark 0 (the return position) is not displayed
because it is very disturbing in practice.

To make this work, a new method BookmarksSection::bookmarksInPar
retuns the list of bookmarks in a paragraph along with their position.

Force redraw when using bookmark-save and bookmark-clear.

Fixes bug #2496.
2021-01-06 20:20:03 +01:00
Richard Kimberly Heck
84e8ce4ce5 Simplify 2021-01-04 01:40:22 -05:00
Richard Kimberly Heck
db36ec1ccf Pop a message if the search fails. Fixes #11441 2021-01-04 01:06:33 -05:00
Yuriy Skalko
9cb98136ce Cleanup headers 2020-12-03 00:38:27 +02:00
Jean-Marc Lasgouttes
f41ca959fd Reduce top/bottom margin for Adv F&R workareas 2020-12-01 12:01:20 +01:00
Jean-Marc Lasgouttes
1b3ffa6627 Rewrite (again!) the code for caret drawing
The caret geometry is now computed in BufferView as a list of shapes
(caret, horizontal l-shape if needed, completion triangle if needed)
kept in a variable of type CaretGeometry.

The code in WorkArea.cpp only has to draw these shapes. The
CaretWidget (which never was a widget) in GuiWorkArea.cpp is gone
now.

As a consequence, the bounding box for the cursor is known precisely
and therefore rows should be repainted correctly now. This avoids
caret droppings.

Fixes bug #12024.
2020-11-24 20:12:42 +01:00
Jean-Marc Lasgouttes
7a28258d32 (almost) Proper fix for caret droppings
Try to find the most inner row that is overwritten by the caret. This
allows to replace the hack in TextMetrics::draw, which did not really
work.

Note that there are still issues with emphasized caret at the
beginning of inset, which will require some code reorganisation.

Fixes current recipe of bug #12024.
2020-11-21 20:00:26 +01:00
Jean-Marc Lasgouttes
ba8ca0e384 Correct caret position from the start 2020-11-21 19:39:48 +01:00
Yuriy Skalko
589e780e15 Whitespace & renaming 2020-11-06 21:34:02 +02:00
Yuriy Skalko
d38eddb397 Match header/source function argument naming 2020-11-01 22:23:44 +02:00
Yuriy Skalko
5061db891c Use const references 2020-11-01 22:23:26 +02:00
Yuriy Skalko
196d9caeb0 Clean includes using the output of iwyu tool 2020-10-20 11:38:55 +03:00
Yuriy Skalko
65c88f0a0a Remove redundant const & for primitive types 2020-10-19 12:50:07 +03:00
Jean-Marc Lasgouttes
c516c86d19 Make cursor width depend on current font
This makes the cursor more visible wrt current font.

Moreover make the cursor width scalable by default.
2020-10-13 17:27:52 +02:00
Jean-Marc Lasgouttes
7f1b1729b4 Cleanup the caret geometry code
Intended changes:

* code is shorter and cleaner

* caret scales better with zoom when cursor_width=0: completion
  indicator, l-shaped cursor...

Details:

* Rename BufferView::getPosAndHeight to getPosAndDim because ascent is
  needed too and width could in the future be set depending on font.

* Get rid of rect_ in CaretWidget and record a Dimension (and y value) instead.
  Remove also caret_width_ and slant_, replace rtl_ with dir.

* Make CaretWidget members public and lose the trailing _.

* change CaretWidget::update to read its parameters from current bufferview.
2020-10-01 13:17:01 +02:00
Thibaut Cuvelier
8ed8d36595 Fix two warnings in BufferView. 2020-09-19 20:43:40 +02:00
Jean-Marc Lasgouttes
d68f6f7f40 Add FIXME: do we need to update scrollbar at each draw()?
Related to ticket #11947.
2020-08-30 19:16:38 +02:00
Stephan Witt
0fa4b7e736 #9376 prepare use of Length in lyxrc - move the class Length to support 2020-08-07 09:24:31 +02:00
Jean-Marc Lasgouttes
501f4e848f Cleanup: BufferView should not need to be friend of TextMetrics
It did access par_metrics_[] directly because there was no non-const
parMetrics().

This patch adds one and unfriends BufferView. The code is equivalent
since in all these cases, the metrics have just been computed with
redoParagraph().
2020-07-14 00:08:07 +02:00
Jean-Marc Lasgouttes
2e8c9cfc83 Fix paragraph position in TextMetrics::singleParUpdate()
When running redoParagraph, it may happen that the ascent of the first
row changes. Since the ParagraphMetrics position is actually the
baseline of its first row, it may be necessary to update it.

Fixes bug #11601.
2020-07-13 23:43:09 +02:00
Jean-Marc Lasgouttes
907f020724 Improve handling of top and bottom margin
The 20px space on top and bottom of document have traditionally been
obtained by adding them to the ascent/descent of the first/last row.
This leads to annoyances like selections that are drawn in these
margins and issues with the nesting marker.

The change is to add the value to the ParagraphMetrics ascent/descent
only and to correct one place where the ascent of the first row may be
different from the ascent of the ParagraphMetrcs object. There may be
other places where this should be done.

Fixes bug #9545.
2020-07-13 02:42:39 +02:00
Jean-Marc Lasgouttes
32f06d01ec Revert "Improve handling of top and bottom margin"
It turns out this is not ready at all.

This reverts commit ff7cdf1b74.
2020-07-13 00:00:36 +02:00
Jean-Marc Lasgouttes
ff7cdf1b74 Improve handling of top and bottom margin
The 20px space on top and bottom of document have traditionally been
obtained by adding the to the ascent/descent of the first/last row.
This reads to annoyances like selections that are drawn in these
margins and issues with the nesting marker.

The change is to add the values to a separate member of the Row
object, and to add new Row::total(Ascent|Descent) methods that add the
effect of this padding.

Moreover, some methods are added to TextMetrics to simplify the
BufferView code.

Fixes bug #9545.
2020-07-12 20:32:04 +02:00
Jean-Marc Lasgouttes
8d51b3e7bb Simplify code by using initializer lists for vectors.
{ REFERENCE_NEXT, NOTE_NEXT } can be used as a value for a
vector<FuncCode> since C++11.
2020-05-23 17:10:17 +02:00
Jean-Marc Lasgouttes
7761e1317e Fix first draw of auto-open inset
note-next and reference-next should trigger an update so that metrics
are updated when the cursor ends up in an auto-open inset.

Fixes bug #11870.
2020-05-23 16:50:04 +02:00