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 * 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 x, int y, int w, int h);
57 /// set the buffer we are viewing
58 void buffer(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 bool 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 /// update paragraph dialogs
112 void updateParagraphDialog();
114 /// return the current encoding at the cursor
115 Encoding const * getEncoding() const;
117 /// return the parent language of the given inset
118 Language const * getParentLanguage(InsetOld * inset) const;
120 /// replace the currently selected word
121 void replaceWord(std::string const & replacestring);
123 /// move cursor to the named label
124 void gotoLabel(std::string const & label);
131 /// get the stored error list
132 ErrorList const & getErrorList() const;
133 /// show the error list to the user
134 void showErrorList(std::string const &) const;
135 /// set the cursor based on the given TeX source row
136 void setCursorFromRow(int row);
139 * Insert an inset into the buffer.
140 * Place it in a layout of lout,
142 bool insertInset(InsetOld * inset, std::string const & lout = std::string());
144 /// Inserts a lyx file at cursor position. return false if it fails
145 bool insertLyXFile(std::string const & file);
148 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
150 /// hide the cursor if it is visible
153 /// center the document view around the cursor
155 /// scroll document by the given number of lines of default height
156 void scroll(int lines);
157 /// Scroll the view by a number of pixels
158 void scrollDocView(int);
160 /// return the pixel width of the document view
161 int workWidth() const;
162 /// return the pixel height of the document view
163 int workHeight() const;
165 /// switch between primary and secondary keymaps for RTL entry
169 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
171 /// get the contents of the window system clipboard
172 std::string const getClipboard() const;
173 /// fill the window system clipboard
174 void stuffClipboard(std::string const &) const;
175 /// tell the window system we have a selection
176 void haveSelection(bool sel);
178 /// execute the given function
179 bool dispatch(FuncRequest const & argument);
181 /// set target x position of cursor
182 void x_target(int x);
183 /// return target x position of cursor
184 int x_target() const;
186 /// clear the X selection
189 /// access to full cursor
190 LCursor & fullCursor();
191 /// access to full cursor
192 void fullCursor(LCursor const &);
193 /// access to full cursor
194 LCursor const & fullCursor() const;
195 /// access to topmost cursor slice
196 CursorSlice & cursor();
197 /// access to topmost cursor slice
198 CursorSlice const & cursor() const;
199 /// access to selection anchor
200 CursorSlice & anchor();
201 /// access to selection anchor
202 CursorSlice const & anchor() const;
204 UpdatableInset * innerInset() const;
206 LyXText * text() const;
214 friend struct BufferView::Pimpl;
219 * The target x position of the cursor. This is used for when
220 * we have text like :
222 * blah blah blah blah| blah blah blah
224 * blah blah blah blah blah blah
226 * When we move onto row 3, we would like to be vertically aligned
227 * with where we were in row 1, despite the fact that row 2 is
234 #endif // BUFFERVIEW_H