mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
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
This commit is contained in:
parent
49b753f603
commit
c6f0c8d0b6
@ -721,7 +721,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_FONT_STATE:
|
case LFUN_FONT_STATE:
|
||||||
cur.message(from_utf8(cur.currentState()));
|
cur.message(cur.currentState());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_BOOKMARK_SAVE:
|
case LFUN_BOOKMARK_SAVE:
|
||||||
|
@ -35,7 +35,8 @@ bool operator==(Author const & l, Author const & r)
|
|||||||
|
|
||||||
std::ostream & operator<<(std::ostream & os, Author const & a)
|
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;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +44,9 @@ std::istream & operator>>(std::istream & is, Author & a)
|
|||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
getline(is, s);
|
getline(is, s);
|
||||||
a.name_ = trim(token(s, '\"', 1));
|
// FIXME UNICODE
|
||||||
a.email_ = trim(token(s, '\"', 2));
|
a.name_ = from_utf8(trim(token(s, '\"', 1)));
|
||||||
|
a.email_ = from_utf8(trim(token(s, '\"', 2)));
|
||||||
return is;
|
return is;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
src/author.h
15
src/author.h
@ -12,9 +12,10 @@
|
|||||||
#ifndef AUTHOR_H
|
#ifndef AUTHOR_H
|
||||||
#define AUTHOR_H
|
#define AUTHOR_H
|
||||||
|
|
||||||
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
@ -24,23 +25,23 @@ class Author {
|
|||||||
public:
|
public:
|
||||||
Author() {}
|
Author() {}
|
||||||
|
|
||||||
Author(std::string const & name, std::string const & email)
|
Author(docstring const & name, docstring const & email)
|
||||||
: name_(name), email_(email) {}
|
: name_(name), email_(email) {}
|
||||||
|
|
||||||
std::string const name() const {
|
docstring const name() const {
|
||||||
return name_;
|
return name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const email() const {
|
docstring const email() const {
|
||||||
return email_;
|
return email_;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend std::istream & operator>>(std::istream & os, Author & a);
|
friend std::istream & operator>>(std::istream & os, Author & a);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string name_;
|
docstring name_;
|
||||||
|
|
||||||
std::string email_;
|
docstring email_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -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 it = bstore.begin();
|
||||||
BufferStorage::iterator end = bstore.end();
|
BufferStorage::iterator end = bstore.end();
|
||||||
|
@ -12,9 +12,10 @@
|
|||||||
#ifndef BUFFER_LIST_H
|
#ifndef BUFFER_LIST_H
|
||||||
#define BUFFER_LIST_H
|
#define BUFFER_LIST_H
|
||||||
|
|
||||||
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ public:
|
|||||||
Buffer * previous(Buffer const *) const;
|
Buffer * previous(Buffer const *) const;
|
||||||
|
|
||||||
/// reset current author for all buffers
|
/// 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:
|
private:
|
||||||
/// ask to save a buffer on quit, returns false if should cancel
|
/// ask to save a buffer on quit, returns false if should cancel
|
||||||
|
@ -261,7 +261,8 @@ BufferParams::Impl::Impl()
|
|||||||
: defskip(VSpace::MEDSKIP)
|
: defskip(VSpace::MEDSKIP)
|
||||||
{
|
{
|
||||||
// set initial author
|
// 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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1203,18 +1203,18 @@ docstring LCursor::selectionAsString(bool label) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string LCursor::currentState()
|
docstring LCursor::currentState()
|
||||||
{
|
{
|
||||||
if (inMathed()) {
|
if (inMathed()) {
|
||||||
odocstringstream os;
|
odocstringstream os;
|
||||||
info(os);
|
info(os);
|
||||||
return to_utf8(os.str());
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inTexted())
|
if (inTexted())
|
||||||
return text()->currentState(*this);
|
return text()->currentState(*this);
|
||||||
|
|
||||||
return string();
|
return docstring();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
|||||||
//
|
//
|
||||||
docstring selectionAsString(bool label) const;
|
docstring selectionAsString(bool label) const;
|
||||||
///
|
///
|
||||||
std::string currentState();
|
docstring currentState();
|
||||||
|
|
||||||
/// auto-correct mode
|
/// auto-correct mode
|
||||||
bool autocorrect() const { return autocorrect_; }
|
bool autocorrect() const { return autocorrect_; }
|
||||||
|
@ -65,12 +65,11 @@ docstring const ControlChanges::getChangeAuthor()
|
|||||||
|
|
||||||
Author const & a(kernel().buffer().params().authors().get(c.author));
|
Author const & a(kernel().buffer().params().authors().get(c.author));
|
||||||
|
|
||||||
// FIXME UNICODE in Author class
|
docstring author(a.name());
|
||||||
docstring author(from_utf8(a.name()));
|
|
||||||
|
|
||||||
if (!a.email().empty()) {
|
if (!a.email().empty()) {
|
||||||
author += " (";
|
author += " (";
|
||||||
author += from_utf8(a.email());
|
author += a.email();
|
||||||
author += ")";
|
author += ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ string const ControlCommandBuffer::historyDown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const ControlCommandBuffer::getCurrentState() const
|
docstring const ControlCommandBuffer::getCurrentState() const
|
||||||
{
|
{
|
||||||
return lv_.view()->cursor().currentState();
|
return lv_.view()->cursor().currentState();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
#ifndef CONTROLCOMMANDBUFFER_H
|
#ifndef CONTROLCOMMANDBUFFER_H
|
||||||
#define CONTROLCOMMANDBUFFER_H
|
#define CONTROLCOMMANDBUFFER_H
|
||||||
|
|
||||||
#include <string>
|
#include "support/docstring.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public:
|
|||||||
std::string const historyDown();
|
std::string const historyDown();
|
||||||
|
|
||||||
/// return the font and depth in the active BufferView as a message.
|
/// 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
|
/// return the possible completions
|
||||||
std::vector<std::string> const completions(std::string const & prefix,
|
std::vector<std::string> const completions(std::string const & prefix,
|
||||||
|
@ -65,7 +65,8 @@ void ControlPrefs::dispatchParams()
|
|||||||
kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
|
kernel().dispatch(FuncRequest(LFUN_LYXRC_APPLY, ss.str()));
|
||||||
|
|
||||||
// FIXME: these need lfuns
|
// 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_;
|
lyx::formats = formats_;
|
||||||
|
|
||||||
|
@ -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-".
|
// When meta-fake key is pressed, show the key sequence so far + "M-".
|
||||||
if (wasMetaKey())
|
if (wasMetaKey())
|
||||||
return to_utf8(keyseq->print() + "M-");
|
return keyseq->print() + "M-";
|
||||||
|
|
||||||
// Else, when a non-complete key sequence is pressed,
|
// Else, when a non-complete key sequence is pressed,
|
||||||
// show the available options.
|
// show the available options.
|
||||||
if (keyseq->length() > 0 && !keyseq->deleted())
|
if (keyseq->length() > 0 && !keyseq->deleted())
|
||||||
return to_utf8(keyseq->printOptions());
|
return keyseq->printOptions();
|
||||||
|
|
||||||
if (!view()->buffer())
|
if (!view()->buffer())
|
||||||
return to_utf8(_("Welcome to LyX!"));
|
return _("Welcome to LyX!");
|
||||||
|
|
||||||
return view()->cursor().currentState();
|
return view()->cursor().currentState();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
void initKeySequences(kb_keymap * kb);
|
void initKeySequences(kb_keymap * kb);
|
||||||
|
|
||||||
/// return the status bar state string
|
/// return the status bar state string
|
||||||
std::string const viewStatusMessage();
|
docstring const viewStatusMessage();
|
||||||
|
|
||||||
///
|
///
|
||||||
void processKeySym(LyXKeySymPtr key, key_modifier::state state);
|
void processKeySym(LyXKeySymPtr key, key_modifier::state state);
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
/// read-write access to individual paragraph
|
/// read-write access to individual paragraph
|
||||||
Paragraph & getPar(pit_type pit) { return pars_[pit]; }
|
Paragraph & getPar(pit_type pit) { return pars_[pit]; }
|
||||||
// Returns the current font and depth as a message.
|
// Returns the current font and depth as a message.
|
||||||
std::string currentState(LCursor & cur);
|
docstring currentState(LCursor & cur);
|
||||||
|
|
||||||
/** returns row near the specified
|
/** returns row near the specified
|
||||||
* y-coordinate in given paragraph (relative to the screen).
|
* y-coordinate in given paragraph (relative to the screen).
|
||||||
|
38
src/text.C
38
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.
|
// Returns the current font and depth as a message.
|
||||||
string LyXText::currentState(LCursor & cur)
|
docstring LyXText::currentState(LCursor & cur)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(this == cur.text());
|
BOOST_ASSERT(this == cur.text());
|
||||||
Buffer & buf = cur.buffer();
|
Buffer & buf = cur.buffer();
|
||||||
Paragraph const & par = cur.paragraph();
|
Paragraph const & par = cur.paragraph();
|
||||||
std::ostringstream os;
|
odocstringstream os;
|
||||||
|
|
||||||
if (buf.params().trackChanges)
|
if (buf.params().trackChanges)
|
||||||
os << "[C] ";
|
os << "[C] ";
|
||||||
@ -2316,10 +2316,11 @@ string LyXText::currentState(LCursor & cur)
|
|||||||
|
|
||||||
if (change.type != Change::UNCHANGED) {
|
if (change.type != Change::UNCHANGED) {
|
||||||
Author const & a = buf.params().authors().get(change.author);
|
Author const & a = buf.params().authors().get(change.author);
|
||||||
os << to_utf8(_("Change: ")) << a.name();
|
os << _("Change: ") << a.name();
|
||||||
if (!a.email().empty())
|
if (!a.email().empty())
|
||||||
os << " (" << a.email() << ")";
|
os << " (" << a.email() << ")";
|
||||||
os << to_utf8(_(" at ")) << ctime(&change.changetime);
|
// FIXME ctime is english, we should translate that
|
||||||
|
os << _(" at ") << ctime(&change.changetime);
|
||||||
os << " : ";
|
os << " : ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2329,34 +2330,31 @@ string LyXText::currentState(LCursor & cur)
|
|||||||
LyXFont font = real_current_font;
|
LyXFont font = real_current_font;
|
||||||
font.reduce(buf.params().getFont());
|
font.reduce(buf.params().getFont());
|
||||||
|
|
||||||
// avoid to_utf8(_(...)) re-entrance problem
|
// FIXME UNICODE
|
||||||
string const s = font.stateText(&buf.params());
|
os << bformat(_("Font: %1$s"), from_utf8(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)));
|
|
||||||
|
|
||||||
// The paragraph depth
|
// The paragraph depth
|
||||||
int depth = cur.paragraph().getDepth();
|
int depth = cur.paragraph().getDepth();
|
||||||
if (depth > 0)
|
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
|
// The paragraph spacing, but only if different from
|
||||||
// buffer spacing.
|
// buffer spacing.
|
||||||
Spacing const & spacing = par.params().spacing();
|
Spacing const & spacing = par.params().spacing();
|
||||||
if (!spacing.isDefault()) {
|
if (!spacing.isDefault()) {
|
||||||
os << to_utf8(_(", Spacing: "));
|
os << _(", Spacing: ");
|
||||||
switch (spacing.getSpace()) {
|
switch (spacing.getSpace()) {
|
||||||
case Spacing::Single:
|
case Spacing::Single:
|
||||||
os << to_utf8(_("Single"));
|
os << _("Single");
|
||||||
break;
|
break;
|
||||||
case Spacing::Onehalf:
|
case Spacing::Onehalf:
|
||||||
os << to_utf8(_("OneHalf"));
|
os << _("OneHalf");
|
||||||
break;
|
break;
|
||||||
case Spacing::Double:
|
case Spacing::Double:
|
||||||
os << to_utf8(_("Double"));
|
os << _("Double");
|
||||||
break;
|
break;
|
||||||
case Spacing::Other:
|
case Spacing::Other:
|
||||||
os << to_utf8(_("Other (")) << spacing.getValueAsString() << ')';
|
os << _("Other (") << from_ascii(spacing.getValueAsString()) << ')';
|
||||||
break;
|
break;
|
||||||
case Spacing::Default:
|
case Spacing::Default:
|
||||||
// should never happen, do nothing
|
// should never happen, do nothing
|
||||||
@ -2365,11 +2363,11 @@ string LyXText::currentState(LCursor & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEVEL_VERSION
|
#ifdef DEVEL_VERSION
|
||||||
os << to_utf8(_(", Inset: ")) << &cur.inset();
|
os << _(", Inset: ") << &cur.inset();
|
||||||
os << to_utf8(_(", Paragraph: ")) << cur.pit();
|
os << _(", Paragraph: ") << cur.pit();
|
||||||
os << to_utf8(_(", Id: ")) << par.id();
|
os << _(", Id: ") << par.id();
|
||||||
os << to_utf8(_(", Position: ")) << cur.pos();
|
os << _(", Position: ") << cur.pos();
|
||||||
os << to_utf8(_(", Boundary: ")) << cur.boundary();
|
os << _(", Boundary: ") << cur.boundary();
|
||||||
// Row & row = cur.textRow();
|
// Row & row = cur.textRow();
|
||||||
// os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos());
|
// os << bformat(_(", Row b:%1$d e:%2$d"), row.pos(), row.endpos());
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user