]> git.lyx.org Git - features.git/blobdiff - src/Text.cpp
Don't save background color in Text. Hand it down at drawing time.
[features.git] / src / Text.cpp
index a2080170192f9739cdc5ac18c947c4b49ab0386a..8250030e36bbe4be22e037c9c90f4f056011b2ec 100644 (file)
 #include "buffer_funcs.h"
 #include "BufferParams.h"
 #include "BufferView.h"
-#include "bufferview_funcs.h"
 #include "Cursor.h"
 #include "ParIterator.h"
-#include "CoordCache.h"
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "DispatchResult.h"
@@ -43,8 +41,6 @@
 #include "Length.h"
 #include "Lexer.h"
 #include "LyXRC.h"
-#include "Row.h"
-#include "MetricsInfo.h"
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
@@ -360,12 +356,6 @@ double Text::spacing(Buffer const & buffer,
 }
 
 
-Color_color Text::backgroundColor() const
-{
-       return Color_color(Color::color(background_color_));
-}
-
-
 void Text::breakParagraph(Cursor & cur, bool keep_layout)
 {
        BOOST_ASSERT(this == cur.text());
@@ -463,7 +453,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                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 &&
@@ -473,7 +463,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                           )
                                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) {
@@ -483,11 +473,11 @@ void Text::insertChar(Cursor & cur, char_type c)
                                     || 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);
                                }
                        }
                }
@@ -519,7 +509,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                // 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();
                
@@ -568,7 +558,7 @@ void Text::insertChar(Cursor & cur, char_type c)
                }
        }
 
-       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);
@@ -810,7 +800,6 @@ void Text::rejectChanges(BufferParams const & bparams)
 }
 
 
-// Delete from cursor up to the end of the current or next word.
 void Text::deleteWordForward(Cursor & cur)
 {
        BOOST_ASSERT(this == cur.text());
@@ -827,7 +816,6 @@ void Text::deleteWordForward(Cursor & cur)
 }
 
 
-// Delete from cursor to start of current or prior word.
 void Text::deleteWordBackward(Cursor & cur)
 {
        BOOST_ASSERT(this == cur.text());
@@ -845,27 +833,6 @@ void Text::deleteWordBackward(Cursor & cur)
 
 
 // Kill to end of line.
-void Text::deleteLineForward(Cursor & cur)
-{
-       BOOST_ASSERT(this == cur.text());
-       if (cur.lastpos() == 0) {
-               // Paragraph is empty, so we just go to the right
-               cursorRight(cur);
-       } else {
-               cur.resetAnchor();
-               cur.selection() = true; // to avoid deletion
-               cursorEnd(cur);
-               cur.setSelection();
-               // What is this test for ??? (JMarc)
-               if (!cur.selection())
-                       deleteWordForward(cur);
-               else
-                       cutSelection(cur, true, false);
-               checkBufferStructure(cur.buffer(), cur);
-       }
-}
-
-
 void Text::changeCase(Cursor & cur, Text::TextCase action)
 {
        BOOST_ASSERT(this == cur.text());
@@ -1127,7 +1094,7 @@ bool Text::backspace(Cursor & cur)
        }
 
        if (cur.pos() == cur.lastpos())
-               setCurrentFont(cur);
+               cur.setCurrentFont();
 
        needsUpdate |= handleBibitems(cur);
 
@@ -1183,19 +1150,6 @@ bool Text::dissolveInset(Cursor & cur) {
 }
 
 
-bool Text::isLastRow(pit_type pit, Row const & row) const
-{
-       return row.endpos() >= pars_[pit].size()
-               && pit + 1 == pit_type(paragraphs().size());
-}
-
-
-bool Text::isFirstRow(pit_type pit, Row const & row) const
-{
-       return row.pos() == 0 && pit == 0;
-}
-
-
 void Text::getWord(CursorSlice & from, CursorSlice & to,
        word_location const loc)
 {
@@ -1327,7 +1281,7 @@ docstring Text::currentState(Cursor & cur)
        // 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()));