2003-08-23 00:17:00 +00:00
|
|
|
/**
|
2007-04-26 04:41:58 +00:00
|
|
|
* \file text2.cpp
|
2003-08-23 00:17:00 +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-08-23 00:17:00 +00:00
|
|
|
* \author Asger Alstrup
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Alfredo Braunstein
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author John Levon
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Allan Rae
|
2007-06-07 19:55:22 +00:00
|
|
|
* \author Stefan Schimanski
|
2003-08-23 00:17:00 +00:00
|
|
|
* \author Dekel Tsur
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
#include "Text.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
2008-02-10 19:52:45 +00:00
|
|
|
#include "Bidi.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Buffer.h"
|
2003-06-24 20:42:15 +00:00
|
|
|
#include "buffer_funcs.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "BufferList.h"
|
|
|
|
#include "BufferParams.h"
|
1999-12-19 22:35:36 +00:00
|
|
|
#include "BufferView.h"
|
2007-10-18 15:29:51 +00:00
|
|
|
#include "Changes.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
#include "Cursor.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
#include "CutAndPaste.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "DispatchResult.h"
|
|
|
|
#include "ErrorList.h"
|
|
|
|
#include "Language.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
#include "Layout.h"
|
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
|
|
|
#include "Lexer.h"
|
2010-02-09 16:11:13 +00:00
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "LyXRC.h"
|
|
|
|
#include "Paragraph.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
#include "ParagraphParameters.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2007-10-11 09:59:01 +00:00
|
|
|
#include "TextMetrics.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "VSpace.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
2008-08-14 15:24:12 +00:00
|
|
|
#include "insets/InsetCollapsable.h"
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
#include "mathed/InsetMathHull.h"
|
2006-09-08 13:52:41 +00:00
|
|
|
|
2008-04-30 08:26:40 +00:00
|
|
|
#include "support/lassert.h"
|
2007-11-29 21:10:35 +00:00
|
|
|
#include "support/debug.h"
|
|
|
|
#include "support/gettext.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
#include "support/textutils.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
2007-10-02 18:27:20 +00:00
|
|
|
#include <boost/next_prior.hpp>
|
2005-09-26 09:20:15 +00:00
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
#include <sstream>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2000-07-21 18:47:54 +00:00
|
|
|
|
2007-09-02 11:46:05 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2009-08-09 15:29:34 +00:00
|
|
|
bool Text::isMainText() const
|
2004-03-18 12:53:43 +00:00
|
|
|
{
|
2009-08-09 15:29:34 +00:00
|
|
|
return &owner_->buffer().text() == this;
|
2004-03-18 12:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-14 15:44:36 +00:00
|
|
|
// Note that this is supposed to return a fully realized font.
|
2009-08-09 15:29:34 +00:00
|
|
|
FontInfo Text::layoutFont(pit_type const pit) const
|
2001-08-03 18:28:11 +00:00
|
|
|
{
|
2008-03-06 21:31:27 +00:00
|
|
|
Layout const & layout = pars_[pit].layout();
|
2001-08-03 18:28:11 +00:00
|
|
|
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
if (!pars_[pit].getDepth()) {
|
2008-03-06 21:31:27 +00:00
|
|
|
FontInfo lf = layout.resfont;
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
// In case the default family has been customized
|
2008-03-06 21:31:27 +00:00
|
|
|
if (layout.font.family() == INHERIT_FAMILY)
|
2009-08-09 15:29:34 +00:00
|
|
|
lf.setFamily(owner_->buffer().params().getFont().fontInfo().family());
|
2008-08-15 01:03:32 +00:00
|
|
|
// FIXME
|
|
|
|
// It ought to be possible here just to use Inset::getLayout() and skip
|
|
|
|
// the asInsetCollapsable() bit. Unfortunatley, that doesn't work right
|
|
|
|
// now, because Inset::getLayout() will return a default-constructed
|
|
|
|
// InsetLayout, and that e.g. sets the foreground color to red. So we
|
|
|
|
// need to do some work to make that possible.
|
2009-08-09 17:01:04 +00:00
|
|
|
InsetCollapsable const * icp = owner_->asInsetCollapsable();
|
2008-08-14 15:44:36 +00:00
|
|
|
if (!icp)
|
|
|
|
return lf;
|
|
|
|
FontInfo icf = icp->getLayout().font();
|
|
|
|
icf.realize(lf);
|
|
|
|
return icf;
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2008-03-06 21:31:27 +00:00
|
|
|
FontInfo font = layout.font;
|
2003-04-15 00:11:03 +00:00
|
|
|
// Realize with the fonts of lesser depth.
|
2009-08-09 18:35:39 +00:00
|
|
|
//font.realize(outerFont(pit));
|
2009-08-09 15:29:34 +00:00
|
|
|
font.realize(owner_->buffer().params().getFont().fontInfo());
|
2003-04-15 00:11:03 +00:00
|
|
|
|
2003-07-27 21:59:06 +00:00
|
|
|
return font;
|
2001-08-03 18:28:11 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-08-03 18:28:11 +00:00
|
|
|
|
2008-08-14 15:44:36 +00:00
|
|
|
// Note that this is supposed to return a fully realized font.
|
2009-08-09 15:29:34 +00:00
|
|
|
FontInfo Text::labelFont(Paragraph const & par) const
|
2001-08-03 18:28:11 +00:00
|
|
|
{
|
2009-08-09 15:29:34 +00:00
|
|
|
Buffer const & buffer = owner_->buffer();
|
2008-03-06 21:31:27 +00:00
|
|
|
Layout const & layout = par.layout();
|
2001-08-03 18:28:11 +00:00
|
|
|
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
if (!par.getDepth()) {
|
2008-03-06 21:31:27 +00:00
|
|
|
FontInfo lf = layout.reslabelfont;
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
// In case the default family has been customized
|
2008-03-06 21:31:27 +00:00
|
|
|
if (layout.labelfont.family() == INHERIT_FAMILY)
|
2007-10-28 18:51:54 +00:00
|
|
|
lf.setFamily(buffer.params().getFont().fontInfo().family());
|
2008-10-25 15:10:54 +00:00
|
|
|
return lf;
|
The Grand Font Selection Redesign:
* lib/lyx2lyx/LyX.py (format_relation): add file format 247 (from Georg BAUM).
* lib/lyx2lyx/lyx_1_5.py: add convert_font_settings, revert_font_settings (from Georg BAUM).
* lib/chkconfig.ltx: Test for newly supported font packages
* lib/doc/LaTeXConfig.lyx.in: document newly supported font packages
* lib/doc/UserGuide.lyx: document new UI.
* lib/doc/Extended.lyx: update PostScript font documentation
* development/FORMAT: document file format change 246->247.
* src/tex-strings.[Ch]: new strings tex_fonts_roman, tex_fonts_sans,
tex_fonts_monospaced (with GUI equivalents).
* src/buffer.C: Format up to 247.
* src/bufferparams.C:
new params fontsRoman, fontsSans, fontsTypewriter, fontsDefaultFamily,
fontsSC, fontsOSF, fontsSansScale and fontsTypewriterScale
(LyXFont const BufferParams::getFont): consider switch of default family.
(string const BufferParams::loadFonts): new method to get all the LaTeX
font stuff done.
* src/paragraph.C
(LyXFont const Paragraph::getFont):
(LyXFont const Paragraph::getLabelFont):
(LyXFont const Paragraph::getLayoutFont): user buffer's not textclass's
default font
* src/text.C
(int LyXText::leftMargin):
(int LyXText::rightMargin): user buffer's not textclass's default font
* src/text2.C
(LyXFont LyXText::getFont):
(LyXFont LyXText::getLayoutFont):
(LyXFont LyXText::getLabelFont): check if the family of the default document
font has been customized.
* src/frontends/gtk/GDocument.[Ch]: implement new font ui (from Georg BAUM).
* src/frontends/gtk/glade/document.glade: implement new font ui (from Georg BAUM).
* src/frontends/qt3/Makefile.dialogs: add new FontModuleBase
* src/frontends/qt3/ui/FontModuleBase.ui: new File
* src/frontends/qt3/ui/TextLayoutModuleBase.ui: remove font widgets
* src/frontends/qt3/QDocument.C
* src/frontends/qt3/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/Makefile.dialogs: add new FontUi
* src/frontends/qt4/QDocumentDialog.[Ch]: implement new font ui
* src/frontends/qt4/ui/FontUi.ui: new File
* src/frontends/qt4/ui/TextLayoutUi.ui: remove font widgets
* src/frontends/qt4/ui/compile_uic.sh: add new FontUi
* src/frontends/xforms/FormDocument.[Ch]: implement new font ui
* src/frontends/xforms/forms/form_document.fd: add new font tab.
* src/frontends/controllers/ControlDocument.[Ch]
(char ControlDocument::fontfamilies):
(char ControlDocument::fontfamilies_gui):
(bool ControlDocument::isFontAvailable):
(bool ControlDocument::providesSC):
(bool ControlDocument::providesOSF):
(bool ControlDocument::providesScale): new methods, providing font info.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14143 a592a061-630c-0410-9148-cb99ea01b6c8
2006-06-19 08:10:17 +00:00
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
2008-03-06 21:31:27 +00:00
|
|
|
FontInfo font = layout.labelfont;
|
2003-04-15 00:11:03 +00:00
|
|
|
// Realize with the fonts of lesser depth.
|
2007-10-28 18:51:54 +00:00
|
|
|
font.realize(buffer.params().getFont().fontInfo());
|
2003-04-15 00:11:03 +00:00
|
|
|
|
2003-07-27 21:59:06 +00:00
|
|
|
return font;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-09 15:29:34 +00:00
|
|
|
void Text::setCharFont(pit_type pit,
|
2007-09-02 21:48:49 +00:00
|
|
|
pos_type pos, Font const & fnt, Font const & display_font)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2009-08-09 15:29:34 +00:00
|
|
|
Buffer const & buffer = owner_->buffer();
|
2007-04-29 18:17:15 +00:00
|
|
|
Font font = fnt;
|
2008-03-06 21:31:27 +00:00
|
|
|
Layout const & layout = pars_[pit].layout();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Get concrete layout font to reduce against
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo layoutfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
if (pos < pars_[pit].beginOfBody())
|
2008-03-06 21:31:27 +00:00
|
|
|
layoutfont = layout.labelfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
2008-03-06 21:31:27 +00:00
|
|
|
layoutfont = layout.font;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Realize against environment font information
|
2004-03-25 09:16:36 +00:00
|
|
|
if (pars_[pit].getDepth()) {
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type tp = pit;
|
2003-04-16 08:12:22 +00:00
|
|
|
while (!layoutfont.resolved() &&
|
2004-11-24 21:53:46 +00:00
|
|
|
tp != pit_type(paragraphs().size()) &&
|
2004-03-25 09:16:36 +00:00
|
|
|
pars_[tp].getDepth()) {
|
2009-08-09 18:35:39 +00:00
|
|
|
tp = outerHook(tp);
|
2004-11-24 21:53:46 +00:00
|
|
|
if (tp != pit_type(paragraphs().size()))
|
2008-03-06 21:31:27 +00:00
|
|
|
layoutfont.realize(pars_[tp].layout().font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-28 12:39:22 +00:00
|
|
|
// Inside inset, apply the inset's font attributes if any
|
|
|
|
// (charstyle!)
|
2009-08-09 15:29:34 +00:00
|
|
|
if (!isMainText())
|
2007-10-28 18:51:54 +00:00
|
|
|
layoutfont.realize(display_font.fontInfo());
|
2006-01-28 12:39:22 +00:00
|
|
|
|
2007-10-28 18:51:54 +00:00
|
|
|
layoutfont.realize(buffer.params().getFont().fontInfo());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Now, reduce font against full layout font
|
2007-10-28 18:51:54 +00:00
|
|
|
font.fontInfo().reduce(layoutfont);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
pars_[pit].setFont(pos, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-02 21:48:49 +00:00
|
|
|
void Text::setInsetFont(BufferView const & bv, pit_type pit,
|
2007-05-22 10:51:38 +00:00
|
|
|
pos_type pos, Font const & font, bool toggleall)
|
|
|
|
{
|
|
|
|
Inset * const inset = pars_[pit].getInset(pos);
|
2011-02-22 19:41:04 +00:00
|
|
|
LASSERT(inset && inset->resetFontEdit(), /**/);
|
2008-02-09 10:41:49 +00:00
|
|
|
|
2007-08-21 10:54:04 +00:00
|
|
|
CursorSlice::idx_type endidx = inset->nargs();
|
|
|
|
for (CursorSlice cs(*inset); cs.idx() != endidx; ++cs.idx()) {
|
|
|
|
Text * text = cs.text();
|
|
|
|
if (text) {
|
2007-05-22 10:51:38 +00:00
|
|
|
// last position of the cell
|
2007-08-21 10:54:04 +00:00
|
|
|
CursorSlice cellend = cs;
|
2007-05-22 10:51:38 +00:00
|
|
|
cellend.pit() = cellend.lastpit();
|
|
|
|
cellend.pos() = cellend.lastpos();
|
2007-09-02 21:48:49 +00:00
|
|
|
text->setFont(bv, cs, cellend, font, toggleall);
|
2007-05-22 10:51:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-01-09 09:04:33 +00:00
|
|
|
// return past-the-last paragraph influenced by a layout change on pit
|
2007-04-29 23:33:02 +00:00
|
|
|
pit_type Text::undoSpan(pit_type pit)
|
2004-01-09 09:04:33 +00:00
|
|
|
{
|
2008-09-29 09:33:36 +00:00
|
|
|
pit_type const end = paragraphs().size();
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type nextpit = pit + 1;
|
2004-01-09 09:04:33 +00:00
|
|
|
if (nextpit == end)
|
|
|
|
return nextpit;
|
|
|
|
//because of parindents
|
2004-03-25 09:16:36 +00:00
|
|
|
if (!pars_[pit].getDepth())
|
2004-01-09 09:04:33 +00:00
|
|
|
return boost::next(nextpit);
|
|
|
|
//because of depth constrains
|
|
|
|
for (; nextpit != end; ++pit, ++nextpit) {
|
2004-03-25 09:16:36 +00:00
|
|
|
if (!pars_[pit].getDepth())
|
2004-01-09 09:04:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return nextpit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-09 15:29:34 +00:00
|
|
|
void Text::setLayout(pit_type start, pit_type end,
|
2009-07-12 21:48:50 +00:00
|
|
|
docstring const & layout)
|
2001-04-04 21:47:26 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(start != end, /**/);
|
2002-03-02 16:39:54 +00:00
|
|
|
|
2009-08-09 15:29:34 +00:00
|
|
|
Buffer const & buffer = owner_->buffer();
|
2009-07-12 21:48:50 +00:00
|
|
|
BufferParams const & bp = buffer.params();
|
|
|
|
Layout const & lyxlayout = bp.documentClass()[layout];
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
for (pit_type pit = start; pit != end; ++pit) {
|
2007-01-15 16:58:14 +00:00
|
|
|
Paragraph & par = pars_[pit];
|
|
|
|
par.applyLayout(lyxlayout);
|
2008-03-06 20:01:30 +00:00
|
|
|
if (lyxlayout.margintype == MARGIN_MANUAL)
|
2009-07-12 21:48:50 +00:00
|
|
|
par.setLabelWidthString(par.expandLabel(lyxlayout, bp));
|
2003-12-08 12:47:18 +00:00
|
|
|
}
|
2000-05-04 08:14:34 +00:00
|
|
|
}
|
2001-04-04 21:47:26 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-01-13 16:28:54 +00:00
|
|
|
// set layout over selection and make a total rebreak of those paragraphs
|
2007-07-11 13:39:08 +00:00
|
|
|
void Text::setLayout(Cursor & cur, docstring const & layout)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2003-05-19 07:12:09 +00:00
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type start = cur.selBegin().pit();
|
|
|
|
pit_type end = cur.selEnd().pit() + 1;
|
2005-11-28 11:52:03 +00:00
|
|
|
pit_type undopit = undoSpan(end - 1);
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
recUndo(cur, start, undopit - 1);
|
2009-08-09 15:29:34 +00:00
|
|
|
setLayout(start, end, layout);
|
2010-07-09 14:37:00 +00:00
|
|
|
cur.forceBufferUpdate();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
static bool changeDepthAllowed(Text::DEPTH_CHANGE type,
|
2005-09-26 22:54:12 +00:00
|
|
|
Paragraph const & par, int max_depth)
|
2003-11-26 09:48:21 +00:00
|
|
|
{
|
2008-03-06 21:31:27 +00:00
|
|
|
if (par.layout().labeltype == LABEL_BIBLIO)
|
2003-11-26 09:48:21 +00:00
|
|
|
return false;
|
|
|
|
int const depth = par.params().depth();
|
2007-04-29 23:33:02 +00:00
|
|
|
if (type == Text::INC_DEPTH && depth < max_depth)
|
2003-11-26 09:48:21 +00:00
|
|
|
return true;
|
2007-04-29 23:33:02 +00:00
|
|
|
if (type == Text::DEC_DEPTH && depth > 0)
|
2003-11-26 09:48:21 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2003-04-03 01:26:02 +00:00
|
|
|
|
2001-05-31 02:23:46 +00:00
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::changeDepthAllowed(Cursor & cur, DEPTH_CHANGE type) const
|
2003-11-26 09:48:21 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2006-08-14 19:14:44 +00:00
|
|
|
// this happens when selecting several cells in tabular (bug 2630)
|
|
|
|
if (cur.selBegin().idx() != cur.selEnd().idx())
|
|
|
|
return false;
|
|
|
|
|
2004-12-06 12:55:03 +00:00
|
|
|
pit_type const beg = cur.selBegin().pit();
|
|
|
|
pit_type const end = cur.selEnd().pit() + 1;
|
|
|
|
int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
|
2003-04-02 21:19:35 +00:00
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
for (pit_type pit = beg; pit != end; ++pit) {
|
2006-10-21 00:16:43 +00:00
|
|
|
if (lyx::changeDepthAllowed(type, pars_[pit], max_depth))
|
2003-11-26 09:48:21 +00:00
|
|
|
return true;
|
2004-03-25 09:16:36 +00:00
|
|
|
max_depth = pars_[pit].getMaxDepthAfter();
|
2001-05-31 02:23:46 +00:00
|
|
|
}
|
2003-11-26 09:48:21 +00:00
|
|
|
return false;
|
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2003-04-03 01:26:02 +00:00
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::changeDepth(Cursor & cur, DEPTH_CHANGE type)
|
2003-11-26 09:48:21 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2004-12-06 12:55:03 +00:00
|
|
|
pit_type const beg = cur.selBegin().pit();
|
|
|
|
pit_type const end = cur.selEnd().pit() + 1;
|
2007-10-18 11:51:17 +00:00
|
|
|
cur.recordUndoSelection();
|
2004-12-06 12:55:03 +00:00
|
|
|
int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2004-11-24 21:53:46 +00:00
|
|
|
for (pit_type pit = beg; pit != end; ++pit) {
|
2004-11-30 01:59:49 +00:00
|
|
|
Paragraph & par = pars_[pit];
|
2006-10-21 00:16:43 +00:00
|
|
|
if (lyx::changeDepthAllowed(type, par, max_depth)) {
|
2004-11-30 01:59:49 +00:00
|
|
|
int const depth = par.params().depth();
|
2004-03-18 13:57:20 +00:00
|
|
|
if (type == INC_DEPTH)
|
2004-11-30 01:59:49 +00:00
|
|
|
par.params().depth(depth + 1);
|
2003-11-26 09:48:21 +00:00
|
|
|
else
|
2004-11-30 01:59:49 +00:00
|
|
|
par.params().depth(depth - 1);
|
2003-11-26 09:48:21 +00:00
|
|
|
}
|
2004-11-30 01:59:49 +00:00
|
|
|
max_depth = par.getMaxDepthAfter();
|
2003-04-02 17:59:01 +00:00
|
|
|
}
|
2003-04-07 20:32:29 +00:00
|
|
|
// this handles the counter labels, and also fixes up
|
|
|
|
// depth values for follow-on (child) paragraphs
|
2010-07-09 14:37:00 +00:00
|
|
|
cur.forceBufferUpdate();
|
2001-05-31 02:23:46 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::setFont(Cursor & cur, Font const & font, bool toggleall)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2007-05-17 12:17:38 +00:00
|
|
|
// Set the current_font
|
|
|
|
// Determine basis font
|
2007-10-28 18:51:54 +00:00
|
|
|
FontInfo layoutfont;
|
2007-05-17 12:17:38 +00:00
|
|
|
pit_type pit = cur.pit();
|
|
|
|
if (cur.pos() < pars_[pit].beginOfBody())
|
2009-08-09 15:29:34 +00:00
|
|
|
layoutfont = labelFont(pars_[pit]);
|
2007-05-17 12:17:38 +00:00
|
|
|
else
|
2009-08-09 15:29:34 +00:00
|
|
|
layoutfont = layoutFont(pit);
|
2003-12-08 12:47:18 +00:00
|
|
|
|
2007-05-17 12:17:38 +00:00
|
|
|
// Update current font
|
2007-09-02 13:35:48 +00:00
|
|
|
cur.real_current_font.update(font,
|
2008-11-17 11:46:07 +00:00
|
|
|
cur.buffer()->params().language,
|
2007-05-17 12:17:38 +00:00
|
|
|
toggleall);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-05-17 12:17:38 +00:00
|
|
|
// Reduce to implicit settings
|
2007-09-02 13:35:48 +00:00
|
|
|
cur.current_font = cur.real_current_font;
|
2007-10-28 18:51:54 +00:00
|
|
|
cur.current_font.fontInfo().reduce(layoutfont);
|
2007-05-17 12:17:38 +00:00
|
|
|
// And resolve it completely
|
2007-10-28 18:51:54 +00:00
|
|
|
cur.real_current_font.fontInfo().realize(layoutfont);
|
2002-09-06 15:18:11 +00:00
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
// if there is no selection that's all we need to do
|
2007-05-17 12:17:38 +00:00
|
|
|
if (!cur.selection())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
2004-03-01 17:12:09 +00:00
|
|
|
// Ok, we have a selection.
|
2007-10-18 11:51:17 +00:00
|
|
|
cur.recordUndoSelection();
|
2003-11-27 09:22:41 +00:00
|
|
|
|
2007-09-02 21:48:49 +00:00
|
|
|
setFont(cur.bv(), cur.selectionBegin().top(),
|
2007-08-13 13:36:19 +00:00
|
|
|
cur.selectionEnd().top(), font, toggleall);
|
2007-05-22 10:51:38 +00:00
|
|
|
}
|
2004-04-07 08:07:26 +00:00
|
|
|
|
2003-11-27 09:22:41 +00:00
|
|
|
|
2007-09-02 21:48:49 +00:00
|
|
|
void Text::setFont(BufferView const & bv, CursorSlice const & begin,
|
2007-08-13 13:36:19 +00:00
|
|
|
CursorSlice const & end, Font const & font,
|
2007-05-22 10:51:38 +00:00
|
|
|
bool toggleall)
|
|
|
|
{
|
2007-09-02 21:48:49 +00:00
|
|
|
Buffer const & buffer = bv.buffer();
|
|
|
|
|
2004-08-15 00:01:45 +00:00
|
|
|
// Don't use forwardChar here as ditend might have
|
2004-04-07 08:07:26 +00:00
|
|
|
// pos() == lastpos() and forwardChar would miss it.
|
2005-02-14 08:17:23 +00:00
|
|
|
// Can't use forwardPos either as this descends into
|
2005-04-26 11:12:20 +00:00
|
|
|
// nested insets.
|
2007-05-22 10:51:38 +00:00
|
|
|
Language const * language = buffer.params().language;
|
2007-08-13 13:36:19 +00:00
|
|
|
for (CursorSlice dit = begin; dit != end; dit.forwardPos()) {
|
2008-02-18 07:44:07 +00:00
|
|
|
if (dit.pos() == dit.lastpos())
|
|
|
|
continue;
|
|
|
|
pit_type const pit = dit.pit();
|
|
|
|
pos_type const pos = dit.pos();
|
|
|
|
Inset * inset = pars_[pit].getInset(pos);
|
2011-02-22 19:41:04 +00:00
|
|
|
if (inset && inset->resetFontEdit()) {
|
2008-02-18 07:44:07 +00:00
|
|
|
// We need to propagate the font change to all
|
2011-02-22 19:41:04 +00:00
|
|
|
// text cells of the inset (bugs 1973, 6919).
|
2008-02-18 07:44:07 +00:00
|
|
|
setInsetFont(bv, pit, pos, font, toggleall);
|
2004-04-07 08:07:26 +00:00
|
|
|
}
|
2008-02-18 07:44:07 +00:00
|
|
|
TextMetrics const & tm = bv.textMetrics(this);
|
2008-02-27 23:03:26 +00:00
|
|
|
Font f = tm.displayFont(pit, pos);
|
2008-02-18 07:44:07 +00:00
|
|
|
f.update(font, language, toggleall);
|
2009-08-09 15:29:34 +00:00
|
|
|
setCharFont(pit, pos, f, tm.font_);
|
2010-09-14 05:24:04 +00:00
|
|
|
// font change may change language...
|
|
|
|
// spell checker has to know that
|
|
|
|
pars_[pit].requestSpellCheck(pos);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::cursorTop(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2006-03-16 14:24:53 +00:00
|
|
|
return setCursor(cur, 0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::cursorBottom(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2006-03-16 14:24:53 +00:00
|
|
|
return setCursor(cur, cur.lastpit(), boost::prior(paragraphs().end())->size());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::toggleFree(Cursor & cur, Font const & font, bool toggleall)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
1999-09-27 18:44:28 +00:00
|
|
|
// If the mask is completely neutral, tell user
|
2008-05-07 23:33:56 +00:00
|
|
|
if (font.fontInfo() == ignore_font && font.language() == ignore_language) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// Could only happen with user style
|
2007-05-01 10:25:46 +00:00
|
|
|
cur.message(_("No font change defined."));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Try implicit word selection
|
2002-03-21 17:27:08 +00:00
|
|
|
// If there is a change in the language the implicit word selection
|
2000-04-24 20:58:23 +00:00
|
|
|
// is disabled.
|
2009-07-12 21:48:50 +00:00
|
|
|
CursorSlice const resetCursor = cur.top();
|
|
|
|
bool const implicitSelection =
|
2003-10-28 11:18:40 +00:00
|
|
|
font.language() == ignore_language
|
2007-10-28 18:51:54 +00:00
|
|
|
&& font.fontInfo().number() == FONT_IGNORE
|
2006-10-21 00:16:43 +00:00
|
|
|
&& selectWordWhenUnderCursor(cur, WHOLE_WORD_STRICT);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Set font
|
2004-02-13 07:30:59 +00:00
|
|
|
setFont(cur, font, toggleall);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-07-07 18:19:18 +00:00
|
|
|
// Implicit selections are cleared afterwards
|
2004-02-13 07:30:59 +00:00
|
|
|
// and cursor is set to the original position.
|
1999-09-27 18:44:28 +00:00
|
|
|
if (implicitSelection) {
|
2004-02-13 07:30:59 +00:00
|
|
|
cur.clearSelection();
|
2004-03-01 17:12:09 +00:00
|
|
|
cur.top() = resetCursor;
|
2004-02-13 07:30:59 +00:00
|
|
|
cur.resetAnchor();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
docstring Text::getStringToIndex(Cursor const & cur)
|
2001-07-30 10:50:37 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2001-07-30 10:50:37 +00:00
|
|
|
|
2006-09-03 07:02:38 +00:00
|
|
|
if (cur.selection())
|
2008-02-18 07:44:07 +00:00
|
|
|
return cur.selectionAsString(false);
|
|
|
|
|
|
|
|
// Try implicit word selection. If there is a change
|
|
|
|
// in the language the implicit word selection is
|
|
|
|
// disabled.
|
|
|
|
Cursor tmpcur = cur;
|
|
|
|
selectWord(tmpcur, PREVIOUS_WORD);
|
|
|
|
|
|
|
|
if (!tmpcur.selection())
|
|
|
|
cur.message(_("Nothing to index!"));
|
|
|
|
else if (tmpcur.selBegin().pit() != tmpcur.selEnd().pit())
|
|
|
|
cur.message(_("Cannot index more than one paragraph!"));
|
|
|
|
else
|
|
|
|
return tmpcur.selectionAsString(false);
|
|
|
|
|
|
|
|
return docstring();
|
2001-07-30 10:50:37 +00:00
|
|
|
}
|
|
|
|
|
2001-10-18 16:17:46 +00:00
|
|
|
|
2009-08-09 17:45:24 +00:00
|
|
|
void Text::setLabelWidthStringToSequence(pit_type const par_offset,
|
|
|
|
docstring const & s)
|
|
|
|
{
|
|
|
|
pit_type offset = par_offset;
|
|
|
|
// Find first of same layout in sequence
|
2009-08-09 18:35:39 +00:00
|
|
|
while (!isFirstInSequence(offset)) {
|
|
|
|
offset = depthHook(offset, pars_[offset].getDepth());
|
2009-08-09 17:45:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// now apply label width string to every par
|
|
|
|
// in sequence
|
|
|
|
pit_type const end = pars_.size();
|
|
|
|
depth_type const depth = pars_[offset].getDepth();
|
|
|
|
Layout const & layout = pars_[offset].layout();
|
|
|
|
for (pit_type pit = offset; pit != end; ++pit) {
|
|
|
|
while (pars_[pit].getDepth() > depth)
|
|
|
|
++pit;
|
|
|
|
if (pars_[pit].getDepth() < depth)
|
|
|
|
return;
|
|
|
|
if (pars_[pit].layout() != layout)
|
|
|
|
return;
|
|
|
|
pars_[pit].setLabelWidthString(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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 Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(cur.text(), /**/);
|
1999-09-27 18:44:28 +00:00
|
|
|
// make sure that the depth behind the selection are restored, too
|
2004-11-24 21:53:46 +00:00
|
|
|
pit_type undopit = undoSpan(cur.selEnd().pit());
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
recUndo(cur, cur.selBegin().pit(), undopit - 1);
|
2003-04-13 22:24:28 +00:00
|
|
|
|
2008-02-18 07:44:07 +00:00
|
|
|
//FIXME UNICODE
|
|
|
|
string const argument = to_utf8(arg);
|
2009-07-23 06:14:11 +00:00
|
|
|
depth_type priordepth = -1;
|
|
|
|
Layout priorlayout;
|
2004-11-24 21:53:46 +00:00
|
|
|
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
|
2005-09-26 22:54:12 +00:00
|
|
|
pit <= end; ++pit) {
|
2004-03-25 09:16:36 +00:00
|
|
|
Paragraph & par = pars_[pit];
|
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
|
|
|
ParagraphParameters params = par.params();
|
2008-02-18 07:44:07 +00:00
|
|
|
params.read(argument, merge);
|
2009-07-23 06:14:11 +00:00
|
|
|
// Changes to label width string apply to all paragraphs
|
|
|
|
// with same layout in a sequence.
|
|
|
|
// Do this only once for a selected range of paragraphs
|
|
|
|
// of the same layout and depth.
|
|
|
|
if (par.getDepth() != priordepth || par.layout() != priorlayout)
|
2009-08-09 17:45:24 +00:00
|
|
|
setLabelWidthStringToSequence(pit, params.labelWidthString());
|
2008-03-06 21:31:27 +00:00
|
|
|
par.params().apply(params, par.layout());
|
2009-07-23 06:14:11 +00:00
|
|
|
priordepth = par.getDepth();
|
|
|
|
priorlayout = par.layout();
|
1999-11-04 01:40:20 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +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
|
|
|
//FIXME This is a little redundant now, but it's probably worth keeping,
|
|
|
|
//especially if we're going to go away from using serialization internally
|
|
|
|
//quite so much.
|
|
|
|
void Text::setParagraphs(Cursor & cur, ParagraphParameters const & p)
|
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(cur.text(), /**/);
|
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
|
|
|
// make sure that the depth behind the selection are restored, too
|
|
|
|
pit_type undopit = undoSpan(cur.selEnd().pit());
|
|
|
|
recUndo(cur, cur.selBegin().pit(), undopit - 1);
|
|
|
|
|
2009-07-23 06:14:11 +00:00
|
|
|
depth_type priordepth = -1;
|
|
|
|
Layout priorlayout;
|
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
|
|
|
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
|
|
|
|
pit <= end; ++pit) {
|
|
|
|
Paragraph & par = pars_[pit];
|
2009-07-23 06:14:11 +00:00
|
|
|
// Changes to label width string apply to all paragraphs
|
|
|
|
// with same layout in a sequence.
|
|
|
|
// Do this only once for a selected range of paragraphs
|
|
|
|
// of the same layout and depth.
|
|
|
|
if (par.getDepth() != priordepth || par.layout() != priorlayout)
|
2009-08-09 17:45:24 +00:00
|
|
|
setLabelWidthStringToSequence(pit,
|
|
|
|
par.params().labelWidthString());
|
2008-03-06 21:31:27 +00:00
|
|
|
par.params().apply(p, par.layout());
|
2009-07-23 06:14:11 +00:00
|
|
|
priordepth = par.getDepth();
|
|
|
|
priorlayout = par.layout();
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-16 00:32:04 +00:00
|
|
|
// this really should just insert the inset and not move the cursor.
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::insertInset(Cursor & cur, Inset * inset)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
|
|
|
LASSERT(inset, /**/);
|
2007-09-02 13:35:48 +00:00
|
|
|
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
|
2008-11-17 11:46:07 +00:00
|
|
|
Change(cur.buffer()->params().trackChanges
|
2008-02-18 07:44:07 +00:00
|
|
|
? Change::INSERTED : Change::UNCHANGED));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::setCursor(Cursor & cur, pit_type par, pos_type pos,
|
2005-09-26 22:54:12 +00:00
|
|
|
bool setfont, bool boundary)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-02-22 12:27:56 +00:00
|
|
|
TextMetrics const & tm = cur.bv().textMetrics(this);
|
2008-02-27 23:03:26 +00:00
|
|
|
bool const update_needed = !tm.contains(par);
|
2007-04-26 14:56:30 +00:00
|
|
|
Cursor old = cur;
|
2004-02-13 11:05:29 +00:00
|
|
|
setCursorIntern(cur, par, pos, setfont, boundary);
|
2008-02-22 12:27:56 +00:00
|
|
|
return cur.bv().checkDepm(cur, old) || update_needed;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::setCursor(CursorSlice & cur, pit_type par, pos_type pos)
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(par != int(paragraphs().size()), /**/);
|
2004-11-24 21:53:46 +00:00
|
|
|
cur.pit() = par;
|
2004-02-16 11:58:51 +00:00
|
|
|
cur.pos() = pos;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
2004-01-14 09:33:14 +00:00
|
|
|
// now some strict checking
|
2004-03-25 09:16:36 +00:00
|
|
|
Paragraph & para = getPar(par);
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
// None of these should happen, but we're scaredy-cats
|
2003-10-27 11:44:10 +00:00
|
|
|
if (pos < 0) {
|
2009-12-05 23:18:21 +00:00
|
|
|
lyxerr << "don't like -1" << endl;
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(false, /**/);
|
2004-02-16 11:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pos > para.size()) {
|
2009-12-05 23:18:21 +00:00
|
|
|
lyxerr << "don't like 1, pos: " << pos
|
2004-01-20 14:25:24 +00:00
|
|
|
<< " size: " << para.size()
|
2004-02-13 11:05:29 +00:00
|
|
|
<< " par: " << par << endl;
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(false, /**/);
|
2001-12-28 21:17:18 +00:00
|
|
|
}
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::setCursorIntern(Cursor & cur,
|
2005-09-26 22:54:12 +00:00
|
|
|
pit_type par, pos_type pos, bool setfont, bool boundary)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(this == cur.text(), /**/);
|
2005-07-16 16:34:54 +00:00
|
|
|
cur.boundary(boundary);
|
2005-09-20 08:31:37 +00:00
|
|
|
setCursor(cur.top(), par, pos);
|
2001-08-05 22:12:27 +00:00
|
|
|
if (setfont)
|
2007-09-02 13:35:48 +00:00
|
|
|
cur.setCurrentFont();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::checkAndActivateInset(Cursor & cur, bool front)
|
2003-11-17 14:28:18 +00:00
|
|
|
{
|
2004-02-20 17:19:53 +00:00
|
|
|
if (cur.selection())
|
|
|
|
return false;
|
2007-05-27 08:16:17 +00:00
|
|
|
if (front && cur.pos() == cur.lastpos())
|
|
|
|
return false;
|
|
|
|
if (!front && cur.pos() == 0)
|
2003-11-17 14:28:18 +00:00
|
|
|
return false;
|
2007-05-17 21:53:11 +00:00
|
|
|
Inset * inset = front ? cur.nextInset() : cur.prevInset();
|
2009-04-22 20:55:13 +00:00
|
|
|
if (!inset || !inset->editable())
|
2003-11-17 14:28:18 +00:00
|
|
|
return false;
|
2007-05-17 21:53:11 +00:00
|
|
|
/*
|
|
|
|
* Apparently, when entering an inset we are expected to be positioned
|
|
|
|
* *before* it in the containing paragraph, regardless of the direction
|
|
|
|
* from which we are entering. Otherwise, cursor placement goes awry,
|
|
|
|
* and when we exit from the beginning, we'll be placed *after* the
|
|
|
|
* inset.
|
2007-05-28 22:27:45 +00:00
|
|
|
*/
|
2007-05-17 21:53:11 +00:00
|
|
|
if (!front)
|
|
|
|
--cur.pos();
|
2004-02-12 16:36:01 +00:00
|
|
|
inset->edit(cur, front);
|
2003-11-17 14:28:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-10 19:52:45 +00:00
|
|
|
bool Text::checkAndActivateInsetVisual(Cursor & cur, bool movingForward, bool movingLeft)
|
|
|
|
{
|
|
|
|
if (cur.selection())
|
|
|
|
return false;
|
|
|
|
if (cur.pos() == -1)
|
|
|
|
return false;
|
|
|
|
if (cur.pos() == cur.lastpos())
|
|
|
|
return false;
|
|
|
|
Paragraph & par = cur.paragraph();
|
|
|
|
Inset * inset = par.isInset(cur.pos()) ? par.getInset(cur.pos()) : 0;
|
2009-04-22 20:55:13 +00:00
|
|
|
if (!inset || !inset->editable())
|
2008-02-10 19:52:45 +00:00
|
|
|
return false;
|
|
|
|
inset->edit(cur, movingForward,
|
2008-02-11 08:20:13 +00:00
|
|
|
movingLeft ? Inset::ENTRY_DIRECTION_RIGHT : Inset::ENTRY_DIRECTION_LEFT);
|
2008-02-10 19:52:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-22 22:18:52 +00:00
|
|
|
bool Text::cursorBackward(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2006-11-27 12:49:28 +00:00
|
|
|
// Tell BufferView to test for FitCursor in any case!
|
2010-07-08 20:04:35 +00:00
|
|
|
cur.screenUpdateFlags(Update::FitCursor);
|
2006-11-27 12:49:28 +00:00
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// not at paragraph start?
|
2007-05-17 21:53:11 +00:00
|
|
|
if (cur.pos() > 0) {
|
2007-05-29 20:53:32 +00:00
|
|
|
// if on right side of boundary (i.e. not at paragraph end, but line end)
|
|
|
|
// -> skip it, i.e. set boundary to true, i.e. go only logically left
|
|
|
|
// there are some exceptions to ignore this: lineseps, newlines, spaces
|
2007-05-30 06:58:08 +00:00
|
|
|
#if 0
|
2007-05-30 07:30:17 +00:00
|
|
|
// some effectless debug code to see the values in the debugger
|
2007-05-29 20:53:32 +00:00
|
|
|
bool bound = cur.boundary();
|
|
|
|
int rowpos = cur.textRow().pos();
|
|
|
|
int pos = cur.pos();
|
|
|
|
bool sep = cur.paragraph().isSeparator(cur.pos() - 1);
|
|
|
|
bool newline = cur.paragraph().isNewline(cur.pos() - 1);
|
|
|
|
bool linesep = cur.paragraph().isLineSeparator(cur.pos() - 1);
|
|
|
|
#endif
|
|
|
|
if (!cur.boundary() &&
|
|
|
|
cur.textRow().pos() == cur.pos() &&
|
|
|
|
!cur.paragraph().isLineSeparator(cur.pos() - 1) &&
|
|
|
|
!cur.paragraph().isNewline(cur.pos() - 1) &&
|
|
|
|
!cur.paragraph().isSeparator(cur.pos() - 1)) {
|
|
|
|
return setCursor(cur, cur.pit(), cur.pos(), true, true);
|
2004-02-20 17:19:53 +00:00
|
|
|
}
|
2007-05-29 20:53:32 +00:00
|
|
|
|
|
|
|
// go left and try to enter inset
|
|
|
|
if (checkAndActivateInset(cur, false))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// normal character left
|
|
|
|
return setCursor(cur, cur.pit(), cur.pos() - 1, true, false);
|
2003-11-17 14:28:18 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// move to the previous paragraph or do nothing
|
|
|
|
if (cur.pit() > 0)
|
2007-09-24 22:20:03 +00:00
|
|
|
return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size(), true, false);
|
2005-02-08 02:06:39 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-10 19:52:45 +00:00
|
|
|
bool Text::cursorVisLeft(Cursor & cur, bool skip_inset)
|
|
|
|
{
|
|
|
|
Cursor temp_cur = cur;
|
2008-05-04 20:17:59 +00:00
|
|
|
temp_cur.posVisLeft(skip_inset);
|
|
|
|
if (temp_cur.depth() > cur.depth()) {
|
|
|
|
cur = temp_cur;
|
2008-02-10 19:52:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-04 20:17:59 +00:00
|
|
|
return setCursor(cur, temp_cur.pit(), temp_cur.pos(),
|
|
|
|
true, temp_cur.boundary());
|
2008-02-10 19:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Text::cursorVisRight(Cursor & cur, bool skip_inset)
|
|
|
|
{
|
|
|
|
Cursor temp_cur = cur;
|
2008-05-04 20:17:59 +00:00
|
|
|
temp_cur.posVisRight(skip_inset);
|
|
|
|
if (temp_cur.depth() > cur.depth()) {
|
|
|
|
cur = temp_cur;
|
2008-02-10 19:52:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
2008-05-04 20:17:59 +00:00
|
|
|
return setCursor(cur, temp_cur.pit(), temp_cur.pos(),
|
|
|
|
true, temp_cur.boundary());
|
2008-02-10 19:52:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-22 22:18:52 +00:00
|
|
|
bool Text::cursorForward(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2006-11-27 12:49:28 +00:00
|
|
|
// Tell BufferView to test for FitCursor in any case!
|
2010-07-08 20:04:35 +00:00
|
|
|
cur.screenUpdateFlags(Update::FitCursor);
|
2006-11-27 12:49:28 +00:00
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// not at paragraph end?
|
2004-01-20 14:25:24 +00:00
|
|
|
if (cur.pos() != cur.lastpos()) {
|
2007-05-29 20:53:32 +00:00
|
|
|
// in front of editable inset, i.e. jump into it?
|
|
|
|
if (checkAndActivateInset(cur, true))
|
|
|
|
return false;
|
2007-06-04 18:35:03 +00:00
|
|
|
|
2007-09-02 21:48:49 +00:00
|
|
|
TextMetrics const & tm = cur.bv().textMetrics(this);
|
2007-06-04 18:35:03 +00:00
|
|
|
// if left of boundary -> just jump to right side
|
2007-09-02 21:48:49 +00:00
|
|
|
// but for RTL boundaries don't, because: abc|DDEEFFghi -> abcDDEEF|Fghi
|
2007-09-02 22:28:49 +00:00
|
|
|
if (cur.boundary() && !tm.isRTLBoundary(cur.pit(), cur.pos()))
|
2007-06-04 18:35:03 +00:00
|
|
|
return setCursor(cur, cur.pit(), cur.pos(), true, false);
|
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// next position is left of boundary,
|
|
|
|
// but go to next line for special cases like space, newline, linesep
|
2007-05-30 06:58:08 +00:00
|
|
|
#if 0
|
2007-05-30 07:30:17 +00:00
|
|
|
// some effectless debug code to see the values in the debugger
|
2007-05-29 20:53:32 +00:00
|
|
|
int endpos = cur.textRow().endpos();
|
|
|
|
int lastpos = cur.lastpos();
|
|
|
|
int pos = cur.pos();
|
|
|
|
bool linesep = cur.paragraph().isLineSeparator(cur.pos());
|
|
|
|
bool newline = cur.paragraph().isNewline(cur.pos());
|
|
|
|
bool sep = cur.paragraph().isSeparator(cur.pos());
|
|
|
|
if (cur.pos() != cur.lastpos()) {
|
|
|
|
bool linesep2 = cur.paragraph().isLineSeparator(cur.pos()+1);
|
|
|
|
bool newline2 = cur.paragraph().isNewline(cur.pos()+1);
|
|
|
|
bool sep2 = cur.paragraph().isSeparator(cur.pos()+1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (cur.textRow().endpos() == cur.pos() + 1 &&
|
|
|
|
cur.textRow().endpos() != cur.lastpos() &&
|
|
|
|
!cur.paragraph().isNewline(cur.pos()) &&
|
|
|
|
!cur.paragraph().isLineSeparator(cur.pos()) &&
|
|
|
|
!cur.paragraph().isSeparator(cur.pos())) {
|
|
|
|
return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
|
2004-02-20 17:19:53 +00:00
|
|
|
}
|
2007-05-29 20:53:32 +00:00
|
|
|
|
2007-06-04 18:35:03 +00:00
|
|
|
// in front of RTL boundary? Stay on this side of the boundary because:
|
|
|
|
// ab|cDDEEFFghi -> abc|DDEEFFghi
|
2007-09-02 22:28:49 +00:00
|
|
|
if (tm.isRTLBoundary(cur.pit(), cur.pos() + 1))
|
2007-06-04 18:35:03 +00:00
|
|
|
return setCursor(cur, cur.pit(), cur.pos() + 1, true, true);
|
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// move right
|
|
|
|
return setCursor(cur, cur.pit(), cur.pos() + 1, true, false);
|
2003-11-17 14:28:18 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 20:53:32 +00:00
|
|
|
// move to next paragraph
|
2004-11-24 21:53:46 +00:00
|
|
|
if (cur.pit() != cur.lastpit())
|
2007-09-24 22:20:03 +00:00
|
|
|
return setCursor(cur, cur.pit() + 1, 0, true, false);
|
2005-02-08 02:06:39 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::cursorUpParagraph(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2005-02-08 02:06:39 +00:00
|
|
|
bool updated = false;
|
2004-02-12 16:36:01 +00:00
|
|
|
if (cur.pos() > 0)
|
2005-02-08 02:06:39 +00:00
|
|
|
updated = setCursor(cur, cur.pit(), 0);
|
2004-11-24 21:53:46 +00:00
|
|
|
else if (cur.pit() != 0)
|
2005-02-08 02:06:39 +00:00
|
|
|
updated = setCursor(cur, cur.pit() - 1, 0);
|
|
|
|
return updated;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::cursorDownParagraph(Cursor & cur)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2005-02-08 02:06:39 +00:00
|
|
|
bool updated = false;
|
2004-11-24 21:53:46 +00:00
|
|
|
if (cur.pit() != cur.lastpit())
|
2005-02-08 02:06:39 +00:00
|
|
|
updated = setCursor(cur, cur.pit() + 1, 0);
|
2003-08-01 14:12:04 +00:00
|
|
|
else
|
2005-02-08 02:06:39 +00:00
|
|
|
updated = setCursor(cur, cur.pit(), cur.lastpos());
|
|
|
|
return updated;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2003-08-01 14:12:04 +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
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where)
|
2001-09-27 09:52:06 +00:00
|
|
|
{
|
2005-02-08 02:06:39 +00:00
|
|
|
// Do nothing if cursor is not in the paragraph where the
|
2004-02-13 13:51:12 +00:00
|
|
|
// deletion occured,
|
2004-11-24 21:53:46 +00:00
|
|
|
if (cur.pit() != where.pit())
|
2001-09-27 09:52:06 +00:00
|
|
|
return;
|
|
|
|
|
2005-02-08 02:06:39 +00:00
|
|
|
// If cursor position is after the deletion place update it
|
2001-09-27 09:52:06 +00:00
|
|
|
if (cur.pos() > where.pos())
|
2004-02-12 16:36:01 +00:00
|
|
|
--cur.pos();
|
2001-09-27 09:52:06 +00:00
|
|
|
|
2005-02-08 02:06:39 +00:00
|
|
|
// Check also if we don't want to set the cursor on a spot behind the
|
2002-05-02 12:45:27 +00:00
|
|
|
// pagragraph because we erased the last character.
|
2004-01-20 14:25:24 +00:00
|
|
|
if (cur.pos() > cur.lastpos())
|
|
|
|
cur.pos() = cur.lastpos();
|
2001-09-27 09:52:06 +00:00
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
2007-04-26 14:56:30 +00:00
|
|
|
Cursor & old, bool & need_anchor_change)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
//LYXERR(Debug::DEBUG, "DEPM: cur:\n" << cur << "old:\n" << old);
|
2005-10-25 09:14:11 +00:00
|
|
|
|
|
|
|
Paragraph & oldpar = old.paragraph();
|
2003-10-10 09:01:23 +00:00
|
|
|
|
2000-03-14 23:33:15 +00:00
|
|
|
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
2004-03-25 09:16:36 +00:00
|
|
|
if (oldpar.isFreeSpacing())
|
2002-01-12 21:03:30 +00:00
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2000-01-13 16:28:54 +00:00
|
|
|
/* Ok I'll put some comments here about what is missing.
|
|
|
|
There are still some small problems that can lead to
|
|
|
|
double spaces stored in the document file or space at
|
2003-12-01 13:35:49 +00:00
|
|
|
the beginning of paragraphs(). This happens if you have
|
2003-08-22 07:49:57 +00:00
|
|
|
the cursor between to spaces and then save. Or if you
|
2000-01-13 16:28:54 +00:00
|
|
|
cut and paste and the selection have a space at the
|
2005-10-25 09:14:11 +00:00
|
|
|
beginning and then save right after the paste. (Lgb)
|
2000-01-13 16:28:54 +00:00
|
|
|
*/
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
// If old.pos() == 0 and old.pos()(1) == LineSeparator
|
2000-01-13 16:28:54 +00:00
|
|
|
// delete the LineSeparator.
|
|
|
|
// MISSING
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
// If old.pos() == 1 and old.pos()(0) == LineSeparator
|
2000-01-13 16:28:54 +00:00
|
|
|
// delete the LineSeparator.
|
|
|
|
// MISSING
|
|
|
|
|
2008-11-26 19:26:29 +00:00
|
|
|
// Find a common inset and the corresponding depth.
|
|
|
|
size_t depth = 0;
|
|
|
|
for (; depth < cur.depth(); ++depth)
|
|
|
|
if (&old.inset() == &cur[depth].inset())
|
|
|
|
break;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2008-11-26 19:26:29 +00:00
|
|
|
// Whether a common inset is found and whether the cursor is still in
|
|
|
|
// the same paragraph (possibly nested).
|
2008-11-26 19:42:18 +00:00
|
|
|
bool const same_par = depth < cur.depth() && old.pit() == cur[depth].pit();
|
2008-11-26 19:26:29 +00:00
|
|
|
bool const same_par_pos = depth == cur.depth() - 1 && same_par
|
|
|
|
&& old.pos() == cur[depth].pos();
|
|
|
|
|
2005-10-25 09:14:11 +00:00
|
|
|
// If the chars around the old cursor were spaces, delete one of them.
|
|
|
|
if (!same_par_pos) {
|
2004-03-25 09:16:36 +00:00
|
|
|
// Only if the cursor has really moved.
|
|
|
|
if (old.pos() > 0
|
|
|
|
&& old.pos() < oldpar.size()
|
|
|
|
&& oldpar.isLineSeparator(old.pos())
|
2005-08-01 12:37:25 +00:00
|
|
|
&& oldpar.isLineSeparator(old.pos() - 1)
|
2007-08-29 13:04:29 +00:00
|
|
|
&& !oldpar.isDeleted(old.pos() - 1)
|
|
|
|
&& !oldpar.isDeleted(old.pos())) {
|
2008-11-17 11:46:07 +00:00
|
|
|
oldpar.eraseChar(old.pos() - 1, cur.buffer()->params().trackChanges);
|
2007-08-10 11:47:12 +00:00
|
|
|
// FIXME: This will not work anymore when we have multiple views of the same buffer
|
2001-09-27 09:52:06 +00:00
|
|
|
// In this case, we will have to correct also the cursors held by
|
|
|
|
// other bufferviews. It will probably be easier to do that in a more
|
2004-01-13 14:13:51 +00:00
|
|
|
// automated way in CursorSlice code. (JMarc 26/09/2001)
|
2004-03-25 09:16:36 +00:00
|
|
|
// correct all cursor parts
|
2005-10-25 09:14:11 +00:00
|
|
|
if (same_par) {
|
2008-11-26 19:26:29 +00:00
|
|
|
fixCursorAfterDelete(cur[depth], old.top());
|
2006-12-30 15:05:15 +00:00
|
|
|
need_anchor_change = true;
|
2005-10-25 09:14:11 +00:00
|
|
|
}
|
2005-02-08 02:06:39 +00:00
|
|
|
return true;
|
2000-03-14 23:33:15 +00:00
|
|
|
}
|
2000-01-13 16:28:54 +00:00
|
|
|
}
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
// only do our magic if we changed paragraph
|
2005-10-25 09:14:11 +00:00
|
|
|
if (same_par)
|
2002-01-12 21:03:30 +00:00
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
// don't delete anything if this is the ONLY paragraph!
|
2005-10-25 09:14:11 +00:00
|
|
|
if (old.lastpit() == 0)
|
2002-01-12 21:03:30 +00:00
|
|
|
return false;
|
2000-01-13 16:28:54 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
// Do not delete empty paragraphs with keepempty set.
|
|
|
|
if (oldpar.allowEmpty())
|
2002-01-12 21:03:30 +00:00
|
|
|
return false;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
if (oldpar.empty() || (oldpar.size() == 1 && oldpar.isLineSeparator(0))) {
|
|
|
|
// Delete old par.
|
2007-10-18 11:51:17 +00:00
|
|
|
old.recordUndo(ATOMIC_UNDO,
|
2006-02-06 17:57:49 +00:00
|
|
|
max(old.pit() - 1, pit_type(0)),
|
2006-01-30 16:34:30 +00:00
|
|
|
min(old.pit() + 1, old.lastpit()));
|
2005-10-25 09:14:11 +00:00
|
|
|
ParagraphList & plist = old.text()->paragraphs();
|
2007-09-07 09:55:57 +00:00
|
|
|
bool const soa = oldpar.params().startOfAppendix();
|
2006-03-23 20:11:06 +00:00
|
|
|
plist.erase(boost::next(plist.begin(), old.pit()));
|
2007-09-07 09:55:57 +00:00
|
|
|
// do not lose start of appendix marker (bug 4212)
|
2007-11-22 07:49:25 +00:00
|
|
|
if (soa && old.pit() < pit_type(plist.size()))
|
2007-09-07 10:04:10 +00:00
|
|
|
plist[old.pit()].params().startOfAppendix(true);
|
2005-10-25 09:14:11 +00:00
|
|
|
|
2007-08-10 11:47:12 +00:00
|
|
|
// see #warning (FIXME?) above
|
2005-10-25 09:14:11 +00:00
|
|
|
if (cur.depth() >= old.depth()) {
|
|
|
|
CursorSlice & curslice = cur[old.depth() - 1];
|
2006-04-05 23:56:29 +00:00
|
|
|
if (&curslice.inset() == &old.inset()
|
2005-10-25 09:14:11 +00:00
|
|
|
&& curslice.pit() > old.pit()) {
|
|
|
|
--curslice.pit();
|
|
|
|
// since a paragraph has been deleted, all the
|
|
|
|
// insets after `old' have been copied and
|
|
|
|
// their address has changed. Therefore we
|
|
|
|
// need to `regenerate' cur. (JMarc)
|
|
|
|
cur.updateInsets(&(cur.bottom().inset()));
|
2006-12-30 15:05:15 +00:00
|
|
|
need_anchor_change = true;
|
2005-10-25 09:14:11 +00:00
|
|
|
}
|
2000-01-13 16:28:54 +00:00
|
|
|
}
|
2003-10-28 11:18:40 +00:00
|
|
|
return true;
|
2005-07-17 15:22:15 +00:00
|
|
|
}
|
2003-10-28 11:18:40 +00:00
|
|
|
|
2008-11-17 11:46:07 +00:00
|
|
|
if (oldpar.stripLeadingSpaces(cur.buffer()->params().trackChanges)) {
|
2006-12-30 15:05:15 +00:00
|
|
|
need_anchor_change = true;
|
2007-01-21 16:43:27 +00:00
|
|
|
// We return true here because the Paragraph contents changed and
|
|
|
|
// we need a redraw before further action is processed.
|
|
|
|
return true;
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
2003-10-28 11:18:40 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges)
|
2007-01-25 21:18:36 +00:00
|
|
|
{
|
2008-04-10 21:49:34 +00:00
|
|
|
LASSERT(first >= 0 && first <= last && last < (int) pars_.size(), /**/);
|
2007-01-25 22:28:15 +00:00
|
|
|
|
2007-01-25 21:18:36 +00:00
|
|
|
for (pit_type pit = first; pit <= last; ++pit) {
|
|
|
|
Paragraph & par = pars_[pit];
|
|
|
|
|
|
|
|
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
|
|
|
if (par.isFreeSpacing())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (pos_type pos = 1; pos < par.size(); ++pos) {
|
|
|
|
if (par.isLineSeparator(pos) && par.isLineSeparator(pos - 1)
|
|
|
|
&& !par.isDeleted(pos - 1)) {
|
|
|
|
if (par.eraseChar(pos - 1, trackChanges)) {
|
|
|
|
--pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-18 14:20:03 +00:00
|
|
|
// don't delete anything if this is the only remaining paragraph
|
|
|
|
// within the given range. Note: Text::acceptOrRejectChanges()
|
|
|
|
// sets the cursor to 'first' after calling DEPM
|
2007-01-25 22:51:00 +00:00
|
|
|
if (first == last)
|
2007-01-25 21:18:36 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// don't delete empty paragraphs with keepempty set
|
|
|
|
if (par.allowEmpty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (par.empty() || (par.size() == 1 && par.isLineSeparator(0))) {
|
|
|
|
pars_.erase(boost::next(pars_.begin(), pit));
|
|
|
|
--pit;
|
|
|
|
--last;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
par.stripLeadingSpaces(trackChanges);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::recUndo(Cursor & cur, pit_type first, pit_type last) const
|
2003-10-13 10:59:31 +00:00
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
cur.recordUndo(ATOMIC_UNDO, first, last);
|
2003-10-13 10:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
void Text::recUndo(Cursor & cur, pit_type par) const
|
2003-10-13 10:59:31 +00:00
|
|
|
{
|
2007-10-18 11:51:17 +00:00
|
|
|
cur.recordUndo(ATOMIC_UNDO, par, par);
|
2003-10-13 10:59:31 +00:00
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|