jEdit Community - Resources for users of the jEdit Text Editor
corpus for computational linguisitcs
Submitted by hamyfox on Sunday, 27 September, 2009 - 20:49
Hi,

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.
Selecting lines between two points?
Submitted by hungryOrb on Wednesday, 9 September, 2009 - 02:25
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
Create Global Object in macros
Submitted by Jabberwock on Friday, 24 July, 2009 - 06:05
Hello,

How i cab create a global object in Macro ?

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

It's poossible ?

Thw very much
autocomplete macro question
Submitted by fenderog on Friday, 24 April, 2009 - 17:33
Hello everyone,

I want to write a macro that does a simple autocomplete. It is a macro that I've had for nedit and I would like to get it working on jedit but I dont have too much experience with java so I wanted to ask for a starting point

Pretty much what I want to have is a macro that once executed, searches the buffer *backwards* starting from the current position. and replaces the current word with the first found result , once executed again, replace it with second results , and go on.

here is an example
string $variableA = "bla";
string $variableB = "blabla";
string $variableC = "blablabla";

string $var -> right when I type this , I'd like to execute this macro , and it would replace $var with $variableC , $variableB $variableA


I'm not asking someone to write this for me, I just wanted to know if there is something out there similar that you might have encountered , if not just some example of a macro that's similar to this would be great

Thanks in advance !!
View the console output during the macro
Submitted by lilive on Friday, 13 February, 2009 - 10:02
Hello,
I wrote a macro to compile a file, using :
runCommandInConsole(view, "System", compilCommand);

It work fine. I want to view the console output, so I add :
view.getDockableWindowManager().showDockableWindow("console");

The problem is that the console panel open at the end of the macro.
Does anybody know how to make it open during the macro execution ? Because I want to see the output during the compilation process.

Thank you.

--- and sorry for my english --- just a french ... ---
Run macro in a specific EditPane split screen
Submitted by kircheis on Friday, 6 February, 2009 - 10:16
Someone asked something like this but got no answer.
http://community.jedit.org/?q=node/view/1688

I'm working with some old Cobol code full of "go to" instructions, so I wrote a macro that would take me to the corresponding place in code so I don't have to look for it manually.

I have jEdit screen split vertically in two, working on the same file. I tried adapting my macro to go to the next pane and search from there instead of the first one and then set the focus back again to the first pane.

I tried using view.nextTextArea(), but only the cursor go to the next pane, the macro still runs on the first pane. Then I tried using EditPane setBuffer, but it also runs on the same side of the split screen. Is there some other class with the methods I need or am I doing something really wrong?
Starting a java jar from a Beanshell and vice versa
Submitted by bigmoun10 on Friday, 23 January, 2009 - 15:29
Hi

First, I'm new to all this java and beanshell stuff. Please be patient with me.

In general
* all beanshell files are stored on "C:\Program Files\jEdit\macros\xyMacros" and
* all jar files are stored on "C:\Program Files\jEdit\jars".

First problem:
==============
I want to extend jEdit with a beanshell macro, which calls xy.class in xy.jar file. The class in the class file is defined as "public class xy extends JDialog" and the main method is defined the following way:

public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() ...

The jar file also contains other source files like icons and additional class files.

Now, the question is: how can I call the java code from the beanshell macro and what is needed to make it work (e.g. classpath, imports, ...)?

Second problem:
===============
Once the java code is executed and the dialog pops up I would like to execute a beanshell script, let's say myScript.bsh, when a certain button is pushed. The beanshell script then manipulates the textarea of the actual view in jEdit.
Questions here: How can I call beanshell scripts from the java code? Is there anything I need to do regarding the actual view, e.g. storing it in the java class and then give it to the beanshell script as an argument, or is this working right away?

If somebody could answer and give code examples, this would be great!
Thanks in advance!
RegExp - Replace special characters in a string
Submitted by jrchilds on Thursday, 15 January, 2009 - 20:00
I am writing a macro that will take highlighted text, convert any non alpha numeric characters to underscores, and then open a .chm file to the topic named by the resulting string. I can make everything except the regular expression part of that work. I only yesterday started playing with regular expressions, and I'm not sure how to do this, and google was not much help. Here is what I need.... I have, SomeVariable= "?This!String@1#2&3." I need to make SomeVariable= "_this_string_1_2_3_" Here is the set I want to replace [!@#$%^&*()<>{}[]?~`|\/] Is this an easy thing to achieve? Thanks for the help.
Current project directory
Submitted by takeshin on Saturday, 1 November, 2008 - 12:11
Hi!

