[Konsole-devel] konsole to kdelibs ?

Dominique Devriese fritmebufstek at pandora.be
Wed Jun 19 09:05:38 UTC 2002


Hi,
As you may know, i've been working on code to allow programmers to embed
a konsole widget in their own application:
For the moment, this is only possible using the konsole part.  This
approach has some important limitations:
1 you can only embed an interactive shell.  Currently there is no
support for embedding something else than a shell.  Puetzk once made a
patch to fix this ( openURL( "exec://bin/bash" ) would start bash etc.),
but this is not good accepted because of two things:
a) safety: without specific code for checking
browserExtension->URLArgs(), it would be unsafe... This can be fixed
though (using browserExtension and such...)
b) efficiency: if a programmer only wants to show a certain program, and
he starts a konsole part, then that part will open, and start a shell,
then he will call openURL( "exec://..." ), the shell will be killed, the
other program started etc.  Obviously the starting of the shell is
unnecessary...
2 there aren't very much options: e.g. if i want to show only the
output, and prevent the user from typing in the window ( i can imagine
that e.g. apt-get output in kpackage would need this...), this is not
possible. Maybe this could be done by making ReadOnlyPart be
non-interactive, and the other way around, but that is not very clean...

So, i've been working on a solution, and here is my proposal:
1 We move a large part of konsole into kdelibs:
TEPty, TEWidget, TEmulation and related classes.  Not TESession, since
it's too much geared towards the Konsole program.  This will involve
some license changes, but that shouldn't be a large problem...
2 because those classes aren't particularly handy to use, and there are
quite some gotcha's involved ( i've hit some crash situations and such
because of resizeEvents not being handled in time, and the fonts used to
look terrible because I used a wrong font etc. ), we add a class:
KonsoleWidget.  I have the source code for this attached here, it's
meant to provide a nice, clean, easy-to-use, well-documented interface
to the library, and abstract the difficulties of dealing with TEWidget
and such directly, away.  Currently, it's supposed to be used like this: 
KonsoleWidget* w = new KonsoleWidget( some_parent_widget, some_name );
w->setProgram( "/bin/ls" );
w->addArgument( "-l" );
w->show();
w->start();
This is about as easy as i could get it, improvements are of course
welcome, and more options are also very welcome.  Once KonsoleWidget
supports enough features, i think we can port Konsole and KonsolePart to
using it..
Another advantage here is that now Konsole and KonsolePart currently
both statically link with all the TE* classes.  This is a waste of disk
space, and could be solved with the new library...
A nice place to put this seems kdelibs/konsole, but that's of course a
detail.  I don't know what to name the library either, since
libkonsole.la is already taken by the konsole kinit-library...

I'd like to hear your opinions on this, i think this would be usable in
quite a few places (kpackage (currently uses a KTextView, i think... ),
kdevelop (currently has code copied from konsole, iirc... ), some of my
own future plans :), someone recently asked on kde-devel if there was an
easy way to do this etc...)

sjuus
domi

-- 
Dominique Devriese
http://users.pandora.be/frit/domi.gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: konsole_widget.h
Type: text/x-chdr
Size: 2924 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20020619/a62178b9/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: konsole_widget.cpp
Type: text/x-c++src
Size: 5395 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20020619/a62178b9/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20020619/a62178b9/attachment.sig>


More information about the konsole-devel mailing list