jEdit Community - Resources for users of the jEdit Text Editor
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?
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Hi, I assume that You're usi
by Robert Schwenn on Sun, 08/02/2009 - 19:58
Hi,
I assume that You're using the predefined "textArea" variable to invoke caret positioning. This variable is set once when invoking the beanshell script and it is not changed while the script is running. So, You have to get the other text area to to be able to work with it.

Robert

// set a linenumer to go to
int lineNumber = 11;

// switch to the next textArea
view.nextTextArea();

// get the current textArea, which has changed since macro has been invoked
ta = view.textArea;

// moving the caret to the desired line
ta.setCaretPosition(ta.getLineStartOffset(lineNumber));
 
info
by Robert Schwenn on Tue, 10/02/2009 - 22:27
Just for info: The macro above doesn't work because of a threading issue - see this mail.
 
Thank you for answering. I ju
by kircheis on Mon, 09/02/2009 - 10:50
Thank you for answering. I just tried doing that but it still doesn't work. I was editing the macro on the left half of the split screen, and the cursor was positioned on line 100 of another file on the right half.

When I ran the code, the cursor changed to the right half, but it was still on line 100, and the cursor was positioned on line 11 of the left pane where I was editing the macro.

What I expected was to change to the right half and position the cursor on line 11. Is there something else I'm missing?
 
Yes, I must have been somewha
by Robert Schwenn on Mon, 09/02/2009 - 21:42
Yes, I must have been somewhat confused. I don't know why it doesn't work. So here is a workaround:

// set a linenumer to go to
int lineNumber = 11;

// get the next textArea
EditPane[] panes = view.getEditPanes();
for (i = 0; i < panes.length; i++) {
pane = panes[i];
// "editPane" is the active pane at macro start.
if (pane == editPane) {
break;
}
}
if (i < panes.length - 1) {
k = i + 1;
} else {
k = 0;
}
ta = panes[k].getTextArea();


// moving the caret to the desired line
ta.setCaretPosition(ta.getLineStartOffset(lineNumber - 1));
 
This is just what I needed, I
by kircheis on Mon, 09/02/2009 - 22:45
This is just what I needed, I was trying to understand how to work with the EditPane without luck but now it's clear.

It is even better this way because it moves the other split pane without leaving the one in use.

Thank you very much!
 
jEdit keeps track of where th
by elberry on Mon, 09/02/2009 - 17:52
jEdit keeps track of where the cursor was in each file that is opened. Is it possible the last time you were focused on the second buffer, you were on line 100?

You probably need to keep the cursor position of the left buffer, and then set the position in the next buffer.

Learn from the past. Live in the present. Plan for the future.
11101000
Blog
User login
Browse archives
« November 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   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300