Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [orion-dev] Mark occurrences in the editor

Marking and the onLineStyle event are closely related. Can they be
coordinated? Will that make the result more coherent or messier?

Concretely, Marking could be implemented in two parts:
  1) an reStyle event from plugins to editor. Pass in an array of
source line numbers and the editor calls onLineStyle for each line
visible in the viewport.
  2) a registerUIStyle extension point taking a name and some CSS.
Orion would come with some predefined names, eg oMarkIdentifier.
A plugin client that wants Marking would issue the reStyle event
following the Selection event and apply the oMarkIdentifier style to
matches it has found.

Something like this would decouple the styling and update logic. It
would allow more complex marking systems because the match logic is up
to the plugin and the styles are decentralized.

jjb

On Tue, Mar 6, 2012 at 11:20 AM, Mark Macdonald <mamacdon@xxxxxxxxx> wrote:
> Bug 363387 is the place for feedback on the orion.edit.model service.
> Exposing the full buffer in Selection sounds OK, but I'm hesitant about
> adding output arguments to it for marking occurrences -- marking up parts of
> the buffer seems like a common enough task to deserve an API in its own
> right.
>
> On Mon, Mar 5, 2012 at 11:07 PM, Andrew Eisenberg <andrew@xxxxxxxxxxxx>
> wrote:
>>
>> I saw the orion.edit.highlighter and orion.edit.validator services,
>> but realized that they aren't sufficient for what I need.
>>
>> From my perspective as a plugin developer, I'd rather not have to
>> worry about exactly how the regions are styled.  I just want to tell
>> the editor which regions should be marked and the editor figures out
>> what it looks like (with perhaps an entry on the editor preferences
>> page).
>>
>> I am currently using the orion.edit.model service and hooking into the
>> ModelChanging event to grab the current contents of the editor and the
>> Selection event to feed mark occurrences when the selection changes.
>>
>> I am just missing a way to tell the editor to (temporarily) mark
>> specific regions of the editor.
>>
>> Perhaps a new mark occurrences service is not really needed. Instead
>> we can augment the Selection event in a way that would be sufficient.
>>
>> Here's what it would need:
>>
>> 1. the Selection event provides a way to access the full text of the
>> buffer
>> 2. the Selection event provides an output parameter that contains a
>> list of source locations to highlight (perhaps this list comes
>> pre-populated with the previously highlighted source locations from
>> this plugin).
>>
>> Does something like this work?  Perhaps we're better off moving this
>> to bugzilla.
>
>
>>
>> On Mon, Mar 5, 2012 at 5:31 PM, Mark Macdonald <mamacdon@xxxxxxxxx> wrote:
>> > This would be awesome. I miss "mark occurrences" too.
>> >
>> > There is a way to provide styling for the editor from a plugin -- the
>> > orion.edit.highlighter service [1], which is what powers the CodeMirror
>> > plugin. But this API won't solve your problem in its current state, for
>> > a
>> > few reasons:
>> >
>> > It can't combine contributions from multiple plugins.
>> > You can't write a plugin that just styles identifiers and expect someone
>> > else to provide the regular language syntax highlighting. You have to
>> > provide everything, or nothing.
>> > The annotation treatment is limited.
>> > You can supply styled regions to be styled as "errors" (squiggly line
>> > under
>> > the text) in the editor. But you can't specify annotations to appear in
>> > the
>> > overview ruler, which is important for marking occurrences.
>> >
>> > To do a decent job here, we'll have to pull out a more generic way of
>> > supplying styling. Or make "mark occurrences" into a first-class
>> > extension
>> > point that plugins can implement, but leave the presentation up to the
>> > Orion
>> > side. Maybe both of these.
>> >
>> > This extension is really a first crack, powerful enough to support the
>> > CodeMirror plugin, but no more. I'd be happy to evolve it into something
>> > more useful in 0.5.
>> >
>> > Mark
>> >
>> > [1]
>> >
>> > http://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#orion.edit.highlighter
>> >
>> > On Mon, Mar 5, 2012 at 7:33 PM, Andrew Eisenberg <andrew@xxxxxxxxxxxx>
>> > wrote:
>> >>
>> >> One thing that I have been missing in the Orion editor is mark
>> >> occurrences.  When I select an identifier, I'd like to have all
>> >> occurrences highlighted in some way (just like in Eclipse's Java
>> >> editor).  So, I started implementing a plugin for this.  As a first
>> >> step, mark occurrences will just use a regular expression to find
>> >> occurrences (and this makes it possible to work across languages and
>> >> content types, but will not have any smarts).
>> >>
>> >> I got far enough such that I have a plugin that spits occurrence
>> >> information to the console on all selection changes.  However, I am
>> >> stuck now in that I don't see any infrastructure to add styling
>> >> information to a region of text.  Is this currently possible?
>> >>
>> >> thanks,
>> >> Andrew
>> >> _______________________________________________
>> >> orion-dev mailing list
>> >> orion-dev@xxxxxxxxxxx
>> >> https://dev.eclipse.org/mailman/listinfo/orion-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > orion-dev mailing list
>> > orion-dev@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/orion-dev
>> >
>> _______________________________________________
>> orion-dev mailing list
>> orion-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/orion-dev
>
>
>
> _______________________________________________
> orion-dev mailing list
> orion-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/orion-dev
>


Back to the top