1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-08-04 23:11:50 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file BufferView.h
|
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
1999-11-04 01:40:20 +00:00
|
|
|
|
*
|
2002-03-12 17:15:44 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*/
|
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
|
|
|
|
|
2001-03-08 14:56:55 +00:00
|
|
|
|
#include "LString.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
|
#include "undo.h"
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "insets/inset.h"
|
2002-03-12 17:15:44 +00:00
|
|
|
|
|
2000-10-02 00:55:02 +00:00
|
|
|
|
#include <boost/utility.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
class Change;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class LyXView;
|
2000-02-04 09:38:32 +00:00
|
|
|
|
class LyXText;
|
2000-04-08 17:02:02 +00:00
|
|
|
|
class TeXErrors;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
class Buffer;
|
2002-06-18 15:44:30 +00:00
|
|
|
|
class LyXScreen;
|
2001-01-08 16:14:09 +00:00
|
|
|
|
class Language;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class Painter;
|
|
|
|
|
class UpdatableInset;
|
2002-08-13 14:40:38 +00:00
|
|
|
|
class WordLangTuple;
|
2003-01-05 22:38:42 +00:00
|
|
|
|
class Encoding;
|
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
|
|
|
|
/**
|
|
|
|
|
* Codes to store necessary pending updates
|
|
|
|
|
* of the document rendering.
|
|
|
|
|
*/
|
2000-06-12 11:27:15 +00:00
|
|
|
|
enum UpdateCodes {
|
2003-03-19 14:45:22 +00:00
|
|
|
|
UPDATE = 0, //< repaint
|
|
|
|
|
SELECT = 1 //< reset selection to current cursor pos
|
2000-06-12 11:27:15 +00:00
|
|
|
|
};
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
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
|
|
|
|
|
void buffer(Buffer * b);
|
|
|
|
|
/// 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
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// resize event has happened
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void resize();
|
2002-06-21 02:22:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* Repaint the pixmap. Used for when we don't want
|
|
|
|
|
* to go through the full update() logic, just a simple
|
|
|
|
|
* repaint of the whole screen.
|
|
|
|
|
*/
|
|
|
|
|
void repaint();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-03-08 05:37:54 +00:00
|
|
|
|
/// reload the contained buffer
|
|
|
|
|
void reload();
|
|
|
|
|
|
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
|
|
|
|
// update for a particular lyxtext
|
2001-02-14 08:38:21 +00:00
|
|
|
|
void update(LyXText *, UpdateCodes uc);
|
2003-03-19 14:45:22 +00:00
|
|
|
|
/// update for the top-level lyxtext
|
|
|
|
|
void update(UpdateCodes uc);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// update for a particular inset
|
2003-03-19 14:45:22 +00:00
|
|
|
|
void updateInset(Inset * inset);
|
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
|
|
|
|
/// FIXME
|
2001-02-14 10:11:22 +00:00
|
|
|
|
void beforeChange(LyXText *);
|
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
|
|
|
|
/**
|
|
|
|
|
* This holds the mapping between buffer paragraphs and screen rows.
|
|
|
|
|
* This should be private...but not yet. (Lgb)
|
|
|
|
|
*/
|
1999-12-10 00:07:59 +00:00
|
|
|
|
LyXText * text;
|
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 current inset we are "locked" in
|
2000-10-03 13:55:48 +00:00
|
|
|
|
UpdatableInset * theLockingInset() const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// lock the given inset FIXME: return value ?
|
|
|
|
|
bool lockInset(UpdatableInset * inset);
|
|
|
|
|
/// unlock the given inset
|
|
|
|
|
int unlockInset(UpdatableInset * inset);
|
|
|
|
|
/// unlock the currently locked inset
|
2000-01-07 03:42:16 +00:00
|
|
|
|
void insetUnlock();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2003-01-05 22:38:42 +00:00
|
|
|
|
/// return the current encoding at the cursor
|
|
|
|
|
Encoding const * getEncoding() const;
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the parent language of the given inset
|
|
|
|
|
Language const * getParentLanguage(Inset * inset) const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Select the "current" word
|
|
|
|
|
void selectLastWord();
|
|
|
|
|
/// replace the currently selected word
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void replaceWord(string const & replacestring);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Update after spellcheck finishes
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void endOfSpellCheck();
|
2002-08-06 22:38:44 +00:00
|
|
|
|
/// return the next word
|
|
|
|
|
WordLangTuple const nextWord(float & value);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// move cursor to the named label
|
2003-03-29 10:29:38 +00:00
|
|
|
|
void gotoLabel(string const & label);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// undo last action
|
|
|
|
|
void undo();
|
|
|
|
|
/// redo last action
|
|
|
|
|
void redo();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2000-01-08 21:02:58 +00:00
|
|
|
|
/// removes all autodeletable insets
|
|
|
|
|
bool removeAutoInsets();
|
2003-05-13 21:15:48 +00:00
|
|
|
|
/// show the error list to the user
|
|
|
|
|
void showErrorList();
|
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
|
|
|
|
/**
|
|
|
|
|
* Insert an inset into the buffer.
|
|
|
|
|
* Place it in a layout of lout,
|
|
|
|
|
*/
|
2001-06-04 23:57:32 +00:00
|
|
|
|
bool insertInset(Inset * inset, string const & lout = string());
|
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
|
2000-01-08 21:02:58 +00:00
|
|
|
|
bool insertLyXFile(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-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void lockedInsetStoreUndo(Undo::undo_kind kind);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
2000-02-17 19:59:08 +00:00
|
|
|
|
void toggleSelection(bool = true);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME: my word !
|
2000-02-17 19:59:08 +00:00
|
|
|
|
void toggleToggle();
|
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
|
|
|
|
/// FIXME
|
2000-12-11 09:46:09 +00:00
|
|
|
|
bool ChangeRefsIfUnique(string const & from, string const & to);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
2001-01-31 20:39:53 +00:00
|
|
|
|
bool ChangeCitationsIfUnique(string const & from, string const & to);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// get the contents of the window system clipboard
|
2001-05-03 15:38:24 +00:00
|
|
|
|
string const getClipboard() const;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// fill the window system clipboard
|
2000-05-20 21:37:05 +00:00
|
|
|
|
void stuffClipboard(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
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// execute the given function
|
|
|
|
|
bool dispatch(FuncRequest const & argument);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
private:
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// Set the current locking inset
|
|
|
|
|
void theLockingInset(UpdatableInset * inset);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// return the lyxtext containing this inset
|
|
|
|
|
LyXText * getParentText(Inset * inset) const;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* Change all insets with the given code's contents to a new
|
|
|
|
|
* string. May only be used with InsetCommand-derived insets
|
|
|
|
|
* Returns true if a screen update is needed.
|
|
|
|
|
*/
|
|
|
|
|
bool ChangeInsets(Inset::Code code, string const & from,
|
|
|
|
|
string const & to);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
struct Pimpl;
|
2000-06-26 10:29:33 +00:00
|
|
|
|
friend struct BufferView::Pimpl;
|
2002-10-21 16:21:56 +00:00
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Pimpl * pimpl_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
|
|
|
|
|
|
BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
|
|
|
|
|
BufferView::UpdateCodes uc2);
|
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
#endif // BUFFERVIEW_H
|