Hello o/
I'm currently trying to write a macro to Send Selection To Python, but I need some help to improve the stuff : I would like to be able to switch back to make active the previous buffer (the one the selecton came from) and the best would be maybe to do that in a transparent way without having the file popping into jEdit. I tried with the jEdit.openTemporary(); but didnt figured how to make it work. Some help would be really appreciated Here is the simple macro so far :
// Send Selected Text To Python
String pythonPath = "D:\\Softwares\\Developpement\\Python25\\pythonw.exe";
String currentFile = "D:\\_Temp\\_SendSelectedTextToPython.py";
I want to write a macro to automatically add id attribute for all specified tags (h2, h3, h4…),
when it is not set yet. (for example #h2-1, #h2-2, #h2-3…).
I wrote a simple javascript bookmarklet to do it,
but I dont’t know how to do it in beanshell macro. Set IDs bookmarklet
How to write getElementsByTagName(tag) function?
Maybe just regular expression with returning beanshell replacement will work?
Then how to increment those IDs in regexp?
Hi,
Can anyone demonstrate a macro script that collates an array of filenames that match a certain extension within a specified directory path?
I would need a specific example of how to access each array item, and to know how many array items there are.
This does NOT have to recursive.
Hi,
I'm trying to collate the names of all the files within a specific directory path with a specific extension.
My bsh macro file contains the following:
---------------------------------------------------------
class OnlyExt implements FilenameFilter
{
String ext;
public OnlyExt(String ext)
{
this.ext = "." + ext;
}
public boolean accept(File dir, String name)
{
return name.endsWith(ext);
}
}
example()
{
file_path = "/example/mydir";
File f1 = new File(sys_file_path);
FilenameFilter only = new OnlyExt("bak");
// This is the OFFENDING LINE!!!
String filtered_files[] = f1.list(only);
for (int i=0; i
I have a macro that I use to save my current document to disk and then to the server on which I am required to launch builds. This all works fine. But when I do a save, the macro runs (running ssh) and the cursor ends up in the Console. How can I have the cursor jump back into the text area where I am working?
Also, the act of saving causes any errors in the Error List to be cleared. I can understand this given that Console does the error parsing, but is there some way I can tell Console not to clear the Error List?
How would I create a macro to toggle the tab size between 4 and 8? I tried to start one by recording a macro while I changed the tab size using the buffer options dialog, but the resulting macro only showed this: new BufferOptions(view,buffer) - which just brings up the buffer options dialog. I'm not sure now how to proceed. I want to learn how to write good macros, and eventually plugins, so I'm hoping for advice rather than a complete solution. But any help at all will be appreciated.
I have some simple macros to which I want to add consistent shortcut keys as part of the install.
I assume that I use the jEdit.setProperty option with something like:
jEdit.setProperty("my_macros/macro1.shortcut", "CA+1"); but that does not work.
When I check the global options, the shortcut is recorded as the literal string, but Ctrl + Alt + 1 does not activate the macro.
Does anyone know how to set such a shortcut? For example, is there some form of key combination code that I need to enter to get this combination to work through setProperty()?
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.