本文整理匯總了Java中org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.getFoldManager方法的典型用法代碼示例。如果您正苦於以下問題:Java RSyntaxTextArea.getFoldManager方法的具體用法?Java RSyntaxTextArea.getFoldManager怎麽用?Java RSyntaxTextArea.getFoldManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
的用法示例。
在下文中一共展示了RSyntaxTextArea.getFoldManager方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findOpenFoldClosestTo
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
private Fold findOpenFoldClosestTo(Point p) {
Fold fold = null;
RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
if (rsta.isCodeFoldingEnabled()) { // Should always be true
int offs = rsta.viewToModel(p); // TODO: Optimize me
if (offs>-1) {
try {
int line = rsta.getLineOfOffset(offs);
FoldManager fm = rsta.getFoldManager();
fold = fm.getFoldForLine(line);
if (fold==null) {
fold = fm.getDeepestOpenFoldContaining(offs);
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}
}
}
return fold;
}
示例2: mouseClicked
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
// // TODO: Implement code folding with word wrap enabled
// if (textArea.getLineWrap()) {
// UIManager.getLookAndFeel().provideErrorFeedback(textArea);
// return;
// }
Point p = e.getPoint();
int line = rowAtPoint(p);
RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
FoldManager fm = rsta.getFoldManager();
Fold fold = fm.getFoldForLine(line);
if (fold!=null) {
fold.toggleCollapsedState();
getGutter().repaint();
textArea.repaint();
}
}
示例3: getToolTipText
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; //導入方法依賴的package包/類
/**
* Overridden to show the content of a collapsed fold on mouse-overs.
*
* @param e The mouse location.
*/
@Override
public String getToolTipText(MouseEvent e) {
String text = null;
RSyntaxTextArea rsta = (RSyntaxTextArea)textArea;
if (rsta.isCodeFoldingEnabled()) {
FoldManager fm = rsta.getFoldManager();
int pos = rsta.viewToModel(new Point(0, e.getY()));
if (pos>=0) { // Not -1
int line = 0;
try {
line = rsta.getLineOfOffset(pos);
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
return null;
}
Fold fold = fm.getFoldForLine(line);
if (fold!=null && fold.isCollapsed()) {
int endLine = fold.getEndLine();
if (fold.getLineCount()>25) { // Not too big
endLine = fold.getStartLine() + 25;
}
StringBuilder sb = new StringBuilder("<html><nobr>");
while (line<=endLine && line<rsta.getLineCount()) { // Sanity
Token t = rsta.getTokenListForLine(line);
while (t!=null && t.isPaintable()) {
t.appendHTMLRepresentation(sb, rsta, true, true);
t = t.getNextToken();
}
sb.append("<br>");
line++;
}
text = sb.toString();
}
}
}
return text;
}