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
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
|
|
|
|
* \author Angus Leeming
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \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
|
|
|
|
|
* \author J<EFBFBD>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
|
|
|
|
|
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"
|
2003-09-12 17:13:22 +00:00
|
|
|
|
#include "Bullet.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 "Color.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
|
#include "CutAndPaste.h"
|
2000-04-08 17:02:02 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "DispatchResult.h"
|
|
|
|
|
#include "ErrorList.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Language.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"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFunc.h"
|
|
|
|
|
#include "LyXRC.h"
|
|
|
|
|
#include "Paragraph.h"
|
2003-04-14 18:35:29 +00:00
|
|
|
|
#include "paragraph_funcs.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "ParagraphParameters.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "ParIterator.h"
|
2007-04-29 16:22:46 +00:00
|
|
|
|
#include "Server.h"
|
|
|
|
|
#include "ServerSocket.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Undo.h"
|
|
|
|
|
#include "VSpace.h"
|
2003-09-06 18:38:02 +00:00
|
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "insets/InsetEnvironment.h"
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "mathed/InsetMathHull.h"
|
2006-09-08 13:52:41 +00:00
|
|
|
|
|
2003-09-06 18:38:02 +00:00
|
|
|
|
#include "support/textutils.h"
|
2004-07-24 10:55:30 +00:00
|
|
|
|
|
2005-09-26 09:20:15 +00:00
|
|
|
|
#include <boost/current_function.hpp>
|
|
|
|
|
|
2004-07-24 10:55:30 +00:00
|
|
|
|
#include <sstream>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2003-09-08 00:33:41 +00:00
|
|
|
|
using std::ostringstream;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2006-01-30 16:34:30 +00:00
|
|
|
|
using std::max;
|
2005-07-15 12:56:23 +00:00
|
|
|
|
using std::min;
|
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
|
|
|
|
using std::istringstream;
|
2000-07-21 18:47:54 +00:00
|
|
|
|
|
2007-09-02 11:46:05 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Text::Text()
|
2007-09-02 14:34:15 +00:00
|
|
|
|
: autoBreakRows_(false)
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
bool Text::isMainText(Buffer const & buffer) const
|
2004-03-18 12:53:43 +00:00
|
|
|
|
{
|
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
|
|
|
|
return &buffer.text() == this;
|
2004-03-18 12:53:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Font Text::getLayoutFont(Buffer const & buffer, pit_type const pit) const
|
2001-08-03 18:28:11 +00:00
|
|
|
|
{
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr 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()) {
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font 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
|
2007-04-29 18:17:15 +00:00
|
|
|
|
if (layout->font.family() == Font::INHERIT_FAMILY)
|
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
|
|
|
|
lf.setFamily(buffer.params().getFont().family());
|
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
|
|
|
|
return lf;
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font = layout->font;
|
2003-04-15 00:11:03 +00:00
|
|
|
|
// Realize with the fonts of lesser depth.
|
2003-12-01 13:35:49 +00:00
|
|
|
|
//font.realize(outerFont(pit, paragraphs()));
|
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
|
|
|
|
font.realize(buffer.params().getFont());
|
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
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
Font Text::getLabelFont(Buffer const & buffer, Paragraph const & par) const
|
2001-08-03 18:28:11 +00:00
|
|
|
|
{
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr 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()) {
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font 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
|
2007-04-29 18:17:15 +00:00
|
|
|
|
if (layout->labelfont.family() == Font::INHERIT_FAMILY)
|
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
|
|
|
|
lf.setFamily(buffer.params().getFont().family());
|
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
|
|
|
|
return lf;
|
|
|
|
|
}
|
2001-08-03 18:28:11 +00:00
|
|
|
|
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font = layout->labelfont;
|
2003-04-15 00:11:03 +00:00
|
|
|
|
// Realize with the fonts of lesser depth.
|
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
|
|
|
|
font.realize(buffer.params().getFont());
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
void Text::setCharFont(Buffer const & buffer, 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
|
|
|
|
{
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font font = fnt;
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr const & layout = pars_[pit].layout();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Get concrete layout font to reduce against
|
2007-04-29 18:17:15 +00:00
|
|
|
|
Font layoutfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (pos < pars_[pit].beginOfBody())
|
2002-06-24 20:28:12 +00:00
|
|
|
|
layoutfont = layout->labelfont;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
else
|
2002-06-24 20:28:12 +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()) {
|
2003-12-01 13:35:49 +00:00
|
|
|
|
tp = outerHook(tp, paragraphs());
|
2004-11-24 21:53:46 +00:00
|
|
|
|
if (tp != pit_type(paragraphs().size()))
|
2004-03-25 09:16:36 +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!)
|
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
|
|
|
|
if (!isMainText(buffer))
|
2007-09-02 21:48:49 +00:00
|
|
|
|
layoutfont.realize(display_font);
|
2006-01-28 12:39:22 +00:00
|
|
|
|
|
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
|
|
|
|
layoutfont.realize(buffer.params().getFont());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
// Now, reduce font against full layout font
|
|
|
|
|
font.reduce(layoutfont);
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(pars_[pit].isInset(pos) &&
|
2007-05-28 22:27:45 +00:00
|
|
|
|
pars_[pit].getInset(pos)->noFontChange());
|
2007-05-22 10:51:38 +00:00
|
|
|
|
|
|
|
|
|
Inset * const inset = pars_[pit].getInset(pos);
|
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
|
|
|
|
{
|
2004-11-24 21:53:46 +00:00
|
|
|
|
pit_type end = paragraphs().size();
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
void Text::setLayout(Buffer const & buffer, pit_type start, pit_type end,
|
2007-07-11 13:39:08 +00:00
|
|
|
|
docstring const & layout)
|
2001-04-04 21:47:26 +00:00
|
|
|
|
{
|
2004-01-09 09:04:33 +00:00
|
|
|
|
BOOST_ASSERT(start != end);
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
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
|
|
|
|
BufferParams const & bufparams = buffer.params();
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr const & lyxlayout = bufparams.getTextClass()[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);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
if (lyxlayout->margintype == MARGIN_MANUAL)
|
2007-01-15 16:58:14 +00:00
|
|
|
|
par.setLabelWidthString(par.translateIfPossible(
|
|
|
|
|
lyxlayout->labelstring(), buffer.params()));
|
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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
2003-05-19 07:12:09 +00:00
|
|
|
|
// special handling of new environment insets
|
2004-04-08 15:03:33 +00:00
|
|
|
|
BufferView & bv = cur.bv();
|
2007-08-21 13:03:55 +00:00
|
|
|
|
BufferParams const & params = bv.buffer().params();
|
2007-08-23 19:59:07 +00:00
|
|
|
|
LayoutPtr const & lyxlayout = params.getTextClass()[layout];
|
2003-05-19 07:12:09 +00:00
|
|
|
|
if (lyxlayout->is_environment) {
|
|
|
|
|
// move everything in a new environment inset
|
2007-07-11 13:39:08 +00:00
|
|
|
|
LYXERR(Debug::DEBUG) << "setting layout " << to_utf8(layout) << endl;
|
2006-10-11 17:24:46 +00:00
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_LINE_BEGIN));
|
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_LINE_END_SELECT));
|
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_CUT));
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * inset = new InsetEnvironment(params, layout);
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertInset(cur, inset);
|
2004-02-13 13:51:12 +00:00
|
|
|
|
//inset->edit(cur, true);
|
2006-10-11 17:24:46 +00:00
|
|
|
|
//lyx::dispatch(FuncRequest(LFUN_PASTE));
|
2003-05-19 07:12:09 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
setLayout(cur.buffer(), start, end, layout);
|
2006-04-16 14:19:25 +00:00
|
|
|
|
updateLabels(cur.buffer());
|
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
|
|
|
|
{
|
|
|
|
|
if (par.layout()->labeltype == LABEL_BIBLIO)
|
|
|
|
|
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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(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;
|
2004-02-13 07:30:59 +00:00
|
|
|
|
recordUndoSelection(cur);
|
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
|
2006-04-16 14:19:25 +00:00
|
|
|
|
updateLabels(cur.buffer());
|
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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
2007-05-17 12:17:38 +00:00
|
|
|
|
// Set the current_font
|
|
|
|
|
// Determine basis font
|
|
|
|
|
Font layoutfont;
|
|
|
|
|
pit_type pit = cur.pit();
|
|
|
|
|
if (cur.pos() < pars_[pit].beginOfBody())
|
|
|
|
|
layoutfont = getLabelFont(cur.buffer(), pars_[pit]);
|
|
|
|
|
else
|
|
|
|
|
layoutfont = getLayoutFont(cur.buffer(), 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,
|
2007-05-17 12:17:38 +00:00
|
|
|
|
cur.buffer().params().language,
|
|
|
|
|
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;
|
|
|
|
|
cur.current_font.reduce(layoutfont);
|
2007-05-17 12:17:38 +00:00
|
|
|
|
// And resolve it completely
|
2007-09-02 13:35:48 +00:00
|
|
|
|
cur.real_current_font.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.
|
2004-02-13 07:30:59 +00:00
|
|
|
|
recordUndoSelection(cur);
|
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()) {
|
2004-08-15 00:01:45 +00:00
|
|
|
|
if (dit.pos() != dit.lastpos()) {
|
2007-05-22 10:51:38 +00:00
|
|
|
|
pit_type const pit = dit.pit();
|
|
|
|
|
pos_type const pos = dit.pos();
|
|
|
|
|
if (pars_[pit].isInset(pos) &&
|
|
|
|
|
pars_[pit].getInset(pos)->noFontChange())
|
|
|
|
|
// We need to propagate the font change to all
|
|
|
|
|
// text cells of the inset (bug 1973).
|
|
|
|
|
// FIXME: This should change, see documentation
|
2007-05-29 17:02:29 +00:00
|
|
|
|
// of noFontChange in Inset.h
|
2007-09-02 21:48:49 +00:00
|
|
|
|
setInsetFont(bv, pit, pos, font, toggleall);
|
|
|
|
|
TextMetrics const & tm = bv.textMetrics(this);
|
2007-09-02 22:28:49 +00:00
|
|
|
|
Font f = tm.getDisplayFont(pit, pos);
|
2007-05-29 17:02:29 +00:00
|
|
|
|
f.update(font, language, toggleall);
|
2007-09-02 21:48:49 +00:00
|
|
|
|
setCharFont(buffer, pit, pos, f, tm.font_);
|
2004-04-07 08:07:26 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
// If the mask is completely neutral, tell user
|
2007-04-29 18:17:15 +00:00
|
|
|
|
if (font == Font(Font::ALL_IGNORE)) {
|
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.
|
2004-03-01 17:12:09 +00:00
|
|
|
|
CursorSlice resetCursor = cur.top();
|
2003-10-29 10:47:21 +00:00
|
|
|
|
bool implicitSelection =
|
2003-10-28 11:18:40 +00:00
|
|
|
|
font.language() == ignore_language
|
2007-04-29 18:17:15 +00:00
|
|
|
|
&& font.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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
2001-07-30 10:50:37 +00:00
|
|
|
|
|
2006-09-03 07:02:38 +00:00
|
|
|
|
docstring idxstring;
|
|
|
|
|
if (cur.selection())
|
2004-02-11 14:45:44 +00:00
|
|
|
|
idxstring = cur.selectionAsString(false);
|
2006-09-03 07:02:38 +00:00
|
|
|
|
else {
|
2005-05-30 15:35:11 +00:00
|
|
|
|
// Try implicit word selection. If there is a change
|
|
|
|
|
// in the language the implicit word selection is
|
|
|
|
|
// disabled.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
Cursor tmpcur = cur;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
selectWord(tmpcur, PREVIOUS_WORD);
|
2005-05-30 15:35:11 +00:00
|
|
|
|
|
|
|
|
|
if (!tmpcur.selection())
|
2006-09-11 08:54:10 +00:00
|
|
|
|
cur.message(_("Nothing to index!"));
|
2005-05-30 15:35:11 +00:00
|
|
|
|
else if (tmpcur.selBegin().pit() != tmpcur.selEnd().pit())
|
2006-09-11 08:54:10 +00:00
|
|
|
|
cur.message(_("Cannot index more than one paragraph!"));
|
2005-05-30 15:35:11 +00:00
|
|
|
|
else
|
|
|
|
|
idxstring = tmpcur.selectionAsString(false);
|
|
|
|
|
}
|
2003-01-31 13:50:21 +00:00
|
|
|
|
|
2006-11-04 14:40:59 +00:00
|
|
|
|
return idxstring;
|
2001-07-30 10:50:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-10-18 16:17:46 +00:00
|
|
|
|
|
Add LFUN_PARAGRAPH_PARAMS (= paragraph-params), used for changing a paragraph's alignment, spacing, etc. This is complementary to LFUN_PARAGRAPH_PARAMS_APPLY, which sets the parameters. The difference is that APPLY over-rides all existing parameters, setting any not given to the default, whereas this one simply changes those that are given. So
paragraph-params \align right
will align the paragraph right, leaving spacing, etc, as they were, whereas
paragraph-params-apply \align right
will align the paragraph right but also reset all other parameters to defaults. Note, by the way, that this means that
paragraph-params-apply
sets everything to default.
Some new arguments have also been introduced. These are:
\indent
\indent-toggle
\spacing default
Of course, none of these are found in valid LyX files, but they are useful in menu bindings, etc.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19581 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-15 02:21:09 +00:00
|
|
|
|
void Text::setParagraphs(Cursor & cur, docstring arg, bool merge)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
|
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();
|
|
|
|
|
params.read(to_utf8(arg), merge);
|
|
|
|
|
Layout const & layout = *(par.layout());
|
|
|
|
|
par.params().apply(params, 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)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(cur.text());
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
for (pit_type pit = cur.selBegin().pit(), end = cur.selEnd().pit();
|
|
|
|
|
pit <= end; ++pit) {
|
|
|
|
|
Paragraph & par = pars_[pit];
|
|
|
|
|
Layout const & layout = *(par.layout());
|
|
|
|
|
par.params().apply(p, layout);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2004-02-13 11:05:29 +00:00
|
|
|
|
BOOST_ASSERT(this == cur.text());
|
2004-03-08 21:14:45 +00:00
|
|
|
|
BOOST_ASSERT(inset);
|
2007-09-02 13:35:48 +00:00
|
|
|
|
cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
|
2006-10-20 13:29:26 +00:00
|
|
|
|
Change(cur.buffer().params().trackChanges ?
|
2007-05-28 22:27:45 +00:00
|
|
|
|
Change::INSERTED : Change::UNCHANGED));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-01-13 16:28:54 +00:00
|
|
|
|
// needed to insert the selection
|
2007-04-29 23:33:02 +00:00
|
|
|
|
void Text::insertStringAsLines(Cursor & cur, docstring const & str)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2005-09-26 22:54:12 +00:00
|
|
|
|
cur.buffer().insertStringAsLines(pars_, cur.pit(), cur.pos(),
|
2007-09-02 13:35:48 +00:00
|
|
|
|
cur.current_font, str, autoBreakRows_);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
// turn double CR to single CR, others are converted into one
|
|
|
|
|
// blank. Then insertStringAsLines is called
|
2007-04-29 23:33:02 +00:00
|
|
|
|
void Text::insertStringAsParagraphs(Cursor & cur, docstring const & str)
|
2001-06-25 00:06:33 +00:00
|
|
|
|
{
|
2006-09-03 07:02:38 +00:00
|
|
|
|
docstring linestr = str;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool newline_inserted = false;
|
2003-06-18 17:43:49 +00:00
|
|
|
|
|
2004-02-13 07:30:59 +00:00
|
|
|
|
for (string::size_type i = 0, siz = linestr.size(); i < siz; ++i) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
if (linestr[i] == '\n') {
|
|
|
|
|
if (newline_inserted) {
|
|
|
|
|
// we know that \r will be ignored by
|
2003-12-01 13:35:49 +00:00
|
|
|
|
// insertStringAsLines. Of course, it is a dirty
|
2001-06-25 00:06:33 +00:00
|
|
|
|
// trick, but it works...
|
|
|
|
|
linestr[i - 1] = '\r';
|
|
|
|
|
linestr[i] = '\n';
|
|
|
|
|
} else {
|
|
|
|
|
linestr[i] = ' ';
|
|
|
|
|
newline_inserted = true;
|
2002-03-21 17:27:08 +00:00
|
|
|
|
}
|
2006-04-08 09:09:57 +00:00
|
|
|
|
} else if (isPrintable(linestr[i])) {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
newline_inserted = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2004-02-13 07:30:59 +00:00
|
|
|
|
insertStringAsLines(cur, linestr);
|
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
|
|
|
|
{
|
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);
|
2006-12-30 15:05:15 +00:00
|
|
|
|
return cur.bv().checkDepm(cur, old);
|
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
|
|
|
|
{
|
2003-12-01 13:35:49 +00:00
|
|
|
|
BOOST_ASSERT(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) {
|
|
|
|
|
lyxerr << "dont like -1" << endl;
|
|
|
|
|
BOOST_ASSERT(false);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pos > para.size()) {
|
2003-10-24 15:04:17 +00:00
|
|
|
|
lyxerr << "dont 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;
|
2003-10-24 15:04:17 +00:00
|
|
|
|
BOOST_ASSERT(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
|
|
|
|
{
|
2006-09-15 09:51:41 +00:00
|
|
|
|
BOOST_ASSERT(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();
|
2003-11-17 14:28:18 +00:00
|
|
|
|
if (!isHighlyEditableInset(inset))
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
bool Text::cursorLeft(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!
|
|
|
|
|
cur.updateFlags(Update::FitCursor);
|
|
|
|
|
|
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)
|
2005-02-08 02:06:39 +00:00
|
|
|
|
return setCursor(cur, cur.pit() - 1, getPar(cur.pit() - 1).size());
|
|
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-29 23:33:02 +00:00
|
|
|
|
bool Text::cursorRight(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!
|
|
|
|
|
cur.updateFlags(Update::FitCursor);
|
|
|
|
|
|
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())
|
2005-02-08 02:06:39 +00:00
|
|
|
|
return setCursor(cur, cur.pit() + 1, 0);
|
|
|
|
|
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-04-01 10:09:49 +00:00
|
|
|
|
//LYXERR(Debug::DEBUG) << "DEPM: cur:\n" << cur << "old:\n" << old << endl;
|
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
|
|
|
|
|
|
2005-10-25 09:14:11 +00:00
|
|
|
|
bool const same_inset = &old.inset() == &cur.inset();
|
|
|
|
|
bool const same_par = same_inset && old.pit() == cur.pit();
|
|
|
|
|
bool const same_par_pos = same_par && old.pos() == cur.pos();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
|
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())) {
|
2007-01-25 21:18:36 +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) {
|
|
|
|
|
fixCursorAfterDelete(cur.top(), 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.
|
2006-01-30 16:34:30 +00:00
|
|
|
|
recordUndo(old, Undo::ATOMIC,
|
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)
|
|
|
|
|
if (soa)
|
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
|
|
|
|
|
2007-01-21 16:43:27 +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
|
|
|
|
{
|
2007-01-26 12:32:03 +00:00
|
|
|
|
BOOST_ASSERT(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-25 22:51:00 +00:00
|
|
|
|
// don't delete anything if this is the only remaining paragraph within the given range
|
2007-05-28 22:27:45 +00:00
|
|
|
|
// 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
|
|
|
|
{
|
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
|
|
|
|
recordUndo(cur, Undo::ATOMIC, 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
|
|
|
|
{
|
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
|
|
|
|
recordUndo(cur, Undo::ATOMIC, par, par);
|
2003-10-13 10:59:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|