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 <boost/utility.hpp>
40 // The structure that keeps track of the selections set.
43 : set_(false), mark_(false)
58 bool set_; // former selection
59 bool mark_; // former mark_set
63 * A buffer view encapsulates a view onto a particular
64 * buffer, and allows access to operate upon it. A view
65 * is a sliding window of the entire document rendering.
67 * Eventually we will allow several views onto a single
68 * buffer, but not yet.
70 class BufferView : boost::noncopyable {
73 * Create a view with the given owner main window,
74 * of the given dimensions.
76 BufferView(LyXView * owner, int x, int y, int w, int h);
80 /// set the buffer we are viewing
81 void buffer(Buffer * b);
82 /// return the buffer being viewed
83 Buffer * buffer() const;
85 /// return the painter object for drawing onto the view
86 Painter & painter() const;
87 /// return the screen object for handling re-drawing
88 LyXScreen & screen() const;
89 /// return the owning main view
90 LyXView * owner() const;
92 /// return the visible top y
95 /// set the visible top y
98 /// resize event has happened
101 /// reload the contained buffer
103 /// create a new buffer based on template
104 bool newFile(std::string const & fname, std::string const & tname,
106 /// load a buffer into the view
107 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
109 /// fit the user cursor within the visible view
111 /// perform pending painting updates
113 /// reset the scrollbar to reflect current view position
114 void updateScrollbar();
116 void redoCurrentBuffer();
119 bool available() const;
121 /// Save the current position as bookmark i
122 void savePosition(unsigned int i);
123 /// Restore the position from bookmark i
124 void restorePosition(unsigned int i);
125 /// does the given bookmark have a saved position ?
126 bool isSavedPosition(unsigned int i);
128 /// return the current change at the cursor
129 Change const getCurrentChange();
131 /// return the lyxtext we are using
132 LyXText * getLyXText() const;
134 /// update paragraph dialogs
135 void updateParagraphDialog();
137 /// return the current encoding at the cursor
138 Encoding const * getEncoding() const;
140 /// return the parent language of the given inset
141 Language const * getParentLanguage(InsetOld * inset) const;
143 /// replace the currently selected word
144 void replaceWord(std::string const & replacestring);
146 /// move cursor to the named label
147 void gotoLabel(std::string const & label);
154 /// get the stored error list
155 ErrorList const & getErrorList() const;
156 /// show the error list to the user
157 void showErrorList(std::string const &) const;
158 /// set the cursor based on the given TeX source row
159 void setCursorFromRow(int row);
162 * Insert an inset into the buffer.
163 * Place it in a layout of lout,
165 bool insertInset(InsetOld * inset, std::string const & lout = std::string());
167 /// Inserts a lyx file at cursor position. return false if it fails
168 bool insertLyXFile(std::string const & file);
171 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
173 /// hide the cursor if it is visible
176 /// center the document view around the cursor
178 /// scroll document by the given number of lines of default height
179 void scroll(int lines);
180 /// Scroll the view by a number of pixels
181 void scrollDocView(int);
183 /// return the pixel width of the document view
184 int workWidth() const;
185 /// return the pixel height of the document view
186 int workHeight() const;
188 /// switch between primary and secondary keymaps for RTL entry
192 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
194 /// get the contents of the window system clipboard
195 std::string const getClipboard() const;
196 /// fill the window system clipboard
197 void stuffClipboard(std::string const &) const;
198 /// tell the window system we have a selection
199 void haveSelection(bool sel);
201 /// execute the given function
202 bool dispatch(FuncRequest const & argument);
204 /// set target x position of cursor
205 void x_target(int x);
206 /// return target x position of cursor
207 int x_target() const;
209 /// clear the X selection
212 /// access to full cursor
213 LCursor & fullCursor();
214 /// access to full cursor
215 void fullCursor(LCursor const &);
216 /// access to full cursor
217 LCursor const & fullCursor() const;
218 /// access to topmost cursor slice
219 CursorSlice & cursor();
220 /// access to topmost cursor slice
221 CursorSlice const & cursor() const;
222 /// access to selection anchor
223 CursorSlice & anchor();
224 /// access to selection anchor
225 CursorSlice const & anchor() const;
227 UpdatableInset * innerInset() const;
229 LyXText * text() const;
233 Selection & selection();
235 Selection const & selection() const;
238 Selection selection_;
244 friend struct BufferView::Pimpl;
249 * The target x position of the cursor. This is used for when
250 * we have text like :
252 * blah blah blah blah| blah blah blah
254 * blah blah blah blah blah blah
256 * When we move onto row 3, we would like to be vertically aligned
257 * with where we were in row 1, despite the fact that row 2 is
264 #endif // BUFFERVIEW_H