Re: [code] [textadept] Modifying non-global buffer

From: Mitchell <m.att.foicica.com>
Date: Sat, 21 Sep 2013 21:48:57 -0400 (EDT)

Chris,

On Sun, 22 Sep 2013, Chris Emerson wrote:

> Mitchell,
>
> On Fri, Sep 20, 2013 at 10:29:42PM -0400, Mitchell wrote:
>> On Fri, 20 Sep 2013, Chris Emerson wrote:
>>> What's the reason you can't call, for example, some_buf:append_text(...)
>>> when some_buf isn't the global one?
>>
>> It boils down to Scintilla's implementation. You pass messages to
>> Scintilla objects (which are the widgets), not individual buffers.
>> The Scintilla objects operate on their current documents.
>
> Buffers or views? ie what about updating a buffer in a different split view?

Sorry for the confusion. Let me try again. But before I do, I need to
clarify some terms. Textadept `buffer` objects are technically the
Scintilla views/widgets, while Textadept `view` objects are the window
parts of split views. Therefore Textadept views are not equal to Scintilla
views and buffers are not exactly Scintilla documents. I wanted to create
an API that makes sense in an object-oriented sense, but due to
Scintilla's implementation, it's not perfect.

When you call `buffer:append_text()`, you are really telling the current
Scintilla view/widget to call its "append_text" function on whatever
document it is currently showing. (You cannot tell a Scintilla document to
"append_text", only its parent view.) Thus, since a buffer is not exactly
equal to a Scintilla document, it does not make sense (from Scintilla's
perspective) to try and do anything to the buffer/document when it is not
visible in a Scintilla view.

So now to answer your other question: if a non-global buffer is available
in another split view, why doesn't `buffer:append_text()` work then? It's
simple: I haven't written the code to do that :) It's certainly
non-trivial (for one it would be in C, not Lua). You would have to first
see which view contains the non-global buffer, then pass Scintilla
messages to it instead of the focused view. You'd have to do this in a few
different places in `src/textadept.c`, particularly in `lbuf_closure()`,
which might result in a performance hit. I would be interested in
exploring this in the future though, because this is a very good question.

I'm sorry if I'm still having trouble understanding your question or
trying to explain.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 21 Sep 2013 - 21:48:57 EDT

This archive was generated by hypermail 2.2.0 : Sun 22 Sep 2013 - 06:36:43 EDT