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>
41 // The structure that keeps track of the selections set.
44 : set_(false), mark_(false)
59 bool set_; // former selection
60 bool mark_; // former mark_set
64 * A buffer view encapsulates a view onto a particular
65 * buffer, and allows access to operate upon it. A view
66 * is a sliding window of the entire document rendering.
68 * Eventually we will allow several views onto a single
69 * buffer, but not yet.
71 class BufferView : boost::noncopyable {
74 * Create a view with the given owner main window,
75 * of the given dimensions.
77 BufferView(LyXView * owner, int x, int y, int w, int h);
81 /// set the buffer we are viewing
82 void buffer(Buffer * b);
83 /// return the buffer being viewed
84 Buffer * buffer() const;
86 /// return the painter object for drawing onto the view
87 Painter & painter() const;
88 /// return the screen object for handling re-drawing
89 LyXScreen & screen() const;
90 /// return the owning main view
91 LyXView * owner() const;
93 /// return the visible top y
96 /// set the visible top y
99 /// resize event has happened
102 /// reload the contained buffer
104 /// create a new buffer based on template
105 bool newFile(std::string const & fname, std::string const & tname,
107 /// load a buffer into the view
108 bool loadLyXFile(std::string const & name, bool tolastfiles = true);
110 /// fit the user cursor within the visible view
112 /// perform pending painting updates
114 /// reset the scrollbar to reflect current view position
115 void updateScrollbar();
117 void redoCurrentBuffer();
120 bool available() const;
122 /// Save the current position as bookmark i
123 void savePosition(unsigned int i);
124 /// Restore the position from bookmark i
125 void restorePosition(unsigned int i);
126 /// does the given bookmark have a saved position ?
127 bool isSavedPosition(unsigned int i);
129 /// return the current change at the cursor
130 Change const getCurrentChange();
132 /// return the lyxtext we are using
133 LyXText * getLyXText() const;
135 /// update paragraph dialogs
136 void updateParagraphDialog();
138 /// return the current encoding at the cursor
139 Encoding const * getEncoding() const;
141 /// return the parent language of the given inset
142 Language const * getParentLanguage(InsetOld * inset) const;
144 /// replace the currently selected word
145 void replaceWord(std::string const & replacestring);
146 /// simple replacing. Use the font of the first selected character
147 void replaceSelectionWithString(std::string const & str);
149 /// move cursor to the named label
150 void gotoLabel(std::string const & label);
157 /// get the stored error list
158 ErrorList const & getErrorList() const;
159 /// show the error list to the user
160 void showErrorList(std::string const &) const;
161 /// set the cursor based on the given TeX source row
162 void setCursorFromRow(int row);
165 * Insert an inset into the buffer.
166 * Place it in a layout of lout,
168 bool insertInset(InsetOld * inset, std::string const & lout = std::string());
170 /// Inserts a lyx file at cursor position. return false if it fails
171 bool insertLyXFile(std::string const & file);
174 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
176 /// hide the cursor if it is visible
179 /// center the document view around the cursor
181 /// scroll document by the given number of lines of default height
182 void scroll(int lines);
183 /// Scroll the view by a number of pixels
184 void scrollDocView(int);
186 /// return the pixel width of the document view
187 int workWidth() const;
188 /// return the pixel height of the document view
189 int workHeight() const;
191 /// switch between primary and secondary keymaps for RTL entry
195 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
197 /// get the contents of the window system clipboard
198 std::string const getClipboard() const;
199 /// fill the window system clipboard
200 void stuffClipboard(std::string const &) const;
201 /// tell the window system we have a selection
202 void haveSelection(bool sel);
204 /// execute the given function
205 bool dispatch(FuncRequest const & argument);
207 /// set target x position of cursor
208 void x_target(int x);
209 /// return target x position of cursor
210 int x_target() const;
212 /// clear the X selection
215 /// access to full cursor
216 LCursor & fullCursor();
217 /// access to full cursor
218 void fullCursor(LCursor const &);
219 /// access to full cursor
220 LCursor const & fullCursor() const;
221 /// access to topmost cursor slice
222 CursorSlice & cursor();
223 /// access to topmost cursor slice
224 CursorSlice const & cursor() const;
225 /// access to selection anchor
226 CursorSlice & anchor();
227 /// access to selection anchor
228 CursorSlice const & anchor() const;
230 UpdatableInset * innerInset() const;
232 LyXText * text() const;
236 Selection & selection();
238 Selection const & selection() const;
240 CursorSlice & selStart();
242 CursorSlice const & selStart() const;
244 CursorSlice & selEnd();
246 CursorSlice const & selEnd() const;
250 void clearSelection();
252 void putSelectionAt(PosIterator const & cur, int length, bool backwards);
255 Selection selection_;
261 friend struct BufferView::Pimpl;
266 * The target x position of the cursor. This is used for when
267 * we have text like :
269 * blah blah blah blah| blah blah blah
271 * blah blah blah blah blah blah
273 * When we move onto row 3, we would like to be vertically aligned
274 * with where we were in row 1, despite the fact that row 2 is
281 #endif // BUFFERVIEW_H