mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
X dependency cleanup (2/3)
(inernal|external)LineEnding are only used by the clipboard code. Therefore move them to the Qt helpers, where the current environment is known. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26824 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2759268092
commit
15b49036ed
@ -311,7 +311,7 @@ docstring const GuiClipboard::getAsText() const
|
||||
if (str.isNull())
|
||||
return docstring();
|
||||
|
||||
return internalLineEnding(qstring_to_ucs4(str));
|
||||
return internalLineEnding(str);
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,9 +27,6 @@
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
using support::internalLineEnding;
|
||||
using support::externalLineEnding;
|
||||
|
||||
|
||||
GuiSelection::GuiSelection()
|
||||
: schedule_check_(true),
|
||||
@ -75,7 +72,7 @@ docstring const GuiSelection::get() const
|
||||
if (str.isNull())
|
||||
return docstring();
|
||||
|
||||
return internalLineEnding(qstring_to_ucs4(str));
|
||||
return internalLineEnding(str);
|
||||
}
|
||||
|
||||
|
||||
@ -83,7 +80,7 @@ void GuiSelection::put(docstring const & str)
|
||||
{
|
||||
LYXERR(Debug::SELECTION, "GuiSelection::put: " << to_utf8(str));
|
||||
|
||||
qApp->clipboard()->setText(toqstr(externalLineEnding(str)),
|
||||
qApp->clipboard()->setText(externalLineEnding(str),
|
||||
QClipboard::Selection);
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,27 @@ QStringList texFileList(QString const & filename)
|
||||
return QList<QString>::fromSet(set);
|
||||
}
|
||||
|
||||
QString const externalLineEnding(docstring const & str)
|
||||
{
|
||||
#ifdef Q_WS_MACX
|
||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
||||
return toqstr(subst(str, '\n', '\r'));
|
||||
#elif defined(Q_WS_WIN)
|
||||
// Windows clipboard uses \r\n for lineendings, and we use \n
|
||||
return toqstr(subst(str, from_ascii("\n"), from_ascii("\r\n")));
|
||||
#else
|
||||
return toqstr(str);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
docstring const internalLineEnding(QString const & str)
|
||||
{
|
||||
docstring const s = subst(qstring_to_ucs4(str),
|
||||
from_ascii("\r\n"), from_ascii("\n"));
|
||||
return subst(s, '\r', '\n');
|
||||
}
|
||||
|
||||
|
||||
QString internalPath(const QString & str)
|
||||
{
|
||||
|
@ -96,6 +96,12 @@ void rescanTexStyles();
|
||||
*/
|
||||
QStringList texFileList(QString const & filename);
|
||||
|
||||
/// Convert internal line endings to line endings as expected by the OS
|
||||
QString const externalLineEnding(docstring const & str);
|
||||
|
||||
/// Convert line endings in any formnat to internal line endings
|
||||
docstring const internalLineEnding(QString const & str);
|
||||
|
||||
// wrapper around the docstring versions
|
||||
QString internalPath(QString const &);
|
||||
QString onlyFilename(QString const & str);
|
||||
|
@ -1004,27 +1004,6 @@ int findToken(char const * const str[], string const & search_token)
|
||||
}
|
||||
|
||||
|
||||
docstring const externalLineEnding(docstring const & str)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
// The MAC clipboard uses \r for lineendings, and we use \n
|
||||
return subst(str, '\n', '\r');
|
||||
#elif defined (_WIN32) || (defined (__CYGWIN__) && defined (X_DISPLAY_MISSING))
|
||||
// Windows clipboard uses \r\n for lineendings, and we use \n
|
||||
return subst(str, from_ascii("\n"), from_ascii("\r\n"));
|
||||
#else
|
||||
return str;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
docstring const internalLineEnding(docstring const & str)
|
||||
{
|
||||
docstring const s = subst(str, from_ascii("\r\n"), from_ascii("\n"));
|
||||
return subst(s, '\r', '\n');
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, int arg1)
|
||||
{
|
||||
|
@ -242,13 +242,6 @@ std::string const getStringFromVector(std::vector<std::string> const & vec,
|
||||
/// found, else -1. The last item in \p str must be "".
|
||||
int findToken(char const * const str[], std::string const & search_token);
|
||||
|
||||
/// Convert internal line endings to line endings as expected by the OS
|
||||
docstring const externalLineEnding(docstring const & str);
|
||||
|
||||
/// Convert line endings in any formnat to internal line endings
|
||||
docstring const internalLineEnding(docstring const & str);
|
||||
|
||||
|
||||
template <class Arg1>
|
||||
docstring bformat(docstring const & fmt, Arg1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user