]> git.lyx.org Git - lyx.git/blob - src/BufferView.h
9168849a6881d485130a627d98670a7a502ce01e
[lyx.git] / src / BufferView.h
1 // -*- C++ -*-
2 /** \file
3  *  Copyright 2002 the LyX Team
4  *  Read the file COPYING
5  *
6  *  \author Lars Gullik Bjønnes
7 */
8
9 #ifndef BUFFER_VIEW_H
10 #define BUFFER_VIEW_H
11
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #include "LString.h"
17 #include "undo.h"
18 #include "commandtags.h"
19
20 #include "insets/inset.h"
21
22 #include <boost/utility.hpp>
23
24 class LyXView;
25 class LyXText;
26 class TeXErrors;
27 class Buffer;
28 class LyXScreen;
29 class Language;
30 class Painter;
31 class UpdatableInset;
32
33 ///
34 class BufferView : boost::noncopyable {
35 public:
36         ///
37         enum UpdateCodes {
38                 ///
39                 UPDATE = 0,
40                 ///
41                 SELECT = 1,
42                 ///
43                 FITCUR = 2,
44                 ///
45                 CHANGE = 4
46         };
47
48         ///
49         BufferView(LyXView * owner, int , int , int, int);
50         ///
51         ~BufferView();
52         ///
53         Buffer * buffer() const;
54         ///
55         Painter & painter() const;
56         ///
57         LyXScreen & screen() const;
58         ///
59         void buffer(Buffer * b);
60         ///
61         void resize();
62         ///
63         void redraw();
64         ///
65         bool fitCursor();
66         ///
67         void update();
68         //
69         void update(LyXText *, UpdateCodes uc);
70         ///
71         void updateScrollbar();
72         ///
73         Inset * checkInsetHit(LyXText *, int & x, int & y);
74         ///
75         void redoCurrentBuffer();
76         ///
77         void cursorPrevious(LyXText *);
78         ///
79         void cursorNext(LyXText *);
80         ///
81         bool available() const;
82         ///
83         LyXView * owner() const;
84         ///
85         void beforeChange(LyXText *);
86         ///
87         void savePosition(unsigned int i);
88         ///
89         void restorePosition(unsigned int i);
90         ///
91         bool isSavedPosition(unsigned int i);
92         /** This holds the mapping between buffer paragraphs and screen rows.
93             This should be private...but not yet. (Lgb)
94         */
95         LyXText * text;
96         ///
97         LyXText * getLyXText() const;
98         ///
99         LyXText * getParentText(Inset * inset) const;
100         ///
101         Language const * getParentLanguage(Inset * inset) const;
102         ///
103         int workWidth() const;
104         ///
105         UpdatableInset * theLockingInset() const;
106         ///
107         void theLockingInset(UpdatableInset * inset);
108         ///
109         void updateInset(Inset * inset, bool mark_dirty);
110         ///
111         int slx;
112         ///
113         int sly;
114         ///
115         void insetUnlock();
116         ///
117         void replaceWord(string const & replacestring);
118         ///
119         void endOfSpellCheck();
120         ///
121         void selectLastWord();
122         ///
123         string const nextWord(float & value);
124         ///
125         bool gotoLabel(string const & label);
126         ///
127         void paste();
128         ///
129         void cut(bool realcut = true);
130         ///
131         void copy();
132         ///
133         void pasteEnvironment();
134         ///
135         void copyEnvironment();
136         ///
137         void menuUndo();
138         ///
139         void menuRedo();
140         /// removes all autodeletable insets
141         bool removeAutoInsets();
142         ///
143         void insertErrors(TeXErrors & terr);
144         ///
145         void setCursorFromRow(int row);
146         /** Insert an inset into the buffer.
147             Placie it in a layout of lout,
148             if no_table make sure that it doesn't end up in a table.
149         */
150         //bool insertInset(Inset * inset, string const & lout = string(),
151         //               bool no_table = false);
152         bool insertInset(Inset * inset, string const & lout = string());
153         /** Inserts a lyx file at cursor position.
154             \return #false# if it fails.
155         */
156         bool insertLyXFile(string const & file);
157         ///
158         bool lockInset(UpdatableInset * inset);
159         ///
160         void showLockedInsetCursor(int x, int y, int asc, int desc);
161         ///
162         void hideLockedInsetCursor();
163         ///
164         bool fitLockedInsetCursor(int x, int y, int asc, int desc);
165         ///
166         int unlockInset(UpdatableInset * inset);
167         ///
168         void lockedInsetStoreUndo(Undo::undo_kind kind);
169         ///
170         void showCursor();
171         ///
172         void hideCursor();
173         ///
174         void toggleSelection(bool = true);
175         ///
176         void toggleToggle();
177         ///
178         void center();
179
180         /// Scroll the view by a number of pixels
181         void scrollDocView(int);
182
183         ///
184         void setState();
185
186         ///
187         bool ChangeInsets(Inset::Code code, string const & from,
188                           string const & to);
189         ///
190         bool ChangeRefsIfUnique(string const & from, string const & to);
191         ///
192         bool ChangeCitationsIfUnique(string const & from, string const & to);
193         ///
194         string const getClipboard() const;
195         ///
196         void pasteClipboard(bool asPara);
197         ///
198         void stuffClipboard(string const &) const;
199         ///
200         bool Dispatch(kb_action action, string const & argument);
201 private:
202         ///
203         struct Pimpl;
204         ///
205         friend struct BufferView::Pimpl;
206         ///
207         Pimpl * pimpl_;
208 };
209
210
211 ///
212 BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
213                                   BufferView::UpdateCodes uc2);
214
215 #endif