[prev in list] [next in list] [prev in thread] [next in thread]
List: konsole-devel
Subject: [Konsole-devel] [PATCH] Windows port
From: Patrick Spendrin <ps_ml () gmx ! de>
Date: 2009-01-31 5:29:12
Message-ID: 4983E1A8.70507 () gmx ! de
[Download RAW message or body]
Hello,
After getting many questions about the status of konsole on windows, I
just spoke with ossi about how to port konsole to windows.
As he pointed out, I replaced KPtyProcess with KProcess - this runs
rather well until now as the codebase seems to be rather clean.
I still have the following problems though:
- some keys are not understood correctly; I am still investigating this
and will change the windows.keytab later.
- the tests are not compiled. The main problem here is that the relevant
classes are not exported from a library but are included directly in
either the kpart or in the konsole executable (it might be possible
though to make the kpart a library).
Now to my questions:
Can you please review and comment on the patch?
I would prefer to backport the patch too, since it is rather valuable
for us.
regards,
Patrick
--
web: http://windows.kde.org
mailing list: kde-windows@kde.org
irc: #kde-windows (irc.freenode.net)
["0138-konsole-windows.diff" (text/x-patch)]
Index: data/keyboard-layouts/CMakeLists.txt
===================================================================
--- data/keyboard-layouts/CMakeLists.txt (revision 918271)
+++ data/keyboard-layouts/CMakeLists.txt (working copy)
@@ -1,10 +1,18 @@
-install( FILES
- default.keytab
- linux.keytab
- # DON'T INSTALL VT420 KEYBOARD LAYOUT - IT DOESN'T WORK WITH
- # ACTUAL VT420 SYSTEMS - EITHER RENAME IT OR IMPROVE KONSOLE
- # vt420pc.keytab
- solaris.keytab
- README.KeyTab
- DESTINATION
- ${DATA_INSTALL_DIR}/konsole )
+if(NOT WIN32)
+ install( FILES
+ default.keytab
+ linux.keytab
+ # DON'T INSTALL VT420 KEYBOARD LAYOUT - IT DOESN'T WORK WITH
+ # ACTUAL VT420 SYSTEMS - EITHER RENAME IT OR IMPROVE KONSOLE
+ # vt420pc.keytab
+ solaris.keytab
+ README.KeyTab
+ DESTINATION
+ ${DATA_INSTALL_DIR}/konsole )
+else(NOT WIN32)
+ install( FILES
+ windows.keytab
+ README.KeyTab
+ DESTINATION
+ ${DATA_INSTALL_DIR}/konsole )
+endif(NOT WIN32)
Index: data/keyboard-layouts/windows.keytab
===================================================================
--- data/keyboard-layouts/windows.keytab (revision 0)
+++ data/keyboard-layouts/windows.keytab (revision 0)
@@ -0,0 +1,61 @@
+# [windows.keytab] Konsole Keyboard Table (Windows console keys)
+#
+# --------------------------------------------------------------
+
+# NOT TESTED, MAY NEED SOME CLEANUPS
+keyboard "Windows cmd"
+
+# --------------------------------------------------------------
+#
+# This configuration table allows to customize the
+# meaning of the keys.
+#
+# The syntax is that each entry has the form :
+#
+# "key" Keyname { ("+"|"-") Modename } ":" (String|Operation)
+#
+# Keynames are those defined in <qnamespace.h> with the
+# "Qt::Key_" removed. (We'd better insert the list here)
+#
+# Mode names are :
+#
+# - Shift
+# - Alt
+# - Control
+#
+# The VT100 emulation has two modes that can affect the
+# sequences emitted by certain keys. These modes are
+# under control of the client program.
+#
+# - Newline : effects Return and Enter key.
+# - Application : effects Up and Down key.
+#
+# - Ansi : effects Up and Down key (This is for VT52, really).
+#
+# Operations are
+#
+# - scrollUpLine
+# - scrollUpPage
+# - scrollDownLine
+# - scrollDownPage
+#
+# - emitSelection
+#
+# If the key is not found here, the text of the
+# key event as provided by Qt is emitted, possibly
+# preceeded by ESC if the Alt key is pressed.
+#
+# --------------------------------------------------------------
+
+key Tab : "\t"
+
+key Return-NewLine : "\r\n"
+
+#----------------------------------------------------------
+
+# keypad characters as offered by Qt
+# cannot be recognized as such.
+
+#----------------------------------------------------------
+
+# Following other strings as emitted by konsole.
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt (revision 918271)
+++ src/CMakeLists.txt (working copy)
@@ -111,6 +111,8 @@
RemoteConnectionDialog.ui
)
+ kde4_add_app_icon(konsole_KDEINIT_SRCS \
"${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/utilities-terminal.png") +
kde4_add_kdeinit_executable( konsole ${konsole_KDEINIT_SRCS})
target_link_libraries(kdeinit_konsole ${konsole_LIBS})
Index: src/Profile.h
===================================================================
--- src/Profile.h (revision 918271)
+++ src/Profile.h (working copy)
@@ -61,7 +61,11 @@
* Profiles can be loaded from disk using ProfileReader instances
* and saved to disk using ProfileWriter instances.
*/
+#ifndef Q_WS_WIN
class KDE_EXPORT Profile : public QSharedData
+#else
+class Profile : public QSharedData
+#endif
{
friend class KDE4ProfileReader;
Index: src/Pty.cpp
===================================================================
--- src/Pty.cpp (revision 918271)
+++ src/Pty.cpp (working copy)
@@ -26,8 +26,10 @@
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
+#ifndef Q_WS_WIN
#include <termios.h>
#include <signal.h>
+#endif
// Qt
#include <QtCore/QStringList>
@@ -36,8 +38,10 @@
#include <KStandardDirs>
#include <KLocale>
#include <KDebug>
+#ifndef Q_WS_WIN
#include <KPty>
#include <KPtyDevice>
+#endif
#include <kde_file.h>
using namespace Konsole;
@@ -47,8 +51,10 @@
_windowColumns = cols;
_windowLines = lines;
+#ifndef Q_WS_WIN
if (pty()->masterFd() >= 0)
pty()->setWinSize(lines, cols);
+#endif
}
QSize Pty::windowSize() const
{
@@ -59,6 +65,7 @@
{
_xonXoff = enable;
+#ifndef Q_WS_WIN
if (pty()->masterFd() >= 0)
{
struct ::termios ttmode;
@@ -70,9 +77,11 @@
if (!pty()->tcSetAttr(&ttmode))
kWarning() << "Unable to set terminal attributes.";
}
+#endif
}
bool Pty::flowControlEnabled() const
{
+#ifndef Q_WS_WIN
if (pty()->masterFd() >= 0)
{
struct ::termios ttmode;
@@ -81,6 +90,7 @@
ttmode.c_iflag & IXON;
}
kWarning() << "Unable to get flow control status, terminal not connected.";
+#endif
return false;
}
@@ -107,6 +117,7 @@
{
_eraseChar = erase;
+#ifndef Q_WS_WIN
if (pty()->masterFd() >= 0)
{
struct ::termios ttmode;
@@ -115,10 +126,12 @@
if (!pty()->tcSetAttr(&ttmode))
kWarning() << "Unable to set terminal attributes.";
}
+#endif
}
char Pty::erase() const
{
+#ifndef Q_WS_WIN
if (pty()->masterFd() >= 0)
{
struct ::termios ttyAttributes;
@@ -126,6 +139,7 @@
return ttyAttributes.c_cc[VERASE];
}
+#endif
return _eraseChar;
}
@@ -187,6 +201,7 @@
// BR:149300
setEnv("LANGUAGE",QString(),false /* do not overwrite existing value if any */);
+#ifndef Q_WS_WIN
setUseUtmp(addToUtmp);
struct ::termios ttmode;
@@ -209,6 +224,7 @@
kWarning() << "Unable to set terminal attributes.";
pty()->setWinSize(_windowLines, _windowColumns);
+#endif
KProcess::start();
@@ -220,24 +236,44 @@
void Pty::setWriteable(bool writeable)
{
+#ifndef Q_WS_WIN
KDE_struct_stat sbuf;
KDE_stat(pty()->ttyName(), &sbuf);
if (writeable)
chmod(pty()->ttyName(), sbuf.st_mode | S_IWGRP);
else
chmod(pty()->ttyName(), sbuf.st_mode & ~(S_IWGRP|S_IWOTH));
+#else
+ Q_UNUSED(writeable);
+#endif
}
Pty::Pty(int masterFd, QObject* parent)
+#ifndef Q_WS_WIN
: KPtyProcess(masterFd,parent)
+#else
+ : KProcess(parent)
+#endif
{
init();
}
Pty::Pty(QObject* parent)
+#ifndef Q_WS_WIN
: KPtyProcess(parent)
+#else
+ : KProcess(parent)
+#endif
{
init();
}
+
+#ifdef Q_WS_WIN
+KProcess* Pty::pty()
+{
+ return this;
+}
+#endif
+
void Pty::init()
{
_windowColumns = 0;
@@ -247,7 +283,11 @@
_utf8 =true;
connect(pty(), SIGNAL(readyRead()) , this , SLOT(dataReceived()));
+#ifndef Q_WS_WIN
setPtyChannels(KPtyProcess::AllChannels);
+#else
+ setOutputChannelMode(SeparateChannels);
+#endif
}
Pty::~Pty()
@@ -264,6 +304,9 @@
kWarning() << "Pty::doSendJobs - Could not send input data to terminal \
process."; return;
}
+#ifdef Q_WS_WIN
+ emit receivedData(data,length);
+#endif
}
void Pty::dataReceived()
@@ -285,7 +328,11 @@
int Pty::foregroundProcessGroup() const
{
+#ifndef Q_WS_WIN
int pid = tcgetpgrp(pty()->masterFd());
+#else
+ int pid = KProcess::pid();
+#endif
if ( pid != -1 )
{
@@ -297,6 +344,7 @@
void Pty::setupChildProcess()
{
+#ifndef Q_WS_WIN
KPtyProcess::setupChildProcess();
// reset all signal handlers
@@ -309,6 +357,7 @@
action.sa_flags = 0;
for (int signal=1;signal < NSIG; signal++)
sigaction(signal,&action,0L);
+#endif
}
Index: src/Pty.h
===================================================================
--- src/Pty.h (revision 918271)
+++ src/Pty.h (working copy)
@@ -30,8 +30,12 @@
#include <QtCore/QSize>
// KDE
+#ifndef Q_WS_WIN
#include <KPtyProcess>
#include <kdemacros.h>
+#else
+#include <KProcess>
+#endif
namespace Konsole
{
@@ -49,7 +53,11 @@
* To start the terminal process, call the start() method
* with the program name and appropriate arguments.
*/
+#ifndef Q_WS_WIN
class KDE_EXPORT Pty: public KPtyProcess
+#else
+class Pty: public KProcess
+#endif
{
Q_OBJECT
@@ -141,6 +149,9 @@
*/
int foregroundProcessGroup() const;
+#ifdef Q_WS_WIN
+ KProcess* pty();
+#endif
public slots:
/**
Index: src/Session.cpp
===================================================================
--- src/Session.cpp (revision 918271)
+++ src/Session.cpp (working copy)
@@ -47,7 +47,9 @@
#include <KRun>
#include <kshell.h>
#include <KStandardDirs>
+#ifndef Q_WS_WIN
#include <KPtyDevice>
+#endif
#include <KUrl>
// Konsole
@@ -307,9 +309,14 @@
if ( exec.isEmpty() )
exec = qgetenv("SHELL");
if ( exec.isEmpty() )
+#ifndef Q_WS_WIN
exec = "/bin/sh";
+#else
+ exec = "C:/WINDOWS/system32/cmd.exe";
+#endif
exec = KRun::binaryName(exec, false);
+#ifndef Q_WS_WIN
exec = KShell::tildeExpand(exec);
QString pexec = KGlobal::dirs()->findExe(exec);
if ( pexec.isEmpty() )
@@ -317,7 +324,7 @@
kError() << i18n("Could not find binary: ") << exec;
return QString();
}
-
+#endif
return exec;
}
@@ -349,7 +356,11 @@
}
const int CHOICE_COUNT = 3;
+#ifndef Q_WS_WIN
QString programs[CHOICE_COUNT] = {_program,qgetenv("SHELL"),"/bin/sh"};
+#else
+ QString programs[CHOICE_COUNT] = \
{_program,qgetenv("SHELL"),"C:/WINDOWS/system32/cmd.exe"}; +#endif
QString exec;
int choice = 0;
while (choice < CHOICE_COUNT)
@@ -395,7 +406,7 @@
int result = _shellProcess->start(exec,
arguments,
_environment << backgroundColorHint,
- windowId(),
+ (ulong)windowId(),
_addToUtmp,
dbusService,
(QLatin1String("/Sessions/") +
Index: src/Session.h
===================================================================
--- src/Session.h (revision 918271)
+++ src/Session.h (working copy)
@@ -58,7 +58,11 @@
* or send input to the program in the terminal in the form of keypresses and mouse
* activity.
*/
+#ifndef Q_WS_WIN
class KDE_EXPORT Session : public QObject
+#else
+class Session : public QObject
+#endif
{
Q_OBJECT
Index: src/tests/CMakeLists.txt
===================================================================
--- src/tests/CMakeLists.txt (revision 918271)
+++ src/tests/CMakeLists.txt (working copy)
@@ -1,3 +1,4 @@
+if(NOT WIN32)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
include_directories( ${KDE4_KPTY_INCLUDES} ${KDE4_KPARTS_INCLUDES} \
${QT_QTTEST_INCLUDES})
@@ -11,3 +12,4 @@
kde4_add_unit_test(SessionManagerTest SessionManagerTest.cpp)
target_link_libraries(SessionManagerTest ${KONSOLE_TEST_LIBS})
+endif(NOT WIN32)
_______________________________________________
konsole-devel mailing list
konsole-devel@kde.org
https://mail.kde.org/mailman/listinfo/konsole-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic