Commit Graph

481 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
9c55af4a22 Merge remote-tracking branch 'features/scroll-reloaded'
This implement horizontal scrolling of rows to allow editing insets
(math, tabular...) that are larger then the screen. The scrolling happens
as the cursor moves, in order to make sure that the cursor is always visible.
This effectively closes an 11 years old bug.

This feature is the result of the work of Hashini Senaratne as part of
Google Summer of Code 2013. The code has been cleaned-up for inclusion
and remaining bugs have been fixed.

Fixes bug: #1083.
2015-01-10 18:39:09 +01:00
Jean-Marc Lasgouttes
c6e1db7682 Fix some display glitches
* When doing a redraw with drawing disabled (to set inset positions properly), take horizontal scroll offset in account

* reset horizontal scroll offset when it is smaller than the left margin.

* when drawing a paragraph, do not modify x globally, only for the row that is offset.
2015-01-07 22:55:11 +01:00
Jean-Marc Lasgouttes
fcaf5b5fc8 Remove the special horizontal scrolling support in InsetTabular
It is not necessary anymore now that there is a global mechanism.

Also, fix the clearing of rows in SingleParUpdate mode.
2015-01-07 22:55:11 +01:00
Jean-Marc Lasgouttes
a7ba04dbaf Fine tune the scroll offset setting code
The new code should feel a bit more natural. It avoids explicit pixel values for the margins and does not scroll in some cases where it is not necessary.
2015-01-07 22:55:11 +01:00
Hashini Senaratne
5a361b35cf Keyboard based horizontal scrolling for wide insets
[This commit is the output of the "horizontal scrolling" GSoC 2013
 project, by Hashini Senaratne. The code has been cleaned up, some
 variables have been renamed and moved from the Cursor class to
 BufferView::Private. This is the base from which I (jmarc) will polish
 the feature for landing on master.

 Below is the original commit log of Hashini, updated to reflect the
 changes that have been done.]

This feature also applicable for other insets; graphics and labels.

This implementation is capable of scrolling a single row when reaching
its content which is beyond the screen limits, using left and right
arrow keys.

The attribute 'horiz_scroll_offset_' introduced in the
BufferView::Private class plays a main role in horizontal scrolling of
the wide rows that grow beyond the screen limits. This attribute
represents by how much pixels the current row that the text cursor
lies in should be get scrolled.

The main logic that is responsible for drawing the scrolled rows is
within the BufferView class, BufferView::checkCursorScrollOffset.

 * The main logic is called via BufferView::draw.

 * What this does is set the horiz_scroll_offset_ attribute in in order to
 show the position that the text cursor lies in.

 * To make sure that BufferView::draw gets involved when Update flag is
 FitCursor, necessary changes are made in BufferView::processUpdateFlags.

Basically what the logic that used to set the horiz_scroll_offset_
does is,

 * The row which the text cursor lies in is identified by a
 CursorSlice that points to the beginning of the row. This is the
 'rowSlice' variable used in BufferView::checkCursorScrollOffset. Acessors
 are added to obtain this variable. Here row objects were not used to
 identify the current row, because it appears that row objects can
 disappear when doing a decoration update for example. This means that
 comparing row pointers is not a good idea, because they can change
 without notice.

 * Stop calculations of horiz_scroll_offset_ variable, if metrics have not been
 computed yet. Otherwise the calls to TextMetrics::parMetrics, calls
 redoParagraph and may change the row heigths. Therefore vertical scrolling
 feature may get disturbed. This is avoided.

 * Using BufferView::::setCurrentRowSlice resets horiz_scroll_offset_
 when changing cursor row. This is done in order to prevent unwanted
 scrolling that happens when changing the selected row using up and
 down arrow keys.

 * Recompute inset positions before checking scoll offset of the row, by
 painting the row insets with drawing disabled. This is done because the
 position of insets is computed within the drawing procedure.

 * Current x position of the text cursor is compared with the
 horiz_scroll_offset_ value and the other variables like row.width(),
 bv.workWidth(). Compute the new horiz_scroll_offset_ value in order
 to show where the text cursor lies in. The basics conditions that we
 check before recomputing it are, if the text cursor lies rightward to
 the current right screen boundary, if the text cursor lies leftward
 to the current left screen boundary, if the text cursor lies within
 screen boundaries but the length of the row is less than the left
 boundary of the screen (this happens when we delete some content of
 the row using delete key or backspace key).

 * Change update strategy when scrooll offset has changed. This allows to
 redraw the row when no drawing was scheduled. By doing so, it was
 possible to redraw a wide row when moving to the leftmost position of the
 wide row, from the leftmost position of the row below, using the left
 arrow key.

