Run macro on Event
Submitted by
raccuia on
Monday, 27 December, 2004 - 10:19
Hello,
I'd like to know if I can run a macro when I save a buffer, catching the click on Save button.
Sorry if anyone have already ask for this question, but I don't found anything about it. Can anyone tell me if I can catch this event ed run my macro or where I can found any information?
Thanks in advance.
Mino
Upper/Lower/Invert/Capitalize Case Macros WHITHOUT unselecting text
Submitted by
pdfneuro on
Wednesday, 15 December, 2004 - 17:28
Hi,
Here are 4 separated macro that allows to change word case of selected text WHITHOUT unselecting text:
- - Upper Case
- - Lower Case
- - Invert Case
- - Capitalize Case
Check it out! and enjoy
Macro to sort lines like in Ultraedit?
Submitted by
pdfneuro on
Wednesday, 15 December, 2004 - 13:57
Execute program from macro
Submitted by Anonymous on Monday, 13 December, 2004 - 14:29
Strangely enough I haven't been able to find how to do this simple task in the documentation or the FAQ:
How to I execute a program from a Macro?
(For running a compiler/make or an emulator/interpreter for the code or just somethin like a calculator).
Sort_Lines.bsh
Submitted by
pdfneuro on
Monday, 13 December, 2004 - 09:21
Sort_Lines.bsh
Hi,
I just upload a jedit macro which is able to sort lines in ascending/descending order.
Available options are
- Remove duplicated lines
- Ignore case sorting
Check it at
http://community.jedit.org/?q=filestore/download/1943 and tell me if you find it usefull.
Enjoy
File system browser current selected item/file?
Submitted by
fwelland on
Saturday, 20 November, 2004 - 02:29
jedit macro newbie; jedit user for a bit; java journeyman.
In a macro, is possible to get the currently selected item in the filesystem browser?
so in my random hacks I have gotten this..
doc = view.getDockableWindowManager();
names = doc.getRegisteredDockableWindows();
with the idea that if I had a handle of the file system browser (currently docked) then I could interrogate file system browser for the currently selected file(s) - it seems there are some getSelected methods in the VFSBrowser....on the right track?
Loading and then editing a file
Submitted by
AlvinD on
Tuesday, 16 November, 2004 - 03:43
I have a macro which will parse and modify a list of files. It works as long as the files are preloaded. However, when I use the statement "FileBuffer = jEdit.openFile(view,FilePath+File);" The file is loaded, but it is not editable from within the macro! I can use the "iseditable" method to verify that the textarea is not editable after I open the file. I have spent much time and had no luck in finding out how to make the textarea editable after using an "openFile" statement.
I'm sure the answer is simple, but I have not found it.
Any help would be appreciated.
HTML macro
Submitted by Anonymous on Sunday, 7 November, 2004 - 09:13
Hello,
I'm trying to write a macro, that when I select text it adds the tag to that selected text. I have no problem with making that macro. But I do have a problem when I want to make a (un)orded list. I don't know how I have to search for the line ends (/n) in selected text and add text to for every list item.
Can anybody give a hint how I can do that? BTW I don't no much about beanshell and java
Thnx,
Sjmielh
How to use mysql in macro?
Submitted by
AndreJRenard on
Saturday, 6 November, 2004 - 04:39
I would like to address a mysql database in a macro:
I put the connector file (mysql-connector-java-3.0.15-ga-bin.jar) in the .jedit/jars directory and used the following statements:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
...
Class.forName("com.mysql.jdbc.Driver");
...
con = DriverManager.getConnection("jdbc:mysql://" + url + "/" + db, login, password);
But I got the error message:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at bsh.Reflect.invokeOnMethod(Reflect.java:149)
at bsh.Reflect.invokeStaticMethod(Reflect.java:100)
at bsh.Name.invokeMethod(Name.java:872)
at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BshMethod.invokeImpl(BshMethod.java:349)
at bsh.BshMethod.invoke(BshMethod.java:246)
at bsh.BshMethod.invoke(BshMethod.java:179)
at bsh.Name.invokeLocalMethod(Name.java:915)
at bsh.Name.invokeMethod(Name.java:805)
at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.Interpreter.eval(Interpreter.java:641)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:355)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:284)
at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:210)
at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:990)
at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:417)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:229)
at org.gjt.sp.jedit.jEdit$3.invokeAction(jEdit.java:2910)
at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:216)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
What should I do?
Capitalizing First Letters
Submitted by
ELApro on
Wednesday, 27 October, 2004 - 17:05
How can one write a macro to capitalize the first letter of each word? My current approach would be...
search for words with the regular expression...
([a-zA-Z0-9])([a-zA-Z0-9])+
but can a variable eg, firstLetter, be assigned to $1 so that I can set...
firstLetter.toUpperCase();
for long lines macro generate Error - Array index out of range: 3
Submitted by Anonymous on Monday, 18 October, 2004 - 17:10
Why this macro generate Error?
__________________________________________________________
I write this macro:
// Delete 3 chars at start of line for all except first line
// delete lines longer then 930 characters
textArea.goToBufferStart(false);
textArea.goToNextLine(false);
int textAreagetLineCount=textArea.getLineCount();
java.lang.String pos ="";
for(int j = 0; j < textAreagetLineCount; ++j)
{
textArea.goToNextCharacter(false);
textArea.goToNextCharacter(false);
textArea.goToNextCharacter(false);
textArea.deleteToStartOfLine();
textArea.goToStartOfLine(false);
if(textArea.getLineLength(j) >= 930)
{
textArea.deleteLine();
}
textArea.goToNextLine(false);
textArea.goToStartOfLine(false);
}
buffer.save(view,null,true);
jEdit.closeBuffer(view,buffer);
__________________________________________________________
and example of file:
----Begin of file---
title
g line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long lineg line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long lineg line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line long line
g line long line long line long line
---End of file---
__________________________________________________________
produce this error:
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 3
at org.gjt.sp.jedit.Buffer.getLineEndOffset(Buffer.java:935)
at org.gjt.sp.jedit.Buffer.getLineLength(Buffer.java:958)
at org.gjt.sp.jedit.textarea.JEditTextArea.getLineLength(JEditTextArea.java:1280)
at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at bsh.Reflect.invokeOnMethod(Reflect.java:149)
at bsh.Reflect.invokeObjectMethod(Reflect.java:81)
at bsh.Name.invokeMethod(Name.java:856)
at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:102)
at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:47)
at bsh.BSHBinaryExpression.eval(BSHBinaryExpression.java:52)
at bsh.BSHIfStatement.evaluateCondition(BSHIfStatement.java:63)
at bsh.BSHIfStatement.eval(BSHIfStatement.java:46)
at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BSHBlock.eval(BSHBlock.java:46)
at bsh.BSHForStatement.eval(BSHForStatement.java:111)
at bsh.Interpreter.eval(Interpreter.java:641)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:355)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:284)
at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:210)
at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.java:990)
at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:417)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:229)
at org.gjt.sp.jedit.jEdit$3.invokeAction(jEdit.java:2910)
at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:216)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$MenuDragMouseHandler.menuDragMouseReleased(Unknown Source)
at javax.swing.JMenuItem.fireMenuDragMouseReleased(Unknown Source)
at javax.swing.JMenuItem.processMenuDragMouseEvent(Unknown Source)
at javax.swing.JMenuItem.processMouseEvent(Unknown Source)
at javax.swing.MenuSelectionManager.processMouseEvent(Unknown Source)
at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
[FAQ Candidate]: Can I modify the classpath of a macro?
Submitted by Anonymous on Tuesday, 12 October, 2004 - 10:53
Hi all,
Can I modify the classpath of a macro?
It seems that my question have to be inserted in jEdit FAQ.
------------- References from previous discussions
[1] Using external java libraries in macros 1 05/01/2004 - 6:38am
by AndreJRenard 05/03/2004 - 8:30am
by Brad Mace
[2] How do I modify the classpath of a macro? 0 04/09/2004 - 4:09am
by Anonymous
-------------
The only solution suggested in previous discussions by Brad
was to put my jars into jEdit folder.
That's good, but not too handy. BeanShell's addClassPath() command was
much better.
Currently I have my classes compiled in Eclipse workbench and can play
with them from BeanShell script as much as I like. I run my BeanShell scripts
from command-line currently and I hoped that jEdit's BeanShell Console can be
a better tool.
Changing class in Eclipse is enough for script. But if I had to create jar,
put it into jEdit folder and restart jEdit to catch the changes, it makes it
useless.
My suggestion is to reflect this behaviour in jEdit FAQ.
Best regards,
Egor Abramovich
egor_abramovich@mail.ru
how to swap a file's extension in Console
Submitted by
tclark on
Saturday, 25 September, 2004 - 02:30
I'm trying to set up a macro in Console in which, for the current buffer, call it myfile.prg, I am able to have a a particular application run myfile.prg and store the results in myfile.out. What I can't figure out is how, for the output file, to drop the extension .prg and add the extension .out. Using ${n} I can easily store the results in myfile.prg.out. But I don't know how to get rid of the .prg in the file name. Any suggestions would be much appreciated.
Console's macro functions in languages other than BeanShell?
Submitted by Anonymous on Tuesday, 21 September, 2004 - 19:28
I can get Console's macro functions (such as runInSystemShell) to work in BeanShell scripts, but not in Ruby scripts (via the SuperScript plugin). Does anyone know how?
Thanks.
Search a word from one EditPane in a second EditPane of a view
Submitted by
AndreJRenard on
Sunday, 19 September, 2004 - 19:07
I have a view with two EditPanes of two different files. My cursor is on one word of one EditPane. I would like to write a macro to search for that word in the second EditPane.
Selecting the word in the first window is easy but how can I direct the search in the second window? For the time being I only found a way to search in the second file in the SAME EditPane that the first one:
import javax.swing.border.*;
textArea.selectWord();
word = textArea.getSelectedText() ;
SearchAndReplace.setSearchString(word);
SearchAndReplace.setAutoWrapAround(false);
SearchAndReplace.setReverseSearch(false);
SearchAndReplace.setIgnoreCase(false);
SearchAndReplace.setRegexp(true);
SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
SearchAndReplace.find(view,buffer.getNext(),0);
Also I would like to have the found word sitting at the top of the window. How can I do that?
Thanks for hints.
Andre
How to write a macro to Change Auto-Indent Behavior?
Submitted by
drefty on
Wednesday, 15 September, 2004 - 21:45
PROBLEM:
There is one frustrating aspect of auto-indentation
with jEdit that I would like to change with a macro.
Here is some sample text to demonstrate what I am
talking about. ...
1Potato
2Potato
3Potato
4Potato
1Watermellon
2Watermellon
3Watermellon
4Watermellon
If you put the cursor before "1Watermellon"
and then press ENTER, jEdit will auto-indent
to make it the same indentation level as
"4Potato".
This is contrary to what I'd expect because I'm trying
to insert some blank non-indented lines in between 'potato'
and 'watermellon'. I am *not* trying to make watermellon
indented beneath potato.
The problem seems to be that jEdit does auto-indentation
based on the previous *non-blank* line, instead of just
the previous line.
QUESTION:
How can I change this behavior with a macro or with other
means, short of recompiling jEdit.
Using arrays in macros ...
Submitted by
Lee Elms on
Tuesday, 14 September, 2004 - 13:49
I am trying to create an array in a BeanShell macro, e.g.:
int pos[] = new int[4];
gives an error:
Encountered "[" at line 13, column 8.
How do I successfully create an array of 'int' ?
Run Java Programs using Native OS (WinXP) Command Prompt
Submitted by
frankiechayc on
Wednesday, 1 September, 2004 - 03:49
I have many Java programs that read keyboard input from the command line. The Jedit Console plugin currently does not support reading input from keyboard. So I can't run such programs in Console.
I am trying to write a macro which will run the Java program from the buffer using the native OS shell so that the program can accept keyboard input from users. Help or advice appreciated. Thanks
Execute menu item from macro?
Submitted by
kwerle on
Tuesday, 31 August, 2004 - 08:18
I have just written a very useful console command. It works just the way I want. Unfortunately, console doesn't seem to let you create shortcuts for commands you wrote (another issue). Is it possible for me to write a macro that will call a specific menu item?
I just want it to do something very simple:
executeMenuItem("Plugins.Console.MyCommand");
Is there such a thing, and I'm just not seeing it?
TIA
Hold down key macro
Submitted by Anonymous on Wednesday, 25 August, 2004 - 09:22
I want to write a macro that allows me to instruct a specific key to be held down for set period of time. For instance, i need to be able to instruct that the spacebar be held down for x seconds.
Is this possible and how do i go about it?
Thanks in advance.