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 BufferParams;
|
2000-02-10 17:53:36 +00:00
|
|
|
class BufferView;
|
2020-10-20 08:36:59 +00:00
|
|
|
class Change;
|
2008-03-15 12:22:28 +00:00
|
|
|
class CompletionList;
|
2009-08-09 17:30:41 +00:00
|
|
|
class Cursor;
|
Move some Cursor methods to CursorData
Basically, everything that does not depend on a BufferView should move
there. Some methods that do not seem to need a BufferView, like
selHandle or IdxFirst or push actually depend on it and could not be
moved.
This allows to simplify a few uses of recordUndo helpers.
- Move some methods to DocIterator: nextMath, prevMath, getPossibleLabel,
getEncoding;
- Move some methods to CursorData: setCursor, setCursorSelectionTo,
(setCursorTo|normal|reset)Anchor, (set|clear)Selection,
sel(|ection)(Begin|End), selectionAsString, info, currentState,
(mark|clear|check)NewWordPosition, fixIfBroken, sanitize, all undo
related methods, reset, isInside, leaveInset, current mode;
- kill some unused methods: macromode, replaceWord, setScreenPos, touch,
markInsert, markErase;
- Move code around to group things, and add a few comments (a lot remains to be done).
This changes lead to some related changes in other classes: removal,
change of parameter.
No intended change.
2017-07-23 16:13:33 +00:00
|
|
|
class CursorData;
|
2004-01-26 10:13:15 +00:00
|
|
|
class CursorSlice;
|
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;
|
2020-10-19 08:51:00 +00:00
|
|
|
class InsetText;
|
2007-10-13 09:48:18 +00:00
|
|
|
class Lexer;
|
2020-10-20 08:36:59 +00:00
|
|
|
class Paragraph;
|
|
|
|
class ParagraphParameters;
|
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
|
2017-10-16 02:06:02 +00:00
|
|
|
/// count as empty.
|
2007-08-14 16:59:59 +00:00
|
|
|
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);
|
2012-07-16 21:39:24 +00:00
|
|
|
/// Set given layout to current cursor position or selection.
|
|
|
|
/// Handles undo.
|
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.
|
2020-10-01 10:34:15 +00:00
|
|
|
void changeDepth(Cursor const & 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.
|
2020-10-01 10:34:15 +00:00
|
|
|
bool changeDepthAllowed(Cursor const & 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);
|
2018-12-26 14:46:14 +00:00
|
|
|
/// Stack to save recent text propterty applications
|
|
|
|
std::vector<docstring> getFreeFonts() const;
|
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.
|
2018-04-26 02:22:36 +00:00
|
|
|
docstring getStringForDialog(Cursor & 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;
|
2015-10-04 18:38:47 +00:00
|
|
|
|
|
|
|
/// truncates str to maxlenwith an ellipsis and replaces the characters '\n'
|
|
|
|
/// and '\t' with spaces
|
|
|
|
static void shortenForOutliner(docstring & str, size_t const maxlen);
|
2017-07-03 17:45:58 +00:00
|
|
|
|
2015-10-04 18:38:47 +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
|
2017-01-08 20:57:02 +00:00
|
|
|
/// shorten is true, then os is shortened as above.
|
|
|
|
void forOutliner(docstring & os, size_t maxlen, bool shorten = true) const;
|
|
|
|
/// Appends a possibly abbreviated representation of our text, from
|
|
|
|
/// start to end, to \param os, where \param maxlen defines the
|
|
|
|
/// maximum size of \param os. Omits the label of the first paragraph.
|
|
|
|
void forOutliner(docstring & os, size_t maxlen, pit_type start, pit_type end,
|
|
|
|
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.
|
2017-07-23 22:21:43 +00:00
|
|
|
// When \param devel_mode is true, add more precise information
|
Move some Cursor methods to CursorData
Basically, everything that does not depend on a BufferView should move
there. Some methods that do not seem to need a BufferView, like
selHandle or IdxFirst or push actually depend on it and could not be
moved.
This allows to simplify a few uses of recordUndo helpers.
- Move some methods to DocIterator: nextMath, prevMath, getPossibleLabel,
getEncoding;
- Move some methods to CursorData: setCursor, setCursorSelectionTo,
(setCursorTo|normal|reset)Anchor, (set|clear)Selection,
sel(|ection)(Begin|End), selectionAsString, info, currentState,
(mark|clear|check)NewWordPosition, fixIfBroken, sanitize, all undo
related methods, reset, isInside, leaveInset, current mode;
- kill some unused methods: macromode, replaceWord, setScreenPos, touch,
markInsert, markErase;
- Move code around to group things, and add a few comments (a lot remains to be done).
This changes lead to some related changes in other classes: removal,
change of parameter.
No intended change.
2017-07-23 16:13:33 +00:00
|
|
|
docstring currentState(CursorData const & cur, bool devel_mode) 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);
|
2017-07-03 17:45:58 +00:00
|
|
|
|
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
|
2016-02-29 12:29:06 +00:00
|
|
|
bool setCursor(Cursor & cur, pit_type pit, 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
|
|
|
///
|
2016-02-29 12:29:06 +00:00
|
|
|
void setCursorIntern(Cursor & cur, pit_type pit,
|
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
|
|
|
|
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.
|
2017-02-18 18:12:55 +00:00
|
|
|
/// Use force to skip the confirmDeletion check.
|
|
|
|
void deleteWordForward(Cursor & cur, bool force = false);
|
2007-09-02 11:21:33 +00:00
|
|
|
/// Delete from cursor to start of current or prior word.
|
2017-02-18 18:12:55 +00:00
|
|
|
void deleteWordBackward(Cursor & cur, bool force = false);
|
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);
|
2020-12-24 09:48:52 +00:00
|
|
|
/// FIXME: replace Cursor with DocIterator.
|
|
|
|
bool splitInset(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.
|
2015-05-28 13:43:12 +00:00
|
|
|
void changeCase(Cursor & cur, TextCase action, bool partial);
|
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
|
|
|
*/
|
2020-10-31 17:18:51 +00:00
|
|
|
void setParagraphs(Cursor const & cur, docstring const & arg, bool merge = false);
|
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
|
|
|
/// Sets parameters for current or selected paragraphs
|
2020-10-09 15:50:24 +00:00
|
|
|
void setParagraphs(Cursor const & 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.
|
Move some Cursor methods to CursorData
Basically, everything that does not depend on a BufferView should move
there. Some methods that do not seem to need a BufferView, like
selHandle or IdxFirst or push actually depend on it and could not be
moved.
This allows to simplify a few uses of recordUndo helpers.
- Move some methods to DocIterator: nextMath, prevMath, getPossibleLabel,
getEncoding;
- Move some methods to CursorData: setCursor, setCursorSelectionTo,
(setCursorTo|normal|reset)Anchor, (set|clear)Selection,
sel(|ection)(Begin|End), selectionAsString, info, currentState,
(mark|clear|check)NewWordPosition, fixIfBroken, sanitize, all undo
related methods, reset, isInside, leaveInset, current mode;
- kill some unused methods: macromode, replaceWord, setScreenPos, touch,
markInsert, markErase;
- Move code around to group things, and add a few comments (a lot remains to be done).
This changes lead to some related changes in other classes: removal,
change of parameter.
No intended change.
2017-07-23 16:13:33 +00:00
|
|
|
docstring getPossibleLabel(DocIterator const & cur) const;
|
2004-02-16 11:58:51 +00:00
|
|
|
/// is this paragraph right-to-left?
|
2019-04-02 07:53:40 +00:00
|
|
|
bool isRTL(pit_type pit) 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
|
2014-04-29 20:05:27 +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.
|
2019-02-15 14:33:23 +00:00
|
|
|
/// Handles undo.
|
2007-04-26 14:56:30 +00:00
|
|
|
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
|
2019-02-15 14:33:23 +00:00
|
|
|
/// Does NOT handle undo (responsibility of the caller)
|
2007-01-25 21:18:36 +00:00
|
|
|
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
|
2014-04-29 20:05:27 +00:00
|
|
|
/// as well. Only those macros with a smaller iterator become
|
2007-12-21 20:42:46 +00:00
|
|
|
/// 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;
|
2012-05-14 12:21:49 +00:00
|
|
|
/// find a paragraph before \p par with the given \p depth, if such
|
|
|
|
/// a paragraph cannot be found, \p par is returned
|
2016-02-29 12:29:06 +00:00
|
|
|
pit_type depthHook(pit_type pit, depth_type depth) const;
|
2012-05-14 12:21:49 +00:00
|
|
|
/// find a paragraph before \p par with depth less than the
|
|
|
|
/// depth of \p par. If such paragraph cannot be found because
|
|
|
|
/// \p par already has depth 0, lastpar + 1 is returned. If
|
|
|
|
/// such paragraph cannot be found because there isn't a par
|
|
|
|
/// with less depth before this one, \p par is returned.
|
2016-02-29 12:29:06 +00:00
|
|
|
pit_type outerHook(pit_type pit) const;
|
2009-08-09 18:35:39 +00:00
|
|
|
/// Is it the first par with same depth and layout?
|
2016-02-29 12:29:06 +00:00
|
|
|
bool isFirstInSequence(pit_type pit) const;
|
2017-01-08 20:57:02 +00:00
|
|
|
/// Return the last paragraph with same depth and layout, or a strictly
|
|
|
|
/// greater depth
|
|
|
|
pit_type lastInSequence(pit_type pit) const;
|
2012-12-15 15:47:57 +00:00
|
|
|
/// Is this paragraph in the table of contents?
|
2016-02-29 12:29:06 +00:00
|
|
|
int getTocLevel(pit_type pit) const;
|
2009-08-09 18:35:39 +00:00
|
|
|
/// 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.
|
2016-02-29 12:29:06 +00:00
|
|
|
Font const outerFont(pit_type pit_offset) const;
|
2019-04-03 09:06:43 +00:00
|
|
|
/// Return the label type at the end of paragraph \c pit.
|
|
|
|
int getEndLabel(pit_type pit) 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
|
|
|
|
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.)?
|
2020-10-01 10:34:15 +00:00
|
|
|
bool inDescriptionItem(Cursor const & 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
|
2014-04-29 20:05:27 +00:00
|
|
|
/// and depth in a sequence.
|
2012-07-16 21:39:24 +00:00
|
|
|
void setLabelWidthStringToSequence(Cursor const & cur, 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_;
|
2007-12-21 20:42:46 +00:00
|
|
|
/// position of the text in the buffer.
|
|
|
|
DocIterator macrocontext_position_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
2009-08-09 17:30:41 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
void breakParagraphConservative(BufferParams const & bparams,
|
|
|
|
ParagraphList & paragraphs,
|
2016-02-29 12:29:06 +00:00
|
|
|
pit_type pit,
|
2009-08-09 17:30:41 +00:00
|
|
|
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,
|
2016-02-29 12:29:06 +00:00
|
|
|
ParagraphList & paragraphs, pit_type pit);
|
2009-08-09 17:30:41 +00:00
|
|
|
|
|
|
|
/// 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
|