In TextMetrics::drawParagraph it is checked whether the current row is
what is drawing now. If it is so, the value used to the x value of the row
for drawing is adapted according to BufferView::horizScrollOffset.

The method used to pass boundary() was fixed to get row when cursor was in
a nested inset. This matter is considered in Cursor::textRow and it is
modified accordingly.

GuiWorkArea::Private::showCursor() is modified to show the cursor position
in a scrolled row.
2015-01-07 22:55:11 +01:00
Jean-Marc Lasgouttes
3cbdfa1762 Fix some glitches in inset-select-all
Fix a crash reported in #7727. This happened because cur.pos() was reset before cur.pit(). In this case, cur.lastpos() will usually be wrong.

Fix bad behaviour when selecting at top level with several paragraphs.

Update documentation.
2014-11-14 10:18:34 +01:00
Jean-Marc
093a1fe14c Fix inset-select-all for insets with multiple paragraphs 2014-11-10 11:56:21 +01:00
Jean-Marc Lasgouttes
e52a385493 Reimplement inset-select-all in a generic way
There are 3 possible actions (in order)
* select current cell
* select all calls of inset
* select the inset from outside (in the containing inset)

This fixes completely #7727.
2014-11-01 16:54:23 +01:00
Jean-Marc Lasgouttes
8fb1aa51f8 Whitespace only 2014-07-25 22:40:48 +02:00
Jean-Marc Lasgouttes
5e126d2920 Whitespace only 2014-07-25 22:36:20 +02:00
Jean-Marc Lasgouttes
45eb314a86 Get rid of rtl_support preference
This variable was introduced to guard against any bad consequence of the then-new right-to-left
languages support. Let's be bold and get rid of it altogether!

Now right to left support is always enabled.
2014-07-09 21:11:08 +02:00
Enrico Forestieri
79dcf402b1 Refine fix for bug #9151.
Now the cursor in LyX jumps to the right spot instead of simply the
beginning of the paragraph. This is most useful for branch insets,
for example, which may contain long paragraphs.
2014-06-06 15:35:24 +02:00
Enrico Forestieri
44e09b223e Fix bug #9151 (Wrong reverse search for images and tables).
If the reverse position corresponds to an inset, its paragraph id
does not follow the main text numbering. Typically, an inset has
only a few paragraph, so that we would jump near the beginning of
the document. In this way we at least jump at the beginning of the
inset.
2014-06-05 23:46:18 +02:00
Richard Heck
0a6ff99f28 Typos and style. 2014-04-21 11:51:59 -04:00
Juergen Spitzmueller
9b6eea6ca5 Do not crash when entering math in ct mode with merge dialog open.
Fixes: #7685.
2014-04-21 11:51:58 -04:00
Juergen Spitzmueller
b8661bcfb3 style 2014-04-21 11:51:58 -04:00
Juergen Spitzmueller
a70571258d Fix assertion when ChkTeX hit math.
The problem here was that we used texted-only methods (via paragraph()), which triggered the assertion as soon as we were inside math.

Fixes: #8798
2014-04-21 11:51:57 -04:00
Richard Heck
fdbe775b9f This is the result of an audit of all static variables, looking
for possible thread conflicts, of the sort Georg resolved at
6a30211f. I have made static variables const where possible,
and marked cases that looked potentially problematic with the
comment:
	// FIXME THREAD
Many of these definitely are vulnerable to concurrent access, such
as the static variables declared at the start of output_latex.cpp.
Suppose, e.g., we were outputting latex and also displaying the
source of a different document.

