]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
fix reading the author field.
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /**
3  * \file BufferView.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alfredo Braustein
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  * \author Jürgen Vigna
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef BUFFER_VIEW_H
16 #define BUFFER_VIEW_H
17
18 #include "support/types.h"
19
20 #include <boost/utility.hpp>
21
22 #include <string>
23
24 class Buffer;
25 class Change;
26 class DocIterator;
27 class ErrorList;
28 class FuncRequest;
29 class FuncStatus;
30 class InsetOld;
31 class Language;
32 class LCursor;
33 class LyXText;
34 class LyXScreen;
35 class LyXView;
36 class Painter;
37 class ParIterator;
38
39 /**
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.
43  *
44  * Eventually we will allow several views onto a single
45  * buffer, but not yet.
46  */
47 class BufferView : boost::noncopyable {
48 public:
49         /**
50          * Create a view with the given owner main window,
51          * of the given dimensions.
52          */
53         BufferView(LyXView * owner, int w, int h);
54
55         ~BufferView();
56
57         /// set the buffer we are viewing
58         void setBuffer(Buffer * b);
59         /// return the buffer being viewed
60         Buffer * buffer() const;
61
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;
68
69         /// return the visible top y
70         int top_y() const;
71
72         /// set the visible top y
73         void top_y(int);
74
75         /// resize event has happened
76         void resize();
77
78         /// reload the contained buffer
79         void reload();
80         /// create a new buffer based on template
81         void newFile(std::string const & fname, std::string const & tname,
82                      bool named = true);
83         /// load a buffer into the view
84         bool loadLyXFile(std::string const & name, bool tolastfiles = true);
85
86         /// fit the user cursor within the visible view
87         bool fitCursor();
88         /// perform pending painting updates
89         void update();
90         /// reset the scrollbar to reflect current view position
91         void updateScrollbar();
92         /// FIXME
93         void redoCurrentBuffer();
94
95         /// FIXME
96         bool available() const;
97
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);
104
105         /// return the current change at the cursor
106         Change const getCurrentChange();
107
108         /// return the lyxtext we are using
109         LyXText * getLyXText() const;
110
111         /// simple replacing. Use the font of the first selected character
112         void replaceSelectionWithString(std::string const & str);
113
114         /// move cursor to the named label
115         void gotoLabel(std::string const & label);
116
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);
123
124         /// hide the cursor if it is visible
125         void hideCursor();
126
127         /// center the document view around the cursor
128         void center();
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);
133
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;
138
139         /// switch between primary and secondary keymaps for RTL entry
140         void switchKeyMap();
141
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);
148
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);
153
154         /// clear the X selection
155         void unsetXSel();
156
157         /// access to full cursor
158         LCursor & cursor();
159         /// access to full cursor
160         LCursor const & cursor() const;
161         ///
162         LyXText * text() const;
163         ///
164         void setCursor(ParIterator const & par, lyx::pos_type pos);
165         ///
166         void putSelectionAt(DocIterator const & cur,
167                 int length, bool backwards);
168
169 private:
170         ///
171         struct Pimpl;
172         ///
173         friend struct BufferView::Pimpl;
174         ///
175         Pimpl * pimpl_;
176 };
177
178 #endif // BUFFERVIEW_H