本文整理汇总了Java中org.fife.ui.rtextarea.RTextArea.getTabSize方法的典型用法代码示例。如果您正苦于以下问题:Java RTextArea.getTabSize方法的具体用法?Java RTextArea.getTabSize怎么用?Java RTextArea.getTabSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fife.ui.rtextarea.RTextArea
的用法示例。
在下文中一共展示了RTextArea.getTabSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformedImpl
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
@Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
if (!textArea.isEditable() || !textArea.isEnabled()) {
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
return;
}
Document document = textArea.getDocument();
Element map = document.getDefaultRootElement();
Caret c = textArea.getCaret();
int dot = c.getDot();
int mark = c.getMark();
int dotLine = map.getElementIndex(dot);
int markLine = map.getElementIndex(mark);
// If there is a multi-line selection, indent all lines in
// the selection.
if (dotLine!=markLine) {
int first = Math.min(dotLine, markLine);
int last = Math.max(dotLine, markLine);
Element elem; int start;
// Since we're using Document.insertString(), we must mimic the
// soft tab behavior provided by RTextArea.replaceSelection().
String replacement = "\t";
if (textArea.getTabsEmulated()) {
StringBuilder sb = new StringBuilder();
int temp = textArea.getTabSize();
for (int i=0; i<temp; i++) {
sb.append(' ');
}
replacement = sb.toString();
}
textArea.beginAtomicEdit();
try {
for (int i=first; i<last; i++) {
elem = map.getElement(i);
start = elem.getStartOffset();
document.insertString(start, replacement, null);
}
// Don't do the last line if the caret is at its
// beginning. We must call getDot() again and not just
// use 'dot' as the caret's position may have changed
// due to the insertion of the tabs above.
elem = map.getElement(last);
start = elem.getStartOffset();
if (Math.max(c.getDot(), c.getMark())!=start) {
document.insertString(start, replacement, null);
}
} catch (BadLocationException ble) { // Never happens.
ble.printStackTrace();
UIManager.getLookAndFeel().
provideErrorFeedback(textArea);
} finally {
textArea.endAtomicEdit();
}
}
else {
textArea.replaceSelection("\t");
}
}
示例2: actionPerformedImpl
import org.fife.ui.rtextarea.RTextArea; //导入方法依赖的package包/类
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
if (!textArea.isEditable() || !textArea.isEnabled()) {
UIManager.getLookAndFeel().provideErrorFeedback(textArea);
return;
}
Document document = textArea.getDocument();
Element map = document.getDefaultRootElement();
Caret c = textArea.getCaret();
int dot = c.getDot();
int mark = c.getMark();
int dotLine = map.getElementIndex(dot);
int markLine = map.getElementIndex(mark);
// If there is a multi-line selection, indent all lines in
// the selection.
if (dotLine!=markLine) {
int first = Math.min(dotLine, markLine);
int last = Math.max(dotLine, markLine);
Element elem; int start;
// Since we're using Document.insertString(), we must mimic the
// soft tab behavior provided by RTextArea.replaceSelection().
String replacement = "\t";
if (textArea.getTabsEmulated()) {
StringBuffer sb = new StringBuffer();
int temp = textArea.getTabSize();
for (int i=0; i<temp; i++) {
sb.append(' ');
}
replacement = sb.toString();
}
textArea.beginAtomicEdit();
try {
for (int i=first; i<last; i++) {
elem = map.getElement(i);
start = elem.getStartOffset();
document.insertString(start, replacement, null);
}
// Don't do the last line if the caret is at its
// beginning. We must call getDot() again and not just
// use 'dot' as the caret's position may have changed
// due to the insertion of the tabs above.
elem = map.getElement(last);
start = elem.getStartOffset();
if (Math.max(c.getDot(), c.getMark())!=start) {
document.insertString(start, replacement, null);
}
} catch (BadLocationException ble) { // Never happens.
ble.printStackTrace();
UIManager.getLookAndFeel().
provideErrorFeedback(textArea);
} finally {
textArea.endAtomicEdit();
}
}
else {
textArea.replaceSelection("\t");
}
}