Commit Graph

544 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
8aaec85c8c Now Inset::dimension is only an access to cache
Up to now Inset::dimension was either a helper function to access
CoordCache, or... something else. This created problems to properly
use it.

In particular, the definition of InsetText::dimension created problems
for child classes. Removing this definition (actually renaming it to
dimensionHelper) allows to streamline the code.
2016-12-06 09:52:17 +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
Guillaume Munch
148b3ae773 Move class definitions inside main class
Prepare for following commits.

This prevent's forward-declaration, but including the TexRow header should be
inexpensive.
2016-10-22 23:24:01 +02:00
Guillaume Munch
2e45bade7a Simplify and add debug message 2016-10-22 23:24:00 +02:00
Guillaume Munch
67805de7de New LFUN paragraph-goto id_start pos_start id_end pos_end
This selects from start to end.

id_end must be in the same buffer as id_start.
2016-10-17 00:16:59 +02:00
Enrico Forestieri
6642152e66 Do not rely on math macros being updated
Trying to spare a few cycles by avoiding computing metrics during
screen updates and export. See also 8f86ee74, 72cf7c8f, and e36a8903.
Guillaume will tell whether this also avoids crashing his documents ;)
2016-09-25 20:31:13 +02:00
Guillaume Munch
5fbbf0f281 Reverse search: select a whole row
TexRow now returns a range {start, end} when looking up a particular row.

Reverse-search now selects the whole range instead of simply moving the cursor.
2016-09-23 23:39:48 +02:00
Guillaume Munch
c9fc5bf1c6 Fix: shift-mouse selection doesn't work well across insets
(FIXME in the code, no corresponding ticket found even though it is pretty
annoying)
2016-09-23 23:39:48 +02:00
Guillaume Munch
c36ada6b96 Helpers to set selections to arbitrary DocIterators 2016-09-23 23:39:48 +02:00
Enrico Forestieri
e36a8903d7 Really fix the problem with not updated macros
Revert to the strategy used at 8f86ee74 but not using mathedWordList
because it may be still uninitialized at load time. Instead, use the
globalMacros method for getting the same info.
There was a thinko at 8ec91e80, because globalMacros always returns
null for user defined macros.
2016-09-15 02:39:30 +02:00
Juergen Spitzmueller
c0a425a319 Move wrap check for simple search/replace to lyxfind
This gets rid of some dirty dispatch tricks and fixes wrap-around
on replace and in the spellchecker

