]> git.lyx.org Git - lyx.git/commitdiff
convert author names and status messages to docstring
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 21 Dec 2006 13:58:28 +0000 (13:58 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Thu, 21 Dec 2006 13:58:28 +0000 (13:58 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16363 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
src/BufferView.C
src/author.C
src/author.h
src/bufferlist.C
src/bufferlist.h
src/bufferparams.C
src/cursor.C
src/cursor.h
src/frontends/controllers/ControlChanges.C
src/frontends/controllers/ControlCommandBuffer.C
src/frontends/controllers/ControlCommandBuffer.h
src/frontends/controllers/ControlPrefs.C
src/lyxfunc.C
src/lyxfunc.h
src/lyxtext.h
src/text.C

index 7cda307f1c16cc84ee2fdff26896b5642d07af7f..cd8e79892a3ee8831de55de3c82f513e49117e91 100644 (file)
@@ -721,7 +721,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
                break;
 
        case LFUN_FONT_STATE:
-               cur.message(from_utf8(cur.currentState()));
+               cur.message(cur.currentState());
                break;
 
        case LFUN_BOOKMARK_SAVE:
index 60817affe0da43622d627908f96aa2feb86b990d..ea05ccd83d53dda7c494f6b814a1a1c09945dfb9 100644 (file)
@@ -35,7 +35,8 @@ bool operator==(Author const & l, Author const & r)
 
 std::ostream & operator<<(std::ostream & os, Author const & a)
 {
-       os << "\"" << a.name() << "\" " << a.email();
+       // FIXME UNICODE
+       os << "\"" << to_utf8(a.name()) << "\" " << to_utf8(a.email());
        return os;
 }
 
@@ -43,8 +44,9 @@ std::istream & operator>>(std::istream & is, Author & a)
 {
        string s;
        getline(is, s);
-       a.name_ = trim(token(s, '\"', 1));
-       a.email_ = trim(token(s, '\"', 2));
+       // FIXME UNICODE
+       a.name_ = from_utf8(trim(token(s, '\"', 1)));
+       a.email_ = from_utf8(trim(token(s, '\"', 2)));
        return is;
 }
 
index 9f2a0c7573a626bdbaa8319cd92c5dd2d147e047..bf84737130507c08f70c4652369ca84694236483 100644 (file)
 #ifndef AUTHOR_H
 #define AUTHOR_H
 
+#include "support/docstring.h"
+
 #include <map>
 #include <iosfwd>
-#include <string>
 
 
 namespace lyx {
@@ -24,23 +25,23 @@ class Author {
 public:
        Author() {}
 
-       Author(std::string const & name, std::string const & email)
+       Author(docstring const & name, docstring const & email)
                : name_(name), email_(email) {}
 
-       std::string const name() const {
+       docstring const name() const {
                return name_;
        }
 
-       std::string const email() const {
+       docstring const email() const {
                return email_;
        }
 
-       friend  std::istream & operator>>(std::istream & os, Author & a);
+       friend std::istream & operator>>(std::istream & os, Author & a);
 
 private:
-       std::string name_;
+       docstring name_;
 
-       std::string email_;
+       docstring email_;
 };
 
 
index 1d14c077d34654005c35d15ee9c2d9c57b4f1cb4..f33b00e2c3868a18f1597caf66fe8dfa08a4d0e1 100644 (file)
@@ -435,7 +435,7 @@ Buffer * BufferList::getBufferFromTmp(string const & s)
 }
 
 
-void BufferList::setCurrentAuthor(string const & name, string const & email)
+void BufferList::setCurrentAuthor(docstring const & name, docstring const & email)
 {
        BufferStorage::iterator it = bstore.begin();
        BufferStorage::iterator end = bstore.end();
index 161f95b7f520a63a2742f7ad0d10322164507795..350e5fc7da80a6e7a24e8040424b561662be984a 100644 (file)
 #ifndef BUFFER_LIST_H
 #define BUFFER_LIST_H
 
+#include "support/docstring.h"
+
 #include <boost/utility.hpp>
 
-#include <string>
 #include <vector>
 
 
@@ -100,7 +101,7 @@ public:
        Buffer * previous(Buffer const *) const;
 
        /// reset current author for all buffers
-       void setCurrentAuthor(std::string const & name, std::string const & email);
+       void setCurrentAuthor(docstring const & name, docstring const & email);
 
 private:
        /// ask to save a buffer on quit, returns false if should cancel
index 856fa185eee872db815f24d2f5adcaa5021c188b..7e0a3d1613b5bd94d5a64601b5ec29cf223f1422 100644 (file)
@@ -261,7 +261,8 @@ BufferParams::Impl::Impl()
        : defskip(VSpace::MEDSKIP)
 {
        // set initial author
-       authorlist.record(Author(lyxrc.user_name, lyxrc.user_email));
+       // FIXME UNICODE
+       authorlist.record(Author(from_utf8(lyxrc.user_name), from_utf8(lyxrc.user_email)));
 }
 
 
index 4dacb3674a0d1efb93fec32716b6c8351f4d519d..5bccc4d13b2a146428f7c7fc8a5b7504dd58045d 100644 (file)
@@ -1203,18 +1203,18 @@ docstring LCursor::selectionAsString(bool label) const
 }
 
 
-string LCursor::currentState()
+docstring LCursor::currentState()
 {
        if (inMathed()) {
                odocstringstream os;
                info(os);
-               return to_utf8(os.str());
+               return os.str();
        }
 
        if (inTexted())
                return text()->currentState(*this);
 
-       return string();
+       return docstring();
 }
 
 
index ed3fdef34e4c04b1ed900c2b726ad62f880579d0..b8f3336b5041305688130008cc4a6952ca34a747 100644 (file)
@@ -91,7 +91,7 @@ public:
        //
        docstring selectionAsString(bool label) const;
        ///
-       std::string currentState();
+       docstring currentState();
 
        /// auto-correct mode
        bool autocorrect() const { return autocorrect_; }
index 5c309caa7b0c3257aac760766d94466761a999a7..9c67cc57c50cfec7a713526fe254f5e9d6421c96 100644 (file)
@@ -65,12 +65,11 @@ docstring const ControlChanges::getChangeAuthor()
 
        Author const & a(kernel().buffer().params().authors().get(c.author));
 
-       // FIXME UNICODE in Author class
-       docstring author(from_utf8(a.name()));
+       docstring author(a.name());
 
        if (!a.email().empty()) {
                author += " (";
-               author += from_utf8(a.email());
+               author += a.email();
                author += ")";
        }
 
index e6d0d7ef1689ec0de8396559d4d2075b72882b97..ef4bcb6a281f0c45842c72d684907409fa5e330d 100644 (file)
@@ -79,7 +79,7 @@ string const ControlCommandBuffer::historyDown()
 }
 
 
-string const ControlCommandBuffer::getCurrentState() const
+docstring const ControlCommandBuffer::getCurrentState() const
 {
        return lv_.view()->cursor().currentState();
 }
index dbc059634890788365671b50b3b4d32d7211b417..b1e413411e50f7f4e524299ce3f9b7926c666022 100644 (file)
@@ -14,7 +14,8 @@
 #ifndef CONTROLCOMMANDBUFFER_H
 #define CONTROLCOMMANDBUFFER_H
 
-#include <string>
+#include "support/docstring.h"
+
 #include <vector>
 
 
@@ -41,7 +42,7 @@ public:
        std::string const historyDown();
 
        /// return the font and depth in the active BufferView as a message.
-       std::string const getCurrentState() const;
+       docstring const getCurrentState() const;
 
        /// return the possible completions
        std::vector<std::string> const completions(std::string const & prefix,
index be0cd866e3fcc3ef3567e85bc1f71541d664dedb..5d8c2e2259b69d7183a9e8a91cd0dcf934fd0781 100644 (file)
@@ -65,7 +65,8 @@ void ControlPrefs::dispatchParams()
        kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
 
        // FIXME: these need lfuns
-       theBufferList().setCurrentAuthor(rc_.user_name, rc_.user_email);
+       // FIXME UNICODE
+       theBufferList().setCurrentAuthor(from_utf8(rc_.user_name), from_utf8(rc_.user_email));
 
        lyx::formats = formats_;
 
index 0be7635e257422416ee11f841827352668adf528..f8fe702f076bdc9281e0902e06f0808f2ed4c64f 100644 (file)
@@ -2029,19 +2029,19 @@ void LyXFunc::setMessage(docstring const & m) const
 }
 
 
-string const LyXFunc::viewStatusMessage()
+docstring const LyXFunc::viewStatusMessage()
 {
        // When meta-fake key is pressed, show the key sequence so far + "M-".
        if (wasMetaKey())
-               return to_utf8(keyseq->print() + "M-");
+               return keyseq->print() + "M-";
 
        // Else, when a non-complete key sequence is pressed,
        // show the available options.
        if (keyseq->length() > 0 && !keyseq->deleted())
-               return to_utf8(keyseq->printOptions());
+               return keyseq->printOptions();
 
        if (!view()->buffer())
-               return to_utf8(_("Welcome to LyX!"));
+               return _("Welcome to LyX!");
 
        return view()->cursor().currentState();
 }
index 549e778d897be8ed85797cbcdc508018144712df..2e36ba19ab1bd846fd89f3405a94101e92256f19 100644 (file)
@@ -54,7 +54,7 @@ public:
        void initKeySequences(kb_keymap * kb);
 
        /// return the status bar state string
-       std::string const viewStatusMessage();
+       docstring const viewStatusMessage();
 
        ///
        void processKeySym(LyXKeySymPtr key, key_modifier::state state);
index 38b6e71c68324175304cd179b9ad6aecc9e8ccd1..a908458b03beaffcb3fe20781532b9d330e723a0 100644 (file)
@@ -134,7 +134,7 @@ public:
        /// read-write access to individual paragraph
        Paragraph & getPar(pit_type pit) { return pars_[pit]; }
        // Returns the current font and depth as a message.
-       std::string currentState(LCursor & cur);
+       docstring currentState(LCursor & cur);
 
        /** returns row near the specified
          * y-coordinate in given paragraph (relative to the screen).
index d0fda985ace0bc60e4cda6576c9e13a7e31fa8d3..cab2ac41353cbda9c2ad9bf847c2dffd8a361e22 100644 (file)
@@ -2302,12 +2302,12 @@ int LyXText::cursorY(CursorSlice const & sl, bool boundary) const
 
 
 // Returns the current font and depth as a message.
-string LyXText::currentState(LCursor & cur)
+docstring LyXText::currentState(LCursor & cur)
 {
        BOOST_ASSERT(this == cur.text());
        Buffer & buf = cur.buffer();
        Paragraph const & par = cur.paragraph();
-       std::ostringstream os;
+       odocstringstream os;
 
        if (buf.params().trackChanges)
                os << "[C] ";
@@ -2316,10 +2316,11 @@ string LyXText::currentState(LCursor & cur)
 
        if (change.type != Change::UNCHANGED) {
                Author const & a = buf.params().authors().get(change.author);
-               os << to_utf8(_("Change: ")) << a.name();
+               os << _("Change: ") << a.name();
                if (!a.email().empty())
                        os << " (" << a.email() << ")";
-               os << to_utf8(_(" at ")) << ctime(&change.changetime);
+               // FIXME ctime is english, we should translate that
+               os << _(" at ") << ctime(&change.changetime);
                os << " : ";
        }
 
@@ -2329,34 +2330,31 @@ string LyXText::currentState(LCursor & cur)
        LyXFont font = real_current_font;
        font.reduce(buf.params().getFont());
 
-       // avoid to_utf8(_(...)) re-entrance problem
-       string const s = font.stateText(&buf.params());
-       os << to_utf8(bformat(_("Font: %1$s"), from_utf8(s)));
-
-       // os << to_utf8(bformat(_("Font: %1$s"), font.stateText(&buf.params)));
+       // FIXME UNICODE
+       os << bformat(_("Font: %1$s"), from_utf8(font.stateText(&buf.params())));
 
        // The paragraph depth
        int depth = cur.paragraph().getDepth();
        if (depth > 0)
-               os << to_utf8(bformat(_(", Depth: %1$d"), depth));
+               os << bformat(_(", Depth: %1$d"), depth);
 
        // The paragraph spacing, but only if different from
        // buffer spacing.
        Spacing const & spacing = par.params().spacing();
        if (!spacing.isDefault()) {
-               os << to_utf8(_(", Spacing: "));
+               os << _(", Spacing: ");
                switch (spacing.getSpace()) {
                case Spacing::Single:
-                       os << to_utf8(_("Single"));
+                       os << _("Single");
                        break;
                case Spacing::Onehalf:
-                       os << to_utf8(_("OneHalf"));
+                       os << _("OneHalf");
                        break;
                case Spacing::Double:
-                       os << to_utf8(_("Double"));
+                       os << _("Double");
                        break;
                case Spacing::Other:
-                       os << to_utf8(_("Other (")) << spacing.getValueAsString() << ')';
+                       os << _("Other (") << from_ascii(spacing.getValueAsString()) << ')';
                        break;
                case Spacing::Default:
                        // should never happen, do nothing
@@ -2365,11 +2363,11 @@ string LyXText::currentState(LCursor & cur)
        }
 
 #ifdef DEVEL_VERSION
-       os << to_utf8(_(", Inset: ")) << &cur.inset();
-       os << to_utf8(_(", Paragraph: ")) << cur.pit();
-       os << to_utf8(_(", Id: ")) << par.id();
-       os << to_utf8(_(", Position: ")) << cur.pos();
-       os << to_utf8(_(", Boundary: ")) << cur.boundary();
+       os << _(", Inset: ") << &cur.inset();
+       os << _(", Paragraph: ") << cur.pit();
+       os << _(", Id: ") << par.id();
+       os << _(", Position: ") << cur.pos();
+       os << _(", Boundary: ") << cur.boundary();
 //     Row & row = cur.textRow();
 //     os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos());
 #endif