Plugin Development

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin Development

DosBox
Hi all,

I am trying to create a NetBeans plugin and I need to somehow find out the range of lines currently visible in the editor.

Example: let say a opened file has 100 lines, editor displays 20 lines, scroll position is in the middle. I would like to find such functions that used like this:


Code:
int start = XXX.getVisibleLinesStart();
int end   = XXX.getVisibleLinesEnd();



should return:


Code:
start = 40;
end   = 60;



Is this possible to achieve with NetBeans API? Which component holds the information about document view? Where to look?
I found out that it does not have to be lines, the first and last visible character would do.




Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development

Emilian Bold-2
It's an one-liner but I can't give you an example now since I don't
remember the exact utils classes.

See
* http://wiki.netbeans.org/DevFaqGetOpenEditorWindows
* http://bits.netbeans.org/8.0/javadoc/org-openide-text/org/openide/text/NbDocument.html#findLineNumber(javax.swing.text.StyledDocument,
int)
* JEditorPane javadoc for getting the visible rectangle / lines

PS: Please use [hidden email] , this mailing list will be closed soon.


--emi


On Tue, Oct 24, 2017 at 9:32 AM, DosBox <[hidden email]> wrote:

> Hi all,
>
> I am trying to create a NetBeans plugin and I need to somehow find out the range of lines currently visible in the editor.
>
> Example: let say a opened file has 100 lines, editor displays 20 lines, scroll position is in the middle. I would like to find such functions that used like this:
>
>
> Code:
> int start = XXX.getVisibleLinesStart();
> int end   = XXX.getVisibleLinesEnd();
>
>
>
> should return:
>
>
> Code:
> start = 40;
> end   = 60;
>
>
>
> Is this possible to achieve with NetBeans API? Which component holds the information about document view? Where to look?
> I found out that it does not have to be lines, the first and last visible character would do.
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development

geertjan.wielenga@oracle.com
That should be [hidden email].

Send an empty mail to [hidden email] to subscribe.



Geertjan Wielenga | Principal Product Manager
Phone: +31620320056 | 
Oracle Developer Tools

ORACLE Netherlands | Hertogswetering 163-167 | 3543 AS Utrecht | Netherlands


Oracle is committed to developing practices and products that help protect the environment

On 25 Oct 2017, at 11:40, Emilian Bold <[hidden email]> wrote:

It's an one-liner but I can't give you an example now since I don't
remember the exact utils classes.

See
* http://wiki.netbeans.org/DevFaqGetOpenEditorWindows
* http://bits.netbeans.org/8.0/javadoc/org-openide-text/org/openide/text/NbDocument.html#findLineNumber(javax.swing.text.StyledDocument,
int)
* JEditorPane javadoc for getting the visible rectangle / lines

PS: Please use [hidden email] , this mailing list will be closed soon.


--emi


On Tue, Oct 24, 2017 at 9:32 AM, DosBox <[hidden email]> wrote:
Hi all,

I am trying to create a NetBeans plugin and I need to somehow find out the range of lines currently visible in the editor.

Example: let say a opened file has 100 lines, editor displays 20 lines, scroll position is in the middle. I would like to find such functions that used like this:


Code:
int start = XXX.getVisibleLinesStart();
int end   = XXX.getVisibleLinesEnd();



should return:


Code:
start = 40;
end   = 60;



Is this possible to achieve with NetBeans API? Which component holds the information about document view? Where to look?
I found out that it does not have to be lines, the first and last visible character would do.