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 /** update for a particular inset. Gets a pointer and not a
91 * reference because we really need the pointer information
92 * to find it in the buffer.
94 void updateInset(InsetOld const *);
95 /// reset the scrollbar to reflect current view position
96 void updateScrollbar();
98 void redoCurrentBuffer();
101 bool available() const;
104 void beforeChange(LyXText *);
106 /// Save the current position as bookmark i
107 void savePosition(unsigned int i);
108 /// Restore the position from bookmark i
109 void restorePosition(unsigned int i);
110 /// does the given bookmark have a saved position ?
111 bool isSavedPosition(unsigned int i);
113 /// return the current change at the cursor
114 Change const getCurrentChange();
117 * This holds the mapping between buffer paragraphs and screen rows.
118 * This should be private...but not yet. (Lgb)
121 /// return the lyxtext we are using
122 LyXText * getLyXText() const;
124 /// Return the current inset we are "locked" in
125 UpdatableInset * theLockingInset() const;
126 /// lock the given inset FIXME: return value ?
127 bool lockInset(UpdatableInset * inset);
128 /// unlock the given inset
129 int unlockInset(UpdatableInset * inset);
130 /// unlock the currently locked inset
133 /// return the current encoding at the cursor
134 Encoding const * getEncoding() const;
136 /// return the parent language of the given inset
137 Language const * getParentLanguage(InsetOld * inset) const;
139 /// replace the currently selected word
140 void replaceWord(std::string const & replacestring);
142 /// move cursor to the named label
143 void gotoLabel(std::string const & label);
150 /// get the stored error list
151 ErrorList const & getErrorList() const;
152 /// show the error list to the user
153 void showErrorList(std::string const &) const;
154 /// set the cursor based on the given TeX source row
155 void setCursorFromRow(int row);
158 * Insert an inset into the buffer.
159 * Place it in a layout of lout,
161 bool insertInset(InsetOld * inset, std::string const & lout = std::string());
163 /// Inserts a lyx file at cursor position. return false if it fails
164 bool insertLyXFile(std::string const & file);
167 bool fitLockedInsetCursor(int x, int y, int asc, int desc);
169 /// hide the cursor if it is visible
172 /// center the document view around the cursor
174 /// scroll document by the given number of lines of default height
175 void scroll(int lines);
176 /// Scroll the view by a number of pixels
177 void scrollDocView(int);
179 /// return the pixel width of the document view
180 int workWidth() const;
181 /// return the pixel height of the document view
182 int workHeight() const;
184 /// switch between primary and secondary keymaps for RTL entry
188 bool ChangeRefsIfUnique(std::string const & from, std::string const & to);
190 /// get the contents of the window system clipboard
191 std::string const getClipboard() const;
192 /// fill the window system clipboard
193 void stuffClipboard(std::string const &) const;
194 /// tell the window system we have a selection
195 void haveSelection(bool sel);
197 /// execute the given function
198 bool dispatch(FuncRequest const & argument);
200 /// set target x position of cursor
201 void BufferView::x_target(int x);
202 /// return target x position of cursor
203 int BufferView::x_target() const;
208 LCursor const & cursor() const;
211 /// Set the current locking inset
212 void theLockingInset(UpdatableInset * inset);
215 friend struct BufferView::Pimpl;
220 * The target x position of the cursor. This is used for when
221 * we have text like :
223 * blah blah blah blah| blah blah blah
225 * blah blah blah blah blah blah
227 * When we move onto row 3, we would like to be vertically aligned
228 * with where we were in row 1, despite the fact that row 2 is
235 #endif // BUFFERVIEW_H