jEdit Community - Resources for users of the jEdit Text Editor
How do I determine whether a file exists?
Submitted by PaulCollingwood on Thursday, 17 April, 2008 - 15:43
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 know how this is achieved?

Thanks in advance!
JDialog modal doesnt seem to work in bsh macro
Submitted by drefty on Thursday, 17 April, 2008 - 12:54
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.
Open Search & Replace Dialog
Submitted by andyc on Monday, 4 February, 2008 - 21:56
Hi,

I have what I hope is a simple problem...

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.

Many thanks,

Andy
Run Macro on Shutdown?
Submitted by MasterT on Tuesday, 8 January, 2008 - 15:12
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?
How to use SearchAndReplace in a loop?
Submitted by tvojeho on Wednesday, 21 November, 2007 - 16:59
Hello,

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.

Thanks, tvojeho
Syntax highlight
Submitted by gregus on Tuesday, 23 October, 2007 - 06:52
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.
Return xpath of selected xml element or attribute
Submitted by paulflory on Saturday, 29 September, 2007 - 01:05
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
selecting text from current position till a pattern to search
Submitted by rsc on Monday, 3 September, 2007 - 11:35
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.

What did I miss?

Thanks for your help, Rolf.
Creating a macro that configures Buffer Options and ConfigurableFoldPlugin
Submitted by mbisping on Tuesday, 7 August, 2007 - 13:38
Hi there, I'd like to have a macro that sets the buffer option folding to custom and configures the ConfigurableFoldPlugin to use
Creating a macro that configures Buffer Options and ConfigurableFoldPlugin
Submitted by mbisping on Tuesday, 7 August, 2007 - 13:27
Hi there, I'd like to have a macro that sets the buffer option folding to custom and configures the ConfigurableFoldPlugin to use
IDE for writing jEdit BeanShell macros?
Submitted by Giesen on Tuesday, 5 June, 2007 - 15:51
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?
How to get the string of line comment token(s)?
Submitted by galou on Thursday, 10 May, 2007 - 09:47
Hi,

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).

Can someone help me?
How to return the Console's process code?
Submitted by stretch6555 on Tuesday, 10 April, 2007 - 05:49
Hi,

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.

Any help appreciated. Thanks.
How to return the Console's process code?
Submitted by stretch6555 on Tuesday, 10 April, 2007 - 05:48
Hi,

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.

Any help appreciated. Thanks.
Buffer selection within a macro
Submitted by Anonym on Wednesday, 28 March, 2007 - 11:30
Hello all,

first of all I would like to thank the developers. jEdit is a brilliant tool. The opportunity to write own java based macros is an excellent feature. Unfortunately I have some problems in regard to pick up the right buffer for an automatic safe. But before I go into detail I have to mention, that I am not an experienced Java programmer.

What I try to do is to manipulate data from file A and try to safe it in file B.
For this purpose I take the data out of buffer A use the tokenizer to extract the needed data and write that into buffer B.
Therefore I have written the following code:

editPane.prevBuffer();
textArea.setSelectedText(sNewLine+"\n");
textArea.goToNextLine(false);
editPane.nextBuffer();

The pitty is, that I have to ensure that the order in the buffer selector is correct. That is a little bit unconvienient. Does anyone know if there is an opportunity to select the right buffer by its path or filename?

Anything like: editPane.selectBuffer(string filename/path);

I went through the whole helpfile and online wiki, but didn't found anything how I can manage that task. I also tried to record a macro but the file selection was not recorded.

Thank you for your response.

Best wishes, Andre
Need someone to maintain the JTA plugin
Submitted by poleta33 on Friday, 9 February, 2007 - 13:15
Hi

The JTA plugin is the ONLY features that really miss to jedit : it consists in having multiple connections onto differents servers to execute commands (much more powerfull than the console plugin which is limited to the current station you use)...

so this plugin is not maintained anymore... if someone can try this challenge !

more information here : http://sourceforge.net/tracker/index.php?func=detail&aid=1627596&group_id=588&atid=350588
Searching for a file in a list of directories
Submitted by turtlecove on Wednesday, 6 December, 2006 - 19:54
I am trying to find a single specified file in a set of directories. The filename is currently selected, the directories are listed at the bottom of my text file as follows: [path:adirectory][path:anotherdirectory][path:yetanotherdirectory].

The paths are searched recursively (ie: subdirectories are searched as well), or alternatively I can allow globs in the paths like so: [path:C:\toplevel\projects\*\]

I've got searching the current document for [path:xxxx]. I've got the selected filename.
What I am having trouble with is searching the filesystem for the filename. I am trying to figure out how to use DirectoryListSet to do this, but I cannot see how it can be used alone without involving the GUI. I also tried to figure it out using File.list(), but cannot figure out how to specify a filter.
Any help I've found googling around has been in Java, not Beanshell, and since I'm not expert at either I cannot figure out how to translate the Java solutions into Beanshell.

Any help?
How do I launch the appropriate application for a file?
Submitted by turtlecove on Wednesday, 6 December, 2006 - 19:34
I am trying to write a macro that opens the file named in the selection with the appropriate application. For example, [mysheet.xls] would start Excel and open the file mysheet.xls, [mytext.txt] would open Notepad... I've tried sending the filename to cmd.exe, but that doesn't work. I've tried sending it to Explorer but that just views it in explorer. Here's what I have (not working properly):
  // launch app to open file NOT WORKING!
  /*
  os = System.getProperty("os.name");
  if(os.indexOf("Windows 9") == -1 && os.indexOf("Windows M") == -1) {
    comspec = "cmd.exe /C ";
  } else {
    comspec = "command.exe /C ";
  }
  */
  comspec="explorer.exe ";
  if (myfile.matches("[\\/]")) {
    command=comspec+myfile;
  } else {
    // handle relative paths:
    command=comspec+buffer.getDirectory()+myfile;
  }
  // Macros.error( view, "launching "+command);
  setAccessibility(true);
  runtime = new java.lang.Runtime();
  runtime.exec(command);
  return;


Search and replace with the filename
Submitted by poil on Monday, 27 November, 2006 - 17:22
Hi

I'm struggling to write a macro that will search for a string and replace it with that buffer's file name, or better still, a substring of the filename, across all open buffers.

I'm currently trying to use SearchAndReplace.setBeanShellReplace(true) and putting variable names in SearchAndReplace.setReplaceString("theName") with no luck.

Anyone got a macro like this?

Thanks
Cool macro to share
Submitted by pieroxy on Monday, 16 October, 2006 - 20:06
I have this macro I wrote a while ago that "indents" a piece of code (C, Java, Javascript). I like it over the various beautifiers plugins for the following reasons:
1. It keeps the lines as they are, it justs indents them, so that part of the coding style is preserved.
2. The macro will indent just the selection, not all the file, making the change an easy and visible one.

How shall I share the macro so as it is well exposed? It's around 500 lines and I doubt it is worth getting into the default install (how do one macro gets elected to get in the default install?). I'd also like some user feedback on it.
User login
Browse archives
« April 2024  
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   82349
Context Free Art (*.cfdg)   0.31   46055
BBEdit scheme   1.0   18595
JBuilder scheme   .001   18495
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293