Author: younes
Date: Sun Sep 2 15:35:48 2007
New Revision: 19999
URL: http://www.lyx.org/trac/changeset/19999
Log:
Transfer current_font and real_current_font from Text to Cursor.
Modified:
lyx-devel/trunk/src/Buffer.cpp
lyx-devel/trunk/src/BufferView.cpp
lyx-devel/trunk/src/Cursor.cpp
lyx-devel/trunk/src/Cursor.h
lyx-devel/trunk/src/Paragraph.cpp
lyx-devel/trunk/src/Text.cpp
lyx-devel/trunk/src/Text.h
lyx-devel/trunk/src/Text2.cpp
lyx-devel/trunk/src/Text3.cpp
lyx-devel/trunk/src/TextMetrics.cpp
lyx-devel/trunk/src/frontends/WorkArea.cpp
lyx-devel/trunk/src/insets/InsetERT.cpp
lyx-devel/trunk/src/insets/InsetListings.cpp
lyx-devel/trunk/src/insets/InsetText.cpp
Modified: lyx-devel/trunk/src/Buffer.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Buffer.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Buffer.cpp (original)
+++ lyx-devel/trunk/src/Buffer.cpp Sun Sep 2 15:35:48 2007
@@ -1530,9 +1530,6 @@
for_each(par_iterator_begin(),
par_iterator_end(),
bind(&Paragraph::changeLanguage, _1, params(), from, to));
-
- text().current_font.setLanguage(to);
- text().real_current_font.setLanguage(to);
}
Modified: lyx-devel/trunk/src/BufferView.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/BufferView.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/BufferView.cpp (original)
+++ lyx-devel/trunk/src/BufferView.cpp Sun Sep 2 15:35:48 2007
@@ -134,7 +134,7 @@
cursor_.push(buffer_.inset());
cursor_.resetAnchor();
- buffer_.text().setCurrentFont(cursor_);
+ cursor_.setCurrentFont();
if (graphics::Previews::status() != LyXRC::PREVIEW_OFF)
graphics::Previews::get().generateBufferPreviews(buffer_);
@@ -457,7 +457,7 @@
// Note: only bottom (document) level pit is set.
setCursor(doc_it);
// set the current font.
- buffer_.text().setCurrentFont(cursor_);
+ cursor_.setCurrentFont();
// center the screen on this new position.
center();
}
@@ -469,7 +469,7 @@
void BufferView::translateAndInsert(char_type c, Text * t, Cursor & cur)
{
if (lyxrc.rtl_support) {
- if (cursor_.innerText()->real_current_font.isRightToLeft()) {
+ if (cursor_.real_current_font.isRightToLeft()) {
if (intl_->keymap == Intl::PRIMARY)
intl_->keyMapSec();
} else {
Modified: lyx-devel/trunk/src/Cursor.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Cursor.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Cursor.cpp (original)
+++ lyx-devel/trunk/src/Cursor.cpp Sun Sep 2 15:35:48 2007
@@ -266,7 +266,7 @@
// bv functions are not yet available!
Cursor::Cursor(BufferView & bv)
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
textTargetOffset_(0),
- selection_(false), mark_(false), logicalpos_(false)
+ selection_(false), mark_(false), logicalpos_(false),
current_font(Font::ALL_INHERIT)
{}
@@ -1437,7 +1437,7 @@
Font Cursor::getFont() const
{
- // The logic here should more or less match to the Text::setCurrentFont
+ // The logic here should more or less match to the
Cursor::setCurrentFont
// logic, i.e. the cursor height should give a hint what will happen
// if a character is entered.
@@ -1504,4 +1504,46 @@
}
+void Cursor::setCurrentFont()
+{
+ pos_type cpos = pos();
+ Paragraph & par = paragraph();
+ Text const & ctext = *text();
+
+ // are we behind previous char in fact? -> go to that char
+ if (cpos > 0 && boundary())
+ --cpos;
+
+ // find position to take the font from
+ if (cpos != 0) {
+ // paragraph end? -> font of last char
+ if (cpos == lastpos())
+ --cpos;
+ // on space? -> look at the words in front of space
+ else if (cpos > 0 && par.isSeparator(cpos)) {
+ // abc| def -> font of c
+ // abc |[WERBEH], i.e. boundary==true -> font of c
+ // abc [WERBEH]| def, font of the space
+ if (!ctext.isRTLBoundary(buffer(), par, cpos))
+ --cpos;
+ }
+ }
+
+ // get font
+ BufferParams const & bufparams = buffer().params();
+ current_font = par.getFontSettings(bufparams, cpos);
+ real_current_font = ctext.getFont(buffer(), par, cpos);
+
+ // special case for paragraph end
+ if (pos() == lastpos()
+ && ctext.isRTLBoundary(buffer(), par, pos())
+ && !boundary()) {
+ Language const * lang = par.getParLanguage(bufparams);
+ current_font.setLanguage(lang);
+ current_font.setNumber(Font::OFF);
+ real_current_font.setLanguage(lang);
+ real_current_font.setNumber(Font::OFF);
+ }
+}
+
} // namespace lyx
Modified: lyx-devel/trunk/src/Cursor.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Cursor.h?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Cursor.h (original)
+++ lyx-devel/trunk/src/Cursor.h Sun Sep 2 15:35:48 2007
@@ -14,6 +14,7 @@
#include "DispatchResult.h"
#include "DocIterator.h"
+#include "Font.h"
#include <iosfwd>
#include <vector>
@@ -25,7 +26,6 @@
class BufferView;
class FuncStatus;
class FuncRequest;
-class Font;
class Row;
// these should go
@@ -60,6 +60,9 @@
void leaveInset(Inset const & inset);
/// sets cursor part
void setCursor(DocIterator const & it);
+
+ ///
+ void setCurrentFont();
//
// selection
@@ -230,6 +233,13 @@
/// position before dispatch started
DocIterator beforeDispatchCursor_;
+// FIXME: make them private.
+public:
+ /// the current font settings
+ Font current_font;
+ /// the current font
+ Font real_current_font;
+
private:
//
Modified: lyx-devel/trunk/src/Paragraph.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Paragraph.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Paragraph.cpp (original)
+++ lyx-devel/trunk/src/Paragraph.cpp Sun Sep 2 15:35:48 2007
@@ -1284,17 +1284,6 @@
pimpl_->insertInset(pos, inset, change);
// Set the font/language of the inset...
setFont(pos, font);
- // ... as well as the font/language of the text inside the inset
- // FIXME: This is far from perfect. It basically overrides work being
done
- // in the InsetText constructor. Also, it doesn't work for Tables
- // (precisely because each cell's font/language is set in the Table's
- // constructor, so by now it's too late). The long-term solution should
- // be moving current_font into Cursor, and getting rid of all this...
- // (see
http://thread.gmane.org/gmane.editors.lyx.devel/88869/focus=88944)
- if (inset->asTextInset()) {
- inset->asTextInset()->text_.current_font = font;
- inset->asTextInset()->text_.real_current_font = font;
- }
}
Modified: lyx-devel/trunk/src/Text.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Text.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Text.cpp (original)
+++ lyx-devel/trunk/src/Text.cpp Sun Sep 2 15:35:48 2007
@@ -459,7 +459,7 @@
static docstring const number_unary_operators =
from_ascii("+-");
static docstring const number_seperators = from_ascii(".,:");
- if (current_font.number() == Font::ON) {
+ if (cur.current_font.number() == Font::ON) {
if (!isDigit(c) && !contains(number_operators, c) &&
!(contains(number_seperators, c) &&
cur.pos() != 0 &&
@@ -469,7 +469,7 @@
)
number(cur); // Set current_font.number to OFF
} else if (isDigit(c) &&
- real_current_font.isVisibleRightToLeft()) {
+ cur.real_current_font.isVisibleRightToLeft()) {
number(cur); // Set current_font.number to ON
if (cur.pos() != 0) {
@@ -479,11 +479,11 @@
|| par.isSeparator(cur.pos() - 2)
|| par.isNewline(cur.pos() - 2))
) {
- setCharFont(buffer, pit, cur.pos() - 1,
current_font);
+ setCharFont(buffer, pit, cur.pos() - 1,
cur.current_font);
} else if (contains(number_seperators, c)
&& cur.pos() >= 2
&& getFont(buffer, par, cur.pos() -
2).number() == Font::ON) {
- setCharFont(buffer, pit, cur.pos() - 1,
current_font);
+ setCharFont(buffer, pit, cur.pos() - 1,
cur.current_font);
}
}
}
@@ -515,7 +515,7 @@
// get font in front and behind the space in question. But do NOT
// use getFont(cur.pos()) because the character c is not inserted yet
Font const & pre_space_font = getFont(buffer, par, cur.pos() -
2);
- Font const & post_space_font = real_current_font;
+ Font const & post_space_font = cur.real_current_font;
bool pre_space_rtl = pre_space_font.isVisibleRightToLeft();
bool post_space_rtl = post_space_font.isVisibleRightToLeft();
@@ -564,7 +564,7 @@
}
}
- par.insertChar(cur.pos(), c, current_font, cur.buffer().params().trackChanges);
+ par.insertChar(cur.pos(), c, cur.current_font,
cur.buffer().params().trackChanges);
checkBufferStructure(cur.buffer(), cur);
// cur.updateFlags(Update::Force);
@@ -1100,7 +1100,7 @@
}
if (cur.pos() == cur.lastpos())
- setCurrentFont(cur);
+ cur.setCurrentFont();
needsUpdate |= handleBibitems(cur);
@@ -1287,7 +1287,7 @@
// I think we should only show changes from the default
// font. (Asger)
// No, from the document font (MV)
- Font font = real_current_font;
+ Font font = cur.real_current_font;
font.reduce(buf.params().getFont());
os << bformat(_("Font: %1$s"), font.stateText(&buf.params()));
Modified: lyx-devel/trunk/src/Text.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Text.h?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Text.h (original)
+++ lyx-devel/trunk/src/Text.h Sun Sep 2 15:35:48 2007
@@ -168,8 +168,6 @@
///
void setCursorIntern(Cursor & cur, pit_type par,
pos_type pos, bool setfont = true, bool boundary = false);
- ///
- void setCurrentFont(Cursor & cur);
///
void recUndo(Cursor & cur, pit_type first, pit_type last) const;
@@ -291,10 +289,6 @@
void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool
trackChanges);
public:
- /// the current font settings
- Font current_font;
- /// the current font
- Font real_current_font;
///
int background_color_;
Modified: lyx-devel/trunk/src/Text2.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Text2.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Text2.cpp (original)
+++ lyx-devel/trunk/src/Text2.cpp Sun Sep 2 15:35:48 2007
@@ -71,8 +71,7 @@
namespace lyx {
Text::Text()
- : current_font(Font::ALL_INHERIT),
- background_color_(Color::background),
+ : background_color_(Color::background),
autoBreakRows_(false)
{}
@@ -410,15 +409,15 @@
layoutfont = getLayoutFont(cur.buffer(), pit);
// Update current font
- real_current_font.update(font,
+ cur.real_current_font.update(font,
cur.buffer().params().language,
toggleall);
// Reduce to implicit settings
- current_font = real_current_font;
- current_font.reduce(layoutfont);
+ cur.current_font = cur.real_current_font;
+ cur.current_font.reduce(layoutfont);
// And resolve it completely
- real_current_font.realize(layoutfont);
+ cur.real_current_font.realize(layoutfont);
// if there is no selection that's all we need to do
if (!cur.selection())
@@ -574,7 +573,7 @@
{
BOOST_ASSERT(this == cur.text());
BOOST_ASSERT(inset);
- cur.paragraph().insertInset(cur.pos(), inset, current_font,
+ cur.paragraph().insertInset(cur.pos(), inset, cur.current_font,
Change(cur.buffer().params().trackChanges ?
Change::INSERTED :
Change::UNCHANGED));
}
@@ -584,7 +583,7 @@
void Text::insertStringAsLines(Cursor & cur, docstring const & str)
{
cur.buffer().insertStringAsLines(pars_, cur.pit(), cur.pos(),
- current_font, str, autoBreakRows_);
+ cur.current_font, str, autoBreakRows_);
}
@@ -655,50 +654,7 @@
cur.boundary(boundary);
setCursor(cur.top(), par, pos);
if (setfont)
- setCurrentFont(cur);
-}
-
-
-void Text::setCurrentFont(Cursor & cur)
-{
- BOOST_ASSERT(this == cur.text());
- pos_type pos = cur.pos();
- Paragraph & par = cur.paragraph();
-
- // are we behind previous char in fact? -> go to that char
- if (pos > 0 && cur.boundary())
- --pos;
-
- // find position to take the font from
- if (pos != 0) {
- // paragraph end? -> font of last char
- if (pos == cur.lastpos())
- --pos;
- // on space? -> look at the words in front of space
- else if (pos > 0 && par.isSeparator(pos)) {
- // abc| def -> font of c
- // abc |[WERBEH], i.e. boundary==true -> font of c
- // abc [WERBEH]| def, font of the space
- if (!isRTLBoundary(cur.buffer(), par, pos))
- --pos;
- }
- }
-
- // get font
- BufferParams const & bufparams = cur.buffer().params();
- current_font = par.getFontSettings(bufparams, pos);
- real_current_font = getFont(cur.buffer(), par, pos);
-
- // special case for paragraph end
- if (cur.pos() == cur.lastpos()
- && isRTLBoundary(cur.buffer(), par, cur.pos())
- && !cur.boundary()) {
- Language const * lang = par.getParLanguage(bufparams);
- current_font.setLanguage(lang);
- current_font.setNumber(Font::OFF);
- real_current_font.setLanguage(lang);
- real_current_font.setNumber(Font::OFF);
- }
+ cur.setCurrentFont();
}
Modified: lyx-devel/trunk/src/Text3.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/Text3.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/Text3.cpp (original)
+++ lyx-devel/trunk/src/Text3.cpp Sun Sep 2 15:35:48 2007
@@ -104,7 +104,7 @@
font.number() != Font::IGNORE) {
Paragraph & par = cur.paragraph();
if (cur.boundary() != text->isRTLBoundary(cur.buffer(),
par,
- cur.pos(),
text->real_current_font))
+ cur.pos(),
cur.real_current_font))
text->setCursor(cur, cur.pit(), cur.pos(),
false, !cur.boundary());
}
@@ -824,9 +824,9 @@
}
case LFUN_SERVER_GET_FONT:
- if (current_font.shape() == Font::ITALIC_SHAPE)
+ if (cur.current_font.shape() == Font::ITALIC_SHAPE)
cur.message(from_ascii("E"));
- else if (current_font.shape() == Font::SMALLCAPS_SHAPE)
+ else if (cur.current_font.shape() == Font::SMALLCAPS_SHAPE)
cur.message(from_ascii("N"));
else
cur.message(from_ascii("0"));
@@ -1096,7 +1096,7 @@
}
cur.clearSelection();
- Font const old_font = real_current_font;
+ Font const old_font = cur.real_current_font;
docstring::const_iterator cit = cmd.argument().begin();
docstring::const_iterator end = cmd.argument().end();
@@ -1625,7 +1625,7 @@
{
BOOST_ASSERT(cur.text() == this);
- Font const & font = real_current_font;
+ Font const & font = cur.real_current_font;
bool enable = true;
Inset::Code code = Inset::NO_CODE;
Modified: lyx-devel/trunk/src/TextMetrics.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/TextMetrics.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/TextMetrics.cpp (original)
+++ lyx-devel/trunk/src/TextMetrics.cpp Sun Sep 2 15:35:48 2007
@@ -1112,7 +1112,9 @@
if (!inset) {
// Either we deconst editXY or better we move current_font
// and real_current_font to Cursor
- text_->setCurrentFont(cur);
+ // FIXME: what is needed now that current_font and
real_current_font
+ // are transferred?
+ cur.setCurrentFont();
return 0;
}
@@ -1136,7 +1138,7 @@
inset = inset->editXY(cur, x, y);
if (cur.top().text() == text_)
- text_->setCurrentFont(cur);
+ cur.setCurrentFont();
return inset;
}
Modified: lyx-devel/trunk/src/frontends/WorkArea.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/WorkArea.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/frontends/WorkArea.cpp (original)
+++ lyx-devel/trunk/src/frontends/WorkArea.cpp Sun Sep 2 15:35:48 2007
@@ -32,7 +32,6 @@
#include "LyXFunc.h"
#include "LyXRC.h"
#include "MetricsInfo.h"
-#include "Text.h"
#include "gettext.h"
#include "support/ForkedcallsController.h"
@@ -277,8 +276,7 @@
CursorShape shape = BAR_SHAPE;
- Text const & text = *buffer_view_->cursor().innerText();
- Font const & realfont = text.real_current_font;
+ Font const & realfont = buffer_view_->cursor().real_current_font;
BufferParams const & bp = buffer_view_->buffer().params();
bool const samelang = realfont.language() == bp.language;
bool const isrtl = realfont.isVisibleRightToLeft();
Modified: lyx-devel/trunk/src/insets/InsetERT.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetERT.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/insets/InsetERT.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetERT.cpp Sun Sep 2 15:35:48 2007
@@ -53,8 +53,9 @@
{
setButtonLabel();
setLabelFont(layout_.labelfont);
- text_.current_font.setLanguage(latex_language);
- text_.real_current_font.setLanguage(latex_language);
+ // FIXME: what to do with those?
+ //text_.current_font.setLanguage(latex_language);
+ //text_.real_current_font.setLanguage(latex_language);
}
@@ -254,8 +255,9 @@
// start of an existing paragraph get the buffer language
// and not latex_language, so we take this brute force
// approach.
- text_.current_font.setLanguage(latex_language);
- text_.real_current_font.setLanguage(latex_language);
+ // FIXME: what to do with those?
+ //text_.current_font.setLanguage(latex_language);
+ //text_.real_current_font.setLanguage(latex_language);
InsetCollapsable::doDispatch(cur, cmd);
break;
Modified: lyx-devel/trunk/src/insets/InsetListings.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetListings.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/insets/InsetListings.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetListings.cpp Sun Sep 2 15:35:48 2007
@@ -50,8 +50,9 @@
font.decSize();
font.setColor(Color::none);
setLabelFont(font);
- text_.current_font.setLanguage(latex_language);
- text_.real_current_font.setLanguage(latex_language);
+ // FIXME: what to do with those?
+ //text_.current_font.setLanguage(latex_language);
+ //text_.real_current_font.setLanguage(latex_language);
}
Modified: lyx-devel/trunk/src/insets/InsetText.cpp
URL:
http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetText.cpp?rev=19999
==============================================================================
--- lyx-devel/trunk/src/insets/InsetText.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetText.cpp Sun Sep 2 15:35:48 2007
@@ -82,9 +82,6 @@
{
paragraphs().push_back(Paragraph());
paragraphs().back().layout(bp.getTextClass().defaultLayout());
- // Dispose of the infamous L-shaped cursor.
- text_.current_font.setLanguage(bp.language);
- text_.real_current_font.setLanguage(bp.language);
init();
}
@@ -96,10 +93,6 @@
drawFrame_ = in.drawFrame_;
frame_color_ = in.frame_color_;
text_.paragraphs() = in.text_.paragraphs();
- // Hand current buffer language down to "cloned" textinsets
- // e.g. tabular cells
- text_.current_font = in.text_.current_font;
- text_.real_current_font = in.text_.real_current_font;
init();
}