1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2003-04-03 00:36:31 +00:00
|
|
|
/**
|
2007-04-29 23:33:02 +00:00
|
|
|
* \file Text.h
|
2003-04-03 00:36:31 +00:00
|
|
|
* 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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-04-03 00:36:31 +00:00
|
|
|
* \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
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
#ifndef TEXT_H
|
|
|
|
#define TEXT_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-12-21 20:42:46 +00:00
|
|
|
#include "DocIterator.h"
|
2006-03-23 20:11:06 +00:00
|
|
|
#include "ParagraphList.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2009-08-09 17:30:41 +00:00
|
|
|
class Buffer;
|
|
|
|
class BufferParams;
|
2000-02-10 17:53:36 +00:00
|
|
|
class BufferView;
|
2008-03-15 12:22:28 +00:00
|
|
|
class CompletionList;
|
2009-08-09 17:30:41 +00:00
|
|
|
class Cursor;
|
2004-01-26 10:13:15 +00:00
|
|
|
class CursorSlice;
|
2006-12-30 15:05:15 +00:00
|
|
|
class DocIterator;
|
2006-08-13 16:16:43 +00:00
|
|
|
class ErrorList;
|
2007-09-20 20:44:08 +00:00
|
|
|
class Font;
|
2007-10-28 18:51:54 +00:00
|
|
|
class FontInfo;
|
2004-01-26 10:13:15 +00:00
|
|
|
class FuncRequest;
|
2004-02-20 17:19:53 +00:00
|
|
|
class FuncStatus;
|
2007-04-29 13:39:47 +00:00
|
|
|
class Inset;
|
2007-10-13 09:48:18 +00:00
|
|
|
class Lexer;
|
2004-01-26 10:13:15 +00:00
|
|
|
class PainterInfo;
|
2001-11-26 16:42:04 +00:00
|
|
|
class Spacing;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
2010-01-05 13:16:55 +00:00
|
|
|
/// This class encapsulates the main text data and operations in LyX.
|
|
|
|
/// This is more or less the private implementation of InsetText.
|
2007-04-29 23:33:02 +00:00
|
|
|
class Text {
|
2010-01-05 13:16:55 +00:00
|
|
|
private:
|
|
|
|
/// Default constructor.
|
|
|
|
Text(InsetText * owner, bool use_default_layout);
|
|
|
|
|
|
|
|
/// Copy constructor.
|
|
|
|
Text(InsetText * owner, Text const & text);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
2010-01-05 13:16:55 +00:00
|
|
|
public:
|
2007-08-14 16:59:59 +00:00
|
|
|
/// \return true if there's no content at all.
|
|
|
|
/// \warning a non standard layout on an empty paragraph doesn't
|
|
|
|
// count as empty.
|
|
|
|
bool empty() const;
|
2009-08-09 16:19:43 +00:00
|
|
|
/// Access to owner InsetText.
|
|
|
|
InsetText const & inset() const;
|
2009-08-09 15:05:36 +00:00
|
|
|
|
2005-04-12 18:42:27 +00:00
|
|
|
///
|
2009-08-09 15:29:34 +00:00
|
|
|
FontInfo layoutFont(pit_type pit) const;
|
2001-08-03 18:28:11 +00:00
|
|
|
///
|
2009-08-09 15:29:34 +00:00
|
|
|
FontInfo labelFont(Paragraph const & par) const;
|
2007-05-22 10:51:38 +00:00
|
|
|
/** Set font of character at position \p pos in paragraph \p pit.
|
|
|
|
* Must not be called if \p pos denotes an inset with text contents,
|
|
|
|
* and the inset is not allowed inside a font change (see below).
|
|
|
|
*/
|
2009-08-09 15:29:34 +00:00
|
|
|
void setCharFont(pit_type pit, pos_type pos,
|
2007-09-02 21:48:49 +00:00
|
|
|
Font const & font, Font const & display_font);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2007-05-22 10:51:38 +00:00
|
|
|
/** Needed to propagate font changes to all text cells of insets
|
2011-02-22 19:41:04 +00:00
|
|
|
* that are not allowed inside a font change (bugs 1973, 6919).
|
2007-05-22 10:51:38 +00:00
|
|
|
* Must not be called if \p pos denotes an ordinary character or an
|
|
|
|
* inset that is alowed inside a font change.
|
|
|
|
*/
|
2007-09-02 21:48:49 +00:00
|
|
|
void setInsetFont(BufferView const & bv, pit_type pit, pos_type pos,
|
2012-03-13 16:08:25 +00:00
|
|
|
Font const & font);
|
2007-05-22 10:51:38 +00:00
|
|
|
|
2007-04-14 10:26:45 +00:00
|
|
|
/// what you expect when pressing \<enter\> at cursor position
|
2010-03-10 17:01:08 +00:00
|
|
|
/// \param inverse_logic if false, the same layout is set for the
|
|
|
|
/// new paragraph if the layout is an environment; if true, the
|
|
|
|
/// same layout is set if it is not an environment
|
2007-10-08 13:17:15 +00:00
|
|
|
void breakParagraph(Cursor & cur, bool inverse_logic = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
/// set layout over selection
|
2009-08-09 15:29:34 +00:00
|
|
|
void setLayout(pit_type start, pit_type end,
|
2007-07-11 13:39:08 +00:00
|
|
|
docstring const & layout);
|
2006-12-29 23:54:48 +00:00
|
|
|
/// Set given layout to current cursor position.
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
2007-07-11 13:39:08 +00:00
|
|
|
void setLayout(Cursor & cur, docstring 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)
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
void changeDepth(Cursor & cur, DEPTH_CHANGE type);
|
2003-11-26 09:48:21 +00:00
|
|
|
|
|
|
|
/// Returns whether something would be changed by changeDepth
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
bool changeDepthAllowed(Cursor & 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.
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
2007-04-29 18:17:15 +00:00
|
|
|
void setFont(Cursor & cur, Font const &, bool toggleall = false);
|
2007-05-22 10:51:38 +00:00
|
|
|
/// Set font from \p begin to \p end and rebreak.
|
2007-09-02 21:48:49 +00:00
|
|
|
void setFont(BufferView const & bv, CursorSlice const & begin,
|
2012-03-13 16:08:25 +00:00
|
|
|
CursorSlice const & end, Font const &);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-29 18:17:15 +00:00
|
|
|
void toggleFree(Cursor & cur, Font const &, bool toggleall = false);
|
2001-07-30 10:50:37 +00:00
|
|
|
|
2006-12-29 23:54:48 +00:00
|
|
|
/// ???
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
docstring getStringToIndex(Cursor const & cur);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2008-09-28 17:10:16 +00:00
|
|
|
/// Convert the paragraphs to a string.
|
|
|
|
/// \param AsStringParameter options. This can contain any combination of
|
|
|
|
/// asStringParameter values. Valid examples:
|
|
|
|
/// asString(AS_STR_LABEL)
|
|
|
|
/// asString(AS_STR_LABEL | AS_STR_INSETS)
|
|
|
|
/// asString(AS_STR_INSETS)
|
|
|
|
docstring asString(int options = AS_STR_NONE) const;
|
|
|
|
///
|
|
|
|
docstring asString(pit_type beg, pit_type end,
|
|
|
|
int options = AS_STR_NONE) const;
|
2010-12-20 21:55:09 +00:00
|
|
|
/// Appends a possibly abbreviated representation of our text
|
|
|
|
/// to \param os, where \param maxlen defines the maximum size
|
|
|
|
/// of \param os. If \param shorten is true, then we will shorten
|
|
|
|
/// \param os to maxlen chars and replace the final three by "...,
|
|
|
|
/// if \param os is longer than maxlen chars.
|
2012-01-16 15:01:02 +00:00
|
|
|
/// if \param maxlen is passed as 0, then it is ignored. (In fact,
|
|
|
|
/// it is reset to the maximum value for size_t.)
|
2010-12-20 21:55:09 +00:00
|
|
|
void forToc(docstring & os, size_t maxlen, bool shorten = true) const;
|
2008-09-28 17:10:16 +00:00
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
/// insert a character at cursor position
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
void insertChar(Cursor & cur, char_type c);
|
2004-01-30 11:41:12 +00:00
|
|
|
/// insert an inset at cursor position
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
2007-04-29 13:39:47 +00:00
|
|
|
void insertInset(Cursor & cur, Inset * inset);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
/// try to handle that request
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
void dispatch(Cursor & cur, FuncRequest & cmd);
|
2004-02-20 17:19:53 +00:00
|
|
|
/// do we want to handle this event?
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
2004-03-18 13:57:20 +00:00
|
|
|
FuncStatus & status) const;
|
2004-02-20 17:19:53 +00:00
|
|
|
|
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.
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
2008-08-13 13:46:19 +00:00
|
|
|
docstring currentState(Cursor const & cur) const;
|
2003-06-28 01:23:11 +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
|
|
|
|
*/
|
2008-02-26 00:38:30 +00:00
|
|
|
void getWord(CursorSlice & from, CursorSlice & to, word_location const) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// just selects the word the cursor is in
|
2007-04-26 14:56:30 +00:00
|
|
|
void selectWord(Cursor & cur, word_location loc);
|
2009-02-07 15:24:47 +00:00
|
|
|
/// select all text
|
|
|
|
void selectAll(Cursor & cur);
|
2008-03-15 12:22:28 +00:00
|
|
|
/// convenience function get the previous word or an empty string
|
|
|
|
docstring previousWord(CursorSlice const & sl) const;
|
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
/// what type of change operation to make
|
2007-01-25 21:18:36 +00:00
|
|
|
enum ChangeOp {
|
|
|
|
ACCEPT,
|
|
|
|
REJECT
|
|
|
|
};
|
2007-01-23 21:53:16 +00:00
|
|
|
/// accept or reject the selected change
|
2007-04-26 14:56:30 +00:00
|
|
|
void acceptOrRejectChanges(Cursor & cur, ChangeOp op);
|
2007-04-29 23:33:02 +00:00
|
|
|
/// accept the changes within the complete Text
|
2009-08-09 15:52:33 +00:00
|
|
|
void acceptChanges();
|
2007-04-29 23:33:02 +00:00
|
|
|
/// reject the changes within the complete Text
|
2009-08-09 15:52:33 +00:00
|
|
|
void rejectChanges();
|
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
|
2007-04-26 14:56:30 +00:00
|
|
|
bool setCursor(Cursor & 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
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void setCursorIntern(Cursor & 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
|
|
|
|
2003-10-13 10:59:31 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void recUndo(Cursor & cur, pit_type first, pit_type last) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
void recUndo(Cursor & cur, pit_type first) const;
|
2006-12-30 15:53:19 +00:00
|
|
|
|
2007-10-22 22:18:52 +00:00
|
|
|
/// Move cursor one position backwards
|
2005-02-08 02:06:39 +00:00
|
|
|
/**
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
*/
|
2007-10-22 22:18:52 +00:00
|
|
|
bool cursorBackward(Cursor & cur);
|
2008-02-10 19:52:45 +00:00
|
|
|
/// Move cursor visually one position to the left
|
|
|
|
/**
|
|
|
|
* \param skip_inset if true, don't enter insets
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
*/
|
|
|
|
bool cursorVisLeft(Cursor & cur, bool skip_inset = false);
|
2007-10-22 22:18:52 +00:00
|
|
|
/// Move cursor one position forward
|
2005-02-08 02:06:39 +00:00
|
|
|
/**
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
*/
|
2007-10-22 22:18:52 +00:00
|
|
|
bool cursorForward(Cursor & cur);
|
2008-02-10 19:52:45 +00:00
|
|
|
/// Move cursor visually one position to the right
|
|
|
|
/**
|
|
|
|
* \param skip_inset if true, don't enter insets
|
|
|
|
* Returns true if an update is needed after the move.
|
|
|
|
*/
|
|
|
|
bool cursorVisRight(Cursor & cur, bool skip_inset = false);
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2007-10-28 20:35:57 +00:00
|
|
|
bool cursorBackwardOneWord(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-10-28 20:35:57 +00:00
|
|
|
bool cursorForwardOneWord(Cursor & cur);
|
2008-05-04 20:22:19 +00:00
|
|
|
///
|
|
|
|
bool cursorVisLeftOneWord(Cursor & cur);
|
|
|
|
///
|
|
|
|
bool cursorVisRightOneWord(Cursor & cur);
|
2007-09-02 11:21:33 +00:00
|
|
|
/// Delete from cursor up to the end of the current or next word.
|
|
|
|
void deleteWordForward(Cursor & cur);
|
|
|
|
/// Delete from cursor to start of current or prior word.
|
|
|
|
void deleteWordBackward(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool cursorUpParagraph(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool cursorDownParagraph(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool cursorTop(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool cursorBottom(Cursor & cur);
|
2006-04-09 00:26:19 +00:00
|
|
|
/// Erase character at cursor. Honour change tracking
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
bool erase(Cursor & cur);
|
2006-03-12 10:06:59 +00:00
|
|
|
/// Delete character before cursor. Honour CT
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
bool backspace(Cursor & cur);
|
2006-09-08 14:08:26 +00:00
|
|
|
// Dissolve the inset under cursor
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
bool dissolveInset(Cursor & cur);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool selectWordWhenUnderCursor(Cursor & cur, word_location);
|
1999-11-22 16:19:48 +00:00
|
|
|
/// Change the case of the word at cursor position.
|
2007-04-26 14:56:30 +00:00
|
|
|
void changeCase(Cursor & cur, TextCase action);
|
2006-11-17 09:03:30 +00:00
|
|
|
/// Transposes the character at the cursor with the one before it
|
2007-04-26 14:56:30 +00:00
|
|
|
void charsTranspose(Cursor & cur);
|
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.
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19581 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 02:21:09 +00:00
|
|
|
This function will handle a multi-paragraph selection.
|
2002-03-21 17:27:08 +00:00
|
|
|
*/
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19581 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 02:21:09 +00:00
|
|
|
void setParagraphs(Cursor & cur, docstring arg, bool modify = false);
|
|
|
|
/// Sets parameters for current or selected paragraphs
|
|
|
|
void setParagraphs(Cursor & cur, ParagraphParameters const & p);
|
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
|
2011-09-24 18:21:41 +00:00
|
|
|
void insertStringAsLines(Cursor & cur, docstring const & str,
|
2009-08-09 16:49:41 +00:00
|
|
|
Font const & font);
|
1999-09-27 18:44:28 +00:00
|
|
|
/// needed to insert the selection
|
2011-09-24 18:21:41 +00:00
|
|
|
void insertStringAsParagraphs(Cursor & cur, docstring const & str,
|
2009-08-09 16:49:41 +00:00
|
|
|
Font const & font);
|
1999-11-04 01:40:20 +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
|
2009-08-09 15:29:34 +00:00
|
|
|
bool isMainText() const;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2003-10-28 11:18:40 +00:00
|
|
|
///
|
2009-08-09 15:29:34 +00:00
|
|
|
double spacing(Paragraph const & par) const;
|
2004-02-13 13:51:12 +00:00
|
|
|
/// make a suggestion for a label
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
2008-08-13 13:46:19 +00:00
|
|
|
docstring getPossibleLabel(Cursor const & cur) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
/// is this paragraph right-to-left?
|
2009-08-09 15:29:34 +00:00
|
|
|
bool isRTL(Paragraph const & par) const;
|
2007-06-07 19:50:02 +00:00
|
|
|
|
2003-11-17 14:28:18 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool checkAndActivateInset(Cursor & cur, bool front);
|
2008-02-10 19:52:45 +00:00
|
|
|
///
|
|
|
|
bool checkAndActivateInsetVisual(Cursor & cur, bool movingForward, bool movingLeft);
|
2003-11-17 14:28:18 +00:00
|
|
|
|
2003-12-02 12:39:14 +00:00
|
|
|
///
|
2009-08-09 15:29:34 +00:00
|
|
|
void write(std::ostream & os) const;
|
2009-02-04 09:52:10 +00:00
|
|
|
/// returns true if \end_document has not been read
|
It used to be that things like InsetFlex, InsetCaption, and the like used the default layout, whatever that is---usually Standard. That gave rise to bug 2178, the solution to which is to define a new empty layout, which insets like these use instead of the default. See r22966.
So, when we have an older LyX file, it will look like this:
\begin_inset ERT
status open
\begin_layout Standard
this that
\end_layout
\end_inset
which is now invalid, because ERT uses only PlainLayout. So I had put some code into Text::readParToken, where the layout for a paragraph gets set as it is read:
if (par.forceEmptyLayout()) {
// in this case only the empty layout is allowed
layoutname = tclass.emptyLayoutName();
} else if (par.useEmptyLayout()) {
// in this case, default layout maps to empty layout
if (layoutname == tclass.defaultLayoutName())
layoutname = tclass.emptyLayoutName();
} else {
// otherwise, the empty layout maps to the default
if (layoutname == tclass.emptyLayoutName())
layoutname = tclass.defaultLayoutName();
}
This turns out not to work, because par.forceEmptyLayout() and par.useEmptyLayout() always return false here, because par.inInset() always returns a null pointer, because the paragraph's inset hasn't yet been set when Text::readParagraph() gets called from Text::read() gets called from InsetText::read(). The solution is to set the paragraph's inset when it is created, which means passing a pointer to the various read() routines along the way.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23057 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-19 02:35:07 +00:00
|
|
|
/// insetPtr is the containing Inset
|
2009-08-09 15:29:34 +00:00
|
|
|
bool read(Lexer & lex, ErrorList & errorList,
|
2008-02-19 03:46:11 +00:00
|
|
|
InsetText * insetPtr);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
2007-01-25 21:18:36 +00:00
|
|
|
/// delete double spaces, leading spaces, and empty paragraphs around old cursor.
|
2007-01-21 16:55:41 +00:00
|
|
|
/// \retval true if a change has happened and we need a redraw.
|
2007-04-26 14:56:30 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator. This is not possible right
|
|
|
|
/// now because recordUndo() is called which needs a Cursor.
|
|
|
|
static bool deleteEmptyParagraphMechanism(Cursor & cur,
|
|
|
|
Cursor & old, bool & need_anchor_change);
|
2005-12-01 10:28:50 +00:00
|
|
|
|
2007-01-25 21:18:36 +00:00
|
|
|
/// delete double spaces, leading spaces, and empty paragraphs
|
|
|
|
/// from \first to \last paragraph
|
|
|
|
void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges);
|
|
|
|
|
2007-12-21 20:42:46 +00:00
|
|
|
/// To resolve macros properly the texts get their DocIterator.
|
|
|
|
/// Every macro definition is stored with its DocIterator
|
|
|
|
/// as well. Only those macros with a smaller iterator become
|
|
|
|
/// visible in a paragraph.
|
|
|
|
DocIterator macrocontextPosition() const;
|
|
|
|
///
|
|
|
|
void setMacrocontextPosition(DocIterator const & pos);
|
|
|
|
|
2008-03-15 12:22:28 +00:00
|
|
|
///
|
|
|
|
bool completionSupported(Cursor const & cur) const;
|
|
|
|
///
|
|
|
|
CompletionList const * createCompletionList(Cursor const & cur) const;
|
|
|
|
///
|
|
|
|
bool insertCompletion(Cursor & cur, docstring const & s, bool /*finished*/);
|
|
|
|
///
|
|
|
|
docstring completionPrefix(Cursor const & cur) const;
|
2009-08-09 18:35:39 +00:00
|
|
|
/// for the environments
|
|
|
|
pit_type depthHook(pit_type par, depth_type depth) const;
|
|
|
|
///
|
|
|
|
pit_type outerHook(pit_type par) const;
|
|
|
|
/// Is it the first par with same depth and layout?
|
|
|
|
bool isFirstInSequence(pit_type par) const;
|
|
|
|
/// Get the font of the "environment" of paragraph \p par_offset in \p pars.
|
|
|
|
/// All font changes of the paragraph are relative to this font.
|
|
|
|
Font const outerFont(pit_type par_offset) const;
|
2008-03-15 12:22:28 +00:00
|
|
|
|
2009-08-09 16:00:25 +00:00
|
|
|
private:
|
|
|
|
/// The InsetText owner shall have access to everything.
|
|
|
|
friend class InsetText;
|
2003-11-22 14:44:59 +00:00
|
|
|
|
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
|
|
|
// fix the cursor `cur' after a characters has been deleted at `where'
|
|
|
|
// position. Called by deleteEmptyParagraphMechanism
|
2007-02-08 15:01:58 +00:00
|
|
|
static void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where);
|
2003-11-22 14:44:59 +00:00
|
|
|
|
2006-11-24 22:26:22 +00:00
|
|
|
// At cursor position 0, try to merge the paragraph with the one before it.
|
|
|
|
// Ignore change tracking, i.e., physically remove the end-of-par character
|
2007-04-26 14:56:30 +00:00
|
|
|
bool backspacePos0(Cursor & cur);
|
2007-05-14 09:24:17 +00:00
|
|
|
/// handle the case where bibitems were deleted
|
|
|
|
bool handleBibitems(Cursor & cur);
|
2008-10-14 13:27:58 +00:00
|
|
|
/// are we in a list item (description etc.)?
|
|
|
|
bool inDescriptionItem(Cursor & cur) const;
|
2003-11-22 14:44:59 +00:00
|
|
|
///
|
2007-10-18 11:51:17 +00:00
|
|
|
void charInserted(Cursor & cur);
|
2003-11-22 14:44:59 +00:00
|
|
|
/// set 'number' font property
|
2007-04-26 14:56:30 +00:00
|
|
|
void number(Cursor & cur);
|
2007-01-03 07:30:50 +00:00
|
|
|
|
2007-01-06 15:33:07 +00:00
|
|
|
/// paste plain text at current cursor.
|
2007-01-03 07:30:50 +00:00
|
|
|
/// \param str string to paste
|
2007-01-06 15:33:07 +00:00
|
|
|
/// \param asParagraphs whether to paste as paragraphs or as lines
|
2007-04-26 14:56:30 +00:00
|
|
|
void pasteString(Cursor & cur, docstring const & str,
|
2007-01-06 15:33:07 +00:00
|
|
|
bool asParagraphs);
|
2009-08-09 15:29:34 +00:00
|
|
|
///
|
|
|
|
void readParToken(Paragraph & par, Lexer & lex, std::string const & token,
|
|
|
|
Font & font, Change & change, ErrorList & errorList);
|
|
|
|
///
|
|
|
|
void readParagraph(Paragraph & par, Lexer & lex, ErrorList & errorList);
|
2009-08-09 17:45:24 +00:00
|
|
|
/// Set Label Width string to all paragraphs of the same layout
|
|
|
|
/// and depth in a sequence.
|
|
|
|
void setLabelWidthStringToSequence(pit_type const par_offset, docstring const & s);
|
2007-12-21 20:42:46 +00:00
|
|
|
|
2009-08-09 15:05:36 +00:00
|
|
|
/// Owner Inset.
|
|
|
|
InsetText * owner_;
|
2009-08-09 16:19:43 +00:00
|
|
|
///
|
|
|
|
ParagraphList pars_;
|
|
|
|
///
|
|
|
|
bool autoBreakRows_;
|
2007-12-21 20:42:46 +00:00
|
|
|
/// position of the text in the buffer.
|
|
|
|
DocIterator macrocontext_position_;
|
2009-10-02 23:13:19 +00:00
|
|
|
///
|
|
|
|
unsigned int undo_counter_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2009-08-09 17:30:41 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void breakParagraphConservative(BufferParams const & bparams,
|
|
|
|
ParagraphList & paragraphs,
|
|
|
|
pit_type par,
|
|
|
|
pos_type pos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Append the next paragraph onto the tail of this one.
|
|
|
|
* Be careful, this doesent make any check at all.
|
|
|
|
*/
|
|
|
|
void mergeParagraph(BufferParams const & bparams,
|
|
|
|
ParagraphList & paragraphs, pit_type par);
|
|
|
|
|
|
|
|
/// accept the changes within the complete ParagraphList
|
|
|
|
void acceptChanges(ParagraphList & pars, BufferParams const & bparams);
|
|
|
|
|
2010-06-01 16:13:54 +00:00
|
|
|
/// reject the changes within the complete ParagraphList
|
|
|
|
void rejectChanges(ParagraphList & pars, BufferParams const & bparams);
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-02-27 23:03:26 +00:00
|
|
|
#endif // TEXT_H
|