[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Plugin development related questions
From:       "Paul A. Giannaros" <paul () giannaros ! org>
Date:       2008-09-07 18:58:25
Message-ID: 3cce4fc80809071158k27251989wa1e0b0e94b86d6f0 () mail ! gmail ! com
[Download RAW message or body]

On Sun, Sep 7, 2008 at 7:21 PM, Milian Wolff <mail@milianw.de> wrote:
> Am Sunday 07 September 2008 schrieb Paul A. Giannaros:
>> On Sun, Sep 7, 2008 at 4:20 PM, Milian Wolff <mail@milianw.de> wrote:
>> > Hello!
>> >
>> > To learn C++ and Qt some more, I want to write a plugin for Kate which
>> > does validates PHP files using the `php -l` linter. I'm a bit lost though
>> > and am not sure whether my ideas are even feasible:
>>
>> Sure they are, adding this kind of thing is exactly what Kate plugins are
>> about.
>>
>> > 1. How would I access the highlighter from a plugin? I thought it would
>> > be great to have the "bad lines" marked inside the code, i.e. assigning
>> > them the "Normal Text Style -> Error". But I cannot find any examples or
>> > documentation on how do that. Any hints?
>>
>> I'm not sure, but I don't think it's the highlighter that you want to
>> access. The MarkInterface provided by KTextEditor::Document is probably
>> what you're after -- it lets you mark lines as you wish (e.g as errors or
>> as bookmarks or whatever).
>
> markType07 - Error
>
> Great, that will fit perfectly fine. Actually it could answer 3. since then I
> can rely purely on KTextEditor. A generic plugin which will work in Kwrite and
> Kate (and in Quanta someday maybe as well) should thus be feasible. With the
> techbase tutorial available I should be able to get started.
>
>> > 2. I imagine more sophisticated PHP IDEs include their own PHP parsers
>> > (see also 4.) to generate on-the-fly error reporting which is out of my
>> > reach. For the time being it would be enough to call this linter either
>> > via menu/shortcut or (optionally) each time the document is saved. So far
>> > I did not find a proper signal for that purpose, does one exist? Nearest
>> > I got was KTextEditor::Document::modeChanged or ::modifiedChanged. Do I
>> > have to work with one of those? I.e. on Plugin-Setup get current mode,
>> > then take a "was modified" -> "now not modified" change as "document was
>> > saved" status? Other ideas?
>>
>> How about Document::documentSavedOrUploaded?
>
> Ah, new in trunk, I only had a look at the 4.1 documentation. Good to know,
> thank you.

I didn't realise. I would think there's a way to do it with the old API if
necessary, however.

>
>> > I'm not sure how fast the actual linting process is, but maybe later on I
>> > can get it somewhat optimized so that I could trigger it after a "text
>> > change". How often is the textChanged signal triggered? For every char
>> > that I type? Or is there a "buffer" which makes it trigger after I typed
>> > in some chars and stopped typing? If that is the case I could use that
>> > maybe...
>>
>> I believe it's for every character typed (i.e like Qt's QTextEdit)
>
> Would you think something like:
>
> for every textChanged {
>  kill current timer if available
>  setup new timer which triggers LINT in X secs
> }
>
> would be noticeable when typing? I don't have much experience with performance
> of C++ and "real" GUI applications in general, but I hate it when
> autocompletion or similar slows me down while I'm still typing.

That's fine. You'd be surprised how fast computers are and how slow even
the fastest typists can type ;). With that said, if you're really worried about
performance then you can use a thread. Or actually, Qt's process classes
work asynchronously If you run lint then control will go straight back to
the main loop and you'll get a signal when the process finishes. You could
just do that and make sure that you don't end up with multiple lints going
in parallel. Tell me how it goes -- I've done something similar with Python
and its parser using a thread.
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic