aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2016-09-07 20:42:46 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2016-09-07 20:42:46 (GMT)
commit50c656517729bd6e2cbc21d20c7b640df6948eef (patch)
tree3d6cb9bbb941c7d19801c2dde5d05b5b95b4746e
parentf0b747a14be6edd90578dfed6e05e13154d26448 (diff)
CHANGELOG: support --encoding together with --stdin
BUG: 364169
-rw-r--r--kate/kateapp.cpp6
-rw-r--r--kate/kateapp.h3
-rw-r--r--kate/kateappadaptor.cpp4
-rw-r--r--kate/kateappadaptor.h3
-rw-r--r--kate/main.cpp1
-rw-r--r--kwrite/main.cpp4
6 files changed, 14 insertions, 7 deletions
diff --git a/kate/kateapp.cpp b/kate/kateapp.cpp
index 31fe66c..2c6589e 100644
--- a/kate/kateapp.cpp
+++ b/kate/kateapp.cpp
@@ -200,7 +200,7 @@ bool KateApp::startupKate()
text.append(line + QLatin1Char('\n'));
} while (!line.isNull());
- openInput(text);
+ openInput(text, codec_name);
} else if (doc) {
activeKateMainWindow()->viewManager()->activateView(doc);
}
@@ -310,9 +310,9 @@ bool KateApp::setCursor(int line, int column)
return true;
}
-bool KateApp::openInput(const QString &text)
+bool KateApp::openInput(const QString &text, const QString &encoding)
{
- activeKateMainWindow()->viewManager()->openUrl(QUrl(), QString(), true);
+ activeKateMainWindow()->viewManager()->openUrl(QUrl(), encoding, true);
if (!activeKateMainWindow()->viewManager()->activeView()) {
return false;
diff --git a/kate/kateapp.h b/kate/kateapp.h
index 692614e..0d24d23 100644
--- a/kate/kateapp.h
+++ b/kate/kateapp.h
@@ -208,9 +208,10 @@ public:
* helper to handle stdin input
* open a new document/view, fill it with the text given
* @param text text to fill in the new doc/view
+ * @param encoding encoding to set for the document, if any
* @return success
*/
- bool openInput(const QString &text);
+ bool openInput(const QString &text, const QString &encoding);
//
// KTextEditor::Application interface, called by wrappers via invokeMethod
diff --git a/kate/kateappadaptor.cpp b/kate/kateappadaptor.cpp
index 57fcbe2..9477af0 100644
--- a/kate/kateappadaptor.cpp
+++ b/kate/kateappadaptor.cpp
@@ -96,9 +96,9 @@ bool KateAppAdaptor::setCursor(int line, int column)
return m_app->setCursor(line, column);
}
-bool KateAppAdaptor::openInput(QString text)
+bool KateAppAdaptor::openInput(QString text, QString encoding)
{
- return m_app->openInput(text);
+ return m_app->openInput(text, encoding);
}
bool KateAppAdaptor::activateSession(QString session)
diff --git a/kate/kateappadaptor.h b/kate/kateappadaptor.h
index be04c9f..b2de22c 100644
--- a/kate/kateappadaptor.h
+++ b/kate/kateappadaptor.h
@@ -82,9 +82,10 @@ public Q_SLOTS:
* helper to handle stdin input
* open a new document/view, fill it with the text given
* @param text text to fill in the new doc/view
+ * @param encoding encoding to set for the document, if any
* @return success
*/
- bool openInput(QString text);
+ bool openInput(QString text, QString encoding);
/**
* activate a given session
diff --git a/kate/main.cpp b/kate/main.cpp
index 18cafc5..7e01690 100644
--- a/kate/main.cpp
+++ b/kate/main.cpp
@@ -431,6 +431,7 @@ int main(int argc, char **argv)
QList<QVariant> dbusargs;
dbusargs.append(text);
+ dbusargs.append(codec ? QString::fromLatin1(codec->name()) : QString());
m.setArguments(dbusargs);
QDBusConnection::sessionBus().call(m);
diff --git a/kwrite/main.cpp b/kwrite/main.cpp
index dab9439..edca82a 100644
--- a/kwrite/main.cpp
+++ b/kwrite/main.cpp
@@ -226,6 +226,10 @@ extern "C" Q_DECL_EXPORT int main(int argc, char **argv)
KTextEditor::Document *doc = t->view()->document();
if (doc) {
+ // remember codec in document, e.g. to show the right one
+ if (codec) {
+ doc->setEncoding(QString::fromLatin1(codec->name()));
+ }
doc->setText(text);
}
}