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

List:       jedit-devel
Subject:    Re: [ jEdit-devel ] BufferListener help
From:       Alan Ezust <alan.ezust () gmail ! com>
Date:       2019-11-03 14:11:18
Message-ID: CALy5K9ozX4AdEpLza32Ca3P_KECB-CWRT=qXHunvXjMWYn-5xQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hello Adam,
I was checking the BufferListener API docs and I don't think that's the
right class for that:

* While the
 * {@link org.gjt.sp.jedit.msg.BufferUpdate} EditBus message is used for
 * general buffer state changes, this interface is used for events which are
 * fired frequently, or for which performance is essential.<p>

The BufferUpdate class has a LOADED message that is going to happen when
the buffer is loaded. I think that's the right one to listen for.
If you search for BufferUpdate.LOADED in sourcecode of jEdit or some of its
plugins, you will find examples of its use.




On Sun, Nov 3, 2019 at 5:41 AM Adam Pease <apease@articulatesoftware.com>
wrote:

> Hi Folks,
>    This may be a very basic questions, but I wonder if someone might
> help with an example use of BufferListener.  I'm loading a file and want
> to find the offset for a line number.
>
> jEdit.openFile(view,result.filepath);
> try { wait(1000); } catch(Exception e) {}
> offset = view.getBuffer().getLineStartOffset(result.line);
>
> If I put in a wait I get an answer, and not if I don't, I guess because
> the file load kicks off an asynchronous process.  I haven't done much
> with threads in the past so this may be more of a basic java question.
> I'm guessing that a listener would be the right way to solve this,
> instead of my wait() hack.
>
> all the best,
> Adam
>
> --
> --------
> Adam Pease
> http://www.ontologyportal.org
> http://www.adampease.org
> @apease_ontology on Twitter
>
> --
> -----------------------------------------------
> jEdit Developers' List
> jEdit-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jedit-devel
>

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div>Hello Adam,<br></div><div>I was checking the \
BufferListener API docs and I don&#39;t think that&#39;s the right class for that: \
<br></div><div><br></div><div>* While the<br>  * {@link \
org.gjt.sp.jedit.msg.BufferUpdate} EditBus message is used for<br>  * general buffer \
state changes, this interface is used for events which are<br>  * fired frequently, \
or for which performance is essential.&lt;p&gt;<br>  </div><div>The BufferUpdate \
class has a LOADED message that is going to happen when the buffer is loaded. I think \
that&#39;s the right one to listen for.</div><div>If you search for \
BufferUpdate.LOADED in sourcecode of jEdit or some of its plugins, you will find \
examples of its use.</div><div><br></div><div><br></div><div><br></div></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 3, 2019 at 5:41 AM \
Adam Pease &lt;<a href="mailto:apease@articulatesoftware.com">apease@articulatesoftware.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
                0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi \
                Folks,<br>
     This may be a very basic questions, but I wonder if someone might <br>
help with an example use of BufferListener.   I&#39;m loading a file and want <br>
to find the offset for a line number.<br>
<br>
jEdit.openFile(view,result.filepath);<br>
try { wait(1000); } catch(Exception e) {}<br>
offset = view.getBuffer().getLineStartOffset(result.line);<br>
<br>
If I put in a wait I get an answer, and not if I don&#39;t, I guess because <br>
the file load kicks off an asynchronous process.   I haven&#39;t done much <br>
with threads in the past so this may be more of a basic java question. <br>
I&#39;m guessing that a listener would be the right way to solve this, <br>
instead of my wait() hack.<br>
<br>
all the best,<br>
Adam<br>
<br>
-- <br>
--------<br>
Adam Pease<br>
<a href="http://www.ontologyportal.org" rel="noreferrer" \
target="_blank">http://www.ontologyportal.org</a><br> <a \
href="http://www.adampease.org" rel="noreferrer" \
target="_blank">http://www.adampease.org</a><br> @apease_ontology on Twitter<br>
<br>
-- <br>
-----------------------------------------------<br>
jEdit Developers&#39; List<br>
<a href="mailto:jEdit-devel@lists.sourceforge.net" \
target="_blank">jEdit-devel@lists.sourceforge.net</a><br> <a \
href="https://lists.sourceforge.net/lists/listinfo/jedit-devel" rel="noreferrer" \
target="_blank">https://lists.sourceforge.net/lists/listinfo/jedit-devel</a><br> \
</blockquote></div>





-- 
-----------------------------------------------
jEdit Developers' List
jEdit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-devel


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

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