jEdit Community - Resources for users of the jEdit Text Editor
Use of EditorExitRequested class
Submitted by ebt on Monday, 30 June, 2014 - 08:45
I want to be able to detect that jEdit is closing down in order to do some clean-up operations before it closes.
From browsing the API, it seems that I need to use the EditorExitRequested class, but I don't know how.
Can someone explain how this class is used?
Thank you
ebt
utiliser le chemins long dans une macro
Submitted by claudecnx on Wednesday, 25 December, 2013 - 10:27
J'ai cette ligne dans une macro qui par ailleurs fonctionne bien:
runCommandInConsole(view,"System","C:\\PROGRA~1\\MOZILL~1\\firefox.exe " + "http://127.0.0.1/"+path);

Je voudrais savoir s'il est possible d'utiliser les chemin long sous windows, c'est à dire remplacer le ~1 par le vrai dossier?

Merci de votre réponse.

claudecnx@blanquefort.net
Need Help for my first Macro!
Submitted by alcymart on Thursday, 23 May, 2013 - 02:35
Hello Everyone, I need a very basic macro to get me going in the correct direction. Doing this manually would take me years. I presently know nothing at all about coding with Beanshell except for a few basics. Not enough to write even 1 line of code. Would someone Can someone kind enough write me this small macro. I learn better from example than reading a bunch of tuts. Honestly, I don't even know what to write as the first line of code even if I read all the tutorials as I didn't finish high school.

I kindly ask if anyone here can write the following script which I will explain now:

Lets say I inputed that the highnumber=49 for the sequence of numbers below:

03,15,24,36,38,41

The script must look at the numbers above and translate the line to the
format below with high number being 49 and replace it into this format below
which are all the numbers that aren't in the sequence from 1 to 49 all on 1
line in jedit:

01 02 04 05 06 07 08 09 10 11 12 13 14 16 17 18 19 20 21 22 23 25
26 27 28 29 30 31 32 33 34 35 37 39 40 42 43 44 45 46 47 48 49

If I input the high number of 10 for an easier combo below:

03,05,07

It would return 7 nunbers below which are not in the sequence:

01,02,04,06,08,09,10

the script must thereafter do the next sequence of combinations etc, as there are thousands of lottery draws. Yes its to edit Lotto numbers. It must basically loop until it reaches the last sequence of numbers.

With this sample script I could learn from example and use this script as a foundation for other scripts as the
scripts I need all have to do with editing numbers as above.

Thank you in advance to the kind person who will do this for me...you shall be rewarded accordingly...
is available a link for jedit api 4.4.2 ?
Submitted by sercharlie on Thursday, 27 December, 2012 - 12:13
if yes, where ?

excuse me for the question that can be silly
but I've problems to download it.
thanks in advance
Center Current Line
Submitted by Kevin Moore on Thursday, 18 October, 2012 - 02:43
I needed a macro to center the current line. Here is my first stab at it. It works, but I am sure there is a lot that I am doing wrong. Is there another location in the forums to post macros?

Kevin



void centerCurrentLine(View view){

// need access to textArea.lastLinePartial
setAccessibility(true);



int cur_line = textArea.getCaretLine();
int lines_in_whole_page = textArea.getVisibleLines();
int lines_in_half_page = lines_in_whole_page / 2;
int new_first = cur_line - lines_in_half_page;

textArea.setFirstLine(new_first);
}

centerCurrentLine(view);
textArea "primitives"
Submitted by ebt on Thursday, 11 October, 2012 - 15:49
I am a jEdit/beanshell newbie, so please bear with me.
I have started writing beanshell macros for jEdit, and find that there appears to be a shortage of very basic methods in the jEdit API, such as "move caret down N lines" or "move caret to line XXX".
Since the language is written specifically with text manipulation in mind, I find these omissions rather surprising.
Surfing the java and jEdit APIs is not easy, so I may have missed something. If so, I'd be very happy if someone would point me in the right direction.
P.S. Doesn't this forum have a moderator? It seems to be full of messages about erectile dysfunction!
Create/Modify file silently in background
Submitted by JanciB on Sunday, 23 September, 2012 - 09:06
How can i create/modify file in the background? I have this:

private final String filePath = "c:/dummy.txt";

void updateFile()
{
jEdit.newFile(view);
Calendar rightNow = Calendar.getInstance();
textArea.setText(Calendar.getInstance().getTime().toString());
Buffer scratchBuffer = view.getBuffer();
scratchBuffer.save(view, filePath);
jEdit.closeBuffer(view, scratchBuffer);
}
updateFile();

It creates/modifies file dummy.txt, writes to it current date. It is opening new buffer so it is visible for a brief time, until the macro closes it.
Can I make this in the background?
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 Eye-wink :

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
User login
Browse archives
« November 2017  
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
33%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1092
Syndication
file   ver   dls
German Localization light   4.4.2.1   50818
Context Free Art (*.cfdg)   0.31   40972
JBuilder scheme   .001   16898
ColdFusion scheme   1.0   16479
BBEdit scheme   1.0   16461
R Edit Mode - extensive version   0.1   14722
Advanced HTML edit mode   1.0   13955
Matlab Edit Mode   1.0   13876
jEdit XP icons   1.0   13334
XP icons for jEdit   1.1   12360