|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.editor.Formatter
public class Formatter
Various services related to indentation and text formatting are located here. Each kit can have different formatter so the first action should be getting the right formatter for the given kit by calling Formatter.getFormatter(kitClass).
Constructor Summary | |
---|---|
Formatter(Class kitClass)
Construct new formatter. |
Method Summary | |
---|---|
void |
changeBlockIndent(BaseDocument doc,
int startPos,
int endPos,
int shiftCnt)
Increase/decrease indentation of the block of the code. |
void |
changeRowIndent(BaseDocument doc,
int pos,
int newIndent)
Change the indent of the given row. |
Writer |
createWriter(Document doc,
int offset,
Writer writer)
Creates a writer that formats text that is inserted into it. |
boolean |
expandTabs()
Should the typed tabs be expanded to the spaces? |
static Formatter |
getFormatter(Class kitClass)
Get the formatter for the given kit-class |
String |
getIndentString(BaseDocument doc,
int indent)
|
String |
getIndentString(int indent)
Get the string that is appropriate for the requested indentation. |
Class |
getKitClass()
Get the kit-class for which this formatter is constructed. |
int |
getShiftWidth()
Get the width of one indentation level for non-BaseDocument documents. |
int |
getSpacesPerTab()
Get the number of spaces that should be inserted into the document instead of one typed tab. |
int |
getTabSize()
Get the number of spaces the TAB character ('\t') visually represents for non-BaseDocument documents. |
int |
indentLine(Document doc,
int offset)
Indents the current line. |
int |
indentNewLine(Document doc,
int offset)
Inserts new line at given position and indents the new line with spaces. |
void |
insertTabString(BaseDocument doc,
int dotPos)
Modify the line to move the text starting at dotPos one tab column to the right. |
int |
reformat(BaseDocument doc,
int startOffset,
int endOffset)
Reformat a block of code. |
void |
setExpandTabs(boolean expandTabs)
|
static void |
setFormatter(Class kitClass,
Formatter formatter)
Set the formatter for the given kit-class. |
void |
setShiftWidth(int shiftWidth)
Set the width of one indentation level for non-BaseDocument documents. |
void |
setSpacesPerTab(int spacesPerTab)
|
void |
setTabSize(int tabSize)
Set the number of spaces the TAB character ('\t') visually represents for non-BaseDocument documents. |
void |
settingsChange(SettingsChangeEvent evt)
|
void |
shiftLine(BaseDocument doc,
int dotPos,
boolean right)
Shift line either left or right |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Formatter(Class kitClass)
kitClass
- the class of the kit for which this formatter is being
constructed.Method Detail |
---|
public static Formatter getFormatter(Class kitClass)
public static void setFormatter(Class kitClass, Formatter formatter)
kitClass
- class of the kit for which the formatter
is being assigned.formatter
- new formatter for the given kitpublic Class getKitClass()
public void settingsChange(SettingsChangeEvent evt)
settingsChange
in interface SettingsChangeListener
public int getTabSize()
BaseDocument.getTabSize()
must be used
for BaseDocuments to reflect the document's own tabsize.
BaseDocument.getTabSize()
public void setTabSize(int tabSize)
getTabSize()
,
BaseDocument.setTabSize()
public int getShiftWidth()
getSpacesPerTab()
setShiftWidth()
,
getSpacesPerTab()
public void setShiftWidth(int shiftWidth)
getShiftWidth()
public boolean expandTabs()
public void setExpandTabs(boolean expandTabs)
public int getSpacesPerTab()
public void setSpacesPerTab(int spacesPerTab)
public String getIndentString(BaseDocument doc, int indent)
public String getIndentString(int indent)
public void insertTabString(BaseDocument doc, int dotPos) throws BadLocationException
doc
- document to operate ondotPos
- insertion point
BadLocationException
public void changeRowIndent(BaseDocument doc, int pos, int newIndent) throws BadLocationException
BadLocationException
public void changeBlockIndent(BaseDocument doc, int startPos, int endPos, int shiftCnt) throws BadLocationException
doc
- document to operate onstartPos
- starting line positionendPos
- ending line positionshiftCnt
- positive/negative count of shiftwidths by which indentation
should be shifted right/left
BadLocationException
public void shiftLine(BaseDocument doc, int dotPos, boolean right) throws BadLocationException
BadLocationException
public int reformat(BaseDocument doc, int startOffset, int endOffset) throws BadLocationException
doc
- document to work withstartOffset
- offset at which the formatting startsendOffset
- offset at which the formatting ends
BadLocationException
public int indentLine(Document doc, int offset)
doc
- the document to work onoffset
- the offset of a character on the line
public int indentNewLine(Document doc, int offset)
doc
- the document to work onoffset
- the offset of a character on the line
public Writer createWriter(Document doc, int offset, Writer writer)
The provided document and pos are only informational, should not be modified but only used to find correct indentation strategy.
doc
- documentoffset
- position to begin inserts atwriter
- writer to write to
|
org.netbeans.modules.editor.lib/1 1.14.0 3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |