1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-08-04 23:11:50 +00:00
|
|
|
/**
|
|
|
|
* \file BufferView.h
|
2003-08-23 00:17:00 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-11-04 01:40:20 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Alfredo Braustein
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
#ifndef BUFFER_VIEW_H
|
|
|
|
#define BUFFER_VIEW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2012-03-13 16:13:31 +00:00
|
|
|
#include "DocumentClassPtr.h"
|
2007-04-28 20:44:46 +00:00
|
|
|
#include "update_flags.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
|
2007-10-31 22:40:34 +00:00
|
|
|
#include "support/strfwd.h"
|
2004-02-02 11:07:51 +00:00
|
|
|
#include "support/types.h"
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
namespace support { class FileName; }
|
|
|
|
|
2007-08-27 22:53:16 +00:00
|
|
|
namespace frontend { class Painter; }
|
2007-10-02 18:27:20 +00:00
|
|
|
namespace frontend { class GuiBufferViewDelegate; }
|
2007-08-27 22:53:16 +00:00
|
|
|
|
2003-09-06 19:16:30 +00:00
|
|
|
class Buffer;
|
2003-02-08 19:18:01 +00:00
|
|
|
class Change;
|
2007-10-11 09:59:01 +00:00
|
|
|
class CoordCache;
|
|
|
|
class Cursor;
|
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.
2014-07-26 11:17:28 +00:00
|
|
|
class CursorSlice;
|
2010-01-25 15:14:41 +00:00
|
|
|
class DispatchResult;
|
2004-03-31 19:11:56 +00:00
|
|
|
class DocIterator;
|
2009-09-19 20:56:12 +00:00
|
|
|
class DocumentClass;
|
2003-09-06 19:16:30 +00:00
|
|
|
class FuncRequest;
|
2004-04-01 08:58:45 +00:00
|
|
|
class FuncStatus;
|
2006-09-17 10:03:00 +00:00
|
|
|
class Intl;
|
2007-10-11 09:59:01 +00:00
|
|
|
class Inset;
|
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.
2014-07-26 11:17:28 +00:00
|
|
|
class PainterInfo;
|
2004-02-02 11:07:51 +00:00
|
|
|
class ParIterator;
|
2006-12-29 23:54:48 +00:00
|
|
|
class ParagraphMetrics;
|
2007-11-03 18:50:54 +00:00
|
|
|
class Point;
|
2007-10-11 09:59:01 +00:00
|
|
|
class Text;
|
|
|
|
class TextMetrics;
|
|
|
|
|
2007-09-29 08:02:37 +00:00
|
|
|
enum CursorStatus {
|
|
|
|
CUR_INSIDE,
|
|
|
|
CUR_ABOVE,
|
|
|
|
CUR_BELOW
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Scrollbar Parameters.
|
2006-06-26 16:55:35 +00:00
|
|
|
struct ScrollbarParameters
|
|
|
|
{
|
2008-04-16 18:18:12 +00:00
|
|
|
ScrollbarParameters()
|
2008-06-20 12:52:38 +00:00
|
|
|
: min(0), max(0), position(0), single_step(1), page_step(1)
|
2008-04-16 18:18:12 +00:00
|
|
|
{}
|
2008-01-17 17:06:55 +00:00
|
|
|
/// Minimum scrollbar position in pixels.
|
|
|
|
int min;
|
|
|
|
/// Maximum scrollbar position in pixels.
|
|
|
|
int max;
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Current position in the document in pixels.
|
2006-06-26 16:55:35 +00:00
|
|
|
int position;
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Line-scroll amount in pixels.
|
2008-01-17 17:06:55 +00:00
|
|
|
int single_step;
|
|
|
|
/// Page-scroll amount in pixels.
|
|
|
|
int page_step;
|
2006-06-26 16:55:35 +00:00
|
|
|
};
|
2005-05-31 14:40:30 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Screen view of a Buffer.
|
2002-10-21 16:21:56 +00:00
|
|
|
/**
|
2006-11-09 10:10:06 +00:00
|
|
|
* A BufferView encapsulates a view onto a particular
|
2002-10-21 16:21:56 +00:00
|
|
|
* buffer, and allows access to operate upon it. A view
|
|
|
|
* is a sliding window of the entire document rendering.
|
2006-11-09 10:10:06 +00:00
|
|
|
* It is the official interface between the LyX core and
|
|
|
|
* the frontend WorkArea.
|
2007-05-28 22:27:45 +00:00
|
|
|
*
|
2006-11-09 10:10:06 +00:00
|
|
|
* \sa WorkArea
|
|
|
|
* \sa Buffer
|
|
|
|
* \sa CoordCache
|
2002-10-21 16:21:56 +00:00
|
|
|
*/
|
2007-11-03 18:50:54 +00:00
|
|
|
class BufferView {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2007-08-21 07:33:46 +00:00
|
|
|
///
|
2008-02-09 17:20:23 +00:00
|
|
|
explicit BufferView(Buffer & buffer);
|
2007-10-02 18:27:20 +00:00
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
~BufferView();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// return the buffer being viewed.
|
2007-08-21 13:03:55 +00:00
|
|
|
Buffer & buffer();
|
|
|
|
Buffer const & buffer() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2008-02-09 17:20:23 +00:00
|
|
|
///
|
|
|
|
void setFullScreen(bool full_screen) { full_screen_ = full_screen; }
|
|
|
|
|
|
|
|
/// right margin
|
|
|
|
int rightMargin() const;
|
|
|
|
|
|
|
|
/// left margin
|
|
|
|
int leftMargin() const;
|
|
|
|
|
2008-03-06 12:41:38 +00:00
|
|
|
/// \return true if the BufferView is at the top of the document.
|
|
|
|
bool isTopScreen() const;
|
|
|
|
|
|
|
|
/// \return true if the BufferView is at the bottom of the document.
|
|
|
|
bool isBottomScreen() const;
|
|
|
|
|
2006-12-07 11:46:27 +00:00
|
|
|
/// perform pending metrics updates.
|
|
|
|
/** \c Update::FitCursor means first to do a FitCursor, and to
|
|
|
|
* force an update if screen position changes.
|
|
|
|
* \c Update::Force means to force an update in any case.
|
|
|
|
* \retval true if a screen redraw is needed
|
2004-11-30 01:59:49 +00:00
|
|
|
*/
|
2007-10-10 08:52:55 +00:00
|
|
|
void processUpdateFlags(Update::flags flags);
|
2005-05-31 14:40:30 +00:00
|
|
|
|
2015-10-02 13:25:09 +00:00
|
|
|
/// return true if one shall move the screen to fit the cursor.
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Only to be called with good y coordinates (after a bv::metrics)
|
2015-10-02 13:25:09 +00:00
|
|
|
bool needsFitCursor() const;
|
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.
2014-07-26 11:17:28 +00:00
|
|
|
|
|
|
|
// Returns the amount of horizontal scrolling applied to the
|
|
|
|
// top-level row where the cursor lies
|
|
|
|
int horizScrollOffset() const;
|
|
|
|
|
|
|
|
// Points to the top-level row where the cursor lies (during draw).
|
|
|
|
CursorSlice const & currentRowSlice() const;
|
|
|
|
|
|
|
|
// Points to the top-level row where the cursor lied at last draw event.
|
|
|
|
CursorSlice const & lastRowSlice() const;
|
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// reset the scrollbar to reflect current view position.
|
1999-09-27 18:44:28 +00:00
|
|
|
void updateScrollbar();
|
2006-11-09 10:10:06 +00:00
|
|
|
/// return the Scrollbar Parameters.
|
2006-06-26 16:55:35 +00:00
|
|
|
ScrollbarParameters const & scrollbarParameters() const;
|
2007-12-25 18:53:38 +00:00
|
|
|
/// \return Tool tip for the given position.
|
|
|
|
docstring toolTip(int x, int y) const;
|
2007-12-25 20:12:07 +00:00
|
|
|
/// \return the context menu for the given position.
|
2011-10-29 14:48:55 +00:00
|
|
|
std::string contextMenu(int x, int y) const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Save the current position as bookmark.
|
2007-03-29 03:41:55 +00:00
|
|
|
/// if idx == 0, save to temp_bookmark
|
|
|
|
void saveBookmark(unsigned int idx);
|
2007-08-22 14:25:51 +00:00
|
|
|
/// goto a specified position, try top_id first, and then bottom_pit.
|
|
|
|
/// \return true if success
|
|
|
|
bool moveToPosition(
|
2007-04-16 19:01:32 +00:00
|
|
|
pit_type bottom_pit, ///< Paragraph pit, used when par_id is zero or invalid.
|
|
|
|
pos_type bottom_pos, ///< Paragraph pit, used when par_id is zero or invalid.
|
|
|
|
int top_id, ///< Paragraph ID, \sa Paragraph
|
|
|
|
pos_type top_pos ///< Position in the \c Paragraph
|
2006-11-09 10:10:06 +00:00
|
|
|
);
|
|
|
|
/// return the current change at the cursor.
|
2006-10-11 20:01:32 +00:00
|
|
|
Change const getCurrentChange() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// move cursor to the named label.
|
2006-10-21 00:16:43 +00:00
|
|
|
void gotoLabel(docstring const & label);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// set the cursor based on the given TeX source row.
|
2000-01-08 21:02:58 +00:00
|
|
|
void setCursorFromRow(int row);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
2008-09-17 14:51:27 +00:00
|
|
|
/// set cursor to the given inset. Return true if found.
|
|
|
|
bool setCursorFromInset(Inset const *);
|
2009-03-26 00:09:16 +00:00
|
|
|
/// Recenters the BufferView such that the passed cursor
|
|
|
|
/// is in the center.
|
|
|
|
void recenter();
|
2008-01-29 09:51:12 +00:00
|
|
|
/// Ensure that the BufferView cursor is visible.
|
|
|
|
/// This method will automatically scroll and update the BufferView
|
2015-10-02 13:25:09 +00:00
|
|
|
/// (metrics+drawing) if needed.
|
2014-07-25 20:35:08 +00:00
|
|
|
void showCursor();
|
2008-01-29 09:51:12 +00:00
|
|
|
/// Ensure the passed cursor \p dit is visible.
|
|
|
|
/// This method will automatically scroll and update the BufferView
|
2015-10-02 13:25:09 +00:00
|
|
|
/// (metrics+drawing) if needed.
|
2009-03-26 00:09:16 +00:00
|
|
|
/// \param recenter Whether the cursor should be centered on screen
|
2010-06-14 21:48:23 +00:00
|
|
|
void showCursor(DocIterator const & dit, bool recenter,
|
|
|
|
bool update);
|
2009-03-27 17:27:38 +00:00
|
|
|
/// Scroll to the cursor.
|
|
|
|
void scrollToCursor();
|
|
|
|
/// Scroll to the cursor.
|
|
|
|
/// \param recenter Whether the cursor should be centered on screen
|
|
|
|
bool scrollToCursor(DocIterator const & dit, bool recenter);
|
2007-09-15 12:28:41 +00:00
|
|
|
/// scroll down document by the given number of pixels.
|
2008-07-04 11:33:28 +00:00
|
|
|
int scrollDown(int pixels);
|
2007-09-15 12:28:41 +00:00
|
|
|
/// scroll up document by the given number of pixels.
|
2008-07-04 11:33:28 +00:00
|
|
|
int scrollUp(int pixels);
|
2007-09-15 12:28:41 +00:00
|
|
|
/// scroll document by the given number of pixels.
|
2008-07-04 11:33:28 +00:00
|
|
|
int scroll(int pixels);
|
2006-11-09 10:10:06 +00:00
|
|
|
/// Scroll the view by a number of pixels.
|
2010-06-14 21:48:23 +00:00
|
|
|
void scrollDocView(int pixels, bool update);
|
2006-08-16 15:24:38 +00:00
|
|
|
/// Set the cursor position based on the scrollbar one.
|
|
|
|
void setCursorFromScrollbar();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// return the pixel width of the document view.
|
2002-10-21 16:21:56 +00:00
|
|
|
int workWidth() const;
|
2006-11-09 10:10:06 +00:00
|
|
|
/// return the pixel height of the document view.
|
2002-10-21 16:21:56 +00:00
|
|
|
int workHeight() const;
|
|
|
|
|
2008-02-21 19:42:34 +00:00
|
|
|
/// return the inline completion postfix.
|
|
|
|
docstring const & inlineCompletion() const;
|
|
|
|
/// return the number of unique characters in the inline completion.
|
|
|
|
size_t const & inlineCompletionUniqueChars() const;
|
|
|
|
/// return the position in the buffer of the inline completion postfix.
|
|
|
|
DocIterator const & inlineCompletionPos() const;
|
2010-11-30 03:54:29 +00:00
|
|
|
/// make sure inline completion position is OK
|
2011-02-21 15:26:28 +00:00
|
|
|
void resetInlineCompletionPos();
|
2008-02-21 19:42:34 +00:00
|
|
|
/// set the inline completion postfix and its position in the buffer.
|
2008-02-21 19:43:16 +00:00
|
|
|
/// Updates the updateFlags in \c cur.
|
2011-12-02 22:41:33 +00:00
|
|
|
void setInlineCompletion(Cursor const & cur, DocIterator const & pos,
|
2008-02-21 19:43:16 +00:00
|
|
|
docstring const & completion, size_t uniqueChars = 0);
|
2007-12-25 18:53:38 +00:00
|
|
|
|
2007-06-11 22:05:44 +00:00
|
|
|
/// translate and insert a character, using the correct keymap.
|
|
|
|
void translateAndInsert(char_type c, Text * t, Cursor & cur);
|
2000-02-03 19:51:27 +00:00
|
|
|
|
2009-04-06 12:12:06 +00:00
|
|
|
/// \return true if we've made a decision
|
|
|
|
bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
|
2006-11-09 10:10:06 +00:00
|
|
|
/// execute the given function.
|
2010-01-25 15:14:41 +00:00
|
|
|
void dispatch(FuncRequest const & cmd, DispatchResult & dr);
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// request an X11 selection.
|
|
|
|
/// \return the selected string.
|
2006-10-21 00:16:43 +00:00
|
|
|
docstring const requestSelection();
|
2006-11-09 10:10:06 +00:00
|
|
|
/// clear the X11 selection.
|
2006-09-17 08:35:12 +00:00
|
|
|
void clearSelection();
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
2007-08-24 07:05:19 +00:00
|
|
|
/// resize the BufferView.
|
2006-11-09 10:10:06 +00:00
|
|
|
/// \sa WorkArea
|
2007-08-24 07:05:19 +00:00
|
|
|
void resize(int width, int height);
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// dispatch method helper for \c WorkArea
|
|
|
|
/// \sa WorkArea
|
2007-10-05 09:38:40 +00:00
|
|
|
void mouseEventDispatch(FuncRequest const & ev);
|
* frontends/WorkArea.h(workAreaResize, scrollDocView, workAreaKeyPress,
dispatch, selectionReuqested, selectionLost): remove signals
* BufferView.[Ch] (selectionRequested, selectionLost, workAreaResize,
workAreaKeyPress, workAreaDispatch): add forwarding functions to the pimpl
* BufferView_pimpl.C (Pimpl): Remove the setup of the now deleted signals,
also remove corresponding connection objects.
* frontends/xforms/XWorkArea.h:
* frontends/qt2/QWorkArea.h:
* frontends/qt4/QWorkArea.h:
* frontends/gtk/GWorkArea.h: add LyXView as class variable view_ (qt
classes also get view() medthod)
* frontends/qt2/QWorkArea.C:
* frontends/qt2/QContentPane.C:
* frontends/qt4/QWorkArea.C:
* frontends/xforms/XWorkArea.C:
* frontends/gtk/GWorkArea.C: Change from calling signals to call
the functions directly through view_.view()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13671 a592a061-630c-0410-9148-cb99ea01b6c8
2006-04-13 18:58:48 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// access to anchor.
|
2006-10-21 00:16:43 +00:00
|
|
|
pit_type anchor_ref() const;
|
2005-04-26 11:12:20 +00:00
|
|
|
|
2007-09-29 08:02:37 +00:00
|
|
|
///
|
|
|
|
CursorStatus cursorStatus(DocIterator const & dit) const;
|
2006-11-09 10:10:06 +00:00
|
|
|
/// access to full cursor.
|
2007-04-26 14:56:30 +00:00
|
|
|
Cursor & cursor();
|
2006-11-09 10:10:06 +00:00
|
|
|
/// access to full cursor.
|
2007-04-26 14:56:30 +00:00
|
|
|
Cursor const & cursor() const;
|
2006-11-09 10:10:06 +00:00
|
|
|
/// sets cursor.
|
|
|
|
/// This will also open all relevant collapsable insets.
|
2005-02-22 11:41:22 +00:00
|
|
|
void setCursor(DocIterator const &);
|
2006-12-30 15:05:15 +00:00
|
|
|
/// Check deleteEmptyParagraphMechanism and update metrics if needed.
|
|
|
|
/// \retval true if an update was needed.
|
2007-04-26 14:56:30 +00:00
|
|
|
bool checkDepm(Cursor & cur, Cursor & old);
|
2006-11-09 10:10:06 +00:00
|
|
|
/// sets cursor.
|
|
|
|
/// This is used when handling LFUN_MOUSE_PRESS.
|
2007-10-11 14:46:53 +00:00
|
|
|
bool mouseSetCursor(Cursor & cur, bool select = false);
|
2005-12-01 10:28:50 +00:00
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// sets the selection.
|
|
|
|
/* When \c backwards == false, set anchor
|
2004-09-17 16:28:47 +00:00
|
|
|
* to \c cur and cursor to \c cur + \c length. When \c
|
|
|
|
* backwards == true, set anchor to \c cur and cursor to \c
|
|
|
|
* cur + \c length.
|
|
|
|
*/
|
2004-03-31 19:11:56 +00:00
|
|
|
void putSelectionAt(DocIterator const & cur,
|
2004-03-25 09:16:36 +00:00
|
|
|
int length, bool backwards);
|
2006-11-09 10:10:06 +00:00
|
|
|
|
2011-03-19 10:34:59 +00:00
|
|
|
/// selects the item at cursor if its paragraph is empty.
|
|
|
|
bool selectIfEmpty(DocIterator & cur);
|
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// update the internal \c ViewMetricsInfo.
|
2007-11-06 08:32:25 +00:00
|
|
|
void updateMetrics();
|
2006-07-14 09:56:21 +00:00
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
///
|
2007-04-29 23:33:02 +00:00
|
|
|
TextMetrics const & textMetrics(Text const * t) const;
|
|
|
|
TextMetrics & textMetrics(Text const * t);
|
2006-12-29 23:54:48 +00:00
|
|
|
///
|
2007-04-29 23:33:02 +00:00
|
|
|
ParagraphMetrics const & parMetrics(Text const *, pit_type) const;
|
2006-12-29 23:54:48 +00:00
|
|
|
|
2006-10-13 16:44:44 +00:00
|
|
|
///
|
2007-10-11 09:59:01 +00:00
|
|
|
CoordCache & coordCache();
|
2006-10-13 16:44:44 +00:00
|
|
|
///
|
2007-10-11 09:59:01 +00:00
|
|
|
CoordCache const & coordCache() const;
|
2007-08-27 22:53:16 +00:00
|
|
|
|
2007-09-29 09:22:17 +00:00
|
|
|
///
|
2010-04-21 13:03:04 +00:00
|
|
|
Point getPos(DocIterator const & dit) const;
|
2008-11-18 23:57:26 +00:00
|
|
|
/// is the paragraph of the cursor visible ?
|
|
|
|
bool paragraphVisible(DocIterator const & dit) const;
|
2009-04-03 21:39:06 +00:00
|
|
|
/// is the cursor currently visible in the view
|
|
|
|
bool cursorInView(Point const & p, int h) const;
|
|
|
|
/// get the position and height of the cursor
|
|
|
|
void cursorPosAndHeight(Point & p, int & h) const;
|
2007-09-29 09:22:17 +00:00
|
|
|
|
|
|
|
|
2007-08-27 22:53:16 +00:00
|
|
|
///
|
|
|
|
void draw(frontend::Painter & pain);
|
|
|
|
|
2006-11-09 10:10:06 +00:00
|
|
|
/// get this view's keyboard map handler.
|
2007-10-11 09:59:01 +00:00
|
|
|
Intl & getIntl();
|
2006-09-17 10:03:00 +00:00
|
|
|
///
|
2007-10-11 09:59:01 +00:00
|
|
|
Intl const & getIntl() const;
|
2006-09-17 10:03:00 +00:00
|
|
|
|
2007-10-02 18:27:20 +00:00
|
|
|
//
|
|
|
|
// Messages to the GUI
|
|
|
|
//
|
2006-08-24 14:10:22 +00:00
|
|
|
/// This signal is emitted when some message shows up.
|
2007-10-02 18:27:20 +00:00
|
|
|
void message(docstring const & msg);
|
2006-08-24 14:10:22 +00:00
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
/// This signal is emitted when some dialog needs to be shown.
|
2007-10-02 18:27:20 +00:00
|
|
|
void showDialog(std::string const & name);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
|
|
|
/// This signal is emitted when some dialog needs to be shown with
|
2006-11-09 10:10:06 +00:00
|
|
|
/// some data.
|
2007-11-18 00:39:15 +00:00
|
|
|
void showDialog(std::string const & name, std::string const & data,
|
|
|
|
Inset * inset = 0);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
|
|
|
/// This signal is emitted when some dialogs needs to be updated.
|
2007-10-02 18:27:20 +00:00
|
|
|
void updateDialog(std::string const & name, std::string const & data);
|
|
|
|
|
|
|
|
///
|
|
|
|
void setGuiDelegate(frontend::GuiBufferViewDelegate *);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
2007-10-03 20:15:49 +00:00
|
|
|
///
|
2007-12-02 20:05:17 +00:00
|
|
|
docstring contentsOfPlaintextFile(support::FileName const & f);
|
2007-10-03 18:56:37 +00:00
|
|
|
// Insert plain text file (if filename is empty, prompt for one)
|
2007-12-02 11:55:25 +00:00
|
|
|
void insertPlaintextFile(support::FileName const & f, bool asParagraph);
|
2007-12-02 17:50:08 +00:00
|
|
|
///
|
|
|
|
void insertLyXFile(support::FileName const & f);
|
2009-02-13 13:46:08 +00:00
|
|
|
/// save temporary bookmark for jump back navigation
|
|
|
|
void bookmarkEditPosition();
|
2009-09-27 10:29:13 +00:00
|
|
|
/// Find and return the inset associated with given dialog name.
|
|
|
|
Inset * editedInset(std::string const & name) const;
|
|
|
|
/// Associate an inset associated with given dialog name.
|
|
|
|
void editInset(std::string const & name, Inset * inset);
|
2010-04-30 14:55:37 +00:00
|
|
|
///
|
|
|
|
void clearLastInset(Inset * inset) const;
|
2010-10-24 21:41:47 +00:00
|
|
|
/// Is the mouse hovering a clickable inset or element?
|
|
|
|
bool clickableInset() const;
|
2012-06-04 17:39:24 +00:00
|
|
|
///
|
|
|
|
void makeDocumentClass();
|
2007-10-11 09:59:01 +00:00
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
private:
|
2007-11-03 18:50:54 +00:00
|
|
|
/// noncopyable
|
|
|
|
BufferView(BufferView const &);
|
|
|
|
void operator=(BufferView const &);
|
|
|
|
|
2010-04-21 13:12:40 +00:00
|
|
|
/// the position relative to (0, baseline) of outermost paragraph
|
|
|
|
Point coordOffset(DocIterator const & dit) const;
|
2007-09-28 09:11:24 +00:00
|
|
|
/// Update current paragraph metrics.
|
|
|
|
/// \return true if no further update is needed.
|
|
|
|
bool singleParUpdate();
|
2007-03-28 14:47:52 +00:00
|
|
|
|
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.
2014-07-26 11:17:28 +00:00
|
|
|
// Set the row on which the cursor lives.
|
|
|
|
void setCurrentRowSlice(CursorSlice const & rowSlice);
|
|
|
|
|
|
|
|
// Check whether the row where the cursor lives needs to be scrolled.
|
|
|
|
// Update the drawing strategy if needed.
|
|
|
|
void checkCursorScrollOffset(PainterInfo & pi);
|
|
|
|
|
2009-03-27 17:41:58 +00:00
|
|
|
/// The minimal size of the document that is visible. Used
|
|
|
|
/// when it is allowed to scroll below the document.
|
|
|
|
int minVisiblePart();
|
|
|
|
|
2013-04-19 21:26:58 +00:00
|
|
|
/// Search recursively for the innermost inset that covers (x, y) position.
|
2007-03-28 14:47:52 +00:00
|
|
|
/// \retval 0 if no inset is found.
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset const * getCoveringInset(
|
2007-04-29 23:33:02 +00:00
|
|
|
Text const & text, //< The Text where we start searching.
|
2007-03-28 14:47:52 +00:00
|
|
|
int x, //< x-coordinate on screen
|
|
|
|
int y //< y-coordinate on screen
|
2007-12-25 18:53:38 +00:00
|
|
|
) const;
|
2007-03-28 14:47:52 +00:00
|
|
|
|
2010-03-29 15:21:10 +00:00
|
|
|
/// Update the hovering status of the insets. This is called when
|
|
|
|
/// either the screen is updated or when the buffer has scolled.
|
2010-03-29 15:45:24 +00:00
|
|
|
void updateHoveredInset() const;
|
2010-03-29 15:21:10 +00:00
|
|
|
|
2009-09-19 20:56:12 +00:00
|
|
|
///
|
2012-03-13 16:13:31 +00:00
|
|
|
void updateDocumentClass(DocumentClassConstPtr olddc);
|
2003-11-28 08:55:12 +00:00
|
|
|
///
|
2006-09-16 10:08:51 +00:00
|
|
|
int width_;
|
2003-11-28 08:55:12 +00:00
|
|
|
///
|
2006-09-16 10:08:51 +00:00
|
|
|
int height_;
|
|
|
|
///
|
2008-02-09 17:20:23 +00:00
|
|
|
bool full_screen_;
|
|
|
|
///
|
2007-08-21 07:33:46 +00:00
|
|
|
Buffer & buffer_;
|
2006-09-16 10:08:51 +00:00
|
|
|
|
2007-10-13 07:33:07 +00:00
|
|
|
struct Private;
|
|
|
|
Private * const d;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2007-08-28 15:31:04 +00:00
|
|
|
/// some space for drawing the 'nested' markers (in pixel)
|
|
|
|
inline int nestMargin() { return 15; }
|
|
|
|
|
|
|
|
/// margin for changebar
|
|
|
|
inline int changebarMargin() { return 12; }
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
#endif // BUFFERVIEW_H
|