1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-11-04 01:40:20 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-01-24 18:34:46 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-11-04 01:40:20 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
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"
|
2001-02-23 16:10:03 +00:00
|
|
|
#include "commandtags.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "insets/inset.h"
|
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;
|
2000-06-19 15:33:58 +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;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2001-04-17 13:43:57 +00:00
|
|
|
class BufferView : boost::noncopyable {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2000-06-12 11:27:15 +00:00
|
|
|
///
|
|
|
|
enum UpdateCodes {
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
UPDATE = 0,
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
SELECT = 1,
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
FITCUR = 2,
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
CHANGE = 4
|
|
|
|
};
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-21 06:10:21 +00:00
|
|
|
BufferView(LyXView * owner, int , int , int, int);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-10 00:07:59 +00:00
|
|
|
~BufferView();
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
Buffer * buffer() const;
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
Painter & painter();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-06-19 15:33:58 +00:00
|
|
|
LyXScreen * screen() const;
|
|
|
|
///
|
1999-11-09 23:52:04 +00:00
|
|
|
void buffer(Buffer * b);
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
void resize(int, int, int, int);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void resize();
|
|
|
|
///
|
|
|
|
void redraw();
|
|
|
|
///
|
2001-08-02 14:55:06 +00:00
|
|
|
void fitCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void update();
|
2000-08-07 20:58:24 +00:00
|
|
|
//
|
2001-02-14 08:38:21 +00:00
|
|
|
void update(LyXText *, UpdateCodes uc);
|
2000-01-06 02:44:26 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
void updateScrollbar();
|
|
|
|
///
|
2001-12-17 14:25:04 +00:00
|
|
|
Inset * checkInsetHit(LyXText *, int & x, int & y);
|
2000-07-04 11:30:07 +00:00
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
void redoCurrentBuffer();
|
|
|
|
///
|
|
|
|
int resizeCurrentBuffer();
|
|
|
|
///
|
2000-10-10 10:38:11 +00:00
|
|
|
void cursorPrevious(LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-10-10 10:38:11 +00:00
|
|
|
void cursorNext(LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
bool available() const;
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
LyXView * owner() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-02-14 10:11:22 +00:00
|
|
|
void beforeChange(LyXText *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
void savePosition(unsigned int i);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
void restorePosition(unsigned int i);
|
2000-06-05 15:12:09 +00:00
|
|
|
///
|
2001-01-28 18:31:36 +00:00
|
|
|
bool isSavedPosition(unsigned int i);
|
1999-12-10 00:07:59 +00:00
|
|
|
/** This holds the mapping between buffer paragraphs and screen rows.
|
|
|
|
This should be private...but not yet. (Lgb)
|
|
|
|
*/
|
|
|
|
LyXText * text;
|
2000-01-07 03:42:16 +00:00
|
|
|
///
|
2000-12-17 06:09:35 +00:00
|
|
|
LyXText * getLyXText() const;
|
|
|
|
///
|
2001-01-08 16:14:09 +00:00
|
|
|
LyXText * getParentText(Inset * inset) const;
|
|
|
|
///
|
|
|
|
Language const * getParentLanguage(Inset * inset) const;
|
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
int workWidth() const;
|
2000-02-25 12:06:15 +00:00
|
|
|
///
|
2000-10-03 13:55:48 +00:00
|
|
|
UpdatableInset * theLockingInset() const;
|
2000-10-03 18:38:10 +00:00
|
|
|
///
|
2000-10-03 15:31:35 +00:00
|
|
|
void theLockingInset(UpdatableInset * inset);
|
2000-01-07 03:42:16 +00:00
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
void updateInset(Inset * inset, bool mark_dirty);
|
|
|
|
///
|
2000-01-07 03:42:16 +00:00
|
|
|
int slx;
|
|
|
|
///
|
|
|
|
int sly;
|
|
|
|
///
|
|
|
|
void insetUnlock();
|
|
|
|
///
|
|
|
|
void insetSleep();
|
|
|
|
///
|
|
|
|
void insetWakeup();
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
|
|
|
void replaceWord(string const & replacestring);
|
|
|
|
///
|
|
|
|
void endOfSpellCheck();
|
|
|
|
///
|
|
|
|
void selectLastWord();
|
|
|
|
///
|
2000-09-14 17:53:12 +00:00
|
|
|
string const nextWord(float & value);
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
|
|
|
bool gotoLabel(string const & label);
|
|
|
|
///
|
|
|
|
void paste();
|
|
|
|
///
|
2001-08-08 14:36:56 +00:00
|
|
|
void cut(bool realcut = true);
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
|
|
|
void copy();
|
|
|
|
///
|
|
|
|
void pasteEnvironment();
|
|
|
|
///
|
|
|
|
void copyEnvironment();
|
|
|
|
///
|
|
|
|
void menuUndo();
|
|
|
|
///
|
|
|
|
void menuRedo();
|
|
|
|
/// removes all autodeletable insets
|
|
|
|
bool removeAutoInsets();
|
|
|
|
///
|
|
|
|
void insertErrors(TeXErrors & terr);
|
|
|
|
///
|
|
|
|
void setCursorFromRow(int row);
|
2000-08-07 20:58:24 +00:00
|
|
|
/** Insert an inset into the buffer.
|
|
|
|
Placie it in a layout of lout,
|
|
|
|
if no_table make sure that it doesn't end up in a table.
|
|
|
|
*/
|
2001-06-04 23:57:32 +00:00
|
|
|
//bool insertInset(Inset * inset, string const & lout = string(),
|
|
|
|
// bool no_table = false);
|
|
|
|
bool insertInset(Inset * inset, string const & lout = string());
|
2000-08-07 20:58:24 +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);
|
|
|
|
///
|
2000-04-19 14:42:19 +00:00
|
|
|
bool lockInset(UpdatableInset * inset);
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
void showLockedInsetCursor(int x, int y, int asc, int desc);
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
2000-02-17 19:59:08 +00:00
|
|
|
void hideLockedInsetCursor();
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
2000-09-29 18:44:07 +00:00
|
|
|
void fitLockedInsetCursor(int x, int y, int asc, int desc);
|
2000-01-08 21:02:58 +00:00
|
|
|
///
|
|
|
|
int unlockInset(UpdatableInset * inset);
|
|
|
|
///
|
|
|
|
void lockedInsetStoreUndo(Undo::undo_kind kind);
|
2000-02-17 19:59:08 +00:00
|
|
|
///
|
|
|
|
void showCursor();
|
|
|
|
///
|
|
|
|
void hideCursor();
|
|
|
|
///
|
|
|
|
void toggleSelection(bool = true);
|
|
|
|
///
|
|
|
|
void toggleToggle();
|
|
|
|
///
|
|
|
|
void center();
|
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
bool focus() const;
|
|
|
|
///
|
|
|
|
void focus(bool);
|
|
|
|
///
|
|
|
|
bool active() const;
|
2000-02-23 16:39:03 +00:00
|
|
|
///
|
|
|
|
bool belowMouse() const;
|
2000-04-26 13:57:28 +00:00
|
|
|
/// A callback for the slider in the scrollbar.
|
|
|
|
void scrollCB(double);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-03 19:51:27 +00:00
|
|
|
///
|
2000-02-17 19:59:08 +00:00
|
|
|
void setState();
|
2000-02-03 19:51:27 +00:00
|
|
|
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
void pushIntoUpdateList(Inset * i);
|
2000-05-19 16:46:01 +00:00
|
|
|
///
|
2001-01-31 20:39:53 +00:00
|
|
|
bool ChangeInsets(Inset::Code code, string const & from,
|
|
|
|
string const & to);
|
2000-05-20 01:38:25 +00:00
|
|
|
///
|
2000-12-11 09:46:09 +00:00
|
|
|
bool ChangeRefsIfUnique(string const & from, string const & to);
|
|
|
|
///
|
2001-01-31 20:39:53 +00:00
|
|
|
bool ChangeCitationsIfUnique(string const & from, string const & to);
|
|
|
|
///
|
2001-05-03 15:38:24 +00:00
|
|
|
string const getClipboard() const;
|
|
|
|
///
|
2000-05-20 21:37:05 +00:00
|
|
|
void pasteClipboard(bool asPara);
|
|
|
|
///
|
|
|
|
void stuffClipboard(string const &) const;
|
2001-02-23 16:10:03 +00:00
|
|
|
///
|
|
|
|
bool Dispatch(kb_action action, string const & argument);
|
2000-04-08 17:02:02 +00:00
|
|
|
private:
|
|
|
|
struct Pimpl;
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-26 10:29:33 +00:00
|
|
|
friend struct BufferView::Pimpl;
|
2000-08-07 20:58:24 +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
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2000-06-12 11:27:15 +00:00
|
|
|
BufferView::UpdateCodes operator|(BufferView::UpdateCodes uc1,
|
|
|
|
BufferView::UpdateCodes uc2);
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|