(Sorry for my bad English. I hope you understand my question)
I have to search a String in a known part of a text. So, I'm looking for a method find(View view, Buffer buffer, int start, int end) in the class SearchAndReplace. But i can't find.
I want to write a macro that grabs out the selected text, manipulates it ( using something other than a search and replace) and then re-inserts the text back into the buffer. What are the magic classes and things I need to do to make this happen?
I want to write a macro that grabs out the selected text, manipulates it ( using something other than a search and replace) and then re-inserts the text back into the buffer. What are the magic classes and things I need to do to make this happen?
Can anyone help me write a macro that will import the date from one, two or three days ago.
Example- On August, 29th, 2006 the macro would generate the following text into a document:
Posted from: 08/26/06
I'm also wondering how to create a simple macro to create bold tags around a selected group of text? I thought this would be simple to find. Perhaps I am just looking in the wrong place? Any help is much appreciated. Thanks!
While the macro is executing, the following error occurs, several times.
java.lang.RuntimeException: Invalid screen line count: 0
at
org.gjt.sp.jedit.textarea.DisplayManager.getScreenLineCount(DisplayManager.java:187)
at org.gjt.sp.jedit.textarea.FirstLine.physDown(FirstLine.java:167)
at
org.gjt.sp.jedit.textarea.DisplayManager.setFirstPhysicalLine(DisplayManager.java:621)
at
org.gjt.sp.jedit.textarea.JEditTextArea.setFirstPhysicalLine(JEditTextArea.java:545)
at
org.gjt.sp.jedit.textarea.JEditTextArea.scrollTo(JEditTextArea.java:767)
at
org.gjt.sp.jedit.textarea.JEditTextArea.scrollTo(JEditTextArea.java:673)
at
org.gjt.sp.jedit.search.SearchAndReplace.find(SearchAndReplace.java:641)
at
org.gjt.sp.jedit.search.SearchAndReplace.find(SearchAndReplace.java:498)
at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
(...)
Hello Everyone,
I am creating a macro, using hypersearch_results_to_buffer as a starting point. I have modified the macro so far so that the path is not included. Now, I would like to strip out the line number. Using the following code:
traverseTree(javax.swing.tree.DefaultMutableTreeNode node, StringBuffer results){
if (node.getUserObject() instanceof org.gjt.sp.jedit.search.HyperSearchFileNode)
{
path = node.getUserObject().path;
match = node.getFirstChild();
while(match != null)
{
text = match.getUserObject().str;
results.append(text + "\n");
match = match.getNextSibling();
I get results like:
1770: material CabinetBase
1792: material CabinetBase_Panel_01.jpg.001
So I try to modify the block to:
text = match.getUserObject().str;
myStrLoc = (text.indexOf(":")+1);
text = text.subString(myStrLoc);
results.append(text + "\n");
match = match.getNextSibling();
However, every time I try to run the macro, I get the following error:
Sourced file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : Error in method invocation: Method subString( int ) not found in class'java.lang.String' : at Line: 37 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : text .subString ( myStrLoc )
Called from method: writeHypersearchResultsToBuffer : at Line: 81 : in file: C:\Program Files\jEdit\macros\Misc\HyperSearch_Results_to_Buffer2.bsh : writeHypersearchResultsToBuffer ( view )
I have tried using text = text.subString(1); and text = text.subString(1,8);
...but I get the same results.
What am I missing?? Thanks in advance for your help!!
Hello Developpers
I have a lite Script who work fine in Jedit 4.2 but not in 4.3pre5 and not in 4.3pre6.
The Console Window open and wait but there are errors in the Command Window and in the BeanShell Window.
Is there any idea what I can change?
Regrads,
Fabio
Hello Developpers
I have a lite Script who work fine in Jedit 4.2 but not in 4.3pre5 and not in 4.3pre6.
The Console Window open and wait but there are errors in the Command Window and in the BeanShell Window. Is there any idea what I can change?
Regrads,
Fabio
import console.Console;
{
Buffer b = view.getBuffer();
String strName = b.getName();
String strPath = b.getPath();
String strCmd = new String("java.exe -jar \"C:\\Programme\\Interlis\\ili2c\\ili2c.jar\" --without-warnings \"" + strPath + "\"");
runCommandInConsole(view, "System", strCmd);
}
1) Console Window:
[error] BeanShell: java.lang.NoClassDefFoundError: org/gjt/sp/jedit/search/RESea
rchMatcher
[error] BeanShell: at console.StreamThread.(StreamThread.java:226)
[error] BeanShell: at console.ConsoleProcess.(ConsoleProcess.java:65)
[error] BeanShell: at console.SystemShell.execute(SystemShell.java:222)
[error] BeanShell: at console.Console.run(Console.java:429)
[error] BeanShell: at console.Console.run(Console.java:226)
[error] BeanShell: at console.Console.run(Console.java:202)
[error] BeanShell: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho
d)
[error] BeanShell: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Sourc
e)
[error] BeanShell: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown S
ource)
[error] BeanShell: at java.lang.reflect.Method.invoke(Unknown Source)
[error] BeanShell: at bsh.Reflect.invokeOnMethod(Reflect.java:148)
[error] BeanShell: at bsh.Reflect.invokeObjectMethod(Reflect.java:80)
[error] BeanShell: at bsh.Name.invokeMethod(Name.java:856)
[error] BeanShell: at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)
[error] BeanShell: at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:1
02)
[error] BeanShell: at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:4
7)
[error] BeanShell: at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
[error] BeanShell: at bsh.BSHBlock.eval(BSHBlock.java:80)
[error] BeanShell: at bsh.BshMethod.invokeImpl(BshMethod.java:349)
[error] BeanShell: at bsh.BshMethod.invoke(BshMethod.java:246)
[error] BeanShell: at bsh.BshMethod.invoke(BshMethod.java:179)
[error] BeanShell: at bsh.Name.invokeLocalMethod(Name.java:956)
[error] BeanShell: at bsh.Name.invokeMethod(Name.java:805)
[error] BeanShell: at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:72)
[error] BeanShell: at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:1
02)
[error] BeanShell: at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:4
7)
[error] BeanShell: at bsh.BSHBlock.evalBlock(BSHBlock.java:130)
[error] BeanShell: at bsh.BSHBlock.eval(BSHBlock.java:80)
[error] BeanShell: at bsh.BSHBlock.eval(BSHBlock.java:46)
[error] BeanShell: at bsh.Interpreter.eval(Interpreter.java:641)
[error] BeanShell: at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:339)
[error] BeanShell: at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:284)
[error] BeanShell: at org.gjt.sp.jedit.BeanShell.runScript(BeanShell.java:210)
[error] BeanShell: at org.gjt.sp.jedit.Macros$BeanShellHandler.runMacro(Macros.
java:1012)
[error] BeanShell: at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:435)
[error] BeanShell: at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandl
er.java:229)
[error] BeanShell: at org.gjt.sp.jedit.jEdit$3.invokeAction(jEdit.java:2933)
[error] BeanShell: at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditA
ction.java:224)
[error] BeanShell: at javax.swing.AbstractButton.fireActionPerformed(Unknown So
urce)
[error] BeanShell: at javax.swing.AbstractButton$Handler.actionPerformed(Unknow
n Source)
[error] BeanShell: at javax.swing.DefaultButtonModel.fireActionPerformed(Unknow
n Source)
[error] BeanShell: at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
[error] BeanShell: at javax.swing.AbstractButton.doClick(Unknown Source)
[error] BeanShell: at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown So
urce)
[error] BeanShell: at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseRelea
sed(Unknown Source)
[error] BeanShell: at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source
)
[error] BeanShell: at java.awt.Component.processMouseEvent(Unknown Source)
[error] BeanShell: at javax.swing.JComponent.processMouseEvent(Unknown Source)
[error] BeanShell: at java.awt.Component.processEvent(Unknown Source)
[error] BeanShell: at java.awt.Container.processEvent(Unknown Source)
[error] BeanShell: at java.awt.Component.dispatchEventImpl(Unknown Source)
[error] BeanShell: at java.awt.Container.dispatchEventImpl(Unknown Source)
[error] BeanShell: at java.awt.Component.dispatchEvent(Unknown Source)
[error] BeanShell: at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
Source)
[error] BeanShell: at java.awt.LightweightDispatcher.processMouseEvent(Unknown
Source)
[error] BeanShell: at java.awt.LightweightDispatcher.dispatchEvent(Unknown Sour
ce)
[error] BeanShell: at java.awt.Container.dispatchEventImpl(Unknown Source)
[error] BeanShell: at java.awt.Window.dispatchEventImpl(Unknown Source)
[error] BeanShell: at java.awt.Component.dispatchEvent(Unknown Source)
[error] BeanShell: at java.awt.EventQueue.dispatchEvent(Unknown Source)
[error] BeanShell: at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unk
nown Source)
[error] BeanShell: at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unkno
wn Source)
[error] BeanShell: at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[error] BeanShell: at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[error] BeanShell: at java.awt.EventDispatchThread.run(Unknown Source)
2) BeanShell Window:
java.lang.NoClassDefFoundError: org/gjt/sp/jedit/search/RESearchMatcher
at console.StreamThread.(StreamThread.java:226)
at console.ConsoleProcess.(ConsoleProcess.java:65)
at console.SystemShell.execute(SystemShell.java:222)
at console.Console.run(Console.java:429)
at console.Console.run(Console.java:226)
at console.Console.run(Console.java:202)
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:148)
at bsh.Reflect.invokeObjectMethod(Reflect.java:80)
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.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:956)
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.BSHBlock.evalBlock(BSHBlock.java:130)
at bsh.BSHBlock.eval(BSHBlock.java:80)
at bsh.BSHBlock.eval(BSHBlock.java:46)
at bsh.Interpreter.eval(Interpreter.java:641)
at org.gjt.sp.jedit.BeanShell._runScript(BeanShell.java:339)
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:1012)
at org.gjt.sp.jedit.Macros$Macro.invoke(Macros.java:435)
at org.gjt.sp.jedit.gui.InputHandler.invokeAction(InputHandler.java:229)
at org.gjt.sp.jedit.jEdit$3.invokeAction(jEdit.java:2933)
at org.gjt.sp.jedit.EditAction$Wrapper.actionPerformed(EditAction.java:224)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.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$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.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)
in the ongoing process to adapt all my work the JEdit
I am also finding some limits though. For example, I'll just
execute a buffer with a script engine and the console plug-in does this. But I would like to control, if a COMMAND uses a buffer via TO_BUFFER or just outputs into the console itself.
Is there any way to modify the running buffers properties from the running script?
I just tried:
this.toBuffer = true;
but - even this don't raise any errors - it just does not work.
Providing the GUI for this is easy.
Any help would be great!
Hi All !
I am new to jEdit and try to organize my work around it now.
While writing a library for the XInsert plugin - to be used with VBScript - I got a strange problem.
The statement:
if( (filename.lastIndexOf(".") != 0) && (filename.lastIndexOf(".") > firstPos) )
{
....
}
could not be parsed and the library was out of order and unusable.
This seems to be the fact, because XInsert expects xml !!!
{@
... XInsert expects xml here!!!
}
The workaround I used, was to include the script/macro part into another CDATA section:
This prevents the xml-parser to interpret the macro code and everything is ok.
I found no better docs and discovered it this way. May be, this helps others too. Any other solution is very welcome.
I insert a marker into a buffer, before I make some modifications to it;Just to remember my starting position. After I finish my task, I will remove the marker, but this fails.
My code[snippet] is as follows:
char mc = 'X';
buffer.addMarker(mc, 6);
... my buffer-modies here ...
Marker m = buffer.getMarker(mc);
buffer.removeMarker(m.getPosition());
The marker is stil there [and "m" is NOT null!]
Any help would be really very welcome.
Thanks,
Manfred
I use the FTP plugin to give me remote access to files. I am trying to write a macro to look in the directory of the file I have open in a buffer and determine if another file exists in the same directory.
On a local file system I would simply create a File instance using a path string I constructed and check to see if it exists, like this:
dirname = dir(buffer.getPath());
FQPN = dirname + "new file name";
java.io.File newFile = new java.io.File(FQPN);
if (newFile.exists()) {
//do stuff
}
If I try this when my buffer is on my remote server, newFile.exists() always returns false, regardless of whether the file actually exists or not. I think this is because dirname is something like "ftp://myuserid@myremotehost:21/path/to/new_file_name" and the normal java.io.File.exists() method does not understand URI's like this.
Any ideas on how to tell if the remote file exists or not?
I tried unconditionally opening the file and checking the length of the buffer, expecting a new file to have zero length and then I could close it immediately, but since jEdit.openFile(view, pathToFile) does not seem to be a blocking operation, trying to get the buffer length did not work:
1. aBuffer = jEdit.openFile(view,FQPN);
2. if (aBuffer.getLength() == 0) {
3. // file is new, so close it, as I only want new buffer if file exists
4. }
Could I put a VFSManager.waitForRequests() call between line 1 & 2 to wait for the FTP I/O to complete before checking the buffer length? Is this a static call? If not how to I get access to the VFSManager instance associated with my FTP connection?
I wrote a macro to sort lines of selection or whole buffer.
After I finished it I found there is another sort lines macro here. (Oh! why I don't search it before write this one. )
But my macro is more powerful than the one exist, though the dialog of that one is more pretty.
------------------------------------
Here is the description of my macro, just like the sort tool in editplus 2.
Sort selected lines or whole buffer (when nothing is selected).
This is just similar to the sort function in Editplus 2.
Features:
Order -
Either ascending order or descending order.
Starting column -
Enter a column number from which the sorting operation begins. The text before this column number will be sorted when string after the column is the same. Enter an integer value great than or equals to 1.
Case sensitive -
The case-sensitive comparison option.
Remove duplicates -
Remove any duplicated line after the sorting option.
You can download it here -> download.
Or view the download page here -> download page.
Or you like the old one created by Pascal Dal Farra.
I was playing around with Lee Turner's script (which appears to have started here: http://community.jedit.org/?q=node/view/1128), and because I work with PHP I wanted one to recognise both single and double quotes, and there's also the problem with his that if the caret is between quotations, the space between them gets selected. The latter's not that big of a problem, but trying to allow for both types of quotes is tough.
I thought I had it with this: basically track all openings and closings of quotes in the buffer prior to the caret (in PHP a ' inside "..." doesn't count and vice-versa), and if a quote is open at the caret, search after the caret to find its mate, and select between them. But then if a comment contains apostrophes or irregular double-quotes, this won't work! I could get very complicated and detect comments, but this is language-specific and what I've been thinking from the start is that it would be nice to abstract the searching from the quote syntax.
So my real question is: is there a way for a macro to interact with jEdit's syntax highlighter? It's a waste for my macro to do the work of finding quoted sections when jEdit has obviously already done the work. I'm envisioning methods get the token type of the text under the caret, get the boundaries of a given token section, etc. I've tried looking through the API docs, but (1) I'm don't really understand how the highlighting engine works, and (2) it all feels a little over my head. I am pretty green with Java.
Hi,
I have made a smal commando script to compile (with wmake) and run an application.
This script do 2 thinks, first it compiles my app and then run it (in the system shell) in a directory specified by the user.
This commando script works well with Jedit 4.2final but I'm unable to make It work with Jedit 4.3pre3 with console 4.2.5.1 and 2sdk1.5-sun: the compilation with wmake works fine but I'm unable to lauch my app ? But the 4 commands in the commando dialog are there but in only do the first two ...
Is it a bug with console 4.2.5.1 ?
Any ideas ?
Here is the commando xml file:
buf = new StringBuffer("cd ");
buf.append(compildir);
buf.toString();
buf = new StringBuffer();
if (target.equals("wmake_all")) {
buf.append("wmake");
}
else if (target.equals("wmake_debug")) {
buf.append(" ");
}
else if (target.equals("wmake_clean")) {
buf.append("wclean");
}
buf.toString();
buf = new StringBuffer();
if (exe) {
buf.append("cd "+casedir);
}
buf.toString();
buf = new StringBuffer();
if (exe) {
buf.append(application+" .. ");
buf.append(MiscUtilities.getFileName(casedir));
}
buf.toString();
I am writing a Macro that enables a simple kind of Wiki link in any text file. Basically if I run my macro, it finds the nearest words in [brackets] and uses that as a file name to open. It works well, but I added the feature to jump to an anchor [filename#anchor] and I cannot figure out how to get it to jump to text in a document. Here is what I have:
It behaves very erratically. It always opens the new file ok. But then it sometimes finds the anchor text, but usually does not. I've tried resetting the cursor to the top of the file to make sure it isn't past the anchor text:
view.getTextArea.setCaretPosition(0);
But that didn't help.
Strangely, if I add this:
Macros.message(view, "finding " + anchor);
before the find, it works! I suspect the popup window causes the interface to 'refresh' in some way bringing the newly opened file to some displayed state, as opposed to some open-but-not-yet-displayed-state... but I'm just guessing here...
I'm interested in writing a macro to generate all of my projects in ProjectViewer. Anyone know if this level of interaction with ProjectViewer is possible. I'm also having trouble generating the complete JavaDoc API for ProjectViewer - anyone know if this is available online?
One of my macros saves open buffers, but it pops up an error message anytime it tries to save a file that is in use by another process, and I'd like to avoid that error message, by not trying to say that particular buffer. Is there a way to check a buffer and see if it is being used by another process?