Commit Graph

255 Commits

Author SHA1 Message Date
Guillaume Munch
591b311984 Amend 71623b88
Fix loop of word-delete-backward at the start of a paragraph.
2017-02-19 14:54:44 +01:00
Guillaume Munch
63be456c8d When pressing math with the mouse, move to the closest edge (#9748)
Unless it has some dialog that we want to activate.
2017-02-18 23:03:54 +01:00
Guillaume Munch
71623b88b2 Generalise the deletion protection mechanism from math to text (#9540)
Now backspace and delete in text will select non-empty math and text insets
before deleting them. This is consistent with what happens in math already.

This is implemented for InsetText as well but can be disabled in case of
negative feedback.

This can be set for any sort of inset with the new virtual method
Inset::confirmDeletion.

New option "force" for the LFUN_*_DELETE_* commands, that bypasses the
confirmDeletion check.
2017-02-18 23:03:23 +01:00
Jean-Marc Lasgouttes
1fca708c7f Move TextMetrics::findRowElement to Row class 2017-02-02 15:35:03 +01:00
Jean-Marc Lasgouttes
57c3a94730 Add RtL information to Row
This allows to somewhat simplify the text and avoid some uses of
Paragraph (in the long term, RowPainter should not have to access
these things).

At the same time do a small cleanup to RowPainter: rename
text_metrics_ to tm_, remove pm_ and width_.
2017-02-02 14:53:01 +01:00
Jean-Marc Lasgouttes
344f7f2e7d Make sanitize more robust to dangling pointers.
It is necessary to sanitize the new_word iterator too.
2017-02-01 10:11:55 +01:00
Guillaume Munch
981f065bde New word-movement behaviour in Math
Following discussion on the list:
https://www.mail-archive.com/lyx-users@lists.lyx.org/msg103012.html

This defines a new behaviour for Ctrl[+Shift]+Arrow in math:

* Left/Right does not enter insets

* Left/Right jump groups of insets that have the same math class ("words")

* Enable Up/Down for consistency.
2017-01-03 20:35:41 +01:00
Guillaume Munch
3a73b822a5 GuiSymbols: show all symbols when UseNonTeXFonts 2016-12-03 23:35:15 +01:00
Jean-Marc Lasgouttes
b099d9ae15 Fix height of cursor inside insets
It turns out that Cursor::getFont() does not return a fully realized
font in some cases. This patch uses real_current_font instead, which
seems better anyway.

I suspect that all uses of getFont() should be removed, but this is
not code that I know well.

Fixes bug #10478.
2016-11-04 12:01:43 +01:00
Enrico Forestieri
3bc80220a7 Amend 6a3ced3c
ERT macros are also math insets, sigh...
2016-09-25 18:59:07 +02:00
Enrico Forestieri
6a3ced3cfb Do not confuse global commands with ERT macros 2016-09-25 02:00:55 +02:00
Guillaume Munch
c36ada6b96 Helpers to set selections to arbitrary DocIterators 2016-09-23 23:39:48 +02:00
Guillaume Munch
3fd2398a28 Remove option to disable texrow
I suspect that the gain was negligible, yet it made debugging and maintainance
harder.
2016-09-23 23:39:48 +02:00
Enrico Forestieri
c4aca5705b Correctly distinguish ERT macros from predefined ones such as \alpha 2016-09-16 02:15:52 +02:00
Enrico Forestieri
a26e75cd8a Correctly distinguish LyX macros from those defined in ERT
At this time the MacroData of a macro is still uninitialized,
so the macro() method always returns null.
2016-09-16 00:43:04 +02:00
Enrico Forestieri
364e8d6692 Avoid inserting spurious \text insets in mathed
This amends 5cdbaf51.
2016-09-16 00:37:04 +02:00
Enrico Forestieri
a24033ff0e Ensure consistency
On export, a macro defined in ERT (or not defined at all) is left
in the same environment it is entered. So, don't explicitly insert
it in an ensuremath environment when it is entered in a textmode one.
2016-09-12 07:55:38 +02:00
Enrico Forestieri
615c733844 Make sure a pointer is valid before using it 2016-09-12 05:15:00 +02:00
Enrico Forestieri
5cdbaf51ee Avoid duplicating mode changing commands 2016-09-10 02:39:57 +02:00
Enrico Forestieri
324651899e Ensure proper mode in mathed
A math-mode command entered in a text-mode environment is wrapped
in an ensuremath inset, as well as a text-mode command entered in a
math-mode environment is wrapped in a text inset. Who doesn't like
the extra insets can always dissolve them and rely on the wrapping
performed on export.
2016-09-10 02:07:47 +02:00
Guillaume Munch
670efa8f64 Rationalise includes
Modifying TexRow.h or texstream.h no longer triggers the recompilation of the
complete source tree.
2016-07-04 02:42:17 +02:00
Guillaume Munch
489dca71cd Simplifications, mainly removal of boost::function and useless std::bind 2016-07-03 01:39:32 +02:00
Jean-Marc Lasgouttes
83d8e12cc1 Rename Cursor::setSelection(bool) to selection(bool)
The old name would be confusing wrt setSelection(), which does additional checks.
This one is a pure acessor, and the more complete methods are
* setSelection(), which avoids empty selections
* clearSelection(), which resets anchor, and sets word selection and mark more to false.

Most of the code should use these two instead of selection(bool), but this is for later.
2016-05-29 17:55:46 -04:00
Jean-Marc Lasgouttes
700e480a18 Cleanup bruteFind. 2016-05-29 17:55:45 -04:00
Jean-Marc Lasgouttes
27bc2e4b63 Remove unused bruteFind* functions
And rename bruteFind2 to bruteFind.
2016-05-29 17:55:45 -04:00
Jean-Marc Lasgouttes
171fe0cb43 Remove unused CursorData::logicalpos_
This was introduced in 41ecabf5, probably by mistake.
2016-05-29 17:55:45 -04:00
Guillaume Munch
6d4e6aad24 Automatically show the review toolbar if the document has tracked changes
(#8738)

For efficiency, we add a new flag to the buffer indicating when changes are
present. This flag is updated at each buffer update, and also when explicitly
requested via a dispatch result flag.
2016-05-29 17:55:42 -04:00
Guillaume Munch
70fe2c618e Correct strange FIXME 2016-05-28 17:42:31 -04:00
Jean-Marc Lasgouttes
0aaa930a5c Do not assert when cursor is deeper than anchor
This works around bug #9917 and might give us an occasion of obtaining a recipe for reproducing it.
2016-03-22 13:48:15 +01:00
Jean-Marc Lasgouttes
e8e97d67d9 Fix Cursor::inCoordCache: the root inset is never in the cache
Fixes bug #10007.
2016-03-11 16:55:03 +01:00
Enrico Forestieri
9edbeef7b7 Make sure the cursor is in texted 2016-01-28 14:13:17 +01:00
Enrico Forestieri
bbb5a1a28f Always place the cursor before a separator inset when moving up or down. 2016-01-10 00:08:10 +01:00
Jean-Marc Lasgouttes
d3c0044617 Fix entering inset in visual cursor mode
Improve the test whether cursor has moved in Cursor::posVisLeft. The code for posVisRight had already been fixed for #5764 at 0730c923, but this replaces both tests by the proper == operator.

Fixes bug #9913.
2016-01-05 15:03:30 +01:00
Richard Heck
947aaf7a57 There does not appear to be any need to update the entire Buffer
after each entry into mathed. Instead, we just update the TOC for
anything the mathed happens to be inside.
2015-12-12 17:19:33 -05:00
Jean-Marc Lasgouttes
79bb97b1ba Detect properly when cursor position cannot be computed
Replace old ad-hoc test by a better one that inspects the coordcache to see whether all the insets in the cursor are known.

Fixes bug #9881.
2015-12-07 13:25:10 +01:00
Guillaume Munch
460a764b7f Adding TexRow information on math latex output (#4725)
WriteStream is now built from an otexstream instead of an odocstream, and
therefore counts lines in a TexRow. Calls to TexRow are added in relevant places
in math insets.

This finishes adding line tracking for math in the source panel and for forward
search.
2015-10-19 06:55:17 +01:00
Guillaume Munch
e2d7a4534a Add a unique id to math insets
The id is just the memory address.

The status bar now spits out the math inset uid information when in a math cell
in DEVEL_VERSION, like it already does when in a paragraph.

This is preliminary work for extending the cursor<->row tracking to math.
2015-10-19 06:55:17 +01:00
Jean-Marc Lasgouttes
eb9250ff2c Small code cleanup 2015-10-09 15:48:59 +02:00
Jean-Marc Lasgouttes
e24f782eeb Get rid of old Bidi code
This removes the old implementation of Cursor::getSurroundingPos, that has been superceded in commit .

As this was the last user of the Bidi class, this can be removed too.
2015-10-09 15:17:34 +02:00
Jean-Marc Lasgouttes
21c30a09e1 Rewrite Cursor::getSurroundingPos without Bidi class
New method TextMetrics::findRowElement, excerpted from CursorX.

Reimplement getSurroundingPos using Row information. This is easy when
the cursor is inside a row element. At row element edges, different
situations can occur; hopefully all these situations are taken into
account.

Rename the old getSurroundingPos to getSurroundingPosOrig and
transform getSurroundingPos into a wrapper that compares the two
methods. This will be removed when we are confident that the new
function is equivalent to the old one.

It will then be possible to remove also the Bidi class (at last!).
2015-09-27 22:17:46 +02:00
Jean-Marc
b63421b7dc Merge branch 'rowpainter2' 2015-07-21 23:47:12 +02:00
Jean-Marc Lasgouttes
8ec4080537 Remember the cursor before an undo group
With this patch, the cursor position before undo can be saved when
creating an undo group. Any such value will supercede parameters
passed to recordUndo. Only the first such cursor set by nested
beginUndoGoup takes effect.

Fixes bug #9663.
2015-07-21 11:57:50 +02:00
Jean-Marc Lasgouttes
d328fb2021 Rewrite Cursor::posVisToRowExtremity without Bidi class
It is trivial to implement it using TextMetrics::getPosNearX.
2015-07-18 00:39:55 +02:00
Jean-Marc Lasgouttes
96692bdbb0 Move some functions out of Bidi.*
The functions reverseDirectionNeeded() and reverseDirectionNeeded() do
not rely on the Bidi class. The first one is changed into a Cursor
method, and the second one is replaced with explicit code.
2015-07-16 11:57:40 +02:00
Jean-Marc Lasgouttes
f41e423b30 Small clean-up to debug support 2015-07-08 11:03:42 +02:00
Jean-Marc Lasgouttes
469a1f48a6 Properly notify insets after BufferView::doDispatch
Currently, insets are notified that the cursor entered or leaved them in Cursor::dispatch. This is not the cas efor lfuns which are handled in BufferView.

Adding the proper code allows to fix many bugs where previews are not updated correctly.

This also reverts cf4f79f8, which was the same fix for a particular case.

Fixes bug #6173.
2015-06-08 15:10:36 +02:00
Jean-Marc Lasgouttes
32148586a8 Place the cursor correctly after undoing an inset dissolution
The cleanup in 11ca1406 was not correct. It is actually not possible to implement recordUndoInset from the undo API, since the cursor may not be at a different level than the text to be saved.

Fixes ticket #9553
2015-05-20 12:14:34 +02:00
Georg Baum
b596330093 Fix compilation with boost 1.58
Newer boost versions use complicated type traits for boost::next and
boost::prior, which do not work with the RandomAccessList iterators.
The long term solution is to use std::next and std::prev, for now supply
simple replacements for compilers that do not support C++11 yet.
2015-05-16 00:05:23 +02:00
Jean-Marc Lasgouttes
11ca140667 Clean-up the undo API
* Remove the UndoKind parameter in the general interface
* move recordUndoInset to Cursor
* remove one variant of Undo::recordUndo.
* get rid of Text::recUndo.
2015-04-01 14:18:23 +02:00
Jean-Marc Lasgouttes
97c6e6d1ba Do not sanitize the anchor of cursor when selection is not set
Additionally, move the code to write to a stream from Cursor to CursorData (so that debugging undo is easier). We loose x_target, but I am not sure it is important.

This is the second part of bug #9432.
2015-03-10 16:17:29 +01:00