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-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-04-03 00:36:31 +00:00
|
|
|
|
*/
|
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
|
|
|
|
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "bufferview_funcs.h"
|
2003-10-23 13:28:49 +00:00
|
|
|
|
#include "Bidi.h"
|
2004-01-26 10:13:15 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2004-11-30 01:59:49 +00:00
|
|
|
|
#include "dimension.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "lyxfont.h"
|
2004-01-26 10:13:15 +00:00
|
|
|
|
#include "layout.h"
|
|
|
|
|
#include "lyxlayout_ptr_fwd.h"
|
2006-03-23 20:11:06 +00:00
|
|
|
|
#include "ParagraphList.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-12-02 12:39:14 +00:00
|
|
|
|
#include <iosfwd>
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
class Buffer;
|
|
|
|
|
class BufferParams;
|
2000-02-10 17:53:36 +00:00
|
|
|
|
class BufferView;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class CursorSlice;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Dimension;
|
2006-08-13 16:16:43 +00:00
|
|
|
|
class ErrorList;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class InsetBase;
|
2004-11-25 19:13:07 +00:00
|
|
|
|
class InsetBase_code;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class FuncRequest;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
class FuncStatus;
|
2003-09-18 11:48:11 +00:00
|
|
|
|
class LColor_color;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class LCursor;
|
|
|
|
|
class LyXTextClass;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class MetricsInfo;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
class PainterInfo;
|
2001-11-26 16:42:04 +00:00
|
|
|
|
class Row;
|
2004-03-01 12:23:17 +00:00
|
|
|
|
class RowMetrics;
|
2001-11-26 16:42:04 +00:00
|
|
|
|
class Spacing;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-01-13 15:25:52 +00:00
|
|
|
|
/// This class encapsulates the main text data and operations in LyX
|
|
|
|
|
class LyXText {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2004-02-13 11:05:29 +00:00
|
|
|
|
///
|
|
|
|
|
typedef lyx::pos_type pos_type;
|
|
|
|
|
///
|
2006-08-13 22:54:59 +00:00
|
|
|
|
typedef lyx::char_type char_type;
|
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
typedef lyx::pit_type pit_type;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
/// constructor
|
2004-03-18 12:53:43 +00:00
|
|
|
|
explicit LyXText(BufferView *);
|
2003-11-25 11:17:27 +00:00
|
|
|
|
///
|
2003-07-15 08:26:17 +00:00
|
|
|
|
void init(BufferView *);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2001-02-19 16:01:31 +00:00
|
|
|
|
///
|
2004-08-15 00:01:45 +00:00
|
|
|
|
LyXFont getFont(Paragraph const & par, pos_type pos) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-04-12 18:42:27 +00:00
|
|
|
|
void applyOuterFont(LyXFont &) const;
|
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
LyXFont getLayoutFont(pit_type pit) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
///
|
2004-08-15 00:01:45 +00:00
|
|
|
|
LyXFont getLabelFont(Paragraph const & par) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void setCharFont(pit_type pit, pos_type pos, LyXFont const & font);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void setCharFont(pit_type pit, pos_type pos, LyXFont const & font,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
bool toggleall);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// what you expect when pressing <enter> at cursor position
|
2005-01-31 16:29:48 +00:00
|
|
|
|
void breakParagraph(LCursor & cur, bool keep_layout = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
/// set layout over selection
|
2005-11-28 11:52:03 +00:00
|
|
|
|
void setLayout(pit_type start, pit_type end,
|
2004-03-25 09:16:36 +00:00
|
|
|
|
std::string const & layout);
|
2001-11-26 16:42:04 +00:00
|
|
|
|
///
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void setLayout(LCursor & cur, std::string const & layout);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-03-18 13:57:20 +00:00
|
|
|
|
/// what type of depth change to make
|
|
|
|
|
enum DEPTH_CHANGE {
|
|
|
|
|
INC_DEPTH,
|
|
|
|
|
DEC_DEPTH
|
|
|
|
|
};
|
2004-03-25 09:16:36 +00:00
|
|
|
|
/// Increase or decrease the nesting depth of the selected paragraph(s)
|
2004-03-18 13:57:20 +00:00
|
|
|
|
void changeDepth(LCursor & cur, DEPTH_CHANGE type);
|
2003-11-26 09:48:21 +00:00
|
|
|
|
|
|
|
|
|
/// Returns whether something would be changed by changeDepth
|
2004-03-18 13:57:20 +00:00
|
|
|
|
bool changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
/// Set font over selection paragraphs and rebreak.
|
|
|
|
|
void setFont(LCursor & cur, LyXFont const &, bool toggleall = false);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-08-01 11:22:13 +00:00
|
|
|
|
/// rebreaks the given par
|
2005-05-31 14:40:30 +00:00
|
|
|
|
bool redoParagraph(pit_type pit);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-08-15 21:59:29 +00:00
|
|
|
|
/// returns pos in given par at given x coord
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pos_type x2pos(pit_type pit, int row, int x) const;
|
|
|
|
|
int pos2x(pit_type pit, pos_type pos) const;
|
2004-08-15 21:59:29 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void toggleFree(LCursor & cur, LyXFont const &, bool toggleall = false);
|
2001-07-30 10:50:37 +00:00
|
|
|
|
|
|
|
|
|
///
|
2005-05-30 15:35:11 +00:00
|
|
|
|
std::string getStringToIndex(LCursor const & cur);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
/// insert a character at cursor position
|
2006-04-09 02:30:40 +00:00
|
|
|
|
void insertChar(LCursor & cur, lyx::char_type c);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
/// insert an inset at cursor position
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void insertInset(LCursor & cur, InsetBase * inset);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2003-07-22 10:12:24 +00:00
|
|
|
|
/// compute text metrics
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim);
|
2003-11-28 08:55:12 +00:00
|
|
|
|
/// draw text (only used for insets)
|
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2004-02-06 11:12:49 +00:00
|
|
|
|
/// draw textselection
|
|
|
|
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
/// try to handle that request
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void dispatch(LCursor & cur, FuncRequest & cmd);
|
2004-02-20 17:19:53 +00:00
|
|
|
|
/// do we want to handle this event?
|
2004-03-18 13:57:20 +00:00
|
|
|
|
bool getStatus(LCursor & cur, FuncRequest const & cmd,
|
|
|
|
|
FuncStatus & status) const;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
/// access to out BufferView. This should go...
|
2003-03-17 16:25:00 +00:00
|
|
|
|
BufferView * bv() const;
|
|
|
|
|
|
2005-07-18 11:00:15 +00:00
|
|
|
|
/// read-only access to individual paragraph
|
|
|
|
|
Paragraph const & getPar(pit_type pit) const { return pars_[pit]; }
|
|
|
|
|
/// read-write access to individual paragraph
|
|
|
|
|
Paragraph & getPar(pit_type pit) { return pars_[pit]; }
|
2004-02-13 07:30:59 +00:00
|
|
|
|
// Returns the current font and depth as a message.
|
2006-01-01 20:28:05 +00:00
|
|
|
|
std::string currentState(LCursor & cur);
|
2003-06-28 01:23:11 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/** returns row near the specified
|
|
|
|
|
* y-coordinate in given paragraph (relative to the screen).
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2004-11-30 01:59:49 +00:00
|
|
|
|
Row const & getRowNearY(int y, pit_type pit) const;
|
|
|
|
|
pit_type getPitNearY(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
|
|
|
|
*/
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pos_type getColumnNearX(pit_type pit,
|
2003-10-17 10:31:47 +00:00
|
|
|
|
Row const & row, int & x, bool & boundary) const;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
2004-01-14 09:33:14 +00:00
|
|
|
|
/** Find the word under \c from in the relative location
|
|
|
|
|
* defined by \c word_location.
|
|
|
|
|
* @param from return here the start of the word
|
|
|
|
|
* @param to return here the end of the word
|
|
|
|
|
*/
|
2004-01-13 14:13:51 +00:00
|
|
|
|
void getWord(CursorSlice & from, CursorSlice & to, lyx::word_location const);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// just selects the word the cursor is in
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void selectWord(LCursor & cur, lyx::word_location loc);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// accept selected change
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void acceptChange(LCursor & cur);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
/// reject selected change
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void rejectChange(LCursor & cur);
|
2003-03-04 09:27:27 +00:00
|
|
|
|
|
2002-01-12 21:03:30 +00:00
|
|
|
|
/// returns true if par was empty and was removed
|
2004-11-24 21:53:46 +00:00
|
|
|
|
bool setCursor(LCursor & cur, pit_type par, pos_type pos,
|
2003-10-17 10:31:47 +00:00
|
|
|
|
bool setfont = true, bool boundary = false);
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2005-09-20 08:31:37 +00:00
|
|
|
|
void setCursor(CursorSlice &, pit_type par, pos_type pos);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void setCursorIntern(LCursor & cur, pit_type par,
|
2006-04-05 23:56:29 +00:00
|
|
|
|
pos_type pos, bool setfont = true, bool boundary = false);
|
2000-05-30 19:31:11 +00:00
|
|
|
|
///
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void setCurrentFont(LCursor & cur);
|
2000-05-30 19:31:11 +00:00
|
|
|
|
|
2003-10-13 10:59:31 +00:00
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void recUndo(pit_type first, pit_type last) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void recUndo(pit_type first) const;
|
2005-10-13 14:48:27 +00:00
|
|
|
|
/// returns true if par was empty and was removed
|
|
|
|
|
bool setCursorFromCoordinates(LCursor & cur, int x, int y);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-07-15 00:39:44 +00:00
|
|
|
|
InsetBase * editXY(LCursor & cur, int x, int y);
|
2005-02-08 02:06:39 +00:00
|
|
|
|
/// Move cursor one line up.
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
|
*/
|
|
|
|
|
bool cursorUp(LCursor & cur);
|
|
|
|
|
/// Move cursor one line down.
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
|
*/
|
|
|
|
|
bool cursorDown(LCursor & cur);
|
|
|
|
|
/// Move cursor one position left
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
|
*/
|
|
|
|
|
bool cursorLeft(LCursor & cur);
|
|
|
|
|
/// Move cursor one position right
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
|
*/
|
|
|
|
|
bool cursorRight(LCursor & cur);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorLeftOneWord(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorRightOneWord(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorUpParagraph(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorDownParagraph(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-03-16 14:24:53 +00:00
|
|
|
|
bool cursorHome(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-03-16 14:24:53 +00:00
|
|
|
|
bool cursorEnd(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorPrevious(LCursor & cur);
|
2002-10-11 10:45:28 +00:00
|
|
|
|
///
|
2005-02-08 02:06:39 +00:00
|
|
|
|
bool cursorNext(LCursor & cur);
|
2002-10-11 10:45:28 +00:00
|
|
|
|
///
|
2006-03-16 14:24:53 +00:00
|
|
|
|
bool cursorTop(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2006-03-16 14:24:53 +00:00
|
|
|
|
bool cursorBottom(LCursor & cur);
|
2006-04-09 00:26:19 +00:00
|
|
|
|
/// Erase character at cursor. Honour change tracking
|
|
|
|
|
bool erase(LCursor & cur);
|
2006-03-12 10:06:59 +00:00
|
|
|
|
/** At cursor position 0, merge paragraph with the one before it.
|
|
|
|
|
* Ignore CT (this is used in \c acceptChange, \c rejectChange for
|
|
|
|
|
* physical deletion of paragraph break)
|
|
|
|
|
*/
|
2006-03-11 13:31:41 +00:00
|
|
|
|
bool backspacePos0(LCursor & cur);
|
2006-03-12 10:06:59 +00:00
|
|
|
|
/// Delete character before cursor. Honour CT
|
2005-12-19 12:30:34 +00:00
|
|
|
|
bool backspace(LCursor & cur);
|
2006-09-08 14:08:26 +00:00
|
|
|
|
// Dissolve the inset under cursor
|
|
|
|
|
bool dissolveInset(LCursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2004-02-13 07:30:59 +00:00
|
|
|
|
bool selectWordWhenUnderCursor(LCursor & cur, 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.
|
2004-02-13 07:30:59 +00:00
|
|
|
|
void changeCase(LCursor & cur, TextCase action);
|
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
|
2003-10-27 12:41:26 +00:00
|
|
|
|
settings are given to the new one.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*/
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void setParagraph(LCursor & cur,
|
2001-08-16 10:14:48 +00:00
|
|
|
|
Spacing const & spacing,
|
2002-03-21 17:27:08 +00:00
|
|
|
|
LyXAlignment align,
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::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 */
|
|
|
|
|
|
|
|
|
|
/// needed to insert the selection
|
2006-09-03 07:02:38 +00:00
|
|
|
|
void insertStringAsLines(LCursor & cur, lyx::docstring const & str);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// needed to insert the selection
|
2006-09-03 07:02:38 +00:00
|
|
|
|
void insertStringAsParagraphs(LCursor & cur, lyx::docstring const & str);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
2004-03-01 16:29:30 +00:00
|
|
|
|
/// current text width
|
|
|
|
|
int width() const;
|
2003-03-21 23:53:26 +00:00
|
|
|
|
|
2004-03-01 16:29:30 +00:00
|
|
|
|
/// current text heigth
|
|
|
|
|
int height() const;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-11-25 11:17:27 +00:00
|
|
|
|
/// Returns an inset if inset was hit, or 0 if not.
|
2004-08-13 19:14:17 +00:00
|
|
|
|
InsetBase * checkInsetHit(int x, int y) const;
|
2002-08-28 12:09:19 +00:00
|
|
|
|
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
2004-08-15 00:01:45 +00:00
|
|
|
|
int singleWidth(Paragraph const & par, pos_type pos) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
2004-08-15 00:01:45 +00:00
|
|
|
|
int singleWidth(Paragraph const & par,
|
2006-08-13 22:54:59 +00:00
|
|
|
|
pos_type pos, char_type c, LyXFont const & Font) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
|
|
/// return the color of the canvas
|
2003-09-18 11:48:11 +00:00
|
|
|
|
LColor_color backgroundColor() const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2004-11-24 21:53:46 +00:00
|
|
|
|
int leftMargin(pit_type pit, pos_type pos) const;
|
|
|
|
|
int leftMargin(pit_type pit) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
///
|
2003-11-25 11:17:27 +00:00
|
|
|
|
int rightMargin(Paragraph const & par) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
|
|
|
|
/** this calculates the specified parameters. needed when setting
|
|
|
|
|
* the cursor and when creating a visible row */
|
2004-11-24 21:53:46 +00:00
|
|
|
|
RowMetrics computeRowMetrics(pit_type pit, Row const & row) const;
|
2003-02-26 17:04:10 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
/// access to our paragraphs
|
2005-07-18 11:00:15 +00:00
|
|
|
|
ParagraphList const & paragraphs() const { return pars_; }
|
|
|
|
|
ParagraphList & paragraphs() { return pars_; }
|
2004-03-18 12:53:43 +00:00
|
|
|
|
/// return true if this is the main text
|
|
|
|
|
bool isMainText() const;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-08-14 11:16:31 +00:00
|
|
|
|
/// return first row of text
|
2004-04-21 19:51:18 +00:00
|
|
|
|
Row const & firstRow() const;
|
2003-08-15 08:03:54 +00:00
|
|
|
|
|
2003-10-23 08:15:57 +00:00
|
|
|
|
/// is this row the last in the text?
|
2004-11-24 21:53:46 +00:00
|
|
|
|
bool isLastRow(pit_type pit, Row const & row) const;
|
2003-10-23 08:15:57 +00:00
|
|
|
|
/// is this row the first in the text?
|
2004-11-24 21:53:46 +00:00
|
|
|
|
bool isFirstRow(pit_type pit, Row const & row) const;
|
2003-10-23 08:15:57 +00:00
|
|
|
|
|
2003-10-28 11:18:40 +00:00
|
|
|
|
///
|
2004-02-13 13:51:12 +00:00
|
|
|
|
double spacing(Paragraph const & par) const;
|
|
|
|
|
/// make a suggestion for a label
|
|
|
|
|
std::string getPossibleLabel(LCursor & cur) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
|
/// is this paragraph right-to-left?
|
|
|
|
|
bool isRTL(Paragraph const & par) const;
|
2003-11-17 14:28:18 +00:00
|
|
|
|
///
|
2004-02-12 16:36:01 +00:00
|
|
|
|
bool checkAndActivateInset(LCursor & cur, bool front);
|
2003-11-17 14:28:18 +00:00
|
|
|
|
|
2003-12-02 12:39:14 +00:00
|
|
|
|
///
|
|
|
|
|
void write(Buffer const & buf, std::ostream & os) const;
|
2003-12-03 15:27:16 +00:00
|
|
|
|
/// returns whether we've seen our usual 'end' marker
|
2006-08-13 16:16:43 +00:00
|
|
|
|
bool read(Buffer const & buf, LyXLex & lex, ErrorList & errorList);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2003-12-10 09:45:32 +00:00
|
|
|
|
///
|
|
|
|
|
int ascent() const;
|
|
|
|
|
///
|
|
|
|
|
int descent() const;
|
2003-12-15 11:36:19 +00:00
|
|
|
|
///
|
2005-07-15 15:49:40 +00:00
|
|
|
|
int cursorX(CursorSlice const & cursor, bool boundary) const;
|
2003-12-15 11:36:19 +00:00
|
|
|
|
///
|
2005-07-15 15:49:40 +00:00
|
|
|
|
int cursorY(CursorSlice const & cursor, bool boundary) const;
|
2003-12-10 09:45:32 +00:00
|
|
|
|
|
2005-12-01 10:28:50 +00:00
|
|
|
|
/// delete double space or empty paragraphs around old cursor
|
|
|
|
|
bool deleteEmptyParagraphMechanism(LCursor & cur, LCursor & old);
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
public:
|
2003-11-22 14:44:59 +00:00
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
Dimension dim_;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
///
|
2004-03-01 16:29:30 +00:00
|
|
|
|
int maxwidth_;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
/// the current font settings
|
|
|
|
|
LyXFont current_font;
|
|
|
|
|
/// the current font
|
|
|
|
|
LyXFont real_current_font;
|
|
|
|
|
///
|
2003-12-01 13:35:49 +00:00
|
|
|
|
int background_color_;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
|
|
|
|
/// only the top-level LyXText has this non-zero
|
|
|
|
|
BufferView * bv_owner;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
mutable Bidi bidi;
|
|
|
|
|
///
|
2004-03-25 09:16:36 +00:00
|
|
|
|
ParagraphList pars_;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
2005-04-12 18:42:27 +00:00
|
|
|
|
/// our 'outermost' font. This is handed down from the surrounding
|
|
|
|
|
// inset through the pi/mi parameter (pi.base.font)
|
2003-12-03 18:17:20 +00:00
|
|
|
|
LyXFont font_;
|
|
|
|
|
|
2004-12-17 16:27:12 +00:00
|
|
|
|
///
|
|
|
|
|
bool autoBreakRows_;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
private:
|
2004-01-09 09:04:33 +00:00
|
|
|
|
/// return past-the-last paragraph influenced by a layout
|
|
|
|
|
/// change on pit
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type undoSpan(pit_type pit);
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2003-11-22 14:44:59 +00:00
|
|
|
|
/// Calculate and set the height of the row
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void setHeightOfRow(pit_type, Row & row);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
|
|
|
|
// fix the cursor `cur' after a characters has been deleted at `where'
|
|
|
|
|
// position. Called by deleteEmptyParagraphMechanism
|
2004-01-13 14:13:51 +00:00
|
|
|
|
void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
|
|
|
|
///
|
2004-02-12 16:36:01 +00:00
|
|
|
|
void deleteWordForward(LCursor & cur);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
///
|
2004-02-12 16:36:01 +00:00
|
|
|
|
void deleteWordBackward(LCursor & cur);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
///
|
2004-02-12 16:36:01 +00:00
|
|
|
|
void deleteLineForward(LCursor & cur);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
|
|
|
|
/// sets row.end to the pos value *after* which a row should break.
|
|
|
|
|
/// for example, the pos after which isNewLine(pos) == true
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void rowBreakPoint(pit_type pit, Row & row) const;
|
2004-02-27 09:18:03 +00:00
|
|
|
|
/// sets row.width to the minimum space a row needs on the screen in pixel
|
2004-11-24 21:53:46 +00:00
|
|
|
|
void setRowWidth(pit_type pit, Row & row) const;
|
2004-02-03 08:56:28 +00:00
|
|
|
|
/// the minimum space a manual label needs on the screen in pixels
|
2004-08-15 00:01:45 +00:00
|
|
|
|
int labelFill(Paragraph const & par, Row const & row) const;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
/// FIXME
|
2004-11-24 21:53:46 +00:00
|
|
|
|
int labelEnd(pit_type pit) const;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void charInserted();
|
|
|
|
|
/// set 'number' font property
|
2004-02-13 11:05:29 +00:00
|
|
|
|
void number(LCursor & cur);
|
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
|
2004-02-03 08:56:28 +00:00
|
|
|
|
int defaultRowHeight();
|
2003-02-14 00:41:44 +00:00
|
|
|
|
|
|
|
|
|
#endif // LYXTEXT_H
|