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

List:       kde-commits
Subject:    Re: [kate/KDE/4.12] /: Make working w/ editBegin()/editEnd() little more easy from JS scripts.
From:       Dominik Haumann <dhaumann () kde ! org>
Date:       2013-11-22 8:51:13
Message-ID: 15743309.dB6XoDSdRx () obiwan
[Download RAW message or body]

On Friday, November 22, 2013 08:41:09 Alex Turbov wrote:
> +++ b/part/script/data/libraries/edit_session.js
> @@ -0,0 +1,75 @@

[...]

> +function EditSession()
> +{
> +    this.started = false;
> +}
> +
> +EditSession.prototype.editBegin = function()
> +{
> +    if (!this.started)
> +    {
> +        document.editBegin();
> +        this.started = true;
> +    }
> +}
> +
> +EditSession.prototype.editEnd = function()
> +{
> +    if (this.started)
> +    {
> +        document.editEnd();
> +        this.started = false;
> +    }
> +}

Is this worth it?

Basically, instead of writing

  document.editBegin()
  document.editEnd()

you now write

  tr.editBegin()
  tr.editEnd()

EditSession allows the amount of editStarts and editEnds to differ, but I'm 
not convinced this increases the readability/maintainability of the code.

For instance, what would indeed be cool, if there was something like destrutor 
in C++, that automatically calls editEnd() if required (think of QMutexLocker 
or unique_ptr). But as I understand, EditSession does not provide this 
capability.

So, is there a way we can further improve on that?

Besides that, I'd welcome discussions about adding such public API (similar to 
the fact that I want discussions for new KTextEditor interfaces). Just for the 
simple reason that it's public API we cannot change for quite a long time, 
depending on how hard we try to keep compatibility :-)

Greetings,
Dominik
[prev in list] [next in list] [prev in thread] [next in thread] 

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