I'd like to write a macro for jEdit which runs an external application, and in doing this I wish to check whether a file at a specified path exists, and conditionally execute macro content on this basis.
Does anyone have a script that demonstrates how to use a Modal dialog from within a Beanshell macro?
Problem: I am trying to get user input in a beanshell script and set a variable based on that input. The problem is when I set modal=true for the JDialog box, the JDialog no longer disposes after presses of "OK" or "Cancel". The dialog just sits there and won't go away, therefore I cannot capture the result and set the variable.
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.
Is it possible to run a macro when I shut down jEdit? I know we can throw them in the startup directory to be run on startup, but what about when we shut down?
I have been using jEdit for a few months now, and it is an awesome editor. I have written a few macros, but I do not know Beanshell very well and now I am stumped.
I want to write a macro to correct some words using SearchAndReplace command. I would like to be able to define the words to be searched and replaced, and then to run a loop, where the replacements happen. I am vaguely aware of things such as arrays and maps, and I think in my case I am going to have to use one of those, but I don't know where to begin.
This is an example of how I want it to work (just a concept, not a working code):
//Define search and replace pairs
searchReplacePairs[] = ("thats","that's",
"lets","let's"
"...","...");
//Grab each pair and perform replace
Loop searchReplacePairs
{
SearchAndReplace.setSearchString(textToSearch);
SearchAndReplace.setReplaceString(textToReplace);
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(true);
SearchAndReplace.setRegexp(true);
SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
SearchAndReplace.replaceAll(view);
}
As you can see, I do not know how to define the array, then how to parse it to get the textToSearch/textToReplace pair and process it in the loop. Any help would be welcome.
How do I get to the class or method that control the Highlight. when you save as "example.java" the extension will know that it is a java program other extensions are Java,xml,php, perl.etc. example of what I am saying is below.
public SyntaxStyle getStyle()
{
if(!okClicked)
return null;
Color foreground = (fgColorCheckBox.isSelected()
? fgColor.getSelectedColor()
: null);
When I save a new file as "example.java" Those color on public, getsysle etc. should not appear again.
I have tried all the GlobalOptions, SyntaxHillit, and others I cannot find it. I am a babe learning.
Hi all,
Is it possible to write a macro that can return the xpath of the element or attribute the cursor is located at?
For example, given the following xml document, and assuming the cursor is located on the Target element, the macro would return the string: /Links/Link/Target
/htdocs/images/coffee_cup.jpg
I can not find this functionality in the XML plugin or elsewhere.
Possible?
Thanks,
Paul
I often have the task to select or delete a text (more than one line) from the actual position till a pattern to search for. If you know UEDIT there you can press "shift" and initiate the search. All the text from the current position including the string found will be marked.
I accomplished this by recording a macro and manipulating the Java code afterwards. However, if you are recording a quick macro this is much too intricate.
Currently, I'm getting started writing jEdit BeanShell macros with just a simple text editor and the online User's Guide as a reference. Is there a better way?
Is there any IDE that could provide auto-complete, context-sensitive help, syntax check as I type, and other modern IDE goodies? Or is a plain text editor the way to go?
I try to write a macro that insert a new line of comment, indenting it and adding the space between the comment token(s) and the text, as on the previous line.
For the moment, I use only '%' as comment token and hard coded it. To submit the macro, I would need to know how to get the string of line comment token(s).
I've been trying to write some simple beanshell code which calls some methods from the Console plugin. In one part of this code I'm calling the following method:
runInSystemShell(view, "latex " + file);
Now in examples like the above, the program (in this case "latex") returns a process or error level number when it finishes. If the program completes without errors, it returns 0. If it encounters an error it usually returns a non-zero process code. Is there a beanshell/Java command or Console method that will return this process code?? Unfortunately, the above method (runInSystemShell) doesn't return a value so I don't know what the process code is after it completes.
I've been trying to write some simple beanshell code which calls some methods from the Console plugin. In one part of this code I'm calling the following method:
runInSystemShell(view, "latex " + file);
Now in examples like the above, the program (in this case "latex") returns a process or error level number when it finishes. If the program completes without errors, it returns 0. If it encounters an error it usually returns a non-zero process code. Is there a beanshell/Java command or Console method that will return this process code?? Unfortunately, the above method (runInSystemShell) doesn't return a value so I don't know what the process code is after it completes.
first of all I would like to thank the developers. jEdit is a brilliant tool. The opportunity to write own java based macros is an excellent feature. Unfortunately I have some problems in regard to pick up the right buffer for an automatic safe. But before I go into detail I have to mention, that I am not an experienced Java programmer.
What I try to do is to manipulate data from file A and try to safe it in file B.
For this purpose I take the data out of buffer A use the tokenizer to extract the needed data and write that into buffer B.
Therefore I have written the following code:
The pitty is, that I have to ensure that the order in the buffer selector is correct. That is a little bit unconvienient. Does anyone know if there is an opportunity to select the right buffer by its path or filename?
I went through the whole helpfile and online wiki, but didn't found anything how I can manage that task. I also tried to record a macro but the file selection was not recorded.
The JTA plugin is the ONLY features that really miss to jedit : it consists in having multiple connections onto differents servers to execute commands (much more powerfull than the console plugin which is limited to the current station you use)...
so this plugin is not maintained anymore... if someone can try this challenge !
more information here : http://sourceforge.net/tracker/index.php?func=detail&aid=1627596&group_id=588&atid=350588
I am trying to find a single specified file in a set of directories. The filename is currently selected, the directories are listed at the bottom of my text file as follows: [path:adirectory][path:anotherdirectory][path:yetanotherdirectory].
The paths are searched recursively (ie: subdirectories are searched as well), or alternatively I can allow globs in the paths like so: [path:C:\toplevel\projects\*\]
I've got searching the current document for [path:xxxx]. I've got the selected filename.
What I am having trouble with is searching the filesystem for the filename. I am trying to figure out how to use DirectoryListSet to do this, but I cannot see how it can be used alone without involving the GUI. I also tried to figure it out using File.list(), but cannot figure out how to specify a filter.
Any help I've found googling around has been in Java, not Beanshell, and since I'm not expert at either I cannot figure out how to translate the Java solutions into Beanshell.
I am trying to write a macro that opens the file named in the selection with the appropriate application. For example, [mysheet.xls] would start Excel and open the file mysheet.xls, [mytext.txt] would open Notepad...
I've tried sending the filename to cmd.exe, but that doesn't work. I've tried sending it to Explorer but that just views it in explorer.
Here's what I have (not working properly):
I'm struggling to write a macro that will search for a string and replace it with that buffer's file name, or better still, a substring of the filename, across all open buffers.
I'm currently trying to use SearchAndReplace.setBeanShellReplace(true) and putting variable names in SearchAndReplace.setReplaceString("theName") with no luck.
I have this macro I wrote a while ago that "indents" a piece of code (C, Java, Javascript). I like it over the various beautifiers plugins for the following reasons:
1. It keeps the lines as they are, it justs indents them, so that part of the coding style is preserved.
2. The macro will indent just the selection, not all the file, making the change an easy and visible one.
How shall I share the macro so as it is well exposed? It's around 500 lines and I doubt it is worth getting into the default install (how do one macro gets elected to get in the default install?). I'd also like some user feedback on it.