Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Orion (Archived) » Get line number from ruler
Get line number from ruler [message #869204] Thu, 03 May 2012 04:10 Go to next message
Joe Ertaba is currently offline Joe ErtabaFriend
Messages: 17
Registered: April 2012
Junior Member
Hi,

In some editors it is possible to select lines by clicking on numbers in ruler area. I was wondering if there is any plan for this feature.

If not is there any easy way to get notified when user click on the ruler. Right now to get the according number I do this:

window.document.
    getElementsByClassName("textviewLeftRuler")[0].
    addEventListener("click", function (event){ 
        var num =  parseInt(event.originalTarget.textContent)
    },true)

[Updated on: Thu, 03 May 2012 04:10]

Report message to a moderator

Re: Get line number from ruler [message #869925 is a reply to message #869204] Fri, 04 May 2012 20:17 Go to previous messageGo to next message
Silenio Quarti is currently offline Silenio QuartiFriend
Messages: 31
Registered: July 2009
Member
You can connect to the rulers onClick event either by dojo.connect() or by replacing to the onClick() function. Take a look at [1] line#590 for an example:

[1] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/tree/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js


Re: Get line number from ruler [message #870026 is a reply to message #869925] Sat, 05 May 2012 20:10 Go to previous messageGo to next message
Joe Ertaba is currently offline Joe ErtabaFriend
Messages: 17
Registered: April 2012
Junior Member
Hi Silenio,

Thanks for the replay.
I thought ruler does not support onClick. Can you explain what the original function does?
Re: Get line number from ruler [message #870327 is a reply to message #870026] Mon, 07 May 2012 16:18 Go to previous messageGo to next message
Silenio Quarti is currently offline Silenio QuartiFriend
Messages: 31
Registered: July 2009
Member
What the original function does depends on the type of the ruler. The folding ruler expands/collapses folding annotations when the user clicks them, for example. Note that editor.js also overrides some of the default behaviour defined in rulers.js. See [1] and [2].

The line numbering ruler does nothing currently, but I can see this changing in the future to add/remove breakpoint annotations.

To answer your original question a little better, there is no plans currently to add the select line feature given that it is possible to select the line through other means and we plan to use that gesture to add/remove breakpoints. But again this could be something configurable, so you could open a bug report requesting the feature and we will see what other people think about it.


[1] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/tree/bundles/org.eclipse.orion.client.editor/web/orion/editor/editor.js
[2] http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/tree/bundles/org.eclipse.orion.client.editor/web/orion/textview/rulers.js
Re: Get line number from ruler [message #870337 is a reply to message #870327] Mon, 07 May 2012 17:01 Go to previous messageGo to next message
Joe Ertaba is currently offline Joe ErtabaFriend
Messages: 17
Registered: April 2012
Junior Member
Is there any way to get the ruler html element ("textviewLeftRuler" for example) through Orion API. I guess to implement this feature I need to have access a few more events like mouse move, ...
I prefer to implement it through JavaScript's addEventListener rather than using dojo.
Re: Get line number from ruler [message #870378 is a reply to message #870337] Mon, 07 May 2012 21:01 Go to previous messageGo to next message
Silenio Quarti is currently offline Silenio QuartiFriend
Messages: 31
Registered: July 2009
Member
Sorry, there is no API to get the ruler html element.

Isn't replacing the default onClick() an option? The rulers also have onMouseMove, onMouseDown, etc events.

Maybe the rulers (LineNumberRuler, FoldingRuler, etc) should have the addEventListener API like TextView. That way you would not have to use dojo.
Re: Get line number from ruler [message #870387 is a reply to message #870378] Mon, 07 May 2012 21:51 Go to previous message
Joe Ertaba is currently offline Joe ErtabaFriend
Messages: 17
Registered: April 2012
Junior Member
Actually the current event listeners are just enough. I just don't want to replace them with new functions and then call the old ones afterwards. Sometime this can cause unknown behavior.
Anyhow, either a function to get the html element of rulers or addEventListener API for rulers seems the right solution to me.
Previous Topic:Invisible selected text for not focused editor
Next Topic:Not having tooltip for bookmark annotations
Goto Forum:
  


Current Time: Mon Dec 02 12:14:23 GMT 2024

Powered by FUDForum. Page generated in 0.03895 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top