From: Georg Baum Date: Thu, 21 Dec 2006 13:58:28 +0000 (+0000) Subject: convert author names and status messages to docstring X-Git-Tag: 1.6.10~11476 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c6f0c8d0b60029a24e1ecb2f8aaf48aeae4405e5;p=lyx.git convert author names and status messages to docstring git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16363 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.C b/src/BufferView.C index 7cda307f1c..cd8e79892a 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -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: diff --git a/src/author.C b/src/author.C index 60817affe0..ea05ccd83d 100644 --- a/src/author.C +++ b/src/author.C @@ -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; } diff --git a/src/author.h b/src/author.h index 9f2a0c7573..bf84737130 100644 --- a/src/author.h +++ b/src/author.h @@ -12,9 +12,10 @@ #ifndef AUTHOR_H #define AUTHOR_H +#include "support/docstring.h" + #include #include -#include 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_; }; diff --git a/src/bufferlist.C b/src/bufferlist.C index 1d14c077d3..f33b00e2c3 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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(); diff --git a/src/bufferlist.h b/src/bufferlist.h index 161f95b7f5..350e5fc7da 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -12,9 +12,10 @@ #ifndef BUFFER_LIST_H #define BUFFER_LIST_H +#include "support/docstring.h" + #include -#include #include @@ -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 diff --git a/src/bufferparams.C b/src/bufferparams.C index 856fa185ee..7e0a3d1613 100644 --- a/src/bufferparams.C +++ b/src/bufferparams.C @@ -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))); } diff --git a/src/cursor.C b/src/cursor.C index 4dacb3674a..5bccc4d13b 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -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(); } diff --git a/src/cursor.h b/src/cursor.h index ed3fdef34e..b8f3336b50 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -91,7 +91,7 @@ public: // docstring selectionAsString(bool label) const; /// - std::string currentState(); + docstring currentState(); /// auto-correct mode bool autocorrect() const { return autocorrect_; } diff --git a/src/frontends/controllers/ControlChanges.C b/src/frontends/controllers/ControlChanges.C index 5c309caa7b..9c67cc57c5 100644 --- a/src/frontends/controllers/ControlChanges.C +++ b/src/frontends/controllers/ControlChanges.C @@ -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 += ")"; } diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index e6d0d7ef16..ef4bcb6a28 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -79,7 +79,7 @@ string const ControlCommandBuffer::historyDown() } -string const ControlCommandBuffer::getCurrentState() const +docstring const ControlCommandBuffer::getCurrentState() const { return lv_.view()->cursor().currentState(); } diff --git a/src/frontends/controllers/ControlCommandBuffer.h b/src/frontends/controllers/ControlCommandBuffer.h index dbc0596348..b1e413411e 100644 --- a/src/frontends/controllers/ControlCommandBuffer.h +++ b/src/frontends/controllers/ControlCommandBuffer.h @@ -14,7 +14,8 @@ #ifndef CONTROLCOMMANDBUFFER_H #define CONTROLCOMMANDBUFFER_H -#include +#include "support/docstring.h" + #include @@ -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 const completions(std::string const & prefix, diff --git a/src/frontends/controllers/ControlPrefs.C b/src/frontends/controllers/ControlPrefs.C index be0cd866e3..5d8c2e2259 100644 --- a/src/frontends/controllers/ControlPrefs.C +++ b/src/frontends/controllers/ControlPrefs.C @@ -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_; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 0be7635e25..f8fe702f07 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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(); } diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 549e778d89..2e36ba19ab 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -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); diff --git a/src/lyxtext.h b/src/lyxtext.h index 38b6e71c68..a908458b03 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -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). diff --git a/src/text.C b/src/text.C index d0fda985ac..cab2ac4135 100644 --- a/src/text.C +++ b/src/text.C @@ -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