jEdit Community - Resources for users of the jEdit Text Editor
toggle fold
Submitted by McSwell on Tuesday, 13 February, 2007 - 16:40
I would like to assign a shortcut key to toggle fold. Thus, if the caret is on a line where it makes sense, ^T (let's say) would collapse the fold if the fold was already open, and expand it fully if the fold was already closed.

I don't see any obvious way to do that--there's no command in the Global Options | Shortcuts list that jumps out at me, although I could have missed it. (Nah. I thought I was wrong once, but turned out I was mistaken.)

I suppose I could write a macro, if I knew how to tell whether the current fold was folded or unfolded (and whether the current line was foldable). There must be a way, that's what the little triangles in the gutter do. But I'm not a Java programmer...

I googled this without finding anything obvious. Thanks for any pointers!

Mike Maxwell
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
suggestions
by cvicari on Wed, 14/02/2007 - 10:20
I gave a look at the API, and also I could not find a method to know whether a fold is collapsed or not.
If you really want to see, my suggestion is to use the class org.gjt.sp.jedit.textarea.DisplayManager, that has a method to get the next visible line and the previous one. It the current line is folded, these numbers shouldn't be contiguos
 
toggle fold using MouseOptionPane.java.html?
by homeathouse on Thu, 23/10/2008 - 13:13
can you use "toggle-fold" or "toggle-fold-fully" in
MouseOptionPane.java.shtml?

i am looking for a "toggle fold" setting too--a shortcut to do the same thing as clicking the fold markers in the margin (left of the line numbers).

where's the code for the fold markers? this could help

http://www.docjar.com/html/api/org/gjt/sp/jedit/options/MouseOptionPane.java.html
http://www.devdaily.com/java/jwarehouse/jEdit/org/gjt/sp/jedit/options/MouseOptionPane.java.shtml
 
fold collapsed?
by McSwell on Thu, 15/02/2007 - 15:52
Thanks, but that's a bit beyond what I can do... I've programmed in everything from Fortran IV to Prolog, but Java is not in my skill set!

Mike
 
Tracker or mailing list.
by elberry on Thu, 23/10/2008 - 16:47
I know there has been some work lately on the fold markers. You may want to bring this up in the dev mailing list, or better yet create a feature request tracker item.

https://sourceforge.net/tracker/?group_id=588&atid=350588


Learn from the past. Live in the present. Plan for the future.
11101000
Blog
 
feature request added
by homeathouse on Thu, 23/10/2008 - 18:25
thank you. feature request added.
https://sourceforge.net/tracker2/index.php?func=detail&aid=2190064&group_id=588&atid=350588
 
Here's what you're looking for...
by shlomy on Thu, 23/10/2008 - 18:56
line = textArea.getCaretLine();
if (line < textArea.getLineCount() - 1)
{
        expanded = textArea.displayManager.isLineVisible(line+1);
        if (expanded)
                textArea.collapseFold();
        else {
                pos = textArea.getCaretPosition();
                textArea.expandFold(false);
                textArea.setCaretPosition(pos);
        }
}
 
thanks
by homeathouse on Fri, 24/10/2008 - 00:05
thanks
 
update
by homeathouse on Thu, 30/10/2008 - 18:53
lines=textArea.getLineCount();
cursor_line=textArea.getCaretLine();
cursor_line_next=cursor_line+1;
cursor_line_next_is_visible=textArea.displayManager.isLineVisible(cursor_line_next);
// Macros.message(view,
// "cursor line is "+cursor_line+"\n"+
// "cursor line next is "+cursor_line_next+"\n"+
// "line "+cursor_line_next+" is visible? "+cursor_line_next_is_visible+"\n"+
// ""
// );
if(cursor_line<lines){
if(cursor_line_next_is_visible){
textArea.collapseFold(cursor_line);
}
else{
textArea.expandFold(true);
}
}
User login
Browse archives
« April 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   82349
Context Free Art (*.cfdg)   0.31   46055
BBEdit scheme   1.0   18595
JBuilder scheme   .001   18495
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293