kde Syndicate content

warning: Creating default object from empty value in /www/htdocs/w0065fc9/milianw/modules/taxonomy/taxonomy.pages.inc on line 33.

» PHP support for KDevelop 4 (and eventually Quanta+)

Tue, 03/03/2009 - 00:28

Hello Planet KDE!

I want to give you a little insight on the current state of PHP support in KDevelop4:

Me and Nikolaus Sams (nsams) are working diligently on a plugin for PHP support in playground. It’s somewhat stable, i.e. we fix any crashes we stumble upon, but I would call it Alpha state at most. It may eat your babies so to speak. Yet I’m happy to say that at least one user is already using it for production (hi leinir ;-) ).

implemented PHP support

Well, here’s a (not complete) list of features that are already working. Though I have to warn you: no screenshots included ;-) It’s actually all very similar to the C++ screenies you can see on the web.

sematic highlighting

Let’s start with a feature that only very recently was added for PHP - semantic highlighting. Niko moved some language independent parts of the C++ plugin from KDevelop to KDevplatform and now PHP has the same code highlighting features as C++.

I personally love this feature since it makes it even easier to grasp code and it makes the code highlighting more consistent since there is no visual difference between PHP built-in functions/constants and your own.

code completion

Arguably one of the most useful features the DUChain enables us to write is code completion. There’s already full support for:

  • PHP built-in functions, classes, constants, superglobals
  • user-defined functions, classes, constants, superglobals, variables, etc.
  • proper code completion for objects which respects access modifiers (private, public, protected) and differentiates between static/non-static members and methods
  • code completion for overridable and implementable functions inside classes
  • hints in the argument list of function- and method class
  • sane code completion after keywords such as “extends, implements, catch(), new, throw” and some more I think

There’s still some bugs to fix and a few features to implement. But I can easily say that even the current state of code completion makes one wonder how he could use Quanta (from KDE3 times) for such a long time! It’s simply nothing compared to this!

The next feature I hope to add is support for type hinting in function calls. I.e. only show arrays where arrays are requested and the same for objects of a given type. Also no PHP keywords are currently completed at all

other DUChain/UseBuilder stuff

Thanks to the DUChain you already get lots of information about declarations, such as uses (which files, which lines etc.). Also very neat is the hover popup you might now from C++ which among others shows you phpdoc comments inside your browser. I also plan to integrate the php.net documentation into KDevelop, similar to what is already possible for QtHelp.

inline validation / syntax checking / linting

Another feature which saves lots of time is on-the-fly syntax checking: You won’t have to fire up your web-app inside a browser just to be greated by that pesty “syntax error, unexpected ‘CHAR’ in FILE on line XYZ” message… No! Instead you will see a nice reddish zig-zag line where you made the error and can fix it before heading off to the browser.

But we don’t only do basic syntax checking. We do more than that, thanks again to the power of the (holy?) DUChain. You can spot undeclared variables, function/method/class/constant redeclarations and more. Actually I hope that one day we spot most of the notices, warnings and errors PHP could emit.

tests

We already have a multitude of regression tests which will make sure that we don’t mess up any existing stuff. Lets hope for even more of them :) I love test-driven development.

The End

Well, thats pretty much it for the moment. You can have a look at what we are up to at the Quanta Feature plan on techbase.

If you are a PHP developer and can write C++ with Qt, why not get in touch with us? You can find us both on the KDevelop mailinglist and at least me and leinir are often found in #kdevelop on freenode.

PS:

Let me finish with a quick introduction of myself:

My name is Milian Wolff, I study Physics at the FU Berlin (just finished the 3rd semester). I started learning programming when I was around 14 with PHP. Over the years I became very good in it and the other webdevelopment techniques like Css, JavaScript etc. Recently I started to fullfill my biggest geek dream by learning C++/Qt/KDE and starting to contribute to the KDE project.

Some of you might now my from the LinuxTag in Berlin where I could be found at the Kubuntu-De.org community booth. At least with some of you I had a beer (well, I doubt it was only one). I hope to repeat this tradition in 2009. Every once in a while I can also be spotted at ubuntu-berlin events.

» Attack of the shell helpers

Mon, 03/02/2009 - 02:46

Everyone who uses the command line regularly has a bunch of (at least for him) useful helper scripts. I now took the liberty to put mine on github for general consumption.

