]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
cleanup after svn hang-up, #undef CursorShape. Should be compilable ganin now.
[lyx.git] / src / text.C
index 56f2d4da0e3878793a27fb6acb76c3a3e8345aa5..22b5741227c6da281414ebfb7aad1872b6ca4f4f 100644 (file)
@@ -190,9 +190,9 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                bool hasLayout = tclass.hasLayout(layoutname);
 
                if (!hasLayout) {
-                       errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown layout")),
-                       bformat(lyx::to_utf8(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n")),
-                               layoutname, tclass.name()), par.id(), 0, par.size()));
+                       errorList.push_back(ErrorItem(_("Unknown layout"),
+                       bformat(_("Layout '%1$s' does not exist in textclass '%2$s'\nTrying to use the default instead.\n"),
+                       lyx::from_utf8(layoutname), lyx::from_utf8(tclass.name())), par.id(), 0, par.size()));
                        layoutname = tclass.defaultLayoutName();
                }
 
@@ -221,8 +221,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                        par.insertInset(par.size(), inset, font, change);
                else {
                        lex.eatLine();
-                       string line = lex.getString();
-                       errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown Inset")), line,
+                       docstring line = lyx::from_utf8(lex.getString());
+                       errorList.push_back(ErrorItem(_("Unknown Inset"), line,
                                            par.id(), 0, par.size()));
                }
        } else if (token == "\\family") {
@@ -339,8 +339,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                lyx::time_type ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
-                       errorList.push_back(ErrorItem(lyx::to_utf8(_("Change tracking error")),
-                                           bformat(lyx::to_utf8(_("Unknown author index for insertion: %1$d\n")), aid),
+                       errorList.push_back(ErrorItem(_("Change tracking error"),
+                                           bformat(_("Unknown author index for insertion: %1$d\n"), aid),
                                            par.id(), 0, par.size()));
 
                        change = Change(Change::UNCHANGED);
@@ -353,8 +353,8 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                lyx::time_type ct;
                is >> aid >> ct;
                if (aid >= bp.author_map.size()) {
-                       errorList.push_back(ErrorItem(lyx::to_utf8(_("Change tracking error")),
-                                           bformat(lyx::to_utf8(_("Unknown author index for deletion: %1$d\n")), aid),
+                       errorList.push_back(ErrorItem(_("Change tracking error"),
+                                           bformat(_("Unknown author index for deletion: %1$d\n"), aid),
                                            par.id(), 0, par.size()));
 
                        change = Change(Change::UNCHANGED);
@@ -362,8 +362,9 @@ void readParToken(Buffer const & buf, Paragraph & par, LyXLex & lex,
                        change = Change(Change::DELETED, bp.author_map[aid], ct);
        } else {
                lex.eatLine();
-               errorList.push_back(ErrorItem(lyx::to_utf8(_("Unknown token")),
-                       bformat(lyx::to_utf8(_("Unknown token: %1$s %2$s\n")), token, lex.getString()),
+               errorList.push_back(ErrorItem(_("Unknown token"),
+                       bformat(_("Unknown token: %1$s %2$s\n"), lyx::from_utf8(token),
+                       lyx::from_utf8(lex.getString())),
                        par.id(), 0, par.size()));
        }
 }
@@ -683,8 +684,11 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const
 
 int LyXText::rightMargin(Paragraph const & par) const
 {
+       // FIXME: the correct way is to only call rightMargin() only
+       // within the main LyXText. The following test is thus bogus.
+       LyXText const & text = bv()->buffer()->text();
        // We do not want rightmargins on inner texts.
-       if (bv()->text() != this)
+       if (&text != this)
                return 0;
 
        BufferParams const & params = bv()->buffer()->params();
@@ -1078,8 +1082,12 @@ void LyXText::setHeightOfRow(pit_type const pit, Row & row)
        maxasc  += int(layoutasc  * 2 / (2 + pars_[pit].getDepth()));
        maxdesc += int(layoutdesc * 2 / (2 + pars_[pit].getDepth()));
 
+       // FIXME: the correct way is to do the following is to move the 
+       // following code in another method specially tailored for the 
+       // main LyXText. The following test is thus bogus.
+       LyXText const & text = bv_owner->buffer()->text();
        // Top and bottom margin of the document (only at top-level)
-       if (bv_owner->text() == this) {
+       if (&text == this) {
                if (pit == 0 && row.pos() == 0)
                        maxasc += 20;
                if (pit + 1 == pit_type(pars_.size()) &&
@@ -1240,8 +1248,8 @@ void LyXText::insertChar(LCursor & cur, char_type c)
                if (cur.pos() == 0) {
                        static bool sent_space_message = false;
                        if (!sent_space_message) {
-                               cur.message(lyx::to_utf8(_("You cannot insert a space at the "
-                                                          "beginning of a paragraph. Please read the Tutorial.")));
+                               cur.message(_("You cannot insert a space at the "
+                                                          "beginning of a paragraph. Please read the Tutorial."));
                                sent_space_message = true;
                        }
                        return;
@@ -1252,8 +1260,8 @@ void LyXText::insertChar(LCursor & cur, char_type c)
                    && par.lookupChange(cur.pos() - 1) != Change::DELETED) {
                        static bool sent_space_message = false;
                        if (!sent_space_message) {
-                               cur.message(lyx::to_utf8(_("You cannot type two spaces this way. "
-                                                          "Please read the Tutorial.")));
+                               cur.message(_("You cannot type two spaces this way. "
+                                                          "Please read the Tutorial."));
                                sent_space_message = true;
                        }
                        return;
@@ -2390,14 +2398,14 @@ string LyXText::currentState(LCursor & cur)
 
        // avoid lyx::to_utf8(_(...)) re-entrance problem
        string const s = font.stateText(&buf.params());
-       os << bformat(lyx::to_utf8(_("Font: %1$s")), s);
+       os << lyx::to_utf8(bformat(_("Font: %1$s"), lyx::from_utf8(s)));
 
-       // os << bformat(lyx::to_utf8(_("Font: %1$s")), font.stateText(&buf.params));
+       // os << lyx::to_utf8(bformat(_("Font: %1$s"), font.stateText(&buf.params)));
 
        // The paragraph depth
        int depth = cur.paragraph().getDepth();
        if (depth > 0)
-               os << bformat(lyx::to_utf8(_(", Depth: %1$d")), depth);
+               os << lyx::to_utf8(bformat(_(", Depth: %1$d"), depth));
 
        // The paragraph spacing, but only if different from
        // buffer spacing.
@@ -2530,6 +2538,7 @@ pos_type LyXText::x2pos(pit_type pit, int row, int x) const
 // sets cursor only within this LyXText
 bool LyXText::setCursorFromCoordinates(LCursor & cur, int const x, int const y)
 {
+       BOOST_ASSERT(this == cur.text());
        pit_type pit = getPitNearY(y);
        int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent();
        lyxerr[Debug::DEBUG]