How to get current project directory? (stored in ProjectViewer's xml)
I'd like to have action "add new file to this project".

--
takeshin
disable undo temporary
Submitted by takeshin on Wednesday, 29 October, 2008 - 14:04
Hi!

I have a macro which updates comments at the beginning of the buffer.
Then, when I edit the file and press Ctrl+Z, cursor goes to the beginning of file,
where macro operated.

How to disable undo temporary, so commands executed in macro were not registered in history?

--
takeshin
How to clear only invalid entries in Recent Files
Submitted by tvojeho on Wednesday, 22 October, 2008 - 18:26
Hi all,

I was wondering if there was a way for a macro to go through the items in Recent files list and delete invalid entries, leaving the rest. My Java know-how is not very extensive, and after some googling and searching the default macros code, I have put together a few lines of code which luckily do not throw an exception, but unfortunately do not apply the desired changes to Recent Files menu.

I would be grateful for any help.

  Cheers, tvojeho.

  

BufferHistory.Entry[] recentBuffersArray = BufferHistory.getHistory().toArray(new BufferHistory.Entry[0]); // get history

for(i=0;i {

recentPath = recentBuffersArray[i].path;

if( ! new File(recentPath).exists())

{

BufferHistory.Entry removeEntry(recentPath);

}

}

return;

Wait for buffer reload
Submitted by takeshin on Friday, 17 October, 2008 - 11:06
When i run:
buffer.reload(view);
buffer.save(view, null); // or other I/O

I get: I/O Error
Each buffer can execute only one I/O operation at one time.

How to wait until buffer reloads?
I can't modify textArea until it completes to reload.

I suppose I have to use BufferAdapter and bufferLoaded method. But how to do it?

--
regards,
takeshin
Can I parse the errorlist?
Submitted by PaulCollingwood on Thursday, 21 August, 2008 - 10:59
I have an errorlist being generated from Lint, and so I can move to each warning and error within the code.
What I would like to do is write a macro that, for a given buffer and cursor position is first able to acquire the full path name and file line number (this bit I can do) and then parse the errorlist content looking for a match.
I would then like to insert the comment in the preceding line of the form '/*lint */' which would prevent such errors in future - again. the comment insertion I know how to do.

The question is this - is there a way to parse the errors in the errorlist, extracting file-name, line-number, and error-message for each item in the process?
Search and replace - right way
Submitted by takeshin on Sunday, 17 August, 2008 - 21:48
I have recorded macro like this:

SearchAndReplace.setSearchString("\\{[\\s\\t]+"); SearchAndReplace.setReplaceString("\\{ "); SearchAndReplace.setBeanShellReplace(false); SearchAndReplace.setIgnoreCase(true); SearchAndReplace.setRegexp(true); SearchAndReplace.setSearchFileSet(new CurrentBufferSet()); SearchAndReplace.replaceAll(view);

It works fine, but slow and it beeps each time and so on.

How it should be coded using java.util.regex?

--
regards,
takeshin
Macro or shortcut for Reload with Encoding UTF-8
Submitted by JanciB on Sunday, 17 August, 2008 - 17:24
How can I make macro for "Reload with Encoding UTF-8"? Or can it have a shortcut? I use it often and it is annoying to go through the menu every time.
indicate progress, status bar
Submitted by takeshin on Thursday, 31 July, 2008 - 17:36
I wrote a macro which takes a long time to execute.
(while loop operating on texarea text). While the macro works, jEdit is frozen, and user may think it hanged.
How to notify user that everything is ok?
How to set statusbar message?

How to indicate progress of the macro?
It would be nice to have message box saying: macro in progress… [cancel]

How to use observers in macros?

--
regards,
takeshin
Send Selection To ...
Submitted by Kel Solaar on Friday, 4 July, 2008 - 07:53
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 Smiling 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";

Registers.copy(textArea,'$');
jEdit.newFile(view);
Buffer newBuffer = view.getBuffer();
Registers.paste(textArea,'$',false);
newBuffer.save(view, currentFile);
runInSystemShell(view, "\"" + pythonPath + " -t \"" + currentFile + "\"");
How to parse HTML/DOM to set ID attributes
Submitted by takeshin on Thursday, 19 June, 2008 - 09:23
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?

TIA,
takeshin
Collating file names - basic help.
Submitted by PaulCollingwood on Friday, 6 June, 2008 - 11:50
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.

Thanks in advance,
Paul
File manipulation - what's wrong with this macro?
Submitted by PaulCollingwood on Friday, 6 June, 2008 - 11:41
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
User login
Browse archives
« June 2026  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   130670
Context Free Art (*.cfdg)   0.31   46079
BBEdit scheme   1.0   18614
JBuilder scheme   .001   18515
ColdFusion scheme   1.0   18048
R Edit Mode - extensive version   0.1   17498
Advanced HTML edit mode   1.0   16231
Matlab Edit Mode   1.0   16093
jEdit XP icons   1.0   15250
XP icons for jEdit   1.1   14314