1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-08-04 23:11:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file BufferView.h
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-11-04 01:40:20 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Alfredo Braustein
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
#ifndef BUFFER_VIEW_H
|
|
|
|
|
#define BUFFER_VIEW_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-02-02 11:07:51 +00:00
|
|
|
|
#include "support/types.h"
|
|
|
|
|
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class Buffer;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
class Change;
|
2004-03-31 19:11:56 +00:00
|
|
|
|
class DocIterator;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class Encoding;
|
|
|
|
|
class ErrorList;
|
|
|
|
|
class FuncRequest;
|
2004-04-01 08:58:45 +00:00
|
|
|
|
class FuncStatus;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class InsetBase;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class InsetOld;
|
|
|
|
|
class Language;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
class LCursor;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
class LyXText;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
class LyXScreen;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class LyXView;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class Painter;
|
2004-02-02 11:07:51 +00:00
|
|
|
|
class ParIterator;
|
2003-09-06 19:16:30 +00:00
|
|
|
|
class TeXErrors;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class UpdatableInset;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* A buffer view encapsulates a view onto a particular
|
|
|
|
|
* buffer, and allows access to operate upon it. A view
|
|
|
|
|
* is a sliding window of the entire document rendering.
|
|
|
|
|
*
|
|
|
|
|
* Eventually we will allow several views onto a single
|
|
|
|
|
* buffer, but not yet.
|
|
|
|
|
*/
|
2001-04-17 13:43:57 +00:00
|
|
|
|
class BufferView : boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Create a view with the given owner main window,
|
|
|
|
|
* of the given dimensions.
|
|
|
|
|
*/
|
|
|
|
|
BufferView(LyXView * owner, int x, int y, int w, int h);
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
|
~BufferView();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// set the buffer we are viewing
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void setBuffer(Buffer * b);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the buffer being viewed
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Buffer * buffer() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the painter object for drawing onto the view
|
2002-06-12 02:54:19 +00:00
|
|
|
|
Painter & painter() const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the screen object for handling re-drawing
|
2002-06-18 15:44:30 +00:00
|
|
|
|
LyXScreen & screen() const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the owning main view
|
|
|
|
|
LyXView * owner() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
/// return the visible top y
|
|
|
|
|
int top_y() const;
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
2003-08-27 14:55:20 +00:00
|
|
|
|
/// set the visible top y
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void top_y(int);
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// resize event has happened
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void resize();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-03-08 05:37:54 +00:00
|
|
|
|
/// reload the contained buffer
|
|
|
|
|
void reload();
|
2003-07-07 08:37:02 +00:00
|
|
|
|
/// create a new buffer based on template
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void newFile(std::string const & fname, std::string const & tname,
|
2003-07-07 08:37:02 +00:00
|
|
|
|
bool named = true);
|
2003-06-20 12:46:28 +00:00
|
|
|
|
/// load a buffer into the view
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool loadLyXFile(std::string const & name, bool tolastfiles = true);
|
2003-03-08 05:37:54 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// fit the user cursor within the visible view
|
2002-03-29 15:49:45 +00:00
|
|
|
|
bool fitCursor();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// perform pending painting updates
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void update();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// reset the scrollbar to reflect current view position
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void updateScrollbar();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void redoCurrentBuffer();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool available() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Save the current position as bookmark i
|
2002-03-21 17:27:08 +00:00
|
|
|
|
void savePosition(unsigned int i);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Restore the position from bookmark i
|
2002-03-21 17:27:08 +00:00
|
|
|
|
void restorePosition(unsigned int i);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// does the given bookmark have a saved position ?
|
2001-01-28 18:31:36 +00:00
|
|
|
|
bool isSavedPosition(unsigned int i);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// return the current change at the cursor
|
|
|
|
|
Change const getCurrentChange();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the lyxtext we are using
|
2000-12-17 06:09:35 +00:00
|
|
|
|
LyXText * getLyXText() const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the parent language of the given inset
|
2003-07-25 21:20:24 +00:00
|
|
|
|
Language const * getParentLanguage(InsetOld * inset) const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2004-01-14 17:21:39 +00:00
|
|
|
|
/// simple replacing. Use the font of the first selected character
|
|
|
|
|
void replaceSelectionWithString(std::string const & str);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// move cursor to the named label
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void gotoLabel(std::string const & label);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-05-20 16:51:31 +00:00
|
|
|
|
/// get the stored error list
|
|
|
|
|
ErrorList const & getErrorList() const;
|
2003-05-13 21:15:48 +00:00
|
|
|
|
/// show the error list to the user
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void showErrorList(std::string const &) const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// set the cursor based on the given TeX source row
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void setCursorFromRow(int row);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Inserts a lyx file at cursor position. return false if it fails
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool insertLyXFile(std::string const & file);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
2002-03-29 15:49:45 +00:00
|
|
|
|
bool fitLockedInsetCursor(int x, int y, int asc, int desc);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// hide the cursor if it is visible
|
|
|
|
|
void hideCursor();
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// center the document view around the cursor
|
2000-02-17 19:59:08 +00:00
|
|
|
|
void center();
|
2002-10-21 00:15:48 +00:00
|
|
|
|
/// scroll document by the given number of lines of default height
|
|
|
|
|
void scroll(int lines);
|
2002-06-12 15:01:32 +00:00
|
|
|
|
/// Scroll the view by a number of pixels
|
|
|
|
|
void scrollDocView(int);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the pixel width of the document view
|
|
|
|
|
int workWidth() const;
|
|
|
|
|
/// return the pixel height of the document view
|
|
|
|
|
int workHeight() const;
|
|
|
|
|
|
|
|
|
|
/// switch between primary and secondary keymaps for RTL entry
|
2002-07-17 04:13:41 +00:00
|
|
|
|
void switchKeyMap();
|
2000-02-03 19:51:27 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// get the contents of the window system clipboard
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const getClipboard() const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// fill the window system clipboard
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void stuffClipboard(std::string const &) const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// tell the window system we have a selection
|
2002-08-29 13:41:58 +00:00
|
|
|
|
void haveSelection(bool sel);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2004-04-01 08:58:45 +00:00
|
|
|
|
/// return true for events that will handle
|
|
|
|
|
FuncStatus getStatus(FuncRequest const & cmd);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// execute the given function
|
|
|
|
|
bool dispatch(FuncRequest const & argument);
|
2003-11-04 07:43:03 +00:00
|
|
|
|
|
2003-12-12 15:19:35 +00:00
|
|
|
|
/// clear the X selection
|
|
|
|
|
void unsetXSel();
|
|
|
|
|
|
2004-01-13 18:08:13 +00:00
|
|
|
|
/// access to full cursor
|
2004-01-20 14:25:24 +00:00
|
|
|
|
LCursor & cursor();
|
2004-01-13 18:08:13 +00:00
|
|
|
|
/// access to full cursor
|
2004-01-20 14:25:24 +00:00
|
|
|
|
LCursor const & cursor() const;
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2003-11-28 15:08:38 +00:00
|
|
|
|
LyXText * text() const;
|
2004-01-14 17:21:39 +00:00
|
|
|
|
///
|
2004-02-02 11:07:51 +00:00
|
|
|
|
void setCursor(ParIterator const & par, lyx::pos_type pos);
|
|
|
|
|
///
|
2004-03-31 19:11:56 +00:00
|
|
|
|
void putSelectionAt(DocIterator const & cur,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
int length, bool backwards);
|
2004-01-14 14:16:11 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
private:
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
struct Pimpl;
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2000-06-26 10:29:33 +00:00
|
|
|
|
friend struct BufferView::Pimpl;
|
2003-11-28 08:55:12 +00:00
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Pimpl * pimpl_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
#endif // BUFFERVIEW_H
|