Mercurial > hg > octave-max
changeset 13637:367919252ed6
Integrated kprocess_p in kprocess.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 22 Aug 2011 22:15:00 +0200 |
parents | 6099d4015aae |
children | c6574e6cc8a6 |
files | gui/src/OctaveTerminal.cpp gui/src/OctaveTerminal.h gui/src/terminal/kprocess.cpp gui/src/terminal/kprocess.h gui/src/terminal/kprocess_p.h |
diffstat | 5 files changed, 30 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/OctaveTerminal.cpp +++ b/gui/src/OctaveTerminal.cpp @@ -43,6 +43,7 @@ OctaveTerminal::construct () { setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); + m_textCodec = QTextCodec::codecForLocale (); } void @@ -77,27 +78,27 @@ return; case Qt::Key_Up: - m_shellProcess->sendData ("\EOA"); + m_shellProcess->sendData ("\033OA"); break; case Qt::Key_Down: - m_shellProcess->sendData ("\EOB"); + m_shellProcess->sendData ("\033OB"); break; case Qt::Key_Right: - m_shellProcess->sendData ("\EOC"); + m_shellProcess->sendData ("\033OC"); break; case Qt::Key_Left: - m_shellProcess->sendData ("\EOF"); + m_shellProcess->sendData ("\033OF"); break; case Qt::Key_Backslash: - m_shellProcess->sendData ("\008"); + m_shellProcess->sendData ("\03308"); break; default: - m_shellProcess->sendData (keyEvent->text ().toLocal8Bit ()); + m_shellProcess->sendData (keyEvent->text ().toUtf8 ()); break; } @@ -192,19 +193,6 @@ else textToSend += _codec->fromUnicode (event->text ()); - sendData (textToSend.constData (), textToSend.length ()); - } - else - { - // print an error message to the terminal if no key translator has been - // set - QString translatorError = QString ("No keyboard translator available. " - "The information needed to convert key presses " - "into characters to send to the terminal " - "is missing."); - reset (); - receiveData (translatorError.toAscii ().constData (), - translatorError.count ()); }*/ keyEvent->accept (); }
--- a/gui/src/OctaveTerminal.h +++ b/gui/src/OctaveTerminal.h @@ -19,6 +19,7 @@ #ifndef OCTAVETERMINAL_H #define OCTAVETERMINAL_H #include <QPlainTextEdit> +#include <QTextCodec> #include "Pty.h" class OctaveTerminal:public QPlainTextEdit @@ -42,6 +43,7 @@ private: void construct (); + QTextCodec *m_textCodec; Pty *m_shellProcess; }; #endif // OCTAVETERMINAL_H
--- a/gui/src/terminal/kprocess.cpp +++ b/gui/src/terminal/kprocess.cpp @@ -19,41 +19,18 @@ Boston, MA 02110-1301, USA. */ -#include "kprocess_p.h" +#include "kprocess.h" #include <qfile.h> - -#ifdef Q_OS_WIN -#include <windows.h> -#else #include <unistd.h> #include <errno.h> -#endif -#ifndef Q_OS_WIN #define STD_OUTPUT_HANDLE 1 #define STD_ERROR_HANDLE 2 -#endif - -#ifdef _WIN32_WCE -#include <stdio.h> -#endif void KProcessPrivate::writeAll (const QByteArray & buf, int fd) { -#ifdef Q_OS_WIN -#ifndef _WIN32_WCE - HANDLE h = GetStdHandle (fd); - if (h) - { - DWORD wr; - WriteFile (h, buf.data (), buf.size (), &wr, 0); - } -#else - fwrite (buf.data (), 1, buf.size (), (FILE *) fd); -#endif -#else int off = 0; do { @@ -69,7 +46,6 @@ } } while (off < buf.size ()); -#endif } void @@ -86,21 +62,13 @@ void KProcessPrivate::_k_forwardStdout () { -#ifndef _WIN32_WCE forwardStd (KProcess::StandardOutput, STD_OUTPUT_HANDLE); -#else - forwardStd (KProcess::StandardOutput, (int) stdout); -#endif } void KProcessPrivate::_k_forwardStderr () { -#ifndef _WIN32_WCE forwardStd (KProcess::StandardError, STD_ERROR_HANDLE); -#else - forwardStd (KProcess::StandardError, (int) stderr); -#endif } ///////////////////////////// @@ -214,9 +182,6 @@ d->prog = exe; d->args = args; -#ifdef Q_OS_WIN - setNativeArguments (QString ()); -#endif } void @@ -227,9 +192,6 @@ Q_ASSERT (!argv.isEmpty ()); d->args = argv; d->prog = d->args.takeFirst (); -#ifdef Q_OS_WIN - setNativeArguments (QString ()); -#endif } KProcess & KProcess::operator<< (const QString & arg) @@ -261,9 +223,6 @@ d->prog.clear (); d->args.clear (); -#ifdef Q_OS_WIN - setNativeArguments (QString ()); -#endif } QStringList @@ -348,9 +307,5 @@ int KProcess::pid () const { -#ifdef Q_OS_UNIX return (int) QProcess::pid (); -#else - return QProcess::pid ()? QProcess::pid ()->dwProcessId : 0; -#endif }
--- a/gui/src/terminal/kprocess.h +++ b/gui/src/terminal/kprocess.h @@ -292,8 +292,26 @@ using QProcess::processChannelMode; Q_PRIVATE_SLOT (d_func (), void _k_forwardStdout ()) - Q_PRIVATE_SLOT (d_func (), void _k_forwardStderr ())}; + Q_PRIVATE_SLOT (d_func (), void _k_forwardStderr ()) +}; -#include "kprocess_p.h" +class KProcessPrivate +{ +Q_DECLARE_PUBLIC (KProcess) protected: + KProcessPrivate ():openMode (QIODevice::ReadWrite) + { + } + void writeAll (const QByteArray & buf, int fd); + void forwardStd (KProcess::ProcessChannel good, int fd); + void _k_forwardStdout (); + void _k_forwardStderr (); + + QString prog; + QStringList args; + KProcess::OutputChannelMode outputChannelMode; + QIODevice::OpenMode openMode; + + KProcess *q_ptr; +}; #endif
--- a/gui/src/terminal/kprocess_p.h +++ b/gui/src/terminal/kprocess_p.h @@ -21,28 +21,7 @@ #ifndef KPROCESS_P_H #define KPROCESS_P_H -class KProcess; -class KProcessPrivate; -#include "kprocess.h" -class KProcessPrivate -{ -Q_DECLARE_PUBLIC (KProcess) protected: - KProcessPrivate ():openMode (QIODevice::ReadWrite) - { - } - void writeAll (const QByteArray & buf, int fd); - void forwardStd (KProcess::ProcessChannel good, int fd); - void _k_forwardStdout (); - void _k_forwardStderr (); - - QString prog; - QStringList args; - KProcess::OutputChannelMode outputChannelMode; - QIODevice::OpenMode openMode; - - KProcess *q_ptr; -}; #endif