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
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
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;
|
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 {
|
2002-10-21 16:21:56 +00:00
|
|
|
|
UPDATE = 0, //< FIXME
|
|
|
|
|
SELECT = 1, //< selection change
|
|
|
|
|
FITCUR = 2, //< the cursor needs fitting into the view
|
|
|
|
|
CHANGE = 4 //< document data has changed
|
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
|
|
|
|
|
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);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// update for a particular inset
|
|
|
|
|
void updateInset(Inset * inset, bool mark_dirty);
|
|
|
|
|
/// 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);
|
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
|
|
|
|
|
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
|
2000-01-08 21:02:58 +00:00
|
|
|
|
bool gotoLabel(string const & label);
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// copy the environment type from current paragraph
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void copyEnvironment();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// set the current paragraph's environment type
|
|
|
|
|
void pasteEnvironment();
|
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();
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// insert all errors found when running latex
|
2000-01-08 21:02:58 +00:00
|
|
|
|
void insertErrors(TeXErrors & terr);
|
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
|
|
|
|
/// show the user cursor
|
|
|
|
|
void showCursor();
|
|
|
|
|
/// hide the user cursor
|
|
|
|
|
void hideCursor();
|
|
|
|
|
/// FIXME
|
2000-09-29 18:44:07 +00:00
|
|
|
|
void showLockedInsetCursor(int x, int y, int asc, int desc);
|
2002-10-21 16:21:56 +00:00
|
|
|
|
/// FIXME
|
2000-02-17 19:59:08 +00:00
|
|
|
|
void hideLockedInsetCursor();
|
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
|
|
|
|
|
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
|
|
|
|
/// height of a normal line in pixels (zoom factor considered)
|
|
|
|
|
int defaultHeight() const;
|
|
|
|
|
/// 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
|