You can find them at: http://github.com/milianw/shell-helpers/tree/master

Some of these might be more useful than others, you decide :) Personally, I can’t live without the following:

apupgrade
a shortcut to update your Debian system with one command - no questions asked
openurl
opens a given URL in an already opened browser instance or starts a new browser session. Not only one browser is checked. I use it because firefox is slow to start and konqueror is blazingly fast to start. But when firefox is already open I want to use that.
xerr
shortcut for fast error checking in your Xorg log
clipboard
makes KDE4 Klipper contents available on the CLI (read and write access!)
debug

shortcut to start a GDB session: debug APP APP_ARGS is all you have to do. Its basically the same as doing:

  1. $ gdb APP
  2. > run APP_ARGS

» Kate linter plugin

Thu, 01/15/2009 - 18:58

Just a quicky: I wrote a little plugin for KTextEditor which supplies you with basic error checking when you save documents. Currently only PHP (via php -l) and JavaScript (via JavaScript Lint) are supported.

» Access klipper clipboard on CLI under KDE4

Wed, 08/13/2008 - 23:12

NOTE: find most recent version on github: https://github.com/milianw/shell-helpers/blob/master/clipboard

Here’s a little script you can save in your path and do things like

  1. # paste current clipboard into file
  2. clipboard > "some_file"
  3. # copy some file into clipboard
  4. cat "some_file" | clipboard

Actually I find it rather useful so I thought I should share it.

  1. #!/bin/bash
  2.  
  3. # Access your KDE 4 klipper on the command line
  4. # usage:
  5. # ./clipboard
  6. # will output current contents of klipper
  7. # echo "foobar" | ./clipboard
  8. # will put "foobar" into your clipboard/klipper
  9.  
  10. # check for stdin
  11. if ! tty -s && stdin=$(</dev/stdin) && [[ "$stdin" ]]; then
  12. # get the rest of stdin
  13. stdin=$stdin$'\n'$(cat)
  14. # oh, nice - user input! we set that as current
  15. # clipboard content
  16. qdbus org.kde.klipper /klipper setClipboardContents "$stdin"
  17. exit
  18. fi
  19.  
  20. # if we reach this point no user input was given and we
  21. # print out the current contents of the clipboard
  22. qdbus org.kde.klipper /klipper getClipboardContents

As usually, save the file (attached below) in your $PATH and make it executable.

PS: Thanks to Martin Vidner for his article on D-BUS btw. - it gave me the proper dbus commands. PPS: Thanks the the various comments below!

» Patching Kirocker Music Display for volume control via mouse scrolling

Fri, 03/28/2008 - 16:32

Kirocker is such a great application, it’s a pity the developer Sébastien Laoût has given up on it and is using Windows now!

Usually I only use the kicker applet, the full screen window is nice for parties though. But I didn’t like the way the applet handles scroll events: It seeks (if possible). Since I rarely seek when listening to music I’d rather have the behaviour of the Amarok tray icon: volume control!

I had a look inside the sources and found this part in src/coverdisplay.cpp:

  1. void CoverDisplay::wheelEvent(QWheelEvent *event)
  2. {
  3. if (areControlsShown()) {
  4. if (event->orientation() == Qt::Vertical) {
  5. PlayerInformation *infos = PlayerInformation::instance();
  6. if (infos->canSeek()) {
  7. int deltaSeconds = 10 * (event->delta() > 0 ? 1 : -1);
  8. m_infos->seekRelative(deltaSeconds);
  9. }
  10. } else {
  11. if (event->delta() > 0)
  12. AmarokApi::volumeUp();
  13. else
  14. AmarokApi::volumeDown();
  15. }
  16. }
  17. }

As you can see it already supports volume control via scrolling! The thing is I’ve disable four-way scrolling for my MX1000. Thus I’ve simply swapped the if statements and now I’m really happy with Kirocker. Here’s the updated snippet:

  1. void CoverDisplay::wheelEvent(QWheelEvent *event)
  2. {
  3. if (areControlsShown()) {
  4. if (event->orientation() == Qt::Vertical) {
  5. if (event->delta() > 0)
  6. AmarokApi::volumeUp();
  7. else
  8. AmarokApi::volumeDown();
  9. } else {
  10. PlayerInformation *infos = PlayerInformation::instance();
  11. if (infos->canSeek()) {
  12. int deltaSeconds = 10 * (event->delta() > 0 ? 1 : -1);
  13. m_infos->seekRelative(deltaSeconds);
  14. }
  15. }
  16. }
  17. }

