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