public class Console extends EditControl implements ScrollClient
By default the Console will set its font to the font returned by mApp.findFont("fixed") and there is a convenience method to change the size of the font: setFontSize()
The wrapLength variable controls the wrap length of the Console. It should be 0 for no wrapping, -1 for wrapping to the screen size or a positive value for an explicit maximum line width.
Modifier and Type | Field and Description |
---|---|
protected static ImageBuffer |
blockBuffer |
protected static char[] |
emptyLine |
boolean |
localEcho
If this is true then keys pressed are echoed (displayed) on the console.
|
int |
maxLines
This is the maximum number of lines to store in the Console.
|
boolean |
scrollMode
If this is true, then the arrow keys scroll the console within its
scroll bars.
|
boolean |
showCursor
This is true by default.
|
int |
spacing |
int |
wrapLength
This specifies the number of characters allowed per line, or a value of -1 indicates
that incoming data should wrap to the screen size, or a value of 0 indicates no line wrapping.
|
actAsLabel, blinkId, CASE_LOWER, CASE_NORMAL, CASE_NUMBERS, CASE_SENTENCE, CASE_UPPER, colors, conditionalChar, conditionalCharIndex, defaultInputFlags, doingLocalInput, doingNativeInput, FLAG_INPUT_ON_FOCUS, FLAG_KEEP_FOCUS_AFTER_INPUT, FLAG_NEED_FULL_ACTION, FLAG_PASSIVE, FLAG_USE_NATIVE, inFocus, inputFlags, inputMethod, justGotFocus, nothingEnteredText, oldText, pageColor, startNativeOnPaint, textCase, validator
backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, curFont, debugModify, debugRepaintNow, disabledBackground, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, fontChange, fontFrom, foreGround, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, lockPaint, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, name, next, parent, penStatus, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, startDragResolution, tags, tail, text, toolTip, width, x, y
clipItems, clipObject, clipOwner, debugControl, debugFlag, doubleBuffer, doubleClickTime, doubleSizedFontHeight, firstPress, globalEditable, globalEnabled, PEN_STATUS_DID_HOLD_DOWN, PEN_STATUS_GOT_PEN_DOWN, PEN_STATUS_PEN_IS_ON, pressPoint, TAG_BOOLEAN_KEEP_BELOW_SIP, TAG_HOVER_TIME_INT, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed
GoHigher, GoLower, Horizontal, OPTION_INDICATOR_ONLY, PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTo, Vertical
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_ABUT_ANY, BF_ABUT_BOTTOM, BF_ABUT_LEFT, BF_ABUT_RIGHT, BF_ABUT_TOP, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
ALWAYS_STRETCHABLE, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_HIDDEN, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TAG_BACKGROUND_IMAGE, TAG_BUSY_DISPLAY, TAG_COLORS, TAG_CONTROL_PAINTER, TAG_EXPOSE_GROUP, TAG_FIXEDSIZE, TAG_GRAY_BACKGROUND, TAG_HIDE_CONTROL_OBJECT, TAG_HIDE_PARENT, TAG_INNER_TEXT_INSETS, TAG_INPUT_STACK_PARENT, TAG_INSETS, TAG_MAKE_VISIBLE, TAG_MAXIMUMSIZE, TAG_MINIMUMSIZE, TAG_PAINT_CONTROL_LIST, TAG_PREFERRED_TEXT_SIZE, TAG_PREFERRED_TEXT_SIZE_HEIGHT, TAG_PREFERRED_TEXT_SIZE_WIDTH, TAG_PREFERREDSIZE, TAG_RECT, TAG_SHADOW_INSETS, TAG_SPAN, TAG_SWIPER, TAG_TEMPORARY_ERROR, TAG_TEXT_INSETS, TAG_TEXTSIZE, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, ContainerDontPaintChildren, Disabled, DisablePopupMenu, DisplayOnly, DontBuffer, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, ModifiersInheritedFromWindow, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpUIEvents, ShowSIP, ShrinkToNothing, SmallControl, TakeChildUIEvents, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
KEEP_VISIBLE
Constructor and Description |
---|
Console() |
Modifier and Type | Method and Description |
---|---|
void |
append(char[] data,
int start,
int length,
boolean updateDisplay) |
void |
append(char data,
boolean updateDisplay)
Append a single character to the console.
|
void |
append(String data,
boolean updateDisplay) |
void |
backspace(boolean updateDisplay) |
protected void |
calculateSizes()
Override this to calculate the preferred, minimum and maximum size of your control.
|
boolean |
canGo(int orientation,
int direction,
int position)
This method should return whether the ScrollClient can actually scroll in a particular
direction, given a starting position in units.
|
boolean |
checkSipCoverage() |
void |
clear(boolean updateDisplay)
Clear the console text.
|
void |
closeIO()
If there are open Writers and Readers for this Console, this call will close them.
|
static Handle[] |
connectTo(IConsole c,
InputStream inputStream,
InputStream errorStream,
OutputStream outputStream) |
static Handle[] |
connectTo(IConsole c,
InputStream inputStream,
OutputStream outputStream) |
static Handle[] |
connectTo(IConsole c,
Reader reader,
Writer writer) |
Handle[] |
connectTo(InputStream inputStream,
OutputStream outputStream)
Connect this console to a bi-directional Stream.
|
Handle[] |
connectTo(Reader reader,
Writer writer)
Connect this console to a Reader and a Writer.
|
static Handle[] |
connectToTerminal(ITerminal c,
InputStream inputStream,
InputStream errorStream,
OutputStream outputStream) |
static void |
debug(String data)
Send a line of data to the special debugging/standard IO console.
|
boolean |
deleteSelection() |
void |
doPaint(Graphics g,
Rect area)
This is the main method to override when doing custom Control painting.
|
protected void |
doPaintData(Graphics g)
Repaint the "data" part of the Control.
|
void |
doPaintData(Graphics g,
Rect area) |
void |
doScroll(int which,
int action,
int value)
This is called by the ScrolledServer to indicate that the user has requested
a scroll.
|
protected void |
fontChanged()
This is called when setFont() or applyFont() or setFontChanged() is called.
|
int |
getActual(int direction)
Get the full number of units either vertically or horizontally that the ScrollClient
contains.
|
static Console |
getAppConsole()
Get a special console used for debugging or standard input/output.
|
static IConsole |
getConsole(String title,
int buttonsAndOptions,
int maxLines) |
static Control |
getConsoleControl(IConsole createdConsole) |
int |
getCurrent(int direction)
This should return which unit is currently being displayed.
|
char[] |
getLine(int line) |
int |
getLineLength() |
int |
getNumLines() |
Reader |
getReader()
Get a Reader that you can use to read from the console.
|
int |
getScreenCols(boolean fullyDisplayed)
Get the number of characters that can be partially or fully displayed on a line.
|
int |
getScreenRows(boolean fullyDisplayed)
Get the number of lines that can be partially or fully displayed.
|
Object |
getSelection() |
static ITerminal |
getTerminal(String title,
int buttonsAndOptions,
int maxLines) |
static ITerminal |
getTerminalDontShow(String title,
int buttonsAndOptions,
int maxLines) |
String |
getText()
Get the text of the Control.
|
int |
getVisible(int direction,
int forSize)
Given a display size, this method should return the number of units that can be fully
displayed within the display size for the specified dimension.
|
Writer |
getWriter()
Get a Writer that you can use to write to the console.
|
void |
gotFocus(int how)
This is called when the Control gets the focus.
|
boolean |
hasSelection() |
protected void |
keyPressed(KeyEvent ev)
This gets called when a valid key is pressed.
|
protected char |
keyToChar(KeyEvent key)
This converts a key press to a Unicode character for sending or displaying.
|
protected void |
limitSize(int goingToAdd) |
void |
lostFocus(int how)
This is called when the Control loses the focus.
|
static void |
main(String[] args) |
boolean |
needScrollBar(int direction,
int forSize)
This method should return whether a ScrollBar (or some other form of scrolling
user control) is necessary for the specified dimension.
|
boolean |
noSelection() |
void |
onKeyEvent(KeyEvent ev) |
protected void |
paintChar(Graphics gr,
int line,
int whichChar,
char theChar)
Paint a single character or cursor usually at the end of the line.
|
protected boolean |
paintConditionalChar(Graphics g,
boolean b) |
protected void |
paintCursor() |
protected void |
paintCursor(Graphics g,
boolean clear) |
void |
paintLine(Graphics gr,
int line) |
void |
popupMenuEvent(Object selectedItem)
This is called when the user selects an item from the popup menu.
|
void |
refresh()
This will reposition the display to the end of the text and then do a
full display refresh.
|
boolean |
replaceSelection(Object with) |
void |
selectAll() |
void |
sendChar(char key)
This gets called when a key was pressed by the default sendKey() method.
|
void |
sendChars(char[] keys,
int offset,
int length)
This gets called by the default sendChar() method and can also be called directly.
|
protected void |
sendKey(KeyEvent key)
This gets called when a key was pressed by the default keyPressed() method.
|
protected void |
sendOutNow(char[] keys,
int offset,
int length) |
Control |
setAsStaticDisplay(boolean makeScrollBar)
This modifies the mTextPad to be a static text display - where the cursor is never
displayed and the cursor keys will scroll the display.
|
void |
setFontSize(int size)
Change the size of the font.
|
void |
setPasswordKey(int key)
Set the password mode toggle key.
|
int |
setPasswordMode(int passwordMode)
Password mode currently only works for line buffered mode.
|
void |
setText(String text)
Set the text of the Control, automatically repainting it.
|
void |
setUseLineBuffer(boolean use) |
protected void |
updateDisplay()
This does not shift the position to the end of the text, use refresh() that
instead.
|
void |
updateDisplay(int changedLines) |
protected boolean |
wantKey(KeyEvent ev)
This is used to decide if you wish to process a key press.
|
acceptsData, calculateInputFlags, checkInputMethod, dataBeingRemoved, dataTransferCancelled, fixCase, getBestPassiveFlags, getColors, getNativeInputParameters, hasChanged, inActivePassiveInput, isLabel, keepConditionalChar, nativeInputStopped, onControlEvent, setAsLabel, setConditionalChar, setNativeInputFlags, showHoldDownIndicator, startActiveInput, startLocalInput, startNativeInput, takeData, update, updateData, verifyWantDrag, verifyWantHoldDown
activate, addListener, amOnTopFrame, applyFontChange, baseOnPenEvent, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, bufferGraphics, cache, calculatedSizes, calculateTextSize, calculateTextSize, calculateTextSize, cancelHoldDown, cancelPenPress, canEdit, change, changeDimension, changeTag, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkParentInterceptsUIEvent, checkPenTransparent, childrenPainted, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createNewMenu, dataAccepted, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, deactivate, defaultTo, deferInWindowThread, doAction, doActionKey, doBackground, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintData, doShowMenu, dragged, draw, draw, draw, exitEntry, fillBackground, fillBackgroundNotInFrame, findTagInParents, formClosing, free, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getAncestor, getAncestor, getAncestorProperty, getBackground, getCached, getCachedChildren, getCachedDim, getCachedDim, getCachedRect, getCachedRect, getCachedSubControls, getChildAnchor, getChildren, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getContentsInsets, getContentsInsets, getContentsRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFieldTransfer, getFont, getFontMetrics, getFontMetrics, getFontMetricsForSizeCalculations, getForeground, getFrame, getFrameOrContainer, getGraphics, getGraphics, getHeight, getHideParent, getImage, getLastSelected, getLocation, getLock, getMaximumSize, getMenu, getMinimumSize, getModifiedBorderFlags, getModifiers, getNext, getNextKeyFocus, getPaintParameters, getParent, getParent, getParent, getParentOrListener, getPasswordCharacter, getPosInFrame, getPosInFrame, getPosInParent, getPosInParent, getPreferredSize, getPreferredSizeByParent, getPreferredTextSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getSubControls, getTag, getToolTip, getWidth, getWindow, getWindowGraphics, hasModifier, hasPopupFormAttached, hasTag, hide, inheritModifiers, insetToContents, interceptChildUIEvent, isChildOf, isDirectChildOfWindow, isHidden, isModal, isOnMe, isOnMe, isOnMe, isSomeonesHotKey, make, makeFrameTopMost, makeHot, makeHot, makeInvisible, makeVisible, markAsTemporaryError, menuIsActive, menuStateChanged, modify, modifyAll, modifyAll, modifyFlags, mouseHover, newEventThread, notifyAction, notifyDataChange, notifyDataChange, notifyMenuItemSelected, notifyStructureChanged, onEvent, onLabelPenEvent, onPenEvent, paintBackground, paintWithControlPainter, pauseEventThread, penClicked, penDoubleClicked, penHeld, penPressed, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, postEvent, postInWindowThread, postUIEvent, putInside, queueKeyEvent, queuePenEvent, readLock, recalculatePreferredSize, redisplay, refresh, releaseBufferedGraphics, removed, removeListener, repaint, repaint, repaintDataNow, repaintInWindowThread, repaintInWindowThread, repaintNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetAllCachedProperties, resetCachedProperties, resetRect, resizeTo, restore, restoreBorderModifiers, restoreFlags, resumeEventThread, scrollAndRepaint, sendToListeners, set, setAllFonts, setBackgroundImage, setBorder, setBorderModifiers, setCell, setChildAnchor, setClipObject, setControl, setCursor, setFieldTransfer, setFixedSize, setFont, setFontChange, setFreeDragging, setHidden, setHiddenParent, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPreferredTextSize, setPreferredTextSize, setPromptControl, setRect, setRect, setScaledBackgroundImage, setServer, setShadow, setSwiping, setTag, setTags, setTextSize, setTiledBackgroundImage, setToolTip, shown, simulateClickOn, simulateKeyPresses, simulateKeyType, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeFocus, takeFromClipboard, takePromptControl, testInWindowThread, ticked, tipIsDisplayed, toClipboard, toField, toField, toIDString, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryGetGraphics, tryNext, tryStartMenu, unhide, unlock, updateDCDuringDD, updateFrom, updateTo, waitEventThread, willAcceptDrop, willShowFrame, windowHasFloatingControls, writeLock
doubleSizeIt, getGuiTextHeight, isDoubleSized, isDoubleSizedFont, loadImage, tryLoadImage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getServer, setServer
public int spacing
public int maxLines
public boolean showCursor
public int wrapLength
public boolean scrollMode
protected static ImageBuffer blockBuffer
protected static char[] emptyLine
public boolean localEcho
protected void calculateSizes()
Control
calculateSizes
in class Control
public Control setAsStaticDisplay(boolean makeScrollBar)
The method returns the mTextPad itself if makeScrollBar is false. If makeScrollBar is true it will return a ScrollablePanel() that contains this mTextPad. The returned ScrollablePanel will be a VerticalScrollPanel on a SmartPhone, or a ScrollBarPanel on any other platform.
protected void fontChanged()
Control
fontChanged
in class Control
public void setFontSize(int size)
size
- The new size of the font.protected void limitSize(int goingToAdd)
public void gotFocus(int how)
Control
public void lostFocus(int how)
Control
public void selectAll()
selectAll
in class EditControl
public boolean hasSelection()
hasSelection
in interface Selectable
public boolean noSelection()
noSelection
in interface Selectable
public boolean deleteSelection()
deleteSelection
in interface Selectable
public boolean replaceSelection(Object with)
replaceSelection
in interface Selectable
public Object getSelection()
getSelection
in interface Selectable
public void popupMenuEvent(Object selectedItem)
Control
popupMenuEvent
in class Control
selectedItem
- The item selected.public int getScreenRows(boolean fullyDisplayed)
fullyDisplayed
- if this is true then only the number of fully displayed lines are returned.public int getScreenCols(boolean fullyDisplayed)
fullyDisplayed
- if this is true then only the number of fully displayed characters are returned.public char[] getLine(int line)
protected void updateDisplay()
public void updateDisplay(int changedLines)
public void clear(boolean updateDisplay)
updateDisplay
- if this is true a repaint will be done.public void refresh()
public void backspace(boolean updateDisplay)
public void append(char data, boolean updateDisplay)
data
- The character to append.updateDisplay
- true to update the display after.public void append(char[] data, int start, int length, boolean updateDisplay)
public void append(String data, boolean updateDisplay)
protected void paintChar(Graphics gr, int line, int whichChar, char theChar)
gr
- The graphics context. Can be null.line
- Which line.whichChar
- the index of the char on the line.theChar
- should be 0 to clear the char, -1 for the cursor, or any other char.protected void paintCursor()
protected void paintCursor(Graphics g, boolean clear)
public void paintLine(Graphics gr, int line)
public void doPaint(Graphics g, Rect area)
Control
public void setText(String text)
Control
protected void doPaintData(Graphics g)
Control
doPaintData
in class Control
g
- The Graphics object to paint to.public void doScroll(int which, int action, int value)
ScrollClient
doScroll
in interface ScrollClient
which
- either Horizontal or Verticalaction
- one of PageHigher, PageLower, ScrollHigher, ScrollLower, TrackTovalue
- this is used for the TrackTo action and indicates the position to
track to.public int getLineLength()
public int getNumLines()
public int getActual(int direction)
ScrollClient
getActual
in interface ScrollClient
direction
- either Horizontal or Vertical.public int getCurrent(int direction)
ScrollClient
getCurrent
in interface ScrollClient
direction
- either Horizontal or Vertical.public int getVisible(int direction, int forSize)
ScrollClient
getVisible
in interface ScrollClient
direction
- either Horizontal or Vertical.forSize
- the size (usually in pixels) allowed to be displayed on screen.public boolean needScrollBar(int direction, int forSize)
ScrollClient
However a ScrollClient can return true always if it always wishes a ScrollBar to be present, or false always if it never wishes a ScrollBar to be present.
needScrollBar
in interface ScrollClient
direction
- either Horizontal or Vertical.forSize
- the size (usually in pixels) allowed to be displayed on screen.public boolean canGo(int orientation, int direction, int position)
ScrollClient
canGo
in interface ScrollClient
orientation
- either Horizontal or Vertical.direction
- either GoHigher or GoLower.position
- a starting position in units.public Writer getWriter()
public Reader getReader()
public void closeIO()
public Handle[] connectTo(Reader reader, Writer writer)
reader
- the reader to read characters from to output on the console. If this
is null then no reading is done.writer
- the writer to send characters typed on the console to. If this is null
then no writing is done.public static Handle[] connectTo(IConsole c, InputStream inputStream, OutputStream outputStream)
public static Handle[] connectTo(IConsole c, InputStream inputStream, InputStream errorStream, OutputStream outputStream)
public static Handle[] connectToTerminal(ITerminal c, InputStream inputStream, InputStream errorStream, OutputStream outputStream)
public Handle[] connectTo(InputStream inputStream, OutputStream outputStream)
inputStream
- the stream to read from.outputStream
- the stream to write to.protected final void sendOutNow(char[] keys, int offset, int length)
public void sendChars(char[] keys, int offset, int length)
keys
- a set of characters.offset
- the start of the characters to send.length
- the number of characters to send.public void sendChar(char key)
key
- The pressed key.protected char keyToChar(KeyEvent key)
key
- The pressed key.protected void sendKey(KeyEvent key)
key
- The pressed key event.public void setUseLineBuffer(boolean use)
public void setPasswordKey(int key)
key
- the key. This toggles between off and on to end of line.
Pressing the key with SHIFT will switch on permanently until the key is pressed again.public int setPasswordMode(int passwordMode)
passwordMode
- protected void keyPressed(KeyEvent ev)
ev
- The detected key event.protected boolean wantKey(KeyEvent ev)
ev
- The key event.public void onKeyEvent(KeyEvent ev)
onKeyEvent
in class Control
public static Console getAppConsole()
protected boolean paintConditionalChar(Graphics g, boolean b)
paintConditionalChar
in class EditControl
public static void debug(String data)
public boolean checkSipCoverage()
checkSipCoverage
in class EditControl
public static ITerminal getTerminalDontShow(String title, int buttonsAndOptions, int maxLines)
public static void main(String[] args) throws IOException
IOException