I would like to be able to both detect whether the Incremental Search Bar is displayed, and to close it if it is displayed in a macro (Beanshell). I can't find anything in the API ... I hope I'm missing something obvious.
(I know that there is a command to display the Incremental Search Bar ('Incremental Search Bar'). Also that the macro record facility doesn't record the operation of displaying or closing the bar.)
I made a macro that opens our programming language reference, which is a PDF, and locates the definition for the selected command.
I also have a batch file that installs jEdit and copies the configuration changes needed for editing in our own language. This install is used by anyone who wants to develop in our language.
Here's the problem... In Beanshell, I am using the exec() command to launch the PDF, which requires the full path to the acrobat reader. This is of course different based on the operating system and installed version of the reader.
Here's my question... Is there a way that I can determine the install directory of the acrobat reader? Or is there a simpler solution I haven't yet considered?
I'm trying to figure out how to open html docs in a web browser using jython, but I'm not able to get the webbrowser to load.
I've tried the following:
import webbrowser
Error:
File "C:\Documents and Settings\Administrator\.jedit\macros
\MayaHelp.py", line 3, in ?
ImportError: no module named webbrowser
========================================
from org.gjt.sp.jedit import webBrowser
Which is found using autocompletion but nonetheless throws this error:
ImportError: cannot import name webBrowser
========================================
I also tried:
from org.gjt.sp.jedit import browser
which doesn't throw an import error, but it doesn't have 'open',
'openURL', or 'open_new_tab' attributes, so I assume that isn't a web browser.
ERROR:
Traceback (innermost last):
File "C:\Documents and Settings\Administrator\.jedit\macros\displayHTMLTest.py", line 7, in ?
NameError: InfoViewerPlugin
While messing around with the Template plugin I decided it was pointless to have different templates to take into account differences in comment characters for
different languages, so I poked around to see if I could find a way around this and came up with this.
--
## template = Get mode comment char
#*
Get the line comment character for the current buffer's mode. If the mode
doesn't define a line comment character, complain and ask what prefix
string to use instead. $comment will contain the results either way.
*#
#beanshell (false)
context.put("caret", view.getTextArea().getCaretPosition());
context.put("comment", buffer.getContextSensitiveProperty(caret,"lineComment"));
#end
#if ( $comment )
#else
#prompt ( "Mode doesn't have a line comment. String prefix to use?" $comment )
#end
--
Put that in a file called "getcommentchar.vm" in your templates directory, then in other templates you can do:
--
#parse ( "getcommentchar.vm" )
${comment} Lorem ipsum
${comment} dolor sit amet, consectetur adipiscing
--
The inserted text will be preceded by whatever passes for line comments in the buffer's language, or the prefix text you gave.
You have a macro to do a search in the projects tree, and some for load/unload project, and one to add a project.
If you want to use the unload macro, call always the macro Export.bsh
If you want to load a project, call Import_Tree_Project.bsh, if you want to load a tree project, or Import_a_project.bsh if you want to load only one project.
The Add_project.bsh macro, add a project, and the focus stay where your are, and don't go inside the new project.
Hi all,
This may be useful for newbies. A macro based on the "Insert Tag" macro which comes with jEdit, but which surrounds the selected text with b and /b tags. I bound it to Ctrl-B and it's a very useful way to quickly make a word bold.
void insertTag(tag)
{
caret = textArea.getCaretPosition();
if( tag == null || tag.length() == 0) return;
text = textArea.getSelectedText();
if(text == null) text = "";
sb = new StringBuffer();
sb.append("<").append(tag).append(">");
sb.append(text);
sb.append("").append(tag).append(">");
textArea.setSelectedText(sb.toString());
//if no selected text, put the caret between the tags
if(text.length() == 0)
textArea.setCaretPosition(caret + tag.length() + 2);
}
if(buffer.isReadOnly())
Macros.error(view, "Buffer is read-only.");
else
insertTag("b");
There are two ways to select a block of text in jedit as far as I know.
1) press [Alt] + [\] to enter block selection mode. Then use [Shift] and the Arrow keys.
2) press [Ctrl] + the Left mouse button.
While these are both useful, I am trying to figure out if there is a way to make a third option
3) [Alt] + Arrow keys
The advantage is that it wouldn't leave you in Block Selection mode like 1, and you wouldn't have
to move your hand to the mouse, like 2.
I tried making a macro of 2, but the macro recording facility won't register mouse events.
Is there a way to do this?
I am working on a project at my law school. I receive news articles in .docx format and then convert them to .html. This requires a lot of cleanup of the extra tags Word puts into the text. I have a very simple macro that does a find and replace to delete common unneccessary tags. What I want to do is the entire header tag and its contents (and other tags such as table tags).
I have no programming background and can't figure it out. How would I have a macro search for (head) and (/head) and then delete the tags and everything in between?
Thank you ahead of time for any insights you can give me,
as soon as the script tries to execute the textArea.setSelectedText, I get an exception "Text component read only". Has anyone an idea why I get this exception?
Moving the buffer1.save downward to the buffer2.save the script works fine.
The next challenge: if I try to write in the buffers alternate (first in buffer1, next buffer2 and then in buffer1 again) all the text is written in just one buffer. how do I select where my text is written?
I'm trying to change my existing macro of uppercasing keywords to use exactly the case that is given by the Keyword-XML file, e.g. gettext -> getText instead of GETTEXT.
I get the next token bei using Token.next. But I only get the representation in my TextArea. How can I retrieve the corresponding original Keyword as given by the XML file?
This was posted to jEdit-users but I never saw it show up, so is being re-
submitted it here.
I'm using jEdit 4.3.1 under Mac OS X.6.2 (Snow Leopard).
I recorded a macro to reformat a paragraph differently from how the re-
gular Format macro does it. This 'Reformat' macro is supposed to reformat
only from the line containing the cursor, put two spaces (instead of one)
after the sentence-end punctuation, and finally place itself at the be-
ginning of the next paragraph.
When recorded, it does exactly this, but when run as a macro it doesn't.
Here's what happens. Suppose I have 3 paragraphs, 1, 2, and 3, and the
cursor is somewhere in para 1. Then Reformat
- separates sentences in the region between the cursor and the end of
para 1 with two spaces,
- joins para 1 and para 2 by deleting the empty line separating them
(but without reformatting para 2), and
- if the cursor was on the 1st line of para 1, it moves it to the begin-
ning of that line; if the cursor is below the 1st line of para 1, it
places it at the beginning of para 3.
I'm trying to write a macro to renumber footnotes links in a document - it's pretty simple: I just need to capture the previous number in a backreference, add an offset to it, and rewrite the link with the result. I've got the regex search worked out, but I'm completely in the dark on the syntax for the replacement. This looks like a situation where using a beanshell snippet would be appropriate, but I'm no java programmer.
What I need is:
[value in backreference plus the offset number]
Any help would be appreciated.
You will of course need to have a copy of the YUI compressor and my need to edit the myPathToYUICompressor var above.
Additionally, as written, the code assumes you name your javascript sources with '.source' in the filename. Modify to '-uncompressed' or somesuch as to your practice.
*For a windows install, locate 'Run_Script.bsh' in the as-installed JEdit directory.
-Windoz: C:\Program Files\jEdit\macros\Misc\Run_Script.bsh
-LINUX: probably eg /usr/share/jedit/ (try >> whereis jedit)
Copy 'Run_Script.bsh' into your personal ~/.jedit/ directory. I did so and also renamed it to 'Run_Skript.bsh' so that all of my customized jEdit scripts are in my personal directory, hidden from jedit upgrades.
example:
w/in jedit, i am editing /path/to/my/JS/myJS.source.js
hitting the macro with the uncompressed javascript file in the buffer produces /path/to/my/JS/myJS.js as a compressed version.
I have created a macro that calls toogleRangeComments method from the TextToolsComments plugin if I have made a selection of code else i call toggleLineComments. When I execute this I get a "java.lang.IllegalMonitorStateException" exception, is there something i'm doing wrong ?
Hi, first message here. I have been using jEdit for a short time. I've found it as a replacement for UltraEdit and coding is not my need.
Running Macros/Scripts is what I need to do from time to time to clean up files coming in different formats.
I've had many memory issues with jEdit. But this is something I can't solve. It seems to be jEdit related but I think some of you may help.
I have a 162MB text file, opening chews about >330MB (the Heap is at 2GB now)
I run this Macro (avoiding some obvious constants and declarations) (SEE BELOW)
It works fine, but the memory ramps to 2GB, stays like that for about 30 minutes until I get a message from BeanShell that GC has run out of heap memory.
As you can see, my code does not "retain" things in memory, so I don't see why it's doing that.
I've set the Autosave time to "0" and Undo to "0".
while (SearchAndReplace.find(view))
{
SearchAndReplace.setSearchString("\\d+\\.\\d+");
SearchAndReplace.find(view); //Find first number in line
strTemp = textArea.getSelectedText(); //Copy to a String
SearchAndReplace.setSearchString("\\s+.*\\s+(?=(\\d|-))");
SearchAndReplace.find(view); //Find some other numbers
textArea.backspace(); //Erase that
//Add spaces until caret gets to the column it should be
while ( (textArea.getCaretPosition()-textArea.getLineStartOffset(textArea.getCaretLine()))
< 19)
{
textArea.setSelectedText(" ");
}
textArea.setSelectedText(strTemp); //Paste the previously copied number
//Add spaces until caret gets to a specified column
while ( (textArea.getCaretPosition()-textArea.getLineStartOffset(textArea.getCaretLine()))
< 32)
{
textArea.setSelectedText(" ");
}
I recently discovered Jedit and started working with Jedit macros.
This site resources have been very helpful in assisting me with writing
a search and replace macro for HTML documents for corpus purposes.
I would like to clean HTML files and save them into txt files.
I am familiar with classes and methods from C++ but not quite
with Beanshell coding. Are there any references for Beanshell codes and methods ?
I would appreciate any help, in form of macro code for the following:
1- macro to delete first x lines of a document
2- macro for keeping only contents of title, paragraph or body of an HTML document
Any help in this matter through code or references would be greatly appreciated. Thanks.
Hi all!
I'm a noob user, and am having trouble selecting lines between two points.
In example:
-----------
Text between Div1
Text between Div2
In the macro, I might want to start the cursor at the first div open, then use the search function to find the close so the cursor is at
then press up arrow once, select the line (Div2 line) then add to the selection everything from that line upwards to where my cursor started. So after all, the selection will contain every line from
to "Text between Div2".
However, when I try this, I use the CTRL+F search function, and any selection I have, is overwritten when you hit search and the thing you are looking for replaces the selection. Having 'Multiple Selection' option checked doesn't help..
Thanks for considering my plight!
O
In my case, i create a TelnetWrapper object with the connection, how I can create a global object, becaus i dont' want to process the reconnection, i prefer to re-use my previous object ?
For example :
step 1 : i launch my macro, i create the TelnetWrapper object_toto with the connection.
step 2 : i launch again my macro, but i want to re-use my object_toto without re-connection