Replace the old code, compile Kirocker, install it. Then restart kicker (killall kicker; sleep 1; kicker;) and Kirocker should accept scroll events in the way the Amarok tray icon does!

» Redaxo Impressions

Thu, 03/13/2008 - 00:09

Today at work I had my first contact with Redaxo, a German contact management system written in PHP and based on MySQL. I’ve heard of it before but never used it, there always seemed to exist better solutions - Drupal for example. But the company I work for already committed itself to Redaxo for this client. So no chance to work with Drupal this time - a pity.

But new experience with other solutions is a great thing. I thought Redaxo had its right to exist: its very small.

Here I don’t mean the filesize or whatever - I mean the size of the admin panel to begin with. It has not that many features. It’s very easy to understand. The average John Doe which is not that websavvy wont be confused by a multitude of choices. And I think I got to know pretty much all of Redaxo in just a few hours — which I can’t say about the steep learning curve of Drupal. And since the website of this client will be small I first thought Redaxo will do quite good.

The deeper I dug into Redaxo the more annoyed I got by its shortcomings though: There are modules and addons with which you can do pretty much all you need. But not one module I used was ready out of the box. Always I had to do adjustments. Drupal does much better here. And what you can do with overloading in Drupal is millions of light years ahead of what Redaxo is able to do. Oh and the developers of Redaxo really should take a look at Drupals documentation! After some searching on the official website I stuck to grep -R "function XXX" . for Api references…

That and all those simple and minor bugs / feature omissions add up. I can create a site tree with unlimited depth — but the navigation only displays two levels by default?! How do I get a search mechanism onto the page? Alright - implement an addon, write a module and change the templates. In Drupal? Just a few clicks…

Multi-language sites are possible with Redaxo, quite easy so. But this simpleness show through - you’ll have to create language aware modules, addons and templates yourself.

And why the hell do I have to use a simple textarea for template and module development? Copy’n’Paste for every change I make to my favorite editor (which would be Quanta, Kate or KWrite)? You are kidding, right? And though the “development” addon sounded good, I couldn’t get it to work with either of the stable Redaxo releases (3.2.x or 4.0.1). To have to work without tabs, auto-indentation, syntaxhighlighting etc. etc. etc. is a pain in the ass™. It really steals a lot of my productivity.

I could go on about UTF8 support, lack of addons, etc. - but lets stop here. I really hope that my boss will take into account what I’ve told him about Drupal: Once you’ve got your feet wet and yourself acquainted with its way of thinking it’s a fresh breeze compared to Redaxo.

To conclude: Everyone who ponders wether to use Redaxo or Drupal - go for Drupal. The size of the community alone should be able to speak for itself.

» open URL a in variable browser

Mon, 03/12/2007 - 20:44

I was recently annoyed by how URLs were started in KDE: I used an antiquated firefox command to run an URL in a new tab (firefox-remote "OpenURL(%u, new-window)") which does the job quite well. But: If you have no running firefox instance this command will simply do nothing. Right - nothing! You’ll have to start firefox manually and click once again on the link (in konversation, kopete or wherever).

But the newer firefox versions (I don’t know when this feature was added) support the firefox -newtab %u command. This is all you need if you only use firefox. Configure KDE via kcontrol to use this command as a standard webbrowser.

This was still not enough for me though, as I regularly switch to konqueror or opera, because firefox is sometimes to slow for a quick browse. This is what I came up with:

» KDE and Windows Shares

Sun, 02/25/2007 - 02:19

If you have successfully installed Samba it should be no problem to access your Linux shares from Windows. What I couldn’t do until recently was accessing the Windows shares from Linux.

Today I came across LiSa, the Lan Information Server. It was not installed by default on my Kubuntu Edgy machine but a simple sudo aptitude install lisa was sufficient. Lisa is embedded into kcontrol, launch it and you’ll find two new tabs in Internet & Network -> Network Browser. Go to the lisa-daemon tab and launch the guided setup tour. The descriptions should be pretty much straight forward. Accept the changes, fill in your sudo password to save the lisa config file and restart lisa with sudo /etc/init.d/lisa restart.

Now launch Konqueror or Dolphin and head over to lan:/. You should see all machines in your workgroup.