I'd appreciate it if others could grep for "FIXME THREAD" and see
if some of these are harmless, or what.
2014-04-21 11:51:57 -04:00
Jean-Marc Lasgouttes
ad56bded03 Bug #9005: various things that do not work as intended in passthru paragraphs
* disable branch-add-insert in pass thru paragraphs

* when it is not possible to input a quote inset, insert a single
  ascii quote when argument to quote-insert is "single"

* handle "mathspace" dialog in Text::getStatus

* disable insertion of newline inset in pass thru paragraphs

* handle "mathdelimiter" and "mathmatrix" dialogs in GuiView::getStatus.
2014-03-04 11:56:03 +01:00
Tommaso Cucinotta
2a86379ea7 Adding wrap-around pop-up question to simple find and replace dialog (fixing enhancement request #1262). 2013-07-21 17:51:53 +01:00
Vincent van Ravesteijn
97405fa623 Fix bug 7673 by reverting changes to BufferView::checkDepm
This reverts commit 210a4406 and a part of 5577e877.
2013-05-19 22:17:14 +02:00
Jean-Marc Lasgouttes
21c5bbec71 Fix bug #8627: Command line switches to change branch do not appear to work
Move the handling of branch-(de)activate(master) to Buffer. This code was moved to Bufferview in [3a03e71c/lyxgit] because a cursor was necessary to call Undo::recordUndoFullDocument(). However, it turns out that the undo code is already prepared to handle an empty cursor (and do nothing in this case).

Therefore we do that and move the branch code to Buffer where it belongs.

Note that there was a bug in the previous code that broke undo support: recordUndo should always be called _before_ doing any change.
2013-04-29 17:24:28 +02:00
Richard Heck
d79225ae98 Remove all messages to user related to assertions. We'll just use
a basic message which is defined in lassert.cpp now.
2013-04-27 17:52:55 -04:00
Kornel Benko
06d72d6ca0 Use doctring as LBUFFER() etc parameters 2013-04-27 21:38:01 +02:00
Kornel Benko
07ca50d905 Strings as parameters to LASSERT should not be translatable.
But empty strings are even worse.
2013-04-27 21:13:32 +02:00
Richard Heck
1b1f8dd235 Audit all the LASSERT calls, and try to do something sensible at
each failure.

There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:

Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525:        // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143:                // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83:     // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92:     // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303:                     // LASSERT: Why would this fail?
Text.cpp:995:           // LASSERT: Is it safe to continue here?
2013-04-25 17:27:10 -04:00
Scott Kostyshak
2427e9b57a Remove exclamation mark from "String not found!"
When using 'find' and a string is not found, this is not an error or a
surprising event. It is often expected (e.g. after searching through
the whole document for a certain string eventually you will get this
message). The exclamation mark should be reserved for messages that
are unexpected or that need extra attention, such as errors.
2013-04-01 15:33:41 -04:00
Richard Heck
ef88b88aec Typo. 2013-02-18 09:44:27 -05:00
Jean-Marc Lasgouttes
f7548ae2cd Make sure that inset-forall does not skip insets
This could happen with
  inset-forall Note:Note char-delete-forward
when there where consecutive note insets.
2013-01-25 10:57:10 +01:00
Benjamin Piwowarski
8c09d3ba1a Fixed a bug when there is no citation 2013-01-15 14:51:29 +01:00
Benjamin Piwowarski
9f62413b10 Initial patch for citation-insert 2013-01-15 14:51:29 +01:00
Richard Heck
ae7bc12ab6 Disentangle moduleCanBeAdded for ordinary layout modules and the
new (but not yet functioning, it seems) citation modules. This
fixes a bug reported on the list:
  http://marc.info/?l=lyx-users&m=135456590710371&w=2
2012-12-05 11:16:21 -05:00
Lars Gullik Bjønnes
6b2232a29c src/*.cpp: reformatting to increase consistency 2012-10-28 17:42:07 +01:00
Juergen Spitzmueller
fab7d42608 Whitespace 2012-09-30 16:27:11 +02:00
Juergen Spitzmueller
e26635bfb9 UI for separate control of master/child branch state (#7642, part of #7643) 2012-09-30 14:59:24 +02:00
Vincent van Ravesteijn
a1bda4e045 Fix bug #8296: Crash when clicking on completion in math
When the user clicks on the completion, the completion disappears. This
means that we have to fix the cursor before setting it.
2012-09-23 16:44:22 +02:00
Jean-Marc Lasgouttes
0ef36860c3 Handle sending a FuncRequest object to lyxerr
* Implement the corresponding operator<<

  * Use it in a couple new places
2012-06-07 17:21:49 +02:00
Richard Heck
8b2aab9b3d Style. 2012-06-04 13:42:46 -04:00
Richard Heck
7ef8df460a Fix crash reported by Tommaso:
http://marc.info/?l=lyx-devel&m=133876924408431&w=2
The problem here is that the copy_params() routine in FindAndReplace.cpp
created a new DocumentClass, but it never updated its Buffer to reflect
that new DocumentClass. So its Paragraphs still contained points to the
Layouts in the old DocumentClass which, since ead697d4b6, gets garbage
collected once it is no longer needed. So the Layout doesn't exist, and
we crash.
2012-06-04 13:39:24 -04:00
Richard Heck
ead697d4b6 Deal with memory issue reported some time ago in connection with DocumentClass
objects. The problem that led to the leak is that these objects can be held in
memory long after the Buffer that created them is gone, mostly due to their
use in the CutStack. So they were previously held in a storage facility, the
DocumentClassBundle. Unfortunately, they were now being created too often,
especially by cloning. It's not really a leak, because they're accessible, but
we weren't ever destroying them.

This new approach uses a shared_ptr instead.

Thanks to Vincent for pointing out const_pointer_cast.
2012-05-31 12:34:29 -04:00
Vincent van Ravesteijn
d20cb73b87 Fix bug #8166: Crash on clicking away from empty last paragraph
This reverts the previous fix in [0a33374c/lyxgit] and fixes it
differently.

We always have to call 'notifyCursorLeaves', but we only have to make sure
that we call the 'fixIfBroken()' functions first.
2012-05-23 08:02:40 +02:00
Vincent van Ravesteijn
0a33374c0d Fix bug #8166: Crash on clicking away from empty paragraph
We rely on the 'or' operator to prevent us from calling
'notifyCursorLeaves' if one of the two cursors is broken. This doesn't
work when using the '|' operator. The compiler 'optimizes' the code in
such a way that we always call notifyCursorLeaves anyway. Using the '||'
operator fixes this.
2012-05-23 01:31:43 +02:00
Enrico Forestieri
9825621798 Fix bug #8140: Crash with math macros and input completion
When clicking away in the same math inset after hitting '\', the
cursor may be broken and all of its instances have to be fixed.
2012-04-30 23:55:34 +02:00
Vincent van Ravesteijn
3a395ca0f5 BufferView::dispatch(): add a missing break 2012-04-29 14:51:24 +02:00
Stephan Witt
42dfd71197 #7789 unify and fix buffer statistics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40602 a592a061-630c-0410-9148-cb99ea01b6c8
2012-01-12 07:03:24 +00:00
Tommaso Cucinotta
7422c56d67 Fixing consistency of replace actions in GUI with readonly status of target document buffer
(i.e., it was possible to replace in readonly buffers!)
See also http://comments.gmane.org/gmane.editors.lyx.devel/140074


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40548 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-30 15:31:56 +00:00
Jean-Marc Lasgouttes
84c603255d further fix to #7909
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40505 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-16 14:36:31 +00:00
Pavel Sanda
278498f81b Experimental search for highest upper bound of inset-forall reported by user.
Fixes #7945.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40501 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-15 16:39:35 +00:00
Vincent van Ravesteijn
7d98d770b1 Cleanup r40377
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40379 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-05 13:41:15 +00:00
Vincent van Ravesteijn
a35e512e90 Fix bug #7916: Undo warning message when inserting plaintext file
LFUN_INSERT_PLAINTEXT is handled in GuiView because it might need to ask for a filename. But if the filename is given as a paramater we can handle it in BufferView immediately. Also, when we've asked for the filename in GuiView we should dispatch the LFUN to BufferView in order to properly use the Undo mechanism.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40377 a592a061-630c-0410-9148-cb99ea01b6c8
2011-12-05 13:12:57 +00:00