4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alfredo Braustein
8 * \author Lars Gullik Bjønnes
10 * \author Jürgen Vigna
12 * Full author contact details are available in file CREDITS.
18 #include "support/types.h"
20 #include <boost/utility.hpp>
40 * A buffer view encapsulates a view onto a particular
41 * buffer, and allows access to operate upon it. A view
42 * is a sliding window of the entire document rendering.
44 * Eventually we will allow several views onto a single
45 * buffer, but not yet.
47 class BufferView : boost::noncopyable {
50 * Create a view with the given owner main window,
51 * of the given dimensions.
53 BufferView(LyXView * owner, int w, int h);
57 /// set the buffer we are viewing
58 void setBuffer(Buffer * b);
59 /// return the buffer being viewed
60 Buffer * buffer() const;
62 /// return the painter object for drawing onto the view
63 Painter & painter() const;
64 /// return the screen object for handling re-drawing
65 LyXScreen & screen() const;
66 /// return the owning main view
67 LyXView * owner() const;
69 /// return the visible top y
72 /// set the visible top y
75 /// resize event has happened
78 /// reload the contained buffer
80 /// create a new buffer based on template
81 void newFile(std::string const & fname, std::string const & tname,
83 /// load a buffer into the view
84 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
86 /// fit the user cursor within the visible view
88 /// perform pending painting updates
90 /// reset the scrollbar to reflect current view position
91 void updateScrollbar();
93 void redoCurrentBuffer();
96 bool available() const;
98 /// Save the current position as bookmark i
99 void savePosition(unsigned int i);
100 /// Restore the position from bookmark i
101 void restorePosition(unsigned int i);
102 /// does the given bookmark have a saved position ?
103 bool isSavedPosition(unsigned int i);
105 /// return the current change at the cursor
106 Change const getCurrentChange();
108 /// return the lyxtext we are using
109 LyXText * getLyXText() const;
111 /// simple replacing. Use the font of the first selected character
112 void replaceSelectionWithString(std::string const & str);
114 /// move cursor to the named label
115 void gotoLabel(std::string const & label);
117 /// get the stored error list
118 ErrorList const & getErrorList() const;
119 /// show the error list to the user
120 void showErrorList(std::string const &) const;
121 /// set the cursor based on the given TeX source row
122 void setCursorFromRow(int row);
124 /// hide the cursor if it is visible
127 /// center the document view around the cursor
129 /// scroll document by the given number of lines of default height
130 void scroll(int lines);
131 /// Scroll the view by a number of pixels
132 void scrollDocView(int pixels);
134 /// return the pixel width of the document view
135 int workWidth() const;
136 /// return the pixel height of the document view
137 int workHeight() const;
139 /// switch between primary and secondary keymaps for RTL entry
142 /// get the contents of the window system clipboard
143 std::string const getClipboard() const;
144 /// fill the window system clipboard
145 void stuffClipboard(std::string const &) const;
146 /// tell the window system we have a selection
147 void haveSelection(bool sel);
149 /// return true for events that will handle
150 FuncStatus getStatus(FuncRequest const & cmd);
151 /// execute the given function
152 bool dispatch(FuncRequest const & argument);
154 /// clear the X selection
157 /// access to full cursor
159 /// access to full cursor
160 LCursor const & cursor() const;
162 LyXText * text() const;
164 void setCursor(ParIterator const & par, lyx::pos_type pos);
165 /* Sets the selection. When \c backwards == false, set anchor
166 * to \c cur and cursor to \c cur + \c length. When \c
167 * backwards == true, set anchor to \c cur and cursor to \c
170 void putSelectionAt(DocIterator const & cur,
171 int length, bool backwards);
177 friend struct BufferView::Pimpl;
182 #endif // BUFFERVIEW_H