[ jEdit-users ] Combining selection with search

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

[ jEdit-users ] Combining selection with search

Edward Diener-3
I often want to select text based on the position the caret is on and
something I am searching for from that position. As an example suppose
my caret is at some position but I want to select text from that
position to the next character 's' I find through the Search and Replace
dialog. Is there a way to do such a thing in jedit ?


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: [ jEdit-users ] Combining selection with search

Eric Ladner-2
Not that I know of from the search dialog, but you could set a marker with short cut (Ctrl-t then one char for shortcut name), search for your text, then Ctrl-k (followed by the single char shortcut from before) to swap the position of the marker and the carat, then Ctrl-u (followed by shortcut char again) to select from the new carat position to the marker.

It'll prompt you in the status bar for the shortcut character.

On Thu, Jun 16, 2016 at 2:02 AM Edward Diener <[hidden email]> wrote:
I often want to select text based on the position the caret is on and
something I am searching for from that position. As an example suppose
my caret is at some position but I want to select text from that
position to the next character 's' I find through the Search and Replace
dialog. Is there a way to do such a thing in jedit ?


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: [ jEdit-users ] Combining selection with search

Dale Anson-3
This sounded familiar, so I looked around and found this macro that I wrote a couple of years ago. This also selects the search term, you could change the "addToSelection" line to something like addToSelection(new Selection.Range(start, start + end - toFind.length()) if you don't want the search term selected also.

import java.util.regex.*;
void selectTo()
{
start = textArea.getCaretPosition();
toFind = JOptionPane.showInputDialog(jEdit.getActiveView(), "Enter search term:", "Select To", JOptionPane.QUESTION_MESSAGE);
text = buffer.getText(start, buffer.getLength() - start);
        Pattern pattern = Pattern.compile(toFind, Pattern.DOTALL);
        Matcher matcher = pattern.matcher(text);
        if (matcher.find()) {
            end = matcher.end();
            textArea.selectNone();
            textArea.addToSelection(new Selection.Range(start, start + end));
        }
}

selectTo();


On Thu, Jun 16, 2016 at 12:11 PM, Eric Ladner <[hidden email]> wrote:
Not that I know of from the search dialog, but you could set a marker with short cut (Ctrl-t then one char for shortcut name), search for your text, then Ctrl-k (followed by the single char shortcut from before) to swap the position of the marker and the carat, then Ctrl-u (followed by shortcut char again) to select from the new carat position to the marker.

It'll prompt you in the status bar for the shortcut character.

On Thu, Jun 16, 2016 at 2:02 AM Edward Diener <[hidden email]> wrote:
I often want to select text based on the position the caret is on and
something I am searching for from that position. As an example suppose
my caret is at some position but I want to select text from that
position to the next character 's' I find through the Search and Replace
dialog. Is there a way to do such a thing in jedit ?


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: [ jEdit-users ] Combining selection with search

Edward Diener-3
On 6/16/2016 2:49 PM, Dale Anson wrote:

> This sounded familiar, so I looked around and found this macro that I
> wrote a couple of years ago. This also selects the search term, you
> could change the "addToSelection" line to something like
> addToSelection(new Selection.Range(start, start + end - toFind.length())
> if you don't want the search term selected also.
>
> import java.util.regex.*;
> void selectTo()
> {
> start = textArea.getCaretPosition();
> toFind = JOptionPane.showInputDialog(jEdit.getActiveView(), "Enter
> search term:", "Select To", JOptionPane.QUESTION_MESSAGE);
> text = buffer.getText(start, buffer.getLength() - start);
>         Pattern pattern = Pattern.compile(toFind, Pattern.DOTALL);
>         Matcher matcher = pattern.matcher(text);
>         if (matcher.find()) {
>             end = matcher.end();
>             textArea.selectNone();
>             textArea.addToSelection(new Selection.Range(start, start +
> end));
>         }
> }
>
> selectTo();

Worked very nicely. Thank you !

>
>
> On Thu, Jun 16, 2016 at 12:11 PM, Eric Ladner <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Not that I know of from the search dialog, but you could set a
>     marker with short cut (Ctrl-t then one char for shortcut name),
>     search for your text, then Ctrl-k (followed by the single char
>     shortcut from before) to swap the position of the marker and the
>     carat, then Ctrl-u (followed by shortcut char again) to select from
>     the new carat position to the marker.
>
>     It'll prompt you in the status bar for the shortcut character.
>
>     On Thu, Jun 16, 2016 at 2:02 AM Edward Diener
>     <[hidden email] <mailto:[hidden email]>> wrote:
>
>         I often want to select text based on the position the caret is
>         on and
>         something I am searching for from that position. As an example
>         suppose
>         my caret is at some position but I want to select text from that
>         position to the next character 's' I find through the Search and
>         Replace
>         dialog. Is there a way to do such a thing in jedit ?



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users
Reply | Threaded
Open this post in threaded view
|

Re: [ jEdit-users ] Combining selection with search

Edward Diener-3
In reply to this post by Eric Ladner-2
On 6/16/2016 2:11 PM, Eric Ladner wrote:
> Not that I know of from the search dialog, but you could set a marker
> with short cut (Ctrl-t then one char for shortcut name), search for your
> text, then Ctrl-k (followed by the single char shortcut from before) to
> swap the position of the marker and the carat, then Ctrl-u (followed by
> shortcut char again) to select from the new carat position to the marker.
>
> It'll prompt you in the status bar for the shortcut character.

Thanks for the information. I did not realize the marker functionality
you mentioned, although I use markers, but now I see it in the JEdit Help.

>
> On Thu, Jun 16, 2016 at 2:02 AM Edward Diener <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     I often want to select text based on the position the caret is on and
>     something I am searching for from that position. As an example suppose
>     my caret is at some position but I want to select text from that
>     position to the next character 's' I find through the Search and Replace
>     dialog. Is there a way to do such a thing in jedit ?




------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
--
-----------------------------------------------
jEdit Users' List
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jedit-users