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?
Hi folks,
There is a rails plugin [1] that convert errors to a url that can be opened by textmate.
Here is the main point:
html = "#{line}"
Is there a way for us to do something like this?
Thanks in advance,
- H
[1] code extracted from the plugin
def add_links_to_backtrace(lines)
lines.collect do |line|
expanded = line.gsub '#{RAILS_ROOT}', RAILS_ROOT
if match = expanded.match(/^(.+):(\d+):in/) or match = expanded.match(/^(.+):(\d+)\s*$/)
file = File.expand_path(match[1])
line_number = match[2]
html = "#{line}"
else
line
end
end
end
I miss some kind of reference for building macros in jEdit (I can't find it anywhere).. like what properties (if there's any) textArea has etc. Is there any reference on web?
My issue:
I have macro:
------------
textArea.collapseFold();
textArea.expandFold(true);
------------
I'd like first line to be exectuted only if focused line start of not folded content. I thought of something like:
------------------
if (!textArea.folded) {
textArea.collapseFold();
}
textArea.expandFold(true);
---------------------
Of course as I'm just guessing what properties or syntax to use.. it don't work.
This works fine, but when I have run and closed the program I am left with a jEdit window containing the Console which I have to close manually. Can someone show me how to add a line to my macro to close that Console window? Thanks.
I would like to be able to select this text, have the "///" and new_line characters stripped, and the remaining text put in the clipboard, so I can paste it into another application. Thus, the line I would be pasting would be
Hello,
I'm translating jEdit 4.2 in french (see the link in my signature).
someone use my translation on unbutu (Linux) and said that the accentuated caracters didn't display correctly especially the title of the *.bsh files (macros) and the tips. I do think that's a problem of encoding.
How do I resolve this problem ?
Is there any point to doing "return 1;" instead of "return;" at the end of a macro? Or even "return;" at all? I've seen that in a few of them, but haven't been doing it in mine.
Hi all,
Currently i'm trying to write macro to convert degrees to decimal form and back and have some problems. Input is string and I need convert that string after splitting into parts to numbers, but macro ends with error complaining that unable to casto sting to integer. parseInt also not working. What's wrong ?
Thanks for answers
Here is code:
void convert_coordinates() {
private int Laipsniai;
if (textArea.getSelectedText().contains(" ") == true ) {
format = 1;
Macros.message(view,"Degrees");
} else {
format = 0;
Macros.message(view,"Decimal degrees");
};
switch (format) {
case 1:
Elements = textArea.getSelectedText().split(" ");
Laipsniai = Elements[0];
Macros.message(view,"Laipsniai: "+Laipsniai);
textArea.setSelectedText(Laipsniai);
break;
case 0:
Elements = textArea.getSelectedText().split("[.,]");
textArea.setSelectedText("1:"+Elements[0]+" 2:"+Elements[1]);
break;
};
}
if (textArea.getSelectedText() == null) {
Macros.error(view,"No coordinates selected !!!");
} else {
convert_coordinates();
};
I'm writing a macro which, during its execution, creates a few variables. I'd like
to somehow save or retain these variables (and their contents) when the macro ends, so
that they can be referred to the next time I execute the same macro (or indeed some other
macro). Is this possible?
At first, I thought maybe I could declare the variables as 'static', but this doesn't seem
to work. I suppose another way of saving information between calls, might be to put
the data into some of the JEdit clipboard registers. Can someone suggest a good
solution to this problem?
Also, is there some class or method that my macro can call that will tell it what the
last key the user pressed was? And what about the last macro that was executed?