Fixes: #10378
2016-09-14 10:23:39 +02:00
Enrico Forestieri
72cf7c8f1f Partly revert the bits of 8f86ee74 that are not necessary anymore after 8ec91e80 2016-09-14 02:51:56 +02:00
Enrico Forestieri
8f86ee74cd Make sure that math macros are updated at export time.
The math macros system is quite complex. Macros are updated during
metrics calculation, so a missing update is very likely to cause a
crash. This commit tries to assure that they are updated at export
time, which also happens when the table of contents is updated.
Moreover, in order to circumvent a possible missing update, when
a math macro is detected we try to avoid using the sym_ member
of the MacroData class, as it may contain bogus values.
2016-09-13 08:02:02 +02:00
Guillaume Munch
4d7b912ca1 Fix "scroll here" feature of scrollbar (#10311)
Prevent setRange() from causing a recursive call to scrollTo(). Reduces three
calls of scrollTo() to one call for all scrolling functions of the scroll bar
(e.g. clicking on the arrow, dragging, or clicking somewhere on the scrollbar).
2016-07-31 18:34:33 +01:00
Scott Kostyshak
60e8921349 Const a function parameter 2016-07-29 13:09:54 -04:00
Jean-Marc Lasgouttes
5a3401c66e Revert "Skip all drawing with NoScreenUpdate strategy"
This reverts commit b874bdfd40.

It was commited by mistake and actually does not seem to improve
performance.
2016-07-07 14:22:08 +02:00
Jean-Marc Lasgouttes
b874bdfd40 Skip all drawing with NoScreenUpdate strategy
It seems that it was needed in 0b0c27ef, but nowadays the metrics are
not touched when we set this strategy.
2016-07-06 11:32:54 +02:00
Richard Heck
ddda136924 The previous commit was actually a fix for bug #9158.
This adjusts the comment a bit.
2016-06-30 15:02:09 -04:00
Richard Heck
02847641a8 Fix bug #8782.
We need to invalidate the BibTeX cache when undoing or redoing. I do
not like having to do it for every undo or redo. We should only have
to do it if we restored or deleted an InsetBibTeX. But there is no
way, so far as I can see, to do it that way. I tried.
2016-06-30 14:57:08 -04:00
Guillaume Munch
325c476bcb ScrollbarParameters: clean-up and document
Position is always 0.
2016-06-13 08:46:15 +01:00
Jean-Marc Lasgouttes
e39e4cf96b Do not require an extra pit parameter when a row is available
Now that Row has a pit() member, it is possible to use it instead of passing an extra pit_type parameter to a function which already has access to a Row.
2016-05-30 14:55:41 +02:00
Jean-Marc Lasgouttes
96fee0ed7a Move some horizontal scrolling code from TextMetrics to BufferView
It is better to have all the code in the same place, and it will avoid code duplication later.
2016-05-30 14:55:41 +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
Guillaume Munch
395d9e09e2 Disable certain change tracking commands when there are no changes
Fix TODO
2016-05-29 17:55:42 -04:00
Guillaume Munch
9a09fe38bd getInnerText() 2016-05-29 17:55:42 -04:00
Jean-Marc Lasgouttes
5aa342ed75 Fix cursor position after redo
When document settings are modified, a command
  inset-forall Branch inset-toggle asign
is run to open as needed all branches. At the end of the said loop,
the cursor is reset to where it was. However, the cur_after undo
element member is not set because it already had a value.

To make this work as expected, it is necessary in LFUN_INSET_FORALL to
reset the cursor before ending the undo group and to insert a dummy
recordUndo call.

Fixes bug #10097.
2016-05-29 17:55:42 -04:00
Guillaume Munch
e3540f33e1 Simplify class structure in TocBackend
Deriving from std::vector to provide helper functions appears a touch
excessive. Use typedef instead and move helper functions to the base class. New
header Toc.h provided to replace forward-declarations.

Remove TocIterator which is useless.
2016-05-29 17:55:42 -04:00
Richard Heck
0e1834f2d9 Updates to splitting of consecutive environments.
From Enrico.
2016-05-28 17:43:01 -04:00
Jean-Marc Lasgouttes
d8f6e65ec7 Make inset-select-all select all cells only in tables
inset-select-all has 3 levels
1. select current cell
2. select all cells
3. select inset from outside.

The second level makes sense for tables (text and math), but not for things like a math fraction.

Introduce a new method Inset::isTable() that allows to detect this case properly and skip level 2.
2016-05-28 17:43:01 -04:00
Jean-Marc Lasgouttes
ffe1d53cdb Pass a BufferView to Inset::clickable 2016-05-28 17:43:01 -04:00
Jean-Marc Lasgouttes
98883304e2 When handling mouse events, make the undo group a bit larger
notifyCursorLeave can delete empty insets in mathed.

Fixes bug #10022.
2016-03-16 18:33:39 +01:00
Georg Baum
4bab2ab5f8 Fix regression of 359aef92f8
The context menu of newline insets was completely greyed out if one clicked
at the right of the inset. Thanks Scott for finding this. The fix is to undo
the cursor movement also for insets without settings, but with a context menu.
2016-03-15 21:35:50 +01:00
Enrico Forestieri
8998b88370 Make sure cursor is in texted after clicking
Fixes #9936.
2016-01-20 01:18:42 +01:00
Enrico Forestieri
55b3374f3e Always place the cursor before a separator inset when clicking 2016-01-16 16:41:04 +01:00
Jean-Marc Lasgouttes
01fc62b78e When moving cursor, always reset anchor
This applies to BufferView::moveToPosition, which is used for bookmarks and initial cursor position (on loading).

Fixes bug #9912.
2016-01-05 15:05:27 +01:00
Jean-Marc Lasgouttes
9c43747cc9 Make text margin size dependent on zoom and dpi
The default hardcoded value of 10 corresponds to 2.5mm at 100dpi, but does not make much sense on a HiDpi screen.
2015-12-11 12:26:07 +01:00
Georg Baum
92573c9ddc Fix crash in info inset dialog apply (bug 9896)
posBackward() is the exact inverse of posForward(), not backwardPos().
2015-12-10 20:21:20 +01: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
Richard Heck
2c4ec33591 Move LFUN_CHANGES_TRACK and LFUN_CHANGES_OUTPUT to Buffer.cpp,
and record an undo call. This deals with the problem of marking
the Buffer dirty, as well.

Move LFUN_BUFFER_TOGGLE_COMPRESSION and LFUN_BUFFER_TOGGLE_OUTPUT_SYNC
to Buffer.cpp, and add an undo call.
2015-11-06 23:13:11 -05:00
Jean-Marc Lasgouttes
eb1e85b096 Try to avoid horizontal scrolling with wide insets.
There was a problem with end of paragraph markers. By design, wide insets choose their size without taking in account the marker. This should not lead to unneeded horizontal scrolling.

Part of ticket #9807.
2015-11-05 09:57:42 +01:00
Jean-Marc Lasgouttes
1f81cd7b65 Set current font correctly after inset-select-all
Since we modify directly the cursor, it is wise to make sure that the current font is updated.

Fixes bug #9719.
2015-11-02 14:35:50 +01:00
Jean-Marc Lasgouttes
1f0d210ab5 Fix algorithm that computes horizontal scroll offset
Rewrite the logic completely:
* fix cases where the offset was reset unnecessarily
* fix cases where the row was scrolled too much: as soon as a side of the row is completely visible, there is no need to scroll more.
* fix cases where offset would never reset
2015-11-02 11:17:36 +01:00
Jean-Marc Lasgouttes
1db691c2f5 Fix wrong reset of horizontal scolling of current row
This partially reverts commit 0f1fdaaa9, but only redraws the current
row when the value returns by getPos is obviously false. It would also
be possible to check whether the current cursor has all its insets in
cache instead.

A better fix should be found, but this is unfortunately not 2.2 stuff.

Fixes bugs #9796 and #9812.
2015-11-02 11:11:39 +01:00
Jean-Marc Lasgouttes
26eb5092fb Get rid of ParagraphMetrics::insetDimension
We already have a CoordCache of insets dimensions. It is not necessary
to store the same information in two places.

Give a name to CoordCache tables types to improve code readability.

Remove ParagraphMetrics::singleWidth, which is not used anymore.
2015-10-19 13:17:16 +02:00
Guillaume Munch
789745df7a TexRow info in source panel and gotoCursor() for debugging
These features are active in DEVEL_VERSION when Debug is set to LATEX.

1. The TexRow information is prepended to the source panel.

2. Clicking on any line in the source triggers reverse search. (This would be an
interesting feature to implement on the user side, but we need a proper LFUN.)
2015-10-19 06:55:17 +01:00
Georg Baum
b70f2eff49 Fix regression of 359aef92f8
The context menu did no longer work for some insets, since it requires the
cursor to be in front, and editXY() is also used to determine the inset for
the context menu. Now the cursor is corrected if needed.
2015-10-18 15:26:12 +02:00
Georg Baum
8a047a4112 Add missing intializations
These were found by cppcheck:
Member variable 'x' is not initialized in the constructor.
The crash #9788 would not have happened if this had been done earlier.
2015-10-10 21:04:28 +02:00
Jean-Marc Lasgouttes
f6c6416f28 Remove PainterInfo argument to checkCursorScrollOffset
This will allow later to move its invokation to processUpdateFlags.

Also, remove wrong use of Update::SinglePar flag.
2015-10-05 18:09:34 +02:00
Jean-Marc Lasgouttes
d377e765a2 More updates to painting analysis 2015-10-04 22:28:36 +02:00
Jean-Marc Lasgouttes
ca3e4e1494 Small BufferView cleanup
Rename fitCursor() to needsFitCursor() to show that it does not do any
action. Constify.

Update a few comments.
2015-10-02 15:25:09 +02:00