jEdit Community - Resources for users of the jEdit Text Editor
Open Search & Replace Dialog
Submitted by andyc on Monday, 4 February, 2008 - 21:56
Hi,

I have what I hope is a simple problem...

I am writing a basic macro to find the next occurrence of the currently selected text. Something along these lines already exists and can be downloaded using the Macro Manager plugin. What's new in my version is that I would like to have the Search & Replace dialog be displayed if no text is currently selected. (That way, I can map it to Ctrl+F and still access the dialog via this shortcut.)

I couldn't find much info on this and what I did find seemed to refer to the "SearchDialog.showSerachDialog" method that doesn't seem to exist any more. I would be most grateful if someone could point me in the right direction.

Many thanks,

Andy
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Finding whether something is selected
by shlomy on Wed, 06/02/2008 - 07:16
You can use code like the following in your macro to identify whether text is currently selected:
Selection[] selection = textArea.getSelection();
if(selection == null)
// nothing is selected


Hope this helps.
 
Thanks very much for your rep
by andyc on Wed, 06/02/2008 - 23:04
Thanks very much for your reply.

I'm OK with checking the selection and implementing the search functionality. The only problem I have is getting the Search & Replace dialog to open. Re-reading my post, I appreciate that I didn't make that totally clear!

So, does anyone know how to get that dialog to open?

Thanks,

Andy
 
show SearchDialog
by Robert Schwenn on Fri, 08/02/2008 - 20:12
There is a static method in class SearchDialog to show the dialog:

SearchDialog.showSearchDialog(view, "searchText", SearchDialog.CURRENT_BUFFER);

See jEdit help -> jEdit API Reference -> org.gjt.sp.jedit.search for more details.

Robert
 
Thanks
by andyc on Mon, 11/02/2008 - 20:28
Many thanks for that Robert. It's all working perfectly now!

Somehow I got thrown off the scent before by some dodgy webpage that suggested this method was no longer supported. Clearly not the case Smiling

Thanks, Andy
User login
Browse archives
« March 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82338
Context Free Art (*.cfdg)   0.31   46043
JBuilder scheme   .001   18487
BBEdit scheme   1.0   18107
ColdFusion scheme   1.0   18015
R Edit Mode - extensive version   0.1   17461
Advanced HTML edit mode   1.0   16194
Matlab Edit Mode   1.0   16057
jEdit XP icons   1.0   15220
XP icons for jEdit   1.1   14281