|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.raelity.jvi.swing.TextView
public class TextView
Presents a swing editor interface for use with vi. There is one of these for each JEditorPane;
Notice the listeners for caret changes. If the caret changes to a location that is unexpected, i.e. it came from some external source, then an externalChange message is sent to vi.
The getEditorComponent method should not be used by the primary vi software. The primary vi software should only access, or make changes to, the underlying JEditorPane through other methods in this class.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.raelity.jvi.ViTextView |
---|
ViTextView.FOLDOP, ViTextView.JLOP, ViTextView.MARKOP, ViTextView.NLOP, ViTextView.TABOP, ViTextView.TAGOP, ViTextView.WMOP |
Field Summary | |
---|---|
protected DefaultBuffer |
buf
|
protected TextViewCache |
cache
|
protected JEditorPane |
editorPane
|
protected int |
expectedCaretPosition
|
protected int |
mygen
|
protected TextOps |
ops
|
protected ViStatusDisplay |
statusDisplay
|
boolean |
w_p_nu
jVi doesn't support this flag. |
protected Window |
window
|
Constructor Summary | |
---|---|
TextView(JEditorPane editorPane)
|
Method Summary | |
---|---|
void |
activateOptions(ViTextView tv)
This is invoked when switchto bag's associated editor. |
void |
anonymousMark(ViTextView.MARKOP op,
int count)
Anonymous mark handling. |
protected void |
applyBackground(int[] blocks,
MutableAttributeSet mas)
|
void |
attach()
establish all the listeners |
void |
clearSelect()
clear the select, if any, on the screen, don't move the caret |
int |
coladvanceCoord(int lineOffset,
int colIdx)
|
void |
computeCursorPosition(int offset,
MutableInt line,
MutableInt column)
|
void |
computeCursorPosition(MutableInt offset,
MutableInt line,
MutableInt column)
Determine cursor position, all args get set (call by reference). |
protected void |
createOps(JEditorPane editorPane)
Create methods to invoke and interact with editor pane actions. |
protected ViStatusDisplay |
createStatusDisplay()
Override this class to provide a different implementations of status display. |
protected TextViewCache |
createTextViewCache()
Override this method to provide different cache implementation |
void |
deleteChar(int start,
int end)
Delete a bunch of characters |
void |
deletePreviousChar()
Delete previous character (backspace). |
void |
detach()
tear down all the listeners |
void |
findMatch()
find matching character for character under the cursor. |
void |
foldOperation(ViTextView.FOLDOP op)
Perform the fold operation. |
void |
foldOperation(ViTextView.FOLDOP op,
int offset)
Perform the fold operation. |
DefaultBuffer |
getBuffer()
|
int |
getBufferLineOffset(int coordLine)
Reverse of getCoordLine, convert coord line to document line |
int |
getCaretPosition()
|
int |
getCoordLine(int line)
|
int |
getCoordLineCount()
|
JEditorPane |
getEditorComponent()
|
ViMark |
getMark(int i)
|
int |
getMarkPosition()
|
TextOps |
getOps()
|
ViMark |
getPCMark()
|
ViMark |
getPrevPCMark()
|
ViStatusDisplay |
getStatusDisplay()
Handle displayable editor state changes |
String |
getText(int offset,
int length)
|
int |
getViewBlankLines()
|
int |
getViewBottomLine()
|
int |
getViewCoordBlankLines()
|
int |
getViewCoordBottomLine()
|
int |
getViewCoordTopLine()
|
int |
getViewLines()
|
int |
getViewTopLine()
|
ViFPOS |
getWCursor()
|
int |
getWCurswant()
|
Window |
getWindow()
|
boolean |
getWPList()
|
int |
getWPScroll()
|
boolean |
getWSetCurswant()
|
void |
insertChar(char c)
insert character at cursor position. |
void |
insertNewLine()
Insert new line at current position |
void |
insertTab()
Insert tab at current position |
void |
insertText(int offset,
String s)
insert text at specified location |
void |
insertTypedChar(char c)
Add a character verbatim to the window. |
boolean |
isEditable()
Can the editor text be changed |
boolean |
isShutdown()
|
void |
jumpDefinition(String ident)
Jump to the definition of the identifier under the cursor. |
void |
jumpList(ViTextView.JLOP op,
int count)
Jump list handling |
boolean |
openNewLine(ViTextView.NLOP op)
Create an empty line, autoindented, either before or after current line. |
void |
pushPCMark()
|
void |
redo()
redo a change |
void |
replaceChar(char c,
boolean advanceCursor)
Replace character at current cursor location with argument character |
void |
replaceString(int start,
int end,
String s)
Replace indicated region with string |
void |
scroll(int n_lines)
Scroll down (n_lines positive) or up (n_lines negative) the specified number of lines. |
void |
setCaretPosition(int offset)
set the caret to the indicated position. |
void |
setCaretPosition(int lnum,
int col)
set the caret to the indicated position. |
void |
setCursorCoordLine(int coordLine,
int col)
|
void |
setSelect(int dot,
int mark)
select a region of the screen |
void |
setViewCoordTopLine(int coordLine)
cause the idndicated line to be displayed as top line in view. |
void |
setViewTopLine(int line)
cause the idndicated line to be displayed as top line in view. |
void |
setWCurswant(int c)
|
void |
setWindow(Window window)
|
void |
setWPList(boolean f)
|
void |
setWPScroll(int n)
|
void |
setWSetCurswant(boolean f)
|
void |
shutdown()
going away, do any remaining cleanup |
void |
startup(Buffer buf)
called after TV and Buffer are constructed |
void |
tabOperation(ViTextView.TABOP op,
int count)
move to other file tab. For NEXT,PREV if count == 0 then neighboring tab; if count != 0 then countTh tab, where first is one |
void |
undo()
undo a change |
void |
updateCursor(ViCursor cursor)
Change the cursor shape |
void |
updateHighlightSearchState()
Update the hightlight search state |
void |
updateVisualState()
Update the selection highlight. |
void |
viOptionSet(ViTextView tv,
String name)
The set command used to change an option |
void |
win_close_others(boolean forceit)
Close other windows |
void |
win_close(boolean freeBuf)
Close this window |
void |
win_cycle(int n)
Cycle to the indicated buffer. |
void |
win_goto(int n)
Goto the indicated buffer. |
void |
win_quit()
Quit editing window. |
void |
win_split(int n)
Split this window. |
void |
wordMatchOperation(ViTextView.WMOP op)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int mygen
protected JEditorPane editorPane
protected DefaultBuffer buf
protected TextOps ops
protected TextViewCache cache
protected Window window
protected ViStatusDisplay statusDisplay
protected int expectedCaretPosition
public boolean w_p_nu
Constructor Detail |
---|
public TextView(JEditorPane editorPane)
Method Detail |
---|
public void startup(Buffer buf)
ViTextView
startup
in interface ViTextView
public void shutdown()
ViTextView
shutdown
in interface ViTextView
public boolean isShutdown()
isShutdown
in interface ViTextView
public void viOptionSet(ViTextView tv, String name)
ViOptionBag
viOptionSet
in interface ViOptionBag
public void activateOptions(ViTextView tv)
ViOptionBag
activateOptions
in interface ViOptionBag
public void setWindow(Window window)
setWindow
in interface ViTextView
public Window getWindow()
getWindow
in interface ViTextView
public ViFPOS getWCursor()
getWCursor
in interface ViTextView
public int getWCurswant()
getWCurswant
in interface ViTextView
public void setWCurswant(int c)
setWCurswant
in interface ViTextView
public boolean getWSetCurswant()
getWSetCurswant
in interface ViTextView
public void setWSetCurswant(boolean f)
setWSetCurswant
in interface ViTextView
public ViMark getPCMark()
getPCMark
in interface ViTextView
public ViMark getPrevPCMark()
getPrevPCMark
in interface ViTextView
public void pushPCMark()
pushPCMark
in interface ViTextView
public ViMark getMark(int i)
getMark
in interface ViTextView
public int getWPScroll()
getWPScroll
in interface ViTextView
public void setWPScroll(int n)
setWPScroll
in interface ViTextView
public boolean getWPList()
getWPList
in interface ViTextView
public void setWPList(boolean f)
setWPList
in interface ViTextView
public final DefaultBuffer getBuffer()
getBuffer
in interface ViTextView
protected ViStatusDisplay createStatusDisplay()
protected TextViewCache createTextViewCache()
public void attach()
ViTextView
attach
in interface ViTextView
public void detach()
ViTextView
detach
in interface ViTextView
protected void createOps(JEditorPane editorPane)
public JEditorPane getEditorComponent()
getEditorComponent
in interface ViTextView
public boolean isEditable()
ViTextView
isEditable
in interface ViTextView
public void insertNewLine()
ViTextView
insertNewLine
in interface ViTextView
public void insertTab()
ViTextView
insertTab
in interface ViTextView
public void replaceChar(char c, boolean advanceCursor)
ViTextView
replaceChar
in interface ViTextView
public void deletePreviousChar()
ViTextView
deletePreviousChar
in interface ViTextView
public void insertChar(char c)
insertChar
in interface ViTextView
public void insertTypedChar(char c)
insertTypedChar
in interface ViTextView
public void replaceString(int start, int end, String s)
ViTextView
replaceString
in interface ViTextView
public void deleteChar(int start, int end)
ViTextView
deleteChar
in interface ViTextView
public void insertText(int offset, String s)
ViTextView
insertText
in interface ViTextView
public boolean openNewLine(ViTextView.NLOP op)
Create an empty line, autoindented, either before or after current line. This is simple algorithm; but it ignores guarded text issues and code folding subtlties.
In this example, either the cursor was on line1 and do a NL_FORWARD, or cursor on line2 and NL_BACKWARD. The cursor is shown as '|' positioned where the newLine action will open up a clean line with proper autoindent.line1|\n line2\nThis has problems if line1 is guarded text (write protected), since it modifies that line. And issues with folding in that it will open the fold since a folded line is modified.
openNewLine
in interface ViTextView
public void undo()
ViTextView
undo
in interface ViTextView
public void redo()
ViTextView
redo
in interface ViTextView
public String getText(int offset, int length) throws BadLocationException
BadLocationException
public int getCaretPosition()
getCaretPosition
in interface ViTextView
public int getMarkPosition()
getMarkPosition
in interface ViTextView
public void setCaretPosition(int offset)
ViTextView
setCaretPosition
in interface ViTextView
public void setCaretPosition(int lnum, int col)
ViTextView
setCaretPosition
in interface ViTextView
public void setSelect(int dot, int mark)
ViTextView
setSelect
in interface ViTextView
public void clearSelect()
ViTextView
clearSelect
in interface ViTextView
public void findMatch()
ViTextView
findMatch
in interface ViTextView
public void jumpDefinition(String ident)
ViTextView
jumpDefinition
in interface ViTextView
public void anonymousMark(ViTextView.MARKOP op, int count)
ViTextView
anonymousMark
in interface ViTextView
public void jumpList(ViTextView.JLOP op, int count)
ViTextView
jumpList
in interface ViTextView
public void foldOperation(ViTextView.FOLDOP op)
ViTextView
foldOperation
in interface ViTextView
public void foldOperation(ViTextView.FOLDOP op, int offset)
ViTextView
foldOperation
in interface ViTextView
public void wordMatchOperation(ViTextView.WMOP op)
wordMatchOperation
in interface ViTextView
public void tabOperation(ViTextView.TABOP op, int count)
ViTextView
tabOperation
in interface ViTextView
public void computeCursorPosition(MutableInt offset, MutableInt line, MutableInt column)
ViTextView
computeCursorPosition
in interface ViTextView
public void computeCursorPosition(int offset, MutableInt line, MutableInt column)
public int getViewTopLine()
getViewTopLine
in interface ViTextView
public int getViewBottomLine()
getViewBottomLine
in interface ViTextView
public void setViewTopLine(int line)
ViTextView
setViewTopLine
in interface ViTextView
public int getViewBlankLines()
getViewBlankLines
in interface ViTextView
public int getViewLines()
getViewLines
in interface ViTextView
public void scroll(int n_lines)
scroll
in interface ViTextView
public int getViewCoordTopLine()
getViewCoordTopLine
in interface ViTextView
public void setViewCoordTopLine(int coordLine)
ViTextView
setViewCoordTopLine
in interface ViTextView
public int getViewCoordBlankLines()
getViewCoordBlankLines
in interface ViTextView
public int getViewCoordBottomLine()
getViewCoordBottomLine
in interface ViTextView
public int getCoordLineCount()
getCoordLineCount
in interface ViTextView
public int getCoordLine(int line)
getCoordLine
in interface ViTextView
public int getBufferLineOffset(int coordLine)
ViTextView
getBufferLineOffset
in interface ViTextView
public void setCursorCoordLine(int coordLine, int col)
setCursorCoordLine
in interface ViTextView
public int coladvanceCoord(int lineOffset, int colIdx)
coladvanceCoord
in interface ViTextView
public void updateCursor(ViCursor cursor)
ViTextView
updateCursor
in interface ViTextView
public void win_quit()
win_quit
in interface ViTextView
public void win_split(int n)
win_split
in interface ViTextView
n
- the size of the new window.public void win_close(boolean freeBuf)
win_close
in interface ViTextView
freeBuf
- true if the related buffer may be freedpublic void win_close_others(boolean forceit)
win_close_others
in interface ViTextView
forceit
- true if always hide all other windowspublic void win_goto(int n)
win_goto
in interface ViTextView
n
- the index of the window to make currentpublic void win_cycle(int n)
win_cycle
in interface ViTextView
n
- the positive/negative number of windows to cycle.public ViStatusDisplay getStatusDisplay()
ViTextView
getStatusDisplay
in interface ViTextView
public TextOps getOps()
public void updateVisualState()
updateVisualState
in interface ViTextView
public void updateHighlightSearchState()
ViTextView
updateHighlightSearchState
in interface ViTextView
protected void applyBackground(int[] blocks, MutableAttributeSet mas)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |