This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Auto Completion for KWin Scripts

Tags: None
(comma "," separated)
mgraesslin
KDE Developer
Posts
572
Karma
7
OS

Auto Completion for KWin Scripts

Wed Feb 29, 2012 3:15 pm
as you might now, I'm currently working a lot on JavaScript bindings for KWin. Both the C++ implementation and my example scripts are written inside KDevelop.

My scripting API defines a global properties and the scripts mostly operate the properties of those global variables.

Is it somehow possible to get auto-completion for those known global variables? Some way to tell kdevelop how the API looks like?

Btw the API can be found on techbase and is completely generated from Doxygen XML output
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
The scripts are in JavaScript, aren't they? That will probably be difficult then, because KDevelop doesn't currently have any JavaScript language support.

Greetings


I'm working on the KDevelop IDE.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Auto Completion for KWin Scripts

Mon Mar 05, 2012 11:03 pm
Thinking about it for a few days, depending on what your scripts look like it might not be that difficult to come up with something useful for your special case after all. Could you maybe post a few examples? If most of your function calls have a fixed format (like, they are attributes of some global object which always has the same name) then it could be rather easy to hack an autocompletion-only language support together. Maybe that could even be extended later.

Greetings


I'm working on the KDevelop IDE.
mgraesslin
KDE Developer
Posts
572
Karma
7
OS
Almost all functions have a fixed number of parameters. Without that I would not have had the idea at all :-)

Have a look at http://techbase.kde.org/Development/Tutorials/KWin/Scripting/API_4.9 to get an idea.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS

Re: Auto Completion for KWin Scripts

Tue Mar 06, 2012 10:25 am
Hi,

the problem is less the parameters, but more the way the methods are called. For example, this:
Code: Select all
KWin.Client.active()

would be easy to auto-complete, while this:
Code: Select all
my_client = KWin.Client()
my_client.active()

wouldn't be (always talking about the active() method, i.e. having the cursor behind the dot and invoking autocompletion with the intention of calling that method).

In other words, if the line always looks roughly the same and you could match it with a regex without taking the code before that line into account, then it would be easy, otherwise it would require a more-or-less functional JavaScript language support, which is a large effort to write.

Greetings


I'm working on the KDevelop IDE.
mgraesslin
KDE Developer
Posts
572
Karma
7
OS
most of the calls are actually in a way that regex might work. And that would already be a great help to me, if it would offer a suggestion box for all that belongs to the global variables.
User avatar
scummos
Global Moderator
Posts
1175
Karma
7
OS
Okay! I will think about how difficult it would be to implement a generic regular expression autocompletion plugin which you can feed with XML (or similar) data, and report back here as soon as I have an idea.

We already talked about such a plugin on IRC recently, and figured it doesn't make sense to link such a thing to kdevelop/kdevplatform, as it doesn't make use of its features. Instead, it should be a kate plugin (which would work in KDevelop, too, but also in plain kate).

Optimally, I would imagine it to work with data similar to the kate syntax highlighting files.

Greetings


I'm working on the KDevelop IDE.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell