本文整理了Java中org.netbeans.editor.Utilities.getVisualColumn()
方法的一些代码示例,展示了Utilities.getVisualColumn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utilities.getVisualColumn()
方法的具体详情如下:
包路径:org.netbeans.editor.Utilities
类名称:Utilities
方法名:getVisualColumn
[英]Return visual column (with expanded tabs) on the line.
[中]返回行上的可视列(带有展开的选项卡)。
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-completion
public int getColumn(boolean create) {
if (create && this.col == -1 && this.doc != null) {
try {
this.col = Utilities.getVisualColumn(this.doc, this.offset) + 1;
} catch (BadLocationException ex) {
this.col = -1;
}
}
return this.col;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Get the visual column corresponding to the position after pressing
* the TAB key.
* @param doc document to work with
* @param offset position at which the TAB was pressed
*/
public static int getNextTabColumn(BaseDocument doc, int offset)
throws BadLocationException {
int col = getVisualColumn(doc, offset);
int tabSize = doc.getFormatter().getSpacesPerTab();
return (col + tabSize) / tabSize * tabSize;
}
代码示例来源:origin: net.java.abeille/abeille
public static String debugPosition(BaseDocument doc, int offset) {
String ret;
if (offset >= 0) {
try {
int line = getLineOffset(doc, offset) + 1;
int col = getVisualColumn(doc, offset) + 1;
ret = String.valueOf(line) + ":" + String.valueOf(col); // NOI18N
} catch (BadLocationException e) {
ret = LocaleSupport.getString(WRONG_POSITION_LOCALE) + ' ' + offset + " > " + doc.getLength(); // NOI18N
}
}
else {
ret = String.valueOf(offset);
}
return ret;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public static String debugPosition(BaseDocument doc, int offset) {
String ret;
if (offset >= 0) {
try {
int line = getLineOffset(doc, offset) + 1;
int col = getVisualColumn(doc, offset) + 1;
ret = String.valueOf(line) + ":" + String.valueOf(col); // NOI18N
} catch (BadLocationException e) {
ret = LocaleSupport.getString( WRONG_POSITION_LOCALE )
+ ' ' + offset + " > " + doc.getLength(); // NOI18N
}
} else {
ret = String.valueOf(offset);
}
return ret;
}
代码示例来源:origin: net.java.abeille/abeille
/**
* Get the visual column corresponding to the position after pressing the
* TAB key.
*
* @param doc
* document to work with
* @param offset
* position at which the TAB was pressed
*/
public static int getNextTabColumn(BaseDocument doc, int offset) throws BadLocationException {
int col = getVisualColumn(doc, offset);
int tabSize = doc.getFormatter().getSpacesPerTab();
return (col + tabSize) / tabSize * tabSize;
}
代码示例来源:origin: net.java.abeille/abeille
/** Shift line either left or right */
public void shiftLine(BaseDocument doc, int dotPos, boolean right) throws BadLocationException {
int ind = doc.getShiftWidth();
if (!right) {
ind = -ind;
}
if (Utilities.isRowWhite(doc, dotPos)) {
ind += Utilities.getVisualColumn(doc, dotPos);
}
else {
ind += Utilities.getRowIndent(doc, dotPos);
}
ind = Math.max(ind, 0);
changeRowIndent(doc, dotPos, ind);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** Shift line either left or right */
public void shiftLine(BaseDocument doc, int dotPos, boolean right)
throws BadLocationException {
int ind = doc.getShiftWidth();
if (!right) {
ind = -ind;
}
if (Utilities.isRowWhite(doc, dotPos)) {
ind += Utilities.getVisualColumn(doc, dotPos);
} else {
ind += Utilities.getRowIndent(doc, dotPos);
}
ind = Math.max(ind, 0);
changeRowIndent(doc, dotPos, ind);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
/** @deprecated
* @see Formatter.insertTabString()
*/
public static String getTabInsertString(BaseDocument doc, int offset)
throws BadLocationException {
int col = getVisualColumn(doc, offset);
Formatter f = doc.getFormatter();
boolean expandTabs = f.expandTabs();
if (expandTabs) {
int spacesPerTab = f.getSpacesPerTab();
int len = (col + spacesPerTab) / spacesPerTab * spacesPerTab - col;
return new String(Analyzer.getSpacesBuffer(len), 0, len);
} else { // insert pure tab
return "\t"; // NOI18N
}
}
代码示例来源:origin: net.java.abeille/abeille
/**
* @deprecated
* @see Formatter.insertTabString()
*/
public static String getTabInsertString(BaseDocument doc, int offset) throws BadLocationException {
int col = getVisualColumn(doc, offset);
Formatter f = doc.getFormatter();
boolean expandTabs = f.expandTabs();
if (expandTabs) {
int spacesPerTab = f.getSpacesPerTab();
int len = (col + spacesPerTab) / spacesPerTab * spacesPerTab - col;
return new String(Analyzer.getSpacesBuffer(len), 0, len);
}
else { // insert pure tab
return "\t"; // NOI18N
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
startPos = (startPos >= 0) ? (startPos + 1) : rsPos;
int startCol = Utilities.getVisualColumn(doc, startPos);
int endCol = Utilities.getNextTabColumn(doc, dotPos);
String tabStr = Analyzer.getWhitespaceString(startCol, endCol, expandTabs(), doc.getTabSize());
代码示例来源:origin: net.java.abeille/abeille
startPos = (startPos >= 0) ? (startPos + 1) : rsPos;
int startCol = Utilities.getVisualColumn(doc, startPos);
int endCol = Utilities.getNextTabColumn(doc, dotPos);
String tabStr = Analyzer.getWhitespaceString(startCol, endCol, expandTabs(), doc.getTabSize());
内容来源于网络,如有侵权,请联系作者删除!