jEdit Community - Resources for users of the jEdit Text Editor
unable to use line predefined variable in beanshell
Submitted by jeditfan on Wednesday, 17 May, 2006 - 03:18
Hi
I am a novice user and so far am pleasantly surprised with JEdit features. I face a small problem which I think is due to my lack of exp with this. I want to do a search and replace some string with a beanshell syntax.

for eg
search - (\d+)=(\w+)
replace - _1 + text.getCaretLine() + _2 (beanshell expression).

I get an error to the effect that text is undefined. For that matter, I get the same error even for the predefined var. "line". What is going on?

Any insight will be highly appreciated.
Thanks
SK.
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
TextArea
by Robert Schwenn on Wed, 17/05/2006 - 18:34
Not text.getCaretLine() but textArea.getCaretLine().

B.T.W. If the Result is not what You wanted to get: getCaretLine() return s not the line of the found text but the line of the caret - so it remains the same for one searching operation.

Robert
 
Thanks, but does not work..
by jeditfan on Wed, 17/05/2006 - 19:28
Robert
First of all I want to sincerely thank you for taking some time to reply to my question. I tried your suggestion but I got the error
(search:(\d+)=([/\w+]+,?) replace:_2 + textArea.getCaretLine() + _2 )

"Attempt to resolve method: getCaretLine() on undefined variable or class name: textArea : at Line: 3 : in file: inline evaluation of: ``__internal_replace(ns) { this.callstack.set(0,ns); return (_2 + textArea.getCare . . . '' : textArea .getCaretLine ( ) ".

Not to be deterred, I tried view.getEditPane().getTextArea().getCaretLine() instead of textArea.getCaretLine(). Still, no luck..

Btw, what I want to achieve is that I simply want a line ctr wedged between two regular expression in a beanshell script.

Please let me know if & what I am doing wrong..

Thanks once again
SK.
 
???
by Robert Schwenn on Thu, 18/05/2006 - 16:28
1. It have to work!
When I change "textArea" to i.e. "textArey" I get the same error message except that the undefined variable is called "textArey".
This means: You may have written "textArea" not correct (case sensitiv!) or this variable is really not defined. In last case there's going somthing wrong... I would try to reinstall jedit.

2. May be You cannot achieve Your goal with simple search & replace. Instead record a macro and try to complete it.

Robert
User login
Browse archives
« September 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   99105
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   17480
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