1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-04-03 00:36:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file lyxtext.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-04-03 00:36:31 +00:00
|
|
|
|
* \author unknown
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author John Levon
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2003-04-03 00:36:31 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#ifndef LYXTEXT_H
|
|
|
|
|
#define LYXTEXT_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include "lyxfont.h"
|
|
|
|
|
#include "lyxcursor.h"
|
2000-02-03 19:51:27 +00:00
|
|
|
|
#include "layout.h"
|
2001-07-24 10:13:19 +00:00
|
|
|
|
#include "LColor.h"
|
2001-11-26 16:42:04 +00:00
|
|
|
|
#include "insets/inset.h"
|
2003-03-27 12:41:47 +00:00
|
|
|
|
#include "RowList.h"
|
2003-04-03 00:36:31 +00:00
|
|
|
|
#include "bufferview_funcs.h"
|
2003-06-27 11:53:41 +00:00
|
|
|
|
#include "textcursor.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
class Buffer;
|
|
|
|
|
class BufferParams;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
class BufferView;
|
2000-06-21 15:07:57 +00:00
|
|
|
|
class InsetText;
|
2001-11-26 16:42:04 +00:00
|
|
|
|
class Paragraph;
|
|
|
|
|
class Row;
|
|
|
|
|
class Spacing;
|
|
|
|
|
class UpdatableInset;
|
|
|
|
|
class VSpace;
|
2002-08-13 14:40:38 +00:00
|
|
|
|
class WordLangTuple;
|
2003-03-06 10:02:40 +00:00
|
|
|
|
class ParagraphList;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/**
|
|
|
|
|
This class holds the mapping between buffer paragraphs and screen rows.
|
|
|
|
|
*/
|
2003-06-27 11:53:41 +00:00
|
|
|
|
|
|
|
|
|
// The inheritance from TextCursor should go. It's just there to ease
|
|
|
|
|
// transition...
|
|
|
|
|
class LyXText : public TextCursor {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2000-04-10 21:40:13 +00:00
|
|
|
|
/// Constructor
|
2000-06-12 11:27:15 +00:00
|
|
|
|
LyXText(BufferView *);
|
2002-08-29 12:00:50 +00:00
|
|
|
|
/// sets inset as owner
|
2003-03-17 16:25:00 +00:00
|
|
|
|
LyXText(BufferView *, InsetText *);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-07-15 08:26:17 +00:00
|
|
|
|
void init(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
int height;
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
unsigned int width;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// the current font settings
|
2003-03-18 13:05:08 +00:00
|
|
|
|
LyXFont current_font;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// the current font
|
2003-03-18 13:05:08 +00:00
|
|
|
|
LyXFont real_current_font;
|
2003-03-06 20:21:21 +00:00
|
|
|
|
private:
|
2003-03-18 16:47:18 +00:00
|
|
|
|
/** the 'anchor' row: the position of this row remains constant
|
|
|
|
|
* with respect to the top of the screen
|
2003-03-06 20:21:21 +00:00
|
|
|
|
*/
|
2003-03-30 18:42:37 +00:00
|
|
|
|
RowList::iterator anchor_row_;
|
2003-03-17 16:25:00 +00:00
|
|
|
|
/** the pixel offset with respect to this row of top_y
|
2003-03-06 20:21:21 +00:00
|
|
|
|
*/
|
2003-03-18 16:47:18 +00:00
|
|
|
|
int anchor_row_offset_;
|
2003-03-06 20:21:21 +00:00
|
|
|
|
public:
|
2003-04-12 23:03:05 +00:00
|
|
|
|
/// update all cached row positions
|
|
|
|
|
void updateRowPositions();
|
2003-03-06 20:21:21 +00:00
|
|
|
|
/// get the y coord. of the top of the screen (relative to doc start)
|
|
|
|
|
int top_y() const;
|
2003-03-18 16:47:18 +00:00
|
|
|
|
/// set the y coord. of the top of the screen (relative to doc start)
|
2003-03-06 20:21:21 +00:00
|
|
|
|
void top_y(int newy);
|
2003-03-18 16:47:18 +00:00
|
|
|
|
/// set the anchoring row. top_y will be computed relative to this
|
2003-03-30 21:42:09 +00:00
|
|
|
|
void anchor_row(RowList::iterator rit);
|
2000-06-22 14:55:46 +00:00
|
|
|
|
///
|
|
|
|
|
InsetText * inset_owner;
|
2000-10-03 13:55:48 +00:00
|
|
|
|
///
|
|
|
|
|
UpdatableInset * the_locking_inset;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-19 16:01:31 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
int getRealCursorX() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-04-09 21:34:31 +00:00
|
|
|
|
LyXFont const getFont(Buffer const *, ParagraphList::iterator pit,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-04-10 12:10:04 +00:00
|
|
|
|
LyXFont const getLayoutFont(Buffer const *,
|
|
|
|
|
ParagraphList::iterator pit) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
///
|
2003-04-10 12:10:04 +00:00
|
|
|
|
LyXFont const getLabelFont(Buffer const *,
|
|
|
|
|
ParagraphList::iterator pit) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
///
|
2003-04-10 12:10:04 +00:00
|
|
|
|
void setCharFont(Buffer const *, ParagraphList::iterator pit,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
lyx::pos_type pos, LyXFont const & font);
|
2003-04-10 12:10:04 +00:00
|
|
|
|
void setCharFont(ParagraphList::iterator pit,
|
|
|
|
|
lyx::pos_type pos,
|
|
|
|
|
LyXFont const & font, bool toggleall);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
2003-03-30 21:42:09 +00:00
|
|
|
|
void breakAgainOneRow(RowList::iterator rit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// what you expect when pressing <enter> at cursor position
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void breakParagraph(ParagraphList & paragraphs, char keep_layout = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** set layout over selection and make a total rebreak of
|
|
|
|
|
those paragraphs
|
|
|
|
|
*/
|
2003-04-10 21:07:55 +00:00
|
|
|
|
ParagraphList::iterator
|
|
|
|
|
setLayout(LyXCursor & actual_cursor,
|
|
|
|
|
LyXCursor & selection_start,
|
|
|
|
|
LyXCursor & selection_end,
|
|
|
|
|
string const & layout);
|
2001-11-26 16:42:04 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setLayout(string const & layout);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-04-03 01:26:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* Increase or decrease the nesting depth of the selected paragraph(s)
|
|
|
|
|
* if test_only, don't change any depths. Returns whether something
|
|
|
|
|
* (would have) changed
|
|
|
|
|
*/
|
|
|
|
|
bool changeDepth(bv_funcs::DEPTH_CHANGE type, bool test_only);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
/// get the depth at current cursor position
|
2001-11-26 16:42:04 +00:00
|
|
|
|
int getDepth() const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** set font over selection and make a total rebreak of those
|
|
|
|
|
paragraphs.
|
|
|
|
|
toggleall defaults to false.
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setFont(LyXFont const &, bool toggleall = false);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** deletes and inserts again all paragaphs between the cursor
|
2000-01-13 16:28:54 +00:00
|
|
|
|
and the specified par. The Cursor is needed to set the refreshing
|
2002-03-21 17:27:08 +00:00
|
|
|
|
parameters.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
This function is needed after SetLayout and SetFont etc.
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void redoParagraphs(LyXCursor const & cursor,
|
2003-04-10 21:07:55 +00:00
|
|
|
|
ParagraphList::iterator endpit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void redoParagraph();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void toggleFree(LyXFont const &, bool toggleall = false);
|
2001-07-30 10:50:37 +00:00
|
|
|
|
|
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
string getStringToIndex();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** recalculates the heights of all previous rows of the
|
|
|
|
|
specified paragraph. needed, if the last characters font
|
2002-03-21 17:27:08 +00:00
|
|
|
|
has changed.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void redoHeightOfParagraph();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
/** insert a character, moves all the following breaks in the
|
1999-09-27 18:44:28 +00:00
|
|
|
|
same Paragraph one to the right and make a little rebreak
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void insertChar(char c);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void insertInset(Inset * inset);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-06-27 09:44:26 +00:00
|
|
|
|
/// Completes the insertion with a rebreak from 'need_break_row' on
|
|
|
|
|
void partialRebreak();
|
|
|
|
|
/// a full rebreak of the whole text
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void fullRebreak();
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-30 18:42:37 +00:00
|
|
|
|
RowList::iterator need_break_row;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
|
2003-03-16 00:45:31 +00:00
|
|
|
|
/// clear any pending paints
|
|
|
|
|
void clearPaint();
|
|
|
|
|
|
2003-07-15 11:08:02 +00:00
|
|
|
|
/// Mark position y as the starting point for a repaint
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void postPaint(int start_y);
|
2003-03-16 00:45:31 +00:00
|
|
|
|
|
2003-07-15 11:08:02 +00:00
|
|
|
|
/// Mark the given row at position y as needing a repaint.
|
2003-03-30 21:42:09 +00:00
|
|
|
|
void postRowPaint(RowList::iterator rit, int start_y);
|
2003-03-16 00:45:31 +00:00
|
|
|
|
|
2002-08-19 15:39:25 +00:00
|
|
|
|
///
|
|
|
|
|
Inset::RESULT dispatch(FuncRequest const & cmd);
|
|
|
|
|
|
2003-03-17 16:25:00 +00:00
|
|
|
|
BufferView * bv();
|
|
|
|
|
|
|
|
|
|
BufferView * bv() const;
|
|
|
|
|
|
2003-03-17 01:34:36 +00:00
|
|
|
|
friend class LyXScreen;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the status. This represents what repaints are
|
|
|
|
|
* pending after some operation (e.g. inserting a char).
|
|
|
|
|
*/
|
2003-07-15 11:08:02 +00:00
|
|
|
|
bool needRefresh() const;
|
2003-03-17 01:34:36 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
private:
|
2003-03-17 01:34:36 +00:00
|
|
|
|
/**
|
|
|
|
|
* The pixel y position from which to repaint the screen.
|
|
|
|
|
* The position is absolute along the height of outermost
|
2003-07-15 11:08:02 +00:00
|
|
|
|
* lyxtext (I think). If need_refresh_ is true
|
|
|
|
|
* repaints use this as a starting point (if it's within
|
2003-03-17 01:34:36 +00:00
|
|
|
|
* the viewable portion of the lyxtext).
|
|
|
|
|
*/
|
|
|
|
|
int refresh_y;
|
2003-07-15 11:08:02 +00:00
|
|
|
|
// do we need a refresh?
|
|
|
|
|
bool need_refresh_;
|
2003-03-17 01:34:36 +00:00
|
|
|
|
|
2003-07-10 08:00:41 +00:00
|
|
|
|
public:
|
2003-02-14 00:41:44 +00:00
|
|
|
|
/// only the top-level LyXText has this non-zero
|
|
|
|
|
BufferView * bv_owner;
|
|
|
|
|
|
2003-07-10 08:00:41 +00:00
|
|
|
|
private:
|
2003-06-27 08:38:41 +00:00
|
|
|
|
/// returns a pointer to a specified row.
|
|
|
|
|
RowList::iterator
|
|
|
|
|
getRow(ParagraphList::iterator pit, lyx::pos_type pos) const;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
public:
|
2003-06-27 08:38:41 +00:00
|
|
|
|
/// returns a pointer cursor row
|
|
|
|
|
RowList::iterator getRow(LyXCursor const & cursor) const;
|
|
|
|
|
/// convenience
|
|
|
|
|
RowList::iterator cursorRow() const;
|
2003-06-28 01:23:11 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** returns a pointer to the row near the specified y-coordinate
|
|
|
|
|
(relative to the whole text). y is set to the real beginning
|
|
|
|
|
of this row
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2003-03-30 07:27:36 +00:00
|
|
|
|
RowList::iterator getRowNearY(int & y) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
/** returns the column near the specified x-coordinate of the row
|
1999-09-27 18:44:28 +00:00
|
|
|
|
x is set to the real beginning of this column
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2003-03-30 21:42:09 +00:00
|
|
|
|
lyx::pos_type getColumnNearX(RowList::iterator rit,
|
2003-03-31 16:57:45 +00:00
|
|
|
|
int & x, bool & boundary) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** returns a pointer to a specified row. y is set to the beginning
|
|
|
|
|
of the row
|
|
|
|
|
*/
|
2003-03-30 07:27:36 +00:00
|
|
|
|
RowList::iterator
|
2003-04-10 21:07:55 +00:00
|
|
|
|
getRow(ParagraphList::iterator pit, lyx::pos_type pos, int & y) const;
|
2003-03-29 23:11:20 +00:00
|
|
|
|
|
2003-04-01 00:01:42 +00:00
|
|
|
|
RowList & rows() const {
|
2003-03-29 23:11:20 +00:00
|
|
|
|
return rowlist_;
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-28 01:23:11 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// need the selection cursor:
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setSelection();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void clearSelection();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
/// select the word we need depending on word_location
|
2003-07-01 11:51:20 +00:00
|
|
|
|
void getWord(LyXCursor & from, LyXCursor & to, lyx::word_location const);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// just selects the word the cursor is in
|
2003-07-01 11:51:20 +00:00
|
|
|
|
void selectWord(lyx::word_location loc);
|
2001-07-19 08:52:59 +00:00
|
|
|
|
/// returns the inset at cursor (if it exists), 0 otherwise
|
|
|
|
|
Inset * getInset() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// accept selected change
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void acceptChange();
|
2003-02-08 19:18:01 +00:00
|
|
|
|
|
2003-03-04 09:27:27 +00:00
|
|
|
|
/// reject selected change
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void rejectChange();
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
/** 'selects" the next word, where the cursor is not in
|
|
|
|
|
and returns this word as string. THe cursor will be moved
|
|
|
|
|
to the beginning of this word.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
With SelectSelectedWord can this be highlighted really
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2003-03-18 13:05:08 +00:00
|
|
|
|
WordLangTuple const selectNextWordToSpellcheck(float & value);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void selectSelectedWord();
|
2002-01-12 21:03:30 +00:00
|
|
|
|
/// returns true if par was empty and was removed
|
2003-04-09 09:15:20 +00:00
|
|
|
|
bool setCursor(ParagraphList::iterator pit,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos,
|
2000-05-30 19:31:11 +00:00
|
|
|
|
bool setfont = true,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
bool boundary = false);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2003-04-09 09:15:20 +00:00
|
|
|
|
void setCursor(LyXCursor &, ParagraphList::iterator pit,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
bool boundary = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-04-09 09:15:20 +00:00
|
|
|
|
void setCursorIntern(ParagraphList::iterator pit,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos,
|
2000-05-30 19:31:11 +00:00
|
|
|
|
bool setfont = true,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
bool boundary = false);
|
2000-05-30 19:31:11 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void setCurrentFont();
|
2000-05-30 19:31:11 +00:00
|
|
|
|
|
|
|
|
|
///
|
2003-04-13 01:04:04 +00:00
|
|
|
|
bool isBoundary(Buffer const *, Paragraph const & par,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos) const;
|
2000-05-30 19:31:11 +00:00
|
|
|
|
///
|
2003-04-13 01:04:04 +00:00
|
|
|
|
bool isBoundary(Buffer const *, Paragraph const & par,
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type pos,
|
2000-05-30 19:31:11 +00:00
|
|
|
|
LyXFont const & font) const;
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void setCursorFromCoordinates(int x, int y);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setCursorFromCoordinates(LyXCursor &,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
int x, int y);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorUp(bool selecting = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorDown(bool selecting = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorLeft(bool internal = true);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorRight(bool internal = true);
|
2000-05-30 19:31:11 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorLeftOneWord();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorRightOneWord();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorUpParagraph();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorDownParagraph();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorHome();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorEnd();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void cursorPrevious();
|
2002-10-11 10:45:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void cursorNext();
|
2002-10-11 10:45:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorTop();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void cursorBottom();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void Delete();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void backspace();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-07-01 11:51:20 +00:00
|
|
|
|
bool selectWordWhenUnderCursor(lyx::word_location);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
|
enum TextCase {
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
|
text_lowercase = 0,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
|
text_capitalization = 1,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
1999-11-04 01:40:20 +00:00
|
|
|
|
text_uppercase = 2
|
|
|
|
|
};
|
1999-11-22 16:19:48 +00:00
|
|
|
|
/// Change the case of the word at cursor position.
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void changeCase(TextCase action);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void toggleInset();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void cutSelection(bool doclear = true, bool realcut = true);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void copySelection();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-06-17 15:33:49 +00:00
|
|
|
|
void pasteSelection(size_t sel_index = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** the DTP switches for paragraphs. LyX will store the top settings
|
|
|
|
|
always in the first physical paragraph, the bottom settings in the
|
2002-03-21 17:27:08 +00:00
|
|
|
|
last. When a paragraph is broken, the top settings rest, the bottom
|
1999-09-27 18:44:28 +00:00
|
|
|
|
settings are given to the new one. So I can make shure, they do not
|
|
|
|
|
duplicate themself (and you cannnot make dirty things with them! )
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setParagraph(bool line_top, bool line_bottom,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool pagebreak_top, bool pagebreak_bottom,
|
2000-01-13 16:28:54 +00:00
|
|
|
|
VSpace const & space_top,
|
|
|
|
|
VSpace const & space_bottom,
|
2001-08-16 10:14:48 +00:00
|
|
|
|
Spacing const & spacing,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXAlignment align,
|
2003-03-17 16:25:00 +00:00
|
|
|
|
string const & labelwidthstring,
|
1999-09-27 18:44:28 +00:00
|
|
|
|
bool noindent);
|
2001-05-03 14:31:33 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/* these things are for search and replace */
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* Sets the selection from the current cursor position to length
|
|
|
|
|
* characters to the right. No safety checks.
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void setSelectionRange(lyx::pos_type length);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** simple replacing. The font of the first selected character
|
|
|
|
|
is used
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void replaceSelectionWithString(string const & str);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/// needed to insert the selection
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void insertStringAsLines(string const & str);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// needed to insert the selection
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void insertStringAsParagraphs(string const & str);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
2001-01-15 18:54:31 +00:00
|
|
|
|
/// Find next inset of some specified type.
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bool gotoNextInset(std::vector<Inset::Code> const & codes,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
string const & contents = string());
|
2001-01-15 18:54:31 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void gotoInset(std::vector<Inset::Code> const & codes,
|
|
|
|
|
bool same_content);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void gotoInset(Inset::Code code, bool same_content);
|
2002-08-27 12:32:04 +00:00
|
|
|
|
///
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/* for the greater insets */
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-06-21 15:07:57 +00:00
|
|
|
|
/// returns false if inset wasn't found
|
2003-03-17 16:25:00 +00:00
|
|
|
|
bool updateInset(Inset *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-04-10 21:07:55 +00:00
|
|
|
|
void checkParagraph(ParagraphList::iterator pit, lyx::pos_type pos);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
int workWidth() const;
|
2003-05-23 15:30:48 +00:00
|
|
|
|
/// returns width of row containing inset
|
|
|
|
|
int workWidth(Inset const * inset) const;
|
2003-03-21 23:53:26 +00:00
|
|
|
|
|
2001-10-18 16:49:29 +00:00
|
|
|
|
///
|
2003-04-01 16:55:48 +00:00
|
|
|
|
void computeBidiTables(Buffer const *, RowList::iterator row) const;
|
2000-05-30 19:31:11 +00:00
|
|
|
|
/// Maps positions in the visual string to positions in logical string.
|
2003-03-21 23:53:26 +00:00
|
|
|
|
lyx::pos_type log2vis(lyx::pos_type pos) const;
|
2000-05-30 19:31:11 +00:00
|
|
|
|
/// Maps positions in the logical string to positions in visual string.
|
2003-03-21 23:53:26 +00:00
|
|
|
|
lyx::pos_type vis2log(lyx::pos_type pos) const;
|
|
|
|
|
///
|
|
|
|
|
lyx::pos_type bidi_level(lyx::pos_type pos) const;
|
|
|
|
|
///
|
|
|
|
|
bool bidi_InRange(lyx::pos_type pos) const;
|
2001-11-29 13:43:12 +00:00
|
|
|
|
private:
|
2000-06-12 11:27:15 +00:00
|
|
|
|
///
|
2003-03-31 16:57:45 +00:00
|
|
|
|
mutable RowList rowlist_;
|
2002-12-01 21:10:37 +00:00
|
|
|
|
|
2002-08-09 00:42:12 +00:00
|
|
|
|
///
|
2003-03-31 11:16:39 +00:00
|
|
|
|
float getCursorX(RowList::iterator rit, lyx::pos_type pos,
|
2003-03-17 16:25:00 +00:00
|
|
|
|
lyx::pos_type last, bool boundary) const;
|
2002-08-09 00:42:12 +00:00
|
|
|
|
/// used in setlayout
|
2003-02-26 17:04:10 +00:00
|
|
|
|
void makeFontEntriesLayoutSpecific(Buffer const &, Paragraph & par);
|
2002-08-09 00:42:12 +00:00
|
|
|
|
|
|
|
|
|
/** forces the redrawing of a paragraph. Needed when manipulating a
|
|
|
|
|
right address box
|
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void redoDrawingOfParagraph(LyXCursor const & cursor);
|
2002-08-09 00:42:12 +00:00
|
|
|
|
|
2002-12-01 21:10:37 +00:00
|
|
|
|
/// removes the row and reset the touched counters
|
2003-03-30 18:42:37 +00:00
|
|
|
|
void removeRow(RowList::iterator rit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-08-23 11:49:28 +00:00
|
|
|
|
/// remove all following rows of the paragraph of the specified row.
|
2003-03-30 21:42:09 +00:00
|
|
|
|
void removeParagraph(RowList::iterator rit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-12-01 21:10:37 +00:00
|
|
|
|
/// insert the specified paragraph behind the specified row
|
2003-04-10 21:07:55 +00:00
|
|
|
|
void insertParagraph(ParagraphList::iterator pit,
|
|
|
|
|
RowList::iterator rowit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
/** appends the implizit specified paragraph behind the specified row,
|
|
|
|
|
* start at the implizit given position */
|
2003-03-29 19:29:30 +00:00
|
|
|
|
void appendParagraph(RowList::iterator rowit);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-03-30 18:42:37 +00:00
|
|
|
|
void breakAgain(RowList::iterator rit);
|
2000-01-13 16:28:54 +00:00
|
|
|
|
/// Calculate and set the height of the row
|
2003-03-30 18:42:37 +00:00
|
|
|
|
void setHeightOfRow(RowList::iterator rit);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-09-27 09:52:06 +00:00
|
|
|
|
// fix the cursor `cur' after a characters has been deleted at `where'
|
|
|
|
|
// position. Called by deleteEmptyParagraphMechanism
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void fixCursorAfterDelete(LyXCursor & cur,
|
2003-03-18 13:05:08 +00:00
|
|
|
|
LyXCursor const & where);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
|
/// delete double space (false) or empty paragraphs (true) around old_cursor
|
2003-03-18 13:05:08 +00:00
|
|
|
|
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
public:
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/** Updates all counters starting BEHIND the row. Changed paragraphs
|
2002-03-21 17:27:08 +00:00
|
|
|
|
* with a dynamic left margin will be rebroken. */
|
2003-03-18 13:05:08 +00:00
|
|
|
|
void updateCounters();
|
2002-12-01 21:10:37 +00:00
|
|
|
|
///
|
2003-03-19 14:45:22 +00:00
|
|
|
|
void update();
|
2002-08-28 12:09:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns an inset if inset was hit, or 0 if not.
|
|
|
|
|
* If hit, the coordinates are changed relative to the inset.
|
|
|
|
|
*/
|
2003-03-18 13:05:08 +00:00
|
|
|
|
Inset * checkInsetHit(int & x, int & y);
|
2002-08-28 12:09:19 +00:00
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
2003-04-09 21:34:31 +00:00
|
|
|
|
int singleWidth(ParagraphList::iterator pit,
|
2003-02-26 17:04:10 +00:00
|
|
|
|
lyx::pos_type pos) const;
|
|
|
|
|
///
|
2003-04-09 21:34:31 +00:00
|
|
|
|
int singleWidth(ParagraphList::iterator pit,
|
2003-02-26 17:04:10 +00:00
|
|
|
|
lyx::pos_type pos, char c) const;
|
|
|
|
|
|
|
|
|
|
/// return the color of the canvas
|
|
|
|
|
LColor::color backgroundColor() const;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
mutable bool bidi_same_direction;
|
|
|
|
|
|
2003-04-09 21:34:31 +00:00
|
|
|
|
unsigned char transformChar(unsigned char c, Paragraph const & par,
|
2003-02-26 17:04:10 +00:00
|
|
|
|
lyx::pos_type pos) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the left beginning of the text.
|
|
|
|
|
* This information cannot be taken from the layout object, because
|
|
|
|
|
* in LaTeX the beginning of the text fits in some cases
|
|
|
|
|
* (for example sections) exactly the label-width.
|
|
|
|
|
*/
|
2003-04-01 16:55:48 +00:00
|
|
|
|
int leftMargin(Row const & row) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
|
|
|
|
int rightMargin(Buffer const &, Row const & row) const;
|
|
|
|
|
|
|
|
|
|
/** this calculates the specified parameters. needed when setting
|
|
|
|
|
* the cursor and when creating a visible row */
|
2003-04-01 16:55:48 +00:00
|
|
|
|
void prepareToPrint(RowList::iterator row, float & x,
|
2003-02-26 17:04:10 +00:00
|
|
|
|
float & fill_separator,
|
|
|
|
|
float & fill_hfill,
|
|
|
|
|
float & fill_label_hfill,
|
|
|
|
|
bool bidi = true) const;
|
|
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
|
private:
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2003-04-10 21:07:55 +00:00
|
|
|
|
void setCounter(Buffer const *, ParagraphList::iterator pit);
|
2002-08-19 15:39:25 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void deleteWordForward();
|
2002-08-20 13:00:25 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void deleteWordBackward();
|
2002-08-20 13:00:25 +00:00
|
|
|
|
///
|
2003-03-17 16:25:00 +00:00
|
|
|
|
void deleteLineForward();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/*
|
|
|
|
|
* some low level functions
|
|
|
|
|
*/
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
|
|
2003-03-10 00:05:05 +00:00
|
|
|
|
/// return the pos value *before* which a row should break.
|
|
|
|
|
/// for example, the pos at which IsNewLine(pos) == true
|
2003-03-17 16:25:00 +00:00
|
|
|
|
lyx::pos_type rowBreakPoint(Row const & row) const;
|
2003-03-09 13:46:48 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// returns the minimum space a row needs on the screen in pixel
|
2003-04-01 16:55:48 +00:00
|
|
|
|
int fill(RowList::iterator row, int workwidth) const;
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
2002-12-01 21:10:37 +00:00
|
|
|
|
/**
|
2003-02-26 17:04:10 +00:00
|
|
|
|
* returns the minimum space a manual label needs on the
|
|
|
|
|
* screen in pixels
|
2002-05-30 03:37:24 +00:00
|
|
|
|
*/
|
2003-03-17 16:25:00 +00:00
|
|
|
|
int labelFill(Row const & row) const;
|
2000-02-03 19:51:27 +00:00
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
|
/// FIXME
|
2003-03-17 16:25:00 +00:00
|
|
|
|
int labelEnd(Row const & row) const;
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
2000-02-03 19:51:27 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
mutable std::vector<lyx::pos_type> log2vis_list;
|
2000-02-03 19:51:27 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
mutable std::vector<lyx::pos_type> vis2log_list;
|
2000-04-10 21:40:13 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
mutable std::vector<lyx::pos_type> bidi_levels;
|
2000-02-03 19:51:27 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
mutable lyx::pos_type bidi_start;
|
2000-04-03 11:36:35 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
mutable lyx::pos_type bidi_end;
|
2000-04-03 11:36:35 +00:00
|
|
|
|
|
1999-12-13 00:05:34 +00:00
|
|
|
|
///
|
|
|
|
|
void charInserted();
|
2001-07-06 15:57:54 +00:00
|
|
|
|
public:
|
2000-08-07 20:58:24 +00:00
|
|
|
|
//
|
|
|
|
|
// special owner functions
|
2000-06-12 11:27:15 +00:00
|
|
|
|
///
|
2003-04-02 17:11:38 +00:00
|
|
|
|
ParagraphList & ownerParagraphs() const;
|
2003-02-14 00:41:44 +00:00
|
|
|
|
|
2003-03-17 16:25:00 +00:00
|
|
|
|
/// return true if this is owned by an inset.
|
2003-02-26 17:04:10 +00:00
|
|
|
|
bool isInInset() const;
|
2003-06-27 11:53:41 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/** Cursor related data.
|
|
|
|
|
Later this variable has to be removed. There should be now internal
|
|
|
|
|
cursor in a text */
|
|
|
|
|
///
|
|
|
|
|
///TextCursor cursor_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-14 00:41:44 +00:00
|
|
|
|
/// return the default height of a row in pixels, considering font zoom
|
|
|
|
|
extern int defaultRowHeight();
|
|
|
|
|
|
|
|
|
|
#endif // LYXTEXT_H
|