Macro to make numbered list?
Submitted by
speedracer5 on
Thursday, 20 September, 2012 - 01:36
I'd like a simple macro to create ordered lists like so:
(1) A line of text.
(2) Another line of text.
(3) Another line of text.
(4) Another line of text.
(5) Another line of text.
I've already got a script that will put () at the beginning of each line, but I'm wondering if there's a way to automatically insert the numeral between the parentheses by adding +1 on each iteration.
TIA for any help.
Rectangular selection detect
Submitted by
kemptenkid on
Wednesday, 22 August, 2012 - 04:26
I'm going to modify my paste command to detect if jedit is in rectangular mode, if so then I will issue a vertical paste.
How do i detect jedit in is rectangular mode from the bash macro ?
how to Clear the clipboard ??
Submitted by
DoctorSea on
Monday, 14 May, 2012 - 11:36
I am trying to write a macro that clears the clipboard. This is most important to me.
I tried
a = "";
textArea.setSelection(a);
Registers.copy(textArea,'$');
and a variety of other textArea methods(viewable online) but nothing I can find helps. What am I missing ?
How does one clear the clipboard ? Any ideas anyone? Please?
Macro for removing '\0' possible?
Submitted by
labidus on
Friday, 9 March, 2012 - 01:20
i got a problem by using reload with encoding from UTF-16 to UTF-8, finally I reloaded with US-ASCII
My ASCI file now have a lot of wrong character, 1/2 of the character are useless, basically I need to find the bad character
and replace them with a "" empty char, to restore the file.
I say character '\0' need to be removed but its maybe another number, but the character is lower then space, so in the editor
it seam ok but you need to move the cursor 2 times to actually change to the next character.
Anyway, what i am trying to use is that right now
SearchAndReplace.setSearchString("\\0");
SearchAndReplace.setReplaceString("");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(true);
SearchAndReplace.setRegexp(true);
SearchAndReplace.find(view);
SearchAndReplace.find(view);
SearchAndReplace.replace(view);
But the character \\0 generate a javascript error
thank you, btw I really like this editor, i am using it on my mac for a game project!
Grep_Buffer fix
Submitted by
dougxn on
Friday, 2 March, 2012 - 17:27
Not sure what the correct method for suggesting an update, but I just fixed grep_buffer on my box and thought I would share:
import java.util.regex.*;
Pattern p = null;
Matcher m = null;
String regexp = Macros.input(view, "Regular Expression");
public static final String SEP = " - ";
public static final String LF = "\n";
if(regexp == null) {
return;
} try {
p = Pattern.compile(regexp);
} catch(REException e) {
Macros.error(view, "Invalid regular expression");
return;
}
StringBuffer buf = new StringBuffer();
for(int i = 0; i < textArea.getLineCount(); i++) {
String line = textArea.getLineText(i);
m = p.matcher(line);
if (m.find()) {
buf.append(i).append(SEP).append(line).append(LF);
}
}
noob needs macro assistance..
Submitted by
jdlx on
Friday, 30 December, 2011 - 03:20
Hi,
i'd appreciate if someone could help me on this nobrainer.. (well not for me obviously
:
I'd like to grab some selected text, or if none is selected, the content of the clipboard,
and then do some search/replace, add some text, and paste back to the textarea..
my approach so far:
var = textArea.getSelectedText();
if(var.length == 0){
// get text from clipboard & assign to var..
// Registers.cut(textArea,'$'); does get the clipboard, but i just don't know how to assign it to var..
}
esc_var = var.replaceAll("'", "\"");
textArea.setSelectedText("FB::log("+var+",'"+esc_var+"');");
cheers & thx..
jc
Reading and writing settings in ini-files
Submitted by
tvojeho on
Saturday, 26 November, 2011 - 13:05
Hi, I wanted to ask if anybody might have written a beanshell macro or function to be able to read and write settings in inifiles. The jedit properties do not handle the [Section] parts of the inifiles.
I have been trying to rewrite some functions written for the autohotkey language but the regexes seem to go over my head. I managed to scramble together one function (ini_get, see below), but it was more trial and error than knowing what I was doing, and I was wondering if someone already has written something similar.
Code:
ini_get(_Content, _Section, _Key, Flags, Default)
{
_Section = "\\[\\s*?\\Q"+_Section+"\\E\\s*?]";
//-- Note: The regex of this function was rewritten by Mystiq.
RegEx = "(?im)(?:\\n|^)\\s*"+_Section+"\\s*(?:\\n\\s*|\\n\\s*.+\\s*=\\s*.*?\\s*(?=\\n)|\\n\\s*[;#].*?(?=\\n))*\\n(\\s*\\Q"+_Key+"\\E\\s*=(.*))(?=\\n|$)";
//-- Kompilovat regex expression
Pattern p = Pattern.compile(RegEx);
//-- Vytvořit matcher (boolean)
Matcher m = p.matcher(_Content);
if(m.find())
{
Section = m.group(0);
Key = m.group(1);
Value = m.group(2);
}
if(Flags.indexOf('s') != -1)
return Section;
else if(Flags.indexOf('v') != -1)
return Value;
else if(Flags == null || Flags == "" || Flags.indexOf('k') != -1)
return Key;
}
Regards, tvojeho
mode syntax function (...) {...}
Submitted by
captainhunt on
Wednesday, 28 September, 2011 - 14:08
Hi there,
I am trying to write a mode for a simulator. The syntax looks like
Quasistationary (<options>) {<equations>}
Transient (<options>) {<equations>}
I'd like to match
Quasistationary and
Transient separately and somehow handle the
<options> and
<equations> in different rules. I tried something like:
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="QS_OPTION"><BEGIN>Quasistationary\s*\(</BEGIN><END>)</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="QS_EQ"><BEGIN>.*\{</BEGIN><END>}</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="TRANS_OPTION"><BEGIN>Transient\s*\(</BEGIN><END>)</END></SPAN_REGEXP>
<SPAN_REGEXP TYPE="KEYWORD3" DELEGATE="TRANS_EQ"><BEGIN>.*{</BEGIN><END>}</END></SPAN_REGEXP>
However, the problem with this approach is, that Transient equations (line 4) are captured by the Quasistationary equations (line 2) already.
Any ideas how to solve this?
Thanks in advance
Captainhunt
Need help with macro creating a new view unconnected to the current one
Submitted by
tvojeho on
Thursday, 15 September, 2011 - 13:36
Hi, I would like to create a macro that would close currently open buffer, open it in a new view and run another macro (*) in the new view on the buffer. The second macro often takes a minute or more, and I'd like to be able to work with the original view in the meantime. I need some help on how to create an unconnected new view with only the one buffer.
1) I have tried to use the 'View/New view' command, but it opens all the buffers in the new view which are open in the original view, no matter what bufferscope I try to set.
2) I have used macro recorder and wrote this code:
bsm = jEdit.getBufferSetManager();
if (bsm.getScope() == BufferSet.Scope.global) {
jEdit.newView(view);
}
else {
View.ViewConfig config = new View.ViewConfig();
config.docking = view.getViewConfig().docking;
jEdit.newView(view,buffer,config);
}
It opens only the current buffer in a new view, ok, but the view is still connected to the original and running the macro (*) still freezes the original view.
3) I tried launching the new view from command line with the options -newview -noserver, which worked fine to create an unconnected view, where running macro (*) did not freeze the original view, but the new view still opened all the buffers as in the original.
Any help would be appreciated. I am using the latest jedit4.5pre1 daily version.
tvojeho
P.S. I tried submitting this to jedit-users list, but my message bounced back.
Console-SshConsole : get result of a command
Submitted by
Jabberwock on
Wednesday, 13 July, 2011 - 05:17
Hello,
I'm a french user of jedit
I want to know if someone knows how I can get the result of a command execute via sshconsole(console).
I succed to get a result but the command is executed in a independant thread, so when I execute the command, the result don't contain the complete result but juste a few lines.
So, may be someone know, how I can find if a command is ended ?
Thanks in advance
run bash script on save?
Submitted by
jbrave on
Thursday, 28 April, 2011 - 18:26
Don't know if the Macro forum is the right place for this question, but, I would like to call make install automatically when I save a file, from the parent directory of the file directory. Is there a way to do this automatically, and have a button or something to turn the feature off? If this is the wrong forum, please point me to the correct one.
Thanks,
- Joel
Markers and Line selection - Need Help.
Submitted by
FatDog on
Friday, 15 April, 2011 - 16:45
Hello. I am a developer trying to switch from Years of using Multi-Edit/Brief to JEdit.
I need a macro that will select a range of lines so I can then TAB or Shift-Tab or Delete or search within the selected area.
My old macro would do this:
* Look for the ending tag, set a marker.
* Search backwards for the starting tag, set a marker.
* Go to the end marker and start line text selection
* Jump to starting marker so that all lines from End to Start are selected.
* Stop
This then returns control to me, but leaves many lines selected so I can indent or tab or delete or copy, etc.
I am looking through the textArea API. I see deprecated calls like "getMarkLine()" which look like the functions I want - but it's deprecated.
Basically - interacting with Markers and selecting text - I'm just not getting how to do it. Any advice would be helpful.
Macro to beautify/ align text tables (ex. as used in cucumber scenarios)
Submitted by
gucki on
Tuesday, 5 April, 2011 - 09:45
I just wrote it myself, because I couldn't find one.
You can download it here: http://netskin.blogspot.com/2011/04/jedit-macro-to-beautify-align-text.html
copy file names to file
Submitted by
poleta33 on
Thursday, 31 March, 2011 - 10:20
Hi everybody
I'm trying without success to write a macro that does a simple thing :
copy the file names of the files selected in the browser directory (this could one or more files) into a named file (C:\temp\test.lst)
thanks in advance !
Combining/sequencing macros
Submitted by
highab on
Thursday, 3 February, 2011 - 10:49
I have three macros to run one after the other (or combine into one if I can)....
macro 1: populate hypersearch window with results of search for text between specific tags (and the tags)
macro 2: copy the text from the hypersearch window to a new buffer
macro 3: delete the tags and the superfluous bits
if I run them manually they do what I want. If I try to combine them or call them from a fourth macro that just calls them, they don't work right... I think they try to run at the same time rather than waiting for the previous one to finish ("node has no children". How do I get around this please?
Search and Replace EVERY 2nd occurrence i.e. alternate occurrences
Submitted by
highab on
Thursday, 3 February, 2011 - 10:45
Hi, I'd like to be able to search and replace paragraph marks (\n) with tab marks (\t) for every other line down to the end of a document, effectively merging two lines into one with a tab in between.
thus turning
term1
term2
something else 1
something else 2
into
term1[tab]term2
something else 1[tab]something else 2
this is the code I have so far
SearchAndReplace.setSearchString("\\n");
SearchAndReplace.setReplaceString("\\t");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(true);
SearchAndReplace.setRegexp(true);
SearchAndReplace.replace(view);
SearchAndReplace.setSearchString("\\n");
SearchAndReplace.setBeanShellReplace(false);
SearchAndReplace.setIgnoreCase(true);
SearchAndReplace.setRegexp(true);
SearchAndReplace.find(view);
but if I put it into a loop for textarea number of lines, it replaces ALL occurrences of \n and not every other one.... I'm stumped.
Anyone have any ideas please?
Deleting tags
Submitted by
rsmachado90 on
Monday, 17 January, 2011 - 17:45
Please, I would like some help in the following:
I want delet all:
in the file. The id=* is different for each occurence. I'm trying the:
"(TimeSpan)(.*\n)*.*(/TimeSpan)"
but it's not working. How to fix it?
Thanks in advance,
Ricardo
Run shell command; return to text area
Submitted by
grantciv on
Monday, 29 November, 2010 - 00:28
I'm having trouble writing a macro that runs a shell command and returns to the text area. The ultimate goal is to have a macro that saves all the buffers (without confirmation), runs the current buffer in an appropriate interpreter (python, e.g.), and returns to the text area. Really, if focus could simply remain in the text area, that would be great.
The trouble I'm having is that the view.prevTextArea() call is either being executed too early or it's simply not working the way I understood. The focus ends up in the System shell area. My code is below. I think the only important lines are the three last ones, but I'm including it all, just in case.
// This is a recorded macro. First, check over the
// commands to make sure this is what you intended. Then,
// save this buffer, and the macro should appear in the
// Macros menu.
filetypeToCompilers = new java.util.HashMap();
filetypeToCompilers.put(".py", "python -tt");
filetypeToCompilers.put(".java", "javac");
fileExtensionPattern = java.util.regex.Pattern.compile("(\\.[^.]*)$");
matcher = fileExtensionPattern.matcher(buffer.getName());
if (matcher.find())
{
extension = matcher.group(1);
}
else
{
Macros.error(view, "Unable to determine file type (missing extension?).");
return;
}
compiler = filetypeToCompilers.get(extension);
if (compiler == null)
{
Macros.message(view, "No compiler/interpreter defined for extension '" +
extension + "'");
return;
}
runCommandInConsole(view,"System",compiler + ' ' + buffer.getPath());
waitForConsole(view);
view.prevTextArea();
Any thoughts?
Using the match count as replacement text?
Submitted by
heyvern on
Thursday, 21 October, 2010 - 20:36
I have searched... uh... literally for at least a year on and off for a solution to this.
What I need to do is to "count" matches and use the "count" number as part of the replacement. I am attempting to change the formatting of a 3d file to another 3D application. Some elements that are not numbered in the original format need to be numbered in the target format. The only way I see to do this is with a macro that can track the match count.
I am very familiar and proficient with regex in jEdit but not so hot with writing macros or java programming. Just looking for some kind of "loop" structure in a macro that counts the matches and increments a variable to be inserted on each match/replace.
Problem finding what I want :)
Submitted by
Ziabuch on
Thursday, 23 September, 2010 - 15:07
Hello
I would like to search for the following expression in the text file:
$123 1
Of course the command for this is SearchAndReplace.setSearchString("$123 1");
And it works.
The problem is - that the "123" part of this string is random. So what I really need to find is the first "$", ignore the next 3 digits, find 1 space and finally find "1".
How to create a search command to ignore that "123", or "243" or whatever it may be?
For example if I want to list the file 123AA.txt, I simply put the command "dir ???AA.txt". Is that possible when using BeanShell?
Thanks for advice
Z.