jEdit Community - Resources for users of the jEdit Text Editor
Setting the caret position to lineNumber
Submitted by Manil on Tuesday, 18 July, 2006 - 22:10
I am trying to make CodeBrowser better, i have found a way to highlight the current function(Tag) in CodeBrowser i would like to submit it, but i am highlighting the tag where the caret is. I want to be able to highlight the current tag even when you scrolldown or up so the visible text will be the current tag, i want to move the caret to the top position of the viewed text if it's a scrolldown and bottom position if it's a scrollup so that way CodeBrowser will highlight the tag where the caret is.

I tried JEditeTextArea.setCaretPosition(position), JEditeTextArea.setCaretMagicPosition(position) with no success, is there another function to move the caret to a line that we want??????

Thx a lot
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Caretposition vs. line number
by fixedsys on Wed, 26/07/2006 - 06:43
Hi,

setCaretPosition does not move the caret to a specific line number. The parameter is an offset from the beginning of the buffer. You have to convert this position to a line number. Try this:

textArea.setCaretPosition(textArea.getLineStartOffset(position));

This puts the caret on the beginning of the line with the number "position".

Hope it helps,
Lars
 
Thx a lot
by Manil on Wed, 26/07/2006 - 15:07
Thx a lot for your help i'll test it this afternoon, i think it will work, cause i was missing the getLineStartOffset()......
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