org.eclipse.swt.custom
Class StyledText

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
                          |
                          +--org.eclipse.swt.widgets.Canvas
                                |
                                +--org.eclipse.swt.custom.StyledText
All Implemented Interfaces:
Drawable

public class StyledText
extends Canvas

Safe: A StyledText is an editable user interface object that displays lines of text. The following style attributes can be defined for the text:

In addition to text style attributes, the background color of a line may be specified.

There are two ways to use this widget when specifying text style information. You may use the API that is defined for StyledText or you may define your own LineStyleListener. If you define your own listener, you will be responsible for maintaining the text style information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineStyleListener:

There are two ways to use this widget when specifying line background colors. You may use the API that is defined for StyledText or you may define your own LineBackgroundListener. If you define your own listener, you will be responsible for maintaining the line background color information for the widget. IMPORTANT: You may not define your own listener and use the StyledText API. The following StyledText API is not supported if you have defined a LineBackgroundListener:

The content implementation for this widget may also be user-defined. To do so, you must implement the StyledTextContent interface and use the StyledText API setContent(StyledTextContent) to initialize the widget.

IMPORTANT: This class is not intended to be subclassed.

Styles:
FULL_SELECTION, MULTI, READ_ONLY, SINGLE, WRAP
Events:
ExtendedModify, LineGetBackground, LineGetSegments, LineGetStyle, Modify, Selection, Verify, VerifyKey


Field Summary
(package private)  int autoScrollDirection
           
(package private)  Color background
           
(package private) static int BIDI_CARET_WIDTH
           
(package private)  boolean bidiColoring
           
(package private)  int bottomMargin
           
(package private)  int caretDirection
           
(package private)  int caretOffset
           
(package private)  PaletteData caretPalette
           
(package private)  int clientAreaHeight
           
(package private)  int clientAreaWidth
           
(package private)  Clipboard clipboard
           
(package private)  int columnX
           
(package private)  StyledTextContent content
           
(package private) static int DEFAULT_HEIGHT
           
(package private) static int DEFAULT_WIDTH
           
(package private)  DefaultLineStyler defaultLineStyler
           
(package private)  boolean doubleClickEnabled
           
(package private)  Point doubleClickSelection
           
(package private)  boolean editable
           
(package private) static int ExtendedModify
           
(package private)  Color foreground
           
(package private)  int horizontalScrollOffset
           
(package private)  Cursor ibeamCursor
           
(package private)  boolean isBidi
           
(package private)  boolean isCarbon
           
(package private)  Hashtable keyActionMap
           
(package private)  int lastCaretDirection
           
(package private)  int lastTextChangeNewCharCount
           
(package private)  int lastTextChangeNewLineCount
           
(package private)  int lastTextChangeReplaceCharCount
           
(package private)  int lastTextChangeReplaceLineCount
           
(package private)  int lastTextChangeStart
           
(package private)  Image leftCaretBitmap
           
(package private)  int leftMargin
           
(package private)  org.eclipse.swt.custom.StyledText.LineCache lineCache
           
(package private)  int lineEndSpaceWidth
           
(package private) static int LineGetBackground
           
(package private) static int LineGetSegments
           
(package private) static int LineGetStyle
           
(package private)  int lineHeight
           
(package private)  StyledTextContent logicalContent
           
(package private)  boolean mouseDoubleClick
           
(package private)  boolean overwrite
           
(package private) static String PlatformLineDelimiter
           
(package private)  DisplayRenderer renderer
           
(package private)  Image rightCaretBitmap
           
(package private)  int rightMargin
           
(package private)  Point selection
           
(package private)  int selectionAnchor
           
(package private)  Color selectionBackground
           
(package private)  Color selectionForeground
           
(package private) static char TAB
           
(package private)  int tabLength
           
(package private) static int TextChanged
           
(package private)  TextChangeListener textChangeListener
           
(package private) static int TextChanging
           
(package private)  int textLimit
           
(package private) static int TextSet
           
(package private)  int topIndex
           
(package private)  int topMargin
           
(package private)  int topOffset
           
(package private)  boolean userLineBackground
           
(package private)  boolean userLineStyle
           
(package private) static int VerifyKey
           
(package private)  int verticalScrollOffset
           
(package private)  boolean wordWrap
           
(package private) static int XINSET
           
 
Fields inherited from class org.eclipse.swt.widgets.Canvas
 
Fields inherited from class org.eclipse.swt.widgets.Composite
 
Fields inherited from class org.eclipse.swt.widgets.Scrollable
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
 
Constructor Summary
StyledText(Composite parent, int style)
          Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void addBidiSegmentListener(BidiSegmentListener listener)
          Enabled: Adds a bidirectional segment listener.
 void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
          Enabled: Adds an extended modify listener.
 void addLineBackgroundListener(LineBackgroundListener listener)
          Enabled: Adds a line background listener.
 void addLineStyleListener(LineStyleListener listener)
          Enabled: Adds a line style listener.
 void addModifyListener(ModifyListener modifyListener)
          Enabled: Adds a modify listener.
 void addSelectionListener(SelectionListener listener)
          Enabled: Adds a selection listener.
 void addVerifyKeyListener(VerifyKeyListener listener)
          Enabled: Adds a verify key listener.
 void addVerifyListener(VerifyListener verifyListener)
          Enabled: Adds a verify listener.
 void append(String string)
          Enabled: Appends a string to the text at the end of the widget.
(package private)  void calculateContentWidth()
          Calculates the width of the widest visible line.
(package private)  void calculateScrollBars()
          Calculates the scroll bars
(package private)  void calculateTopIndex()
          Calculates the top index based on the current vertical scroll offset.
(package private) static int checkStyle(int style)
          Hides the scroll bars if widget is created in single line mode.
(package private)  void claimBottomFreeSpace()
          Scrolls down the text to use new space made available by a resize or by deleted lines.
(package private)  void claimRightFreeSpace()
          Scrolls text to the right to use new space made available by a resize.
(package private)  void clearMargin(GC gc, Color background, Rectangle clientArea, int renderHeight)
          Clears the widget margin.
(package private)  void clearSelection(boolean sendEvent)
          Removes the widget selection.
 Point computeSize(int wHint, int hHint, boolean changed)
          Enabled: Computes the preferred size.
 void copy()
          Suppressed: Copies the selected text to the clipboard.
(package private)  void createCaretBitmaps()
          Create the bitmaps to use for the caret in bidi mode.
(package private)  void createKeyBindings()
          Creates default key bindings.
 void cut()
          Suppressed: Moves the selected text to the clipboard.
(package private)  void doAutoScroll(Event event)
          A mouse move event has occurred.
(package private)  void doAutoScroll(int direction)
          Initiates autoscrolling.
(package private)  void doBackspace()
          Deletes the previous character.
(package private)  void doColumnLeft()
          Moves the caret one character to the left.
(package private)  void doColumnRight()
          Moves the caret one character to the right.
(package private)  void doContent(char key)
          Replaces the selection with the character or insert the character at the current caret position if no selection exists.
(package private)  void doContentEnd()
          Moves the caret after the last character of the widget content.
(package private)  void doContentStart()
          Moves the caret in front of the first character of the widget content.
(package private)  void doCursorNext()
          Moves the caret to the end of the selection if a selection exists.
(package private)  void doCursorPrevious()
          Moves the caret to the start of the selection if a selection exists.
(package private)  void doDelete()
          Deletes the next character.
(package private)  void doDeleteWordNext()
          Deletes the next word.
(package private)  void doDeleteWordPrevious()
          Deletes the previous word.
(package private)  int doLineDown()
          Moves the caret one line down and to the same character offset relative to the beginning of the line.
(package private)  void doLineEnd()
          Moves the caret to the end of the line.
(package private)  void doLineStart()
          Moves the caret to the beginning of the line.
(package private)  int doLineUp()
          Moves the caret one line up and to the same character offset relative to the beginning of the line.
(package private)  void doMouseLocationChange(int x, int y, boolean select)
          Moves the caret to the specified location.
(package private)  void doMouseSelection()
          Updates the selection based on the caret position
(package private)  int doMouseWordSelect(int x, int newCaretOffset, int line)
          Returns the offset of the word at the specified offset.
(package private)  void doPageDown(boolean select)
          Scrolls one page down so that the last line (truncated or whole) of the current page becomes the fully visible top line.
(package private)  void doPageEnd()
          Moves the cursor to the end of the last fully visible line.
(package private)  void doPageStart()
          Moves the cursor to the beginning of the first fully visible line.
(package private)  void doPageUp()
          Scrolls one page up so that the first line (truncated or whole) of the current page becomes the fully visible last line.
(package private)  void doSelection(int direction)
          Updates the selection to extend to the current caret position.
(package private)  void doSelectionCursorNext()
          Moves the caret to the next character or to the beginning of the next line if the cursor is at the end of a line.
(package private)  void doSelectionCursorPrevious()
          Moves the caret to the previous character or to the end of the previous line if the cursor is at the beginning of a line.
(package private)  void doSelectionLineDown()
          Moves the caret one line down and to the same character offset relative to the beginning of the line.
(package private)  void doSelectionLineUp()
          Moves the caret one line up and to the same character offset relative to the beginning of the line.
(package private)  void doSelectionPageDown()
          Scrolls one page down so that the last line (truncated or whole) of the current page becomes the fully visible top line.
(package private)  void doSelectionPageUp()
          Scrolls one page up so that the first line (truncated or whole) of the current page becomes the fully visible last line.
(package private)  void doSelectionWordNext()
          Moves the caret to the end of the next word .
(package private)  void doSelectionWordPrevious()
          Moves the caret to the start of the previous word.
(package private)  void doWordNext()
          Moves the caret to the end of the next word.
(package private)  void doWordPrevious()
          Moves the caret to the start of the previous word.
(package private)  void draw(int x, int y, int width, int height, boolean clearBackground)
          Draws the specified rectangle.
(package private)  void endAutoScroll()
          Ends the autoscroll process.
 Color getBackground()
          Enabled: @see org.eclipse.swt.widgets.Control#getBackground
 boolean getBidiColoring()
          Deprecated. use BidiSegmentListener instead.

(package private)  int getBidiOffsetAtMouseLocation(int x, int line)
          Returns the offset at the specified x location in the specified line.
(package private)  int[] getBidiSegments(int lineOffset, String line)
          Returns the text segments that should be treated as if they had a different direction than the surrounding text.
(package private)  int[] getBidiSegmentsCompatibility(String line, int lineOffset)
           
(package private)  int getBidiTextPosition(String text, int endOffset, StyledTextBidi bidi)
          Returns the x position of the character at the specified offset relative to the first character in the line.
(package private)  int getBottomIndex()
          Returns the index of the last fully visible line.
(package private)  int getCaretLine()
          Returns the index of the line the caret is on.
 int getCaretOffset()
          Enabled: Returns the caret position relative to the start of the text.
(package private)  int getCaretOffsetAtX(String line, int lineOffset, int lineXOffset)
          Returns the caret offset at the given x location in the line.
(package private)  int getCaretWidth()
          Returns the caret width.
 int getCharCount()
          Enabled: Gets the number of characters.
 StyledTextContent getContent()
          Enabled: Returns the content implementation that is used for text storage or null if no user defined content implementation has been set.
 boolean getDoubleClickEnabled()
          Enabled: Returns whether the widget implements double click mouse behavior.
 boolean getEditable()
          Enabled: Returns whether the widget content can be edited.
 Color getForeground()
          Enabled: @see org.eclipse.swt.widgets.Control#getForeground
(package private)  GC getGC()
          Return a GC to use for rendering and update the cached font style to represent the current style.
(package private)  int getHorizontalIncrement()
          Returns the horizontal scroll increment.
 int getHorizontalIndex()
          Enabled: Returns the horizontal scroll offset relative to the start of the line.
 int getHorizontalPixel()
          Enabled: Returns the horizontal scroll offset relative to the start of the line.
 int getKeyBinding(int key)
          Enabled: Returns the action assigned to the key.
 int getLineAtOffset(int offset)
          Enabled: Returns the line at the specified offset in the text where 0 <= offset <= getCharCount() so that getLineAtOffset(getCharCount()) returns the line of the insert location.
 Color getLineBackground(int index)
          Enabled: Returns the background color of the line at the given index.
(package private)  StyledTextEvent getLineBackgroundData(int lineOffset, String line)
          Returns the line background data for the given line or null if there is none.
(package private)  org.eclipse.swt.custom.StyledText.LineCache getLineCache(StyledTextContent content)
          Returns a LineCache implementation.
 int getLineCount()
          Enabled: Gets the number of text lines.
(package private)  int getLineCountWhole()
          Returns the number of lines that can be completely displayed in the widget client area.
 String getLineDelimiter()
          Enabled: Returns the line delimiter used for entering new lines by key down or paste operation.
 int getLineHeight()
          Enabled: Returns the line height.
(package private)  StyledTextEvent getLineStyleData(int lineOffset, String line)
          Returns the line style data for the given line or null if there is none.
 Point getLocationAtOffset(int offset)
          Enabled: Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text.
(package private)  String getModelDelimitedText(String text)
          Returns a string that uses only the line delimiter specified by the StyledTextContent implementation.
 int getOffsetAtLine(int lineIndex)
          Enabled: Returns the character offset of the first character of the given line.
 int getOffsetAtLocation(Point point)
          Enabled: Returns the offset of the character at the given location relative to the first character in the document.
(package private)  int getOffsetAtMouseLocation(int x, int line)
          Returns the offset at the specified x location in the specified line.
(package private)  int getOffsetAtX(String line, int lineOffset, int lineXOffset)
          Returns the offset of the character at the given x location in the line.
(package private)  int getPartialBottomIndex()
          Returns the index of the last partially visible line.
(package private)  String getPlatformDelimitedText(org.eclipse.swt.custom.StyledText.TextWriter writer)
          Returns the content in the specified range using the platform line delimiter to separate lines.
(package private)  String getRtf()
          Returns the widget text with style information encoded using RTF format specification version 1.5.
 Point getSelection()
          Enabled: Returns the selection.
 Color getSelectionBackground()
          Suppressed: Returns the receiver's selection background color.
 int getSelectionCount()
          Enabled: Gets the number of selected characters.
 Color getSelectionForeground()
          Suppressed: Returns the receiver's selection foreground color.
 Point getSelectionRange()
          Enabled: Returns the selection.
 String getSelectionText()
          Enabled: Returns the selected text.
(package private)  StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc)
          Returns a StyledTextBidi object for the specified line.
(package private)  StyledTextBidi getStyledTextBidi(String lineText, int lineOffset, GC gc, StyleRange[] styles)
          Returns a StyledTextBidi object for the specified line.
 StyleRange getStyleRangeAtOffset(int offset)
          Enabled: Returns the style range at the given offset.
 StyleRange[] getStyleRanges()
          Enabled: Returns the styles.
 int getTabs()
          Enabled: Returns the tab width measured in characters.
 String getText()
          Enabled: Returns a copy of the widget content.
 String getText(int start, int end)
          Enabled: Returns the widget content between the two offsets.
 int getTextLimit()
          Enabled: Gets the text limit.
(package private)  int getTextPosition(String line, int lineIndex, int length, GC gc)
          Returns the x position of the character at the specified offset relative to the first character in the line.
 String getTextRange(int start, int length)
          Enabled: Returns the widget content starting at start for length characters.
 int getTopIndex()
          Enabled: Gets the top index.
 int getTopPixel()
          Enabled: Gets the top pixel.
(package private)  int getVerticalIncrement()
          Returns the vertical scroll increment.
(package private)  int getWordEnd(int offset)
          Returns the offset of the character after the word at the specified offset.
(package private)  int getWordEndNoSpaces(int offset)
          Returns the offset of the character after the word at the specified offset.
(package private)  int getWordStart(int offset)
          Returns the start offset of the word at the specified offset.
 boolean getWordWrap()
          Enabled: Returns whether the widget wraps lines.
(package private)  int getXAtOffset(String line, int lineIndex, int lineOffset)
          Returns the x location of the character at the give offset in the line.
(package private)  void handleDispose()
          Frees resources.
(package private)  void handleHorizontalScroll(Event event)
          Scrolls the widget horizontally.
(package private)  void handleKey(Event event)
          If an action has been registered for the key stroke execute the action.
(package private)  void handleKeyDown(Event event)
          If a VerifyKey listener exists, verify that the key that was entered should be processed.
(package private)  void handleMouseDoubleClick(Event event)
          Updates the caret location and selection if mouse button 1 has been pressed.
(package private)  void handleMouseDown(Event event)
          Updates the caret location and selection if mouse button 1 has been pressed.
(package private)  void handleMouseMove(Event event)
          Updates the caret location and selection if mouse button 1 is pressed during the mouse move.
(package private)  void handleMouseUp(Event event)
          Autoscrolling ends when the mouse button is released.
(package private)  void handlePaint(Event event)
          Renders the invalidated area specified in the paint event.
(package private)  void handleResize(Event event)
          Recalculates the scroll bars.
(package private)  void handleTextChanged(TextChangedEvent event)
          Updates the caret position and selection and the scroll bars to reflect the content change.
(package private)  void handleTextChanging(TextChangingEvent event)
          Updates the screen to reflect a pending content change.
(package private)  void handleTextSet(TextChangedEvent event)
          Called when the widget content is set programatically, overwriting the old content.
(package private)  void handleTraverse(Event event)
          Called when a traversal key is pressed.
(package private)  void handleVerticalScroll(Event event)
          Scrolls the widget vertically.
(package private)  void initializeRenderer()
          Initializes the fonts used to render font styles.
 void insert(String string)
          Enabled: Inserts a string.
(package private)  void installDefaultContent()
          Creates content change listeners and set the default content model.
(package private)  void installDefaultLineStyler()
          Creates a default line style listener.
(package private)  void installListeners()
          Adds event listeners
(package private)  StyledTextContent internalGetContent()
           
(package private)  int internalGetHorizontalPixel()
           
(package private)  org.eclipse.swt.custom.StyledText.LineCache internalGetLineCache()
           
(package private)  Point internalGetSelection()
           
(package private)  boolean internalGetWordWrap()
           
(package private)  void internalRedraw()
          Used by WordWrapCache to bypass StyledText.redraw which does an unwanted cache reset.
(package private)  void internalRedrawRange(int start, int length, boolean clearBackground)
          Redraws the specified text range.
(package private)  void internalSetSelection(int start, int length, boolean sendEvent)
          Sets the selection.
 void invokeAction(int action)
          Suppressed: Executes the action.
(package private)  boolean isAreaVisible(int firstLine, int lastLine)
          Returns whether or not the given lines are visible.
(package private)  boolean isBidi()
          Temporary until SWT provides this
(package private)  boolean isLineDelimiter(int offset)
          Returns whether the given offset is inside a multi byte line delimiter.
(package private)  boolean isRedrawFirstLine(StyleRange[] ranges, int firstLine, int firstLineOffset)
          Returns whether or not the given styles will necessitate a redraw for the given start line.
(package private)  boolean isRedrawLastLine(StyleRange[] ranges, int lastLine, int lastLineOffset)
          Returns whether or not the given styles will necessitate a redraw for the given end line.
(package private)  boolean isSingleLine()
          Returns whether the widget can have only one line.
(package private)  boolean isStyleChanging(StyleRange range, int start, int end)
          Returns whether the font style in the given style range is changing from SWT.NORMAL to SWT.BOLD or vice versa.
(package private)  void modifyContent(Event event, boolean updateCaret)
          Sends the specified verify event, replace/insert text as defined by the event and send a modify event.
 void paste()
          Suppressed: Replaces the selection with the clipboard text or insert the text at the current caret offset if there is no selection.
(package private)  void performPaint(GC gc, int startLine, int startY, int renderHeight)
          Render the specified area.
 void print()
          Suppressed: Prints the widget's text to the default printer.
 Runnable print(org.eclipse.swt.printing.Printer printer)
          Suppressed: Returns a runnable that will print the widget's text to the specified printer.
 Runnable print(org.eclipse.swt.printing.Printer printer, org.eclipse.swt.custom.StyledTextPrintOptions options)
          Suppressed: Returns a runnable that will print the widget's text to the specified printer.
 void redraw()
          Enabled: Causes the entire bounds of the receiver to be marked as needing to be redrawn.
 void redraw(int x, int y, int width, int height, boolean all)
          Enabled: Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn.
(package private)  void redrawBidiLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground)
          Redraws a text range in the specified lines
(package private)  void redrawLine(int line, int offset)
          Redraw the given line.
(package private)  void redrawLines(int firstLine, int offsetInFirstLine, int lastLine, int endOffset, boolean clearBackground)
          Redraws a text range in the specified lines
(package private)  void redrawMultiLineChange(int y, int newLineCount, int replacedLineCount)
          Fixes the widget to display a text change.
 void redrawRange(int start, int length, boolean clearBackground)
          Enabled: Redraws the specified text range.
 void removeBidiSegmentListener(BidiSegmentListener listener)
          Enabled: Removes the specified bidirectional segment listener.
 void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
          Enabled: Removes the specified extended modify listener.
 void removeLineBackgroundListener(LineBackgroundListener listener)
          Enabled: Removes the specified line background listener.
 void removeLineStyleListener(LineStyleListener listener)
          Enabled: Removes the specified line style listener.
 void removeModifyListener(ModifyListener modifyListener)
          Enabled: Removes the specified modify listener.
 void removeSelectionListener(SelectionListener listener)
          Enabled: Removes the specified selection listener.
 void removeVerifyKeyListener(VerifyKeyListener listener)
          Enabled: Removes the specified key verify listener.
 void removeVerifyListener(VerifyListener verifyListener)
          Enabled: Removes the specified verify listener.
 void replaceStyleRanges(int start, int length, StyleRange[] ranges)
          Enabled: Replaces the styles in the given range with new styles.
 void replaceTextRange(int start, int length, String text)
          Enabled: Replaces the given text range with new text.
(package private)  void reset()
          Resets the caret position, selection and scroll offsets.
(package private)  void resetSelection()
          Resets the selection.
(package private)  void scrollHorizontal(int pixels)
          Scrolls the widget horizontally.
(package private)  boolean scrollHorizontalBar(int pixels)
          Scrolls the widget horizontally and adjust the horizontal scroll bar to reflect the new horizontal offset..
 void selectAll()
          Enabled: Selects all the text.
(package private)  void sendKeyEvent(Event event)
          Replaces/inserts text as defined by the event.
(package private)  StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line)
          Returns a StyledTextEvent that can be used to request data such as styles and background color for a line.
(package private)  void sendSelectionEvent()
          Sends the specified selection event.
 void setBackground(Color color)
          Enabled: @see org.eclipse.swt.widgets.Control#setBackground
(package private)  void setBidiCaretDirection()
          Set the caret to indicate the current typing direction.
(package private)  void setBidiCaretLocation(StyledTextBidi bidi)
          Moves the Caret to the current caret offset.
(package private)  void setBidiCaretLocation(StyledTextBidi bidi, int caretLine)
          Moves the Caret to the current caret offset.
 void setBidiColoring(boolean mode)
          Deprecated. use BidiSegmentListener instead.

(package private)  void setBidiKeyboardLanguage()
          Switches the keyboard language according to the current editing position and cursor direction.
 void setCaret(Caret caret)
          Enabled: Sets the receiver's caret.
(package private)  void setCaretLocation()
          Moves the Caret to the current caret offset.
(package private)  void setCaretLocation(int newCaretX, int line)
          Moves the Caret to the current caret offset.
 void setCaretOffset(int offset)
          Enabled: Sets the caret offset.
(package private)  void setClipboardContent(int start, int length)
          Copies the specified text range to the clipboard.
 void setContent(StyledTextContent newContent)
          Enabled: Sets the content implementation to use for text storage.
 void setCursor(Cursor cursor)
          Enabled: Sets the receiver's cursor to the cursor specified by the argument.
 void setDoubleClickEnabled(boolean enable)
          Enabled: Sets whether the widget implements double click mouse behavior.
 void setEditable(boolean editable)
          Enabled: Sets whether the widget content can be edited.
 void setFont(Font font)
          Enabled: Sets a new font to render text with.
 void setForeground(Color color)
          Enabled: @see org.eclipse.swt.widgets.Control#setForeground
 void setHorizontalIndex(int offset)
          Enabled: Sets the horizontal scroll offset relative to the start of the line.
 void setHorizontalPixel(int pixel)
          Enabled: Sets the horizontal pixel offset relative to the start of the line.
(package private)  void setHorizontalScrollBar()
          Adjusts the maximum and the page size of the horizontal scroll bar to reflect content width changes.
 void setKeyBinding(int key, int action)
          Enabled: Maps a key to an action.
 void setLineBackground(int startLine, int lineCount, Color background)
          Enabled: Sets the background color of the specified lines.
(package private)  void setMouseWordSelectionAnchor()
          Flips selection anchor based on word selection direction.
(package private)  void setScrollBars()
          Adjusts the maximum and the page size of the scroll bars to reflect content width/length changes.
 void setSelection(int start)
          Enabled: Sets the selection to the given position and scrolls it into view.
 void setSelection(int start, int end)
          Enabled: Sets the selection and scrolls it into view.
 void setSelection(Point point)
          Enabled: Sets the selection and scrolls it into view.
 void setSelectionBackground(Color color)
          Suppressed: Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setSelectionForeground(Color color)
          Suppressed: Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
 void setSelectionRange(int start, int length)
          Enabled: Sets the selection.
 void setStyleRange(StyleRange range)
          Enabled: Adds the specified style.
 void setStyleRanges(StyleRange[] ranges)
          Enabled: Sets styles to be used for rendering the widget content.
 void setTabs(int tabs)
          Enabled: Sets the tab width.
 void setText(String text)
          Enabled: Sets the widget content.
 void setTextLimit(int limit)
          Enabled: Sets the text limit.
 void setTopIndex(int topIndex)
          Enabled: Sets the top index.
 void setTopPixel(int pixel)
          Enabled: Sets the top pixel offset.
(package private)  boolean setVerticalScrollOffset(int pixelOffset, boolean adjustScrollBar)
          Scrolls the widget vertically.
 void setWordWrap(boolean wrap)
          Enabled: Sets whether the widget wraps lines.
(package private)  void showBidiCaret()
          Sets the caret location and scrolls the caret offset into view.
(package private)  void showCaret()
          Sets the caret location and scrolls the caret offset into view.
(package private)  void showCaret(int caretLine)
          Sets the caret location and scrolls the caret offset into view.
(package private)  boolean showLocation(int x, int line)
          Scrolls the specified location into view.
(package private)  void showOffset(int offset)
          Scrolls the specified offset into view.
 void showSelection()
          Enabled: /** Scrolls the selection into view.
(package private)  void updateBidiDirection(boolean isBackspace, boolean isDirectionBoundary)
          Updates the caret direction when a delete operation occured based on the type of the delete operation (next/previous character) and the caret location (at a direction boundary or inside a direction segment).
(package private)  void updateSelection(int startOffset, int replacedLength, int newLength)
          Updates the selection and caret position depending on the text change.
(package private)  void wordWrapResize(int oldClientAreaWidth)
          Rewraps all lines
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, layout, moveAbove, moveBelow, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBorderWidth, getBounds, getDisplay, getEnabled, getFont, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBounds, setBounds, setCapture, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, transferActive, transferFocus, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAB

static final char TAB

PlatformLineDelimiter

static final String PlatformLineDelimiter

BIDI_CARET_WIDTH

static final int BIDI_CARET_WIDTH

XINSET

static final int XINSET

DEFAULT_WIDTH

static final int DEFAULT_WIDTH

DEFAULT_HEIGHT

static final int DEFAULT_HEIGHT

ExtendedModify

static final int ExtendedModify

LineGetBackground

static final int LineGetBackground

LineGetStyle

static final int LineGetStyle

TextChanging

static final int TextChanging

TextSet

static final int TextSet

VerifyKey

static final int VerifyKey

TextChanged

static final int TextChanged

LineGetSegments

static final int LineGetSegments

selectionBackground

Color selectionBackground

selectionForeground

Color selectionForeground

logicalContent

StyledTextContent logicalContent

content

StyledTextContent content

renderer

DisplayRenderer renderer

textChangeListener

TextChangeListener textChangeListener

defaultLineStyler

DefaultLineStyler defaultLineStyler

lineCache

org.eclipse.swt.custom.StyledText.LineCache lineCache

userLineStyle

boolean userLineStyle

userLineBackground

boolean userLineBackground

verticalScrollOffset

int verticalScrollOffset

horizontalScrollOffset

int horizontalScrollOffset

topIndex

int topIndex

topOffset

int topOffset

clientAreaHeight

int clientAreaHeight

clientAreaWidth

int clientAreaWidth

lineHeight

int lineHeight

tabLength

int tabLength

lineEndSpaceWidth

int lineEndSpaceWidth

leftMargin

int leftMargin

topMargin

int topMargin

rightMargin

int rightMargin

bottomMargin

int bottomMargin

ibeamCursor

Cursor ibeamCursor

columnX

int columnX

caretOffset

int caretOffset

selection

Point selection

selectionAnchor

int selectionAnchor

doubleClickSelection

Point doubleClickSelection

editable

boolean editable

wordWrap

boolean wordWrap

doubleClickEnabled

boolean doubleClickEnabled

overwrite

boolean overwrite

textLimit

int textLimit

keyActionMap

Hashtable keyActionMap

background

Color background

foreground

Color foreground

clipboard

Clipboard clipboard

mouseDoubleClick

boolean mouseDoubleClick

autoScrollDirection

int autoScrollDirection

lastTextChangeStart

int lastTextChangeStart

lastTextChangeNewLineCount

int lastTextChangeNewLineCount

lastTextChangeNewCharCount

int lastTextChangeNewCharCount

lastTextChangeReplaceLineCount

int lastTextChangeReplaceLineCount

lastTextChangeReplaceCharCount

int lastTextChangeReplaceCharCount

isBidi

boolean isBidi

bidiColoring

boolean bidiColoring

leftCaretBitmap

Image leftCaretBitmap

rightCaretBitmap

Image rightCaretBitmap

caretDirection

int caretDirection

caretPalette

PaletteData caretPalette

lastCaretDirection

int lastCaretDirection

isCarbon

boolean isCarbon
Constructor Detail

StyledText

public StyledText(Composite parent,
                  int style)
Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
See Also:
SWT.FULL_SELECTION, SWT.MULTI, SWT.READ_ONLY, SWT.SINGLE, SWT.WRAP, Widget.getStyle()
Method Detail

addExtendedModifyListener

public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
Enabled: Adds an extended modify listener. An ExtendedModify event is sent by the widget when the widget text has changed.


setKeyBinding

public void setKeyBinding(int key,
                          int action)
Enabled: Maps a key to an action. One action can be associated with N keys. However, each key can only have one action (key:action is N:1 relation).

Parameters:
key - a key code defined in SWT.java or a character. Optionally ORd with a state mask. Preferred state masks are one or more of SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform differences. However, there may be cases where using the specific state masks (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
action - one of the predefined actions defined in ST.java. Use SWT.NULL to remove a key binding.

addBidiSegmentListener

public void addBidiSegmentListener(BidiSegmentListener listener)
Enabled: Adds a bidirectional segment listener. A BidiSegmentEvent is sent whenever a line of text is measured or rendered. The user can specify text ranges in the line that should be treated as if they had a different direction than the surrounding text. This may be used when adjacent segments of right-to-left text should not be reordered relative to each other. E.g., Multiple Java string literals in a right-to-left language should generally remain in logical order to each other, that is, the way they are stored.

Parameters:
listener - the listener
Since:
2.0
See Also:
BidiSegmentEvent

addLineBackgroundListener

public void addLineBackgroundListener(LineBackgroundListener listener)
Enabled: Adds a line background listener. A LineGetBackground event is sent by the widget to determine the background color for a line.

Parameters:
listener - the listener

addLineStyleListener

public void addLineStyleListener(LineStyleListener listener)
Enabled: Adds a line style listener. A LineGetStyle event is sent by the widget to determine the styles for a line.

Parameters:
listener - the listener

addModifyListener

public void addModifyListener(ModifyListener modifyListener)
Enabled: Adds a modify listener. A Modify event is sent by the widget when the widget text has changed.


addSelectionListener

public void addSelectionListener(SelectionListener listener)
Enabled: Adds a selection listener. A Selection event is sent by the widget when the selection has changed.

Parameters:
listener - the listener

addVerifyKeyListener

public void addVerifyKeyListener(VerifyKeyListener listener)
Enabled: Adds a verify key listener. A VerifyKey event is sent by the widget when a key is pressed. The widget ignores the key press if the listener sets the doit field of the event to false.

Parameters:
listener - the listener

addVerifyListener

public void addVerifyListener(VerifyListener verifyListener)
Enabled: Adds a verify listener. A Verify event is sent by the widget when the widget text is about to change. The listener can set the event text and the doit field to change the text that is set in the widget or to force the widget to ignore the text change.


append

public void append(String string)
Enabled: Appends a string to the text at the end of the widget.

Parameters:
string - the string to be appended
See Also:
replaceTextRange(int,int,String)

calculateContentWidth

void calculateContentWidth()
Calculates the width of the widest visible line.


calculateScrollBars

void calculateScrollBars()
Calculates the scroll bars


calculateTopIndex

void calculateTopIndex()
Calculates the top index based on the current vertical scroll offset. The top index is the index of the topmost fully visible line or the topmost partially visible line if no line is fully visible. The top index starts at 0.


checkStyle

static int checkStyle(int style)
Hides the scroll bars if widget is created in single line mode.


claimBottomFreeSpace

void claimBottomFreeSpace()
Scrolls down the text to use new space made available by a resize or by deleted lines.


claimRightFreeSpace

void claimRightFreeSpace()
Scrolls text to the right to use new space made available by a resize.


clearMargin

void clearMargin(GC gc,
                 Color background,
                 Rectangle clientArea,
                 int renderHeight)
Clears the widget margin.

Parameters:
gc - GC to render on
background - background color to use for clearing the margin
clientArea - widget client area dimensions
renderHeight - height in pixel of the rendered lines

clearSelection

void clearSelection(boolean sendEvent)
Removes the widget selection.

Parameters:
sendEvent - a Selection event is sent when set to true and when the selection is actually reset.

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Enabled: Computes the preferred size.

Overrides:
computeSize in class Composite
Parameters:
wHint - the width hint (can be SWT.DEFAULT)
hHint - the height hint (can be SWT.DEFAULT)
changed - true if the control's contents have changed, and false otherwise
Returns:
the preferred size of the control.
See Also:
Layout, Control.getBorderWidth(), Control.getBounds(), Control.getSize(), Control.pack(), "computeTrim, getClientArea for controls that implement them"

copy

public void copy()
Suppressed: Copies the selected text to the clipboard. The text will be put in the clipboard in plain text format and RTF format.


getModelDelimitedText

String getModelDelimitedText(String text)
Returns a string that uses only the line delimiter specified by the StyledTextContent implementation. Returns only the first line if the widget has the SWT.SINGLE style.

Parameters:
text - the text that may have line delimiters that don't match the model line delimiter. Possible line delimiters are CR ('\r'), LF ('\n'), CR/LF ("\r\n")
Returns:
the converted text that only uses the line delimiter specified by the model. Returns only the first line if the widget has the SWT.SINGLE style.

createKeyBindings

void createKeyBindings()
Creates default key bindings.


createCaretBitmaps

void createCaretBitmaps()
Create the bitmaps to use for the caret in bidi mode. This method only needs to be called upon widget creation and when the font changes (the caret bitmap height needs to match font height).


cut

public void cut()
Suppressed: Moves the selected text to the clipboard. The text will be put in the clipboard in plain text format and RTF format.


doAutoScroll

void doAutoScroll(Event event)
A mouse move event has occurred. See if we should start autoscrolling. If the move position is outside of the client area, initiate autoscrolling. Otherwise, we've moved back into the widget so end autoscrolling.


doAutoScroll

void doAutoScroll(int direction)
Initiates autoscrolling.

Parameters:
direction - SWT.UP, SWT.DOWN, SWT.RIGHT, SWT.LEFT

doBackspace

void doBackspace()
Deletes the previous character. Delete the selected text if any. Move the caret in front of the deleted text.


doColumnLeft

void doColumnLeft()
Moves the caret one character to the left. Do not go to the previous line. When in a bidi locale and at a R2L character the caret is moved to the beginning of the R2L segment (visually right) and then one character to the left (visually left because it's now in a L2R segment).


doColumnRight

void doColumnRight()
Moves the caret one character to the right. Do not go to the next line. When in a bidi locale and at a R2L character the caret is moved to the end of the R2L segment (visually left) and then one character to the right (visually right because it's now in a L2R segment).


doContent

void doContent(char key)
Replaces the selection with the character or insert the character at the current caret position if no selection exists. If a carriage return was typed replace it with the line break character used by the widget on this platform.

Parameters:
key - the character typed by the user

doContentEnd

void doContentEnd()
Moves the caret after the last character of the widget content.


doContentStart

void doContentStart()
Moves the caret in front of the first character of the widget content.


doCursorPrevious

void doCursorPrevious()
Moves the caret to the start of the selection if a selection exists. Otherwise, if no selection exists move the cursor according to the cursor selection rules.

See Also:
doSelectionCursorPrevious()

doCursorNext

void doCursorNext()
Moves the caret to the end of the selection if a selection exists. Otherwise, if no selection exists move the cursor according to the cursor selection rules.

See Also:
doSelectionCursorNext()

doDelete

void doDelete()
Deletes the next character. Delete the selected text if any.


doDeleteWordNext

void doDeleteWordNext()
Deletes the next word.


doDeleteWordPrevious

void doDeleteWordPrevious()
Deletes the previous word.


doLineDown

int doLineDown()
Moves the caret one line down and to the same character offset relative to the beginning of the line. Move the caret to the end of the new line if the new line is shorter than the character offset.

Returns:
index of the new line relative to the first line in the document

doLineEnd

void doLineEnd()
Moves the caret to the end of the line.


doLineStart

void doLineStart()
Moves the caret to the beginning of the line.


doLineUp

int doLineUp()
Moves the caret one line up and to the same character offset relative to the beginning of the line. Move the caret to the end of the new line if the new line is shorter than the character offset.

Returns:
index of the new line relative to the first line in the document

doMouseLocationChange

void doMouseLocationChange(int x,
                           int y,
                           boolean select)
Moves the caret to the specified location.

Parameters:
x - x location of the new caret position
y - y location of the new caret position
select - the location change is a selection operation. include the line delimiter in the selection

doMouseSelection

void doMouseSelection()
Updates the selection based on the caret position


doMouseWordSelect

int doMouseWordSelect(int x,
                      int newCaretOffset,
                      int line)
Returns the offset of the word at the specified offset. If the current selection extends from high index to low index (i.e., right to left, or caret is at left border of selecton on non-bidi platforms) the start offset of the word preceeding the selection is returned. If the current selection extends from low index to high index the end offset of the word following the selection is returned.

Parameters:
x - mouse x location
newCaretOffset - caret offset of the mouse cursor location
line - line index of the mouse cursor location

doPageDown

void doPageDown(boolean select)
Scrolls one page down so that the last line (truncated or whole) of the current page becomes the fully visible top line. The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the end of the text where a full page scroll is not possible. In this case the caret is moved after the last character.

Parameters:
select - whether or not to select the page

doPageEnd

void doPageEnd()
Moves the cursor to the end of the last fully visible line.


doPageStart

void doPageStart()
Moves the cursor to the beginning of the first fully visible line.


doPageUp

void doPageUp()
Scrolls one page up so that the first line (truncated or whole) of the current page becomes the fully visible last line. The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the beginning of the text where a full page scroll is not possible. In this case the caret is moved in front of the first character.


doSelection

void doSelection(int direction)
Updates the selection to extend to the current caret position.


doSelectionCursorNext

void doSelectionCursorNext()
Moves the caret to the next character or to the beginning of the next line if the cursor is at the end of a line.


doSelectionCursorPrevious

void doSelectionCursorPrevious()
Moves the caret to the previous character or to the end of the previous line if the cursor is at the beginning of a line.


doSelectionLineDown

void doSelectionLineDown()
Moves the caret one line down and to the same character offset relative to the beginning of the line. Moves the caret to the end of the new line if the new line is shorter than the character offset. Moves the caret to the end of the text if the caret already is on the last line. Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.


doSelectionLineUp

void doSelectionLineUp()
Moves the caret one line up and to the same character offset relative to the beginning of the line. Moves the caret to the end of the new line if the new line is shorter than the character offset. Moves the caret to the beginning of the document if it is already on the first line. Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.


doSelectionPageDown

void doSelectionPageDown()
Scrolls one page down so that the last line (truncated or whole) of the current page becomes the fully visible top line. The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the end of the text where a full page scroll is not possible. In this case the caret is moved after the last character.

Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.


doSelectionPageUp

void doSelectionPageUp()
Scrolls one page up so that the first line (truncated or whole) of the current page becomes the fully visible last line. The caret is scrolled the same number of lines so that its location relative to the top line remains the same. The exception is the beginning of the text where a full page scroll is not possible. In this case the caret is moved in front of the first character.

Adjusts the selection according to the caret change. This can either add to or subtract from the old selection, depending on the previous selection direction.


doSelectionWordNext

void doSelectionWordNext()
Moves the caret to the end of the next word .


doSelectionWordPrevious

void doSelectionWordPrevious()
Moves the caret to the start of the previous word.


doWordNext

void doWordNext()
Moves the caret to the end of the next word. If a selection exists, move the caret to the end of the selection and remove the selection.


doWordPrevious

void doWordPrevious()
Moves the caret to the start of the previous word. If a selection exists, move the caret to the start of the selection and remove the selection.


draw

void draw(int x,
          int y,
          int width,
          int height,
          boolean clearBackground)
Draws the specified rectangle. Draw directly without invalidating the affected area when clearBackground is false.

Parameters:
x - the x position
y - the y position
width - the width
height - the height
clearBackground - true=clear the background by invalidating the requested redraw area, false=draw the foreground directly without invalidating the redraw area.

endAutoScroll

void endAutoScroll()
Ends the autoscroll process.


getBackground

public Color getBackground()
Enabled: @see org.eclipse.swt.widgets.Control#getBackground

Overrides:
getBackground in class Control
Returns:
the background color

getBidiColoring

public boolean getBidiColoring()
Deprecated. use BidiSegmentListener instead.

Enabled: Gets the BIDI coloring mode. When true the BIDI text display algorithm is applied to segments of text that are the same color.

Returns:
the current coloring mode

getBidiOffsetAtMouseLocation

int getBidiOffsetAtMouseLocation(int x,
                                 int line)
Returns the offset at the specified x location in the specified line. Also sets the caret direction so that the caret is placed correctly depending on whether the mouse location is in a R2L or L2R segment.

Parameters:
x - x location of the mouse location
line - line the mouse location is in
Returns:
the offset at the specified x location in the specified line, relative to the beginning of the document

getBidiTextPosition

int getBidiTextPosition(String text,
                        int endOffset,
                        StyledTextBidi bidi)
Returns the x position of the character at the specified offset relative to the first character in the line.

Parameters:
text - text to be measured.
endOffset - offset of the character
bidi - the bidi object to use for measuring text in bidi locales.
Returns:
x position of the character at the specified offset. 0 if the length is outside the specified text.

getBottomIndex

int getBottomIndex()
Returns the index of the last fully visible line.

Returns:
index of the last fully visible line.

getCaretOffset

public int getCaretOffset()
Enabled: Returns the caret position relative to the start of the text.

Returns:
the caret position relative to the start of the text.

getCaretOffsetAtX

int getCaretOffsetAtX(String line,
                      int lineOffset,
                      int lineXOffset)
Returns the caret offset at the given x location in the line. The caret offset is the offset of the character where the caret will be placed when a mouse click occurs. The caret offset will be the offset of the character after the clicked one if the mouse click occurs at the second half of a character. Doesn't properly handle ligatures and other context dependent characters unless the current locale is a bidi locale. Ligatures are handled properly as long as they don't occur at lineXOffset.

Parameters:
line - text of the line to calculate the offset in
lineOffset - offset of the first character in the line. 0 based from the beginning of the document.
lineXOffset - x location in the line
Returns:
caret offset at the x location relative to the start of the line.

getCaretWidth

int getCaretWidth()
Returns the caret width.

Returns:
the caret width, 0 if caret is null.

getContent

public StyledTextContent getContent()
Enabled: Returns the content implementation that is used for text storage or null if no user defined content implementation has been set.

Returns:
content implementation that is used for text storage or null if no user defined content implementation has been set.

getDoubleClickEnabled

public boolean getDoubleClickEnabled()
Enabled: Returns whether the widget implements double click mouse behavior.

Returns:
true if double clicking a word selects the word, false if double clicks have the same effect as regular mouse clicks

getEditable

public boolean getEditable()
Enabled: Returns whether the widget content can be edited.

Returns:
true if content can be edited, false otherwise

getForeground

public Color getForeground()
Enabled: @see org.eclipse.swt.widgets.Control#getForeground

Overrides:
getForeground in class Control
Returns:
the receiver's foreground color

getGC

GC getGC()
Return a GC to use for rendering and update the cached font style to represent the current style.

Returns:
GC.

getHorizontalIncrement

int getHorizontalIncrement()
Returns the horizontal scroll increment.

Returns:
horizontal scroll increment.

getHorizontalIndex

public int getHorizontalIndex()
Enabled: Returns the horizontal scroll offset relative to the start of the line.

Returns:
horizontal scroll offset relative to the start of the line, measured in character increments starting at 0, if > 0 the content is scrolled

getHorizontalPixel

public int getHorizontalPixel()
Enabled: Returns the horizontal scroll offset relative to the start of the line.

Returns:
the horizontal scroll offset relative to the start of the line, measured in pixel starting at 0, if > 0 the content is scrolled.

getKeyBinding

public int getKeyBinding(int key)
Enabled: Returns the action assigned to the key. Returns SWT.NULL if there is no action associated with the key.

Parameters:
key - a key code defined in SWT.java or a character. Optionally ORd with a state mask. Preferred state masks are one or more of SWT.MOD1, SWT.MOD2, SWT.MOD3, since these masks account for modifier platform differences. However, there may be cases where using the specific state masks (i.e., SWT.CTRL, SWT.SHIFT, SWT.ALT, SWT.COMMAND) makes sense.
Returns:
one of the predefined actions defined in ST.java or SWT.NULL if there is no action associated with the key.

getCharCount

public int getCharCount()
Enabled: Gets the number of characters.

Returns:
number of characters in the widget

getLineBackground

public Color getLineBackground(int index)
Enabled: Returns the background color of the line at the given index. Returns null if a LineBackgroundListener has been set or if no background color has been specified for the line. Should not be called if a LineBackgroundListener has been set since the listener maintains the line background colors.

Returns:
the background color of the line at the given index.

getLineBackgroundData

StyledTextEvent getLineBackgroundData(int lineOffset,
                                      String line)
Returns the line background data for the given line or null if there is none.

Parameters:
lineOffset - offset of the line start relative to the start of the content.
line - line to get line background data for
Returns:
line background data for the given line.

getLineCount

public int getLineCount()
Enabled: Gets the number of text lines.

Returns:
the number of lines in the widget

getLineCountWhole

int getLineCountWhole()
Returns the number of lines that can be completely displayed in the widget client area.

Returns:
number of lines that can be completely displayed in the widget client area.

getLineAtOffset

public int getLineAtOffset(int offset)
Enabled: Returns the line at the specified offset in the text where 0 <= offset <= getCharCount() so that getLineAtOffset(getCharCount()) returns the line of the insert location.

Parameters:
offset - offset relative to the start of the content. 0 <= offset <= getCharCount()
Returns:
line at the specified offset in the text

getLineDelimiter

public String getLineDelimiter()
Enabled: Returns the line delimiter used for entering new lines by key down or paste operation.

Returns:
line delimiter used for entering new lines by key down or paste operation.

sendLineEvent

StyledTextEvent sendLineEvent(int eventType,
                              int lineOffset,
                              String line)
Returns a StyledTextEvent that can be used to request data such as styles and background color for a line. The specified line may be a visual (wrapped) line if in word wrap mode. The returned object will always be for a logical (unwrapped) line.

Parameters:
lineOffset - offset of the line. This may be the offset of a visual line if the widget is in word wrap mode.
line - line text. This may be the text of a visualline if the widget is in word wrap mode.
Returns:
StyledTextEvent that can be used to request line data for the given line.

getLineHeight

public int getLineHeight()
Enabled: Returns the line height.

Returns:
line height in pixel.

getLineCache

org.eclipse.swt.custom.StyledText.LineCache getLineCache(StyledTextContent content)
Returns a LineCache implementation. Depending on whether or not word wrap is on this may be a line wrapping or line width calculating implementaiton.

Parameters:
content - StyledTextContent to create the LineCache on.
Returns:
a LineCache implementation

getLineStyleData

StyledTextEvent getLineStyleData(int lineOffset,
                                 String line)
Returns the line style data for the given line or null if there is none. If there is a LineStyleListener but it does not set any styles, the StyledTextEvent.styles field will be initialized to an empty array.

Parameters:
lineOffset - offset of the line start relative to the start of the content.
line - line to get line styles for
Returns:
line style data for the given line. Styles may start before line start and end after line end

getLocationAtOffset

public Point getLocationAtOffset(int offset)
Enabled: Returns the x, y location of the upper left corner of the character bounding box at the specified offset in the text. The point is relative to the upper left corner of the widget client area.

Parameters:
offset - offset relative to the start of the content. 0 <= offset <= getCharCount()
Returns:
x, y location of the upper left corner of the character bounding box at the specified offset in the text.

getOffsetAtLine

public int getOffsetAtLine(int lineIndex)
Enabled: Returns the character offset of the first character of the given line.

Parameters:
lineIndex - index of the line, 0 based relative to the first line in the content. 0 <= lineIndex < getLineCount(), except lineIndex may always be 0
Returns:
offset offset of the first character of the line, relative to the beginning of the document. The first character of the document is at offset 0. When there are not any lines, getOffsetAtLine(0) is a valid call that answers 0.
Since:
2.0

getOffsetAtLocation

public int getOffsetAtLocation(Point point)
Enabled: Returns the offset of the character at the given location relative to the first character in the document. The return value reflects the character offset that the caret will be placed at if a mouse click occurred at the specified location. If the x coordinate of the location is beyond the center of a character the returned offset will be behind the character.

Parameters:
point - the origin of character bounding box relative to the origin of the widget client area.
Returns:
offset of the character at the given location relative to the first character in the document.

getOffsetAtMouseLocation

int getOffsetAtMouseLocation(int x,
                             int line)
Returns the offset at the specified x location in the specified line.

Parameters:
x - x location of the mouse location
line - line the mouse location is in
Returns:
the offset at the specified x location in the specified line, relative to the beginning of the document

getOffsetAtX

int getOffsetAtX(String line,
                 int lineOffset,
                 int lineXOffset)
Returns the offset of the character at the given x location in the line.

Parameters:
line - text of the line to calculate the offset in
lineOffset - offset of the first character in the line. 0 based from the beginning of the document.
lineXOffset - x location in the line
Returns:
offset of the character at the x location relative to the start of the line. -1 if the x location is past the end if the line.

getPartialBottomIndex

int getPartialBottomIndex()
Returns the index of the last partially visible line.

Returns:
index of the last partially visible line.

getPlatformDelimitedText

String getPlatformDelimitedText(org.eclipse.swt.custom.StyledText.TextWriter writer)
Returns the content in the specified range using the platform line delimiter to separate lines.

Parameters:
writer - the TextWriter to write line text into
Returns:
the content in the specified range using the platform line delimiter to separate lines as written by the specified TextWriter.

getSelection

public Point getSelection()
Enabled: Returns the selection.

Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

Returns:
start and end of the selection, x is the offset of the first selected character, y is the offset after the last selected character. The selection values returned are visual (i.e., x will always always be <= y). To determine if a selection is right-to-left (RtoL) vs. left-to-right (LtoR), compare the caretOffset to the start and end of the selection (e.g., caretOffset == start of selection implies that the selection is RtoL).
See Also:
getSelectionRange()

getSelectionRange

public Point getSelectionRange()
Enabled: Returns the selection.

Returns:
start and length of the selection, x is the offset of the first selected character, relative to the first character of the widget content. y is the length of the selection. The selection values returned are visual (i.e., length will always always be positive). To determine if a selection is right-to-left (RtoL) vs. left-to-right (LtoR), compare the caretOffset to the start and end of the selection (e.g., caretOffset == start of selection implies that the selection is RtoL).

getSelectionBackground

public Color getSelectionBackground()
Suppressed: Returns the receiver's selection background color.

Returns:
the selection background color
Since:
2.1

getSelectionCount

public int getSelectionCount()
Enabled: Gets the number of selected characters.

Returns:
the number of selected characters.

getSelectionForeground

public Color getSelectionForeground()
Suppressed: Returns the receiver's selection foreground color.

Returns:
the selection foreground color
Since:
2.1

getSelectionText

public String getSelectionText()
Enabled: Returns the selected text.

Returns:
selected text, or an empty String if there is no selection.

getBidiSegments

int[] getBidiSegments(int lineOffset,
                      String line)
Returns the text segments that should be treated as if they had a different direction than the surrounding text.

Parameters:
lineOffset - offset of the first character in the line. 0 based from the beginning of the document.
line - text of the line to specify bidi segments for
Returns:
text segments that should be treated as if they had a different direction than the surrounding text. Only the start index of a segment is specified, relative to the start of the line. Always starts with 0 and ends with the line length.

getBidiSegmentsCompatibility

int[] getBidiSegmentsCompatibility(String line,
                                   int lineOffset)
See Also:
Supports deprecated setBidiColoring API. Remove when API is removed.

getStyleRangeAtOffset

public StyleRange getStyleRangeAtOffset(int offset)
Enabled: Returns the style range at the given offset. Returns null if a LineStyleListener has been set or if a style is not set for the offset. Should not be called if a LineStyleListener has been set since the listener maintains the styles.

Parameters:
offset - the offset to return the style for. 0 <= offset < getCharCount() must be true.
Returns:
a StyleRange with start == offset and length == 1, indicating the style at the given offset. null if a LineStyleListener has been set or if a style is not set for the given offset.

getStyleRanges

public StyleRange[] getStyleRanges()
Enabled: Returns the styles. Returns an empty array if a LineStyleListener has been set. Should not be called if a LineStyleListener has been set since the listener maintains the styles.

Returns:
the styles or null if a LineStyleListener has been set.

getStyledTextBidi

StyledTextBidi getStyledTextBidi(String lineText,
                                 int lineOffset,
                                 GC gc)
Returns a StyledTextBidi object for the specified line.

Parameters:
lineText - the line that the StyledTextBidi object should work on.
lineOffset - offset of the beginning of the line, relative to the beginning of the document
gc - GC to use when creating a new StyledTextBidi object.
Returns:
a StyledTextBidi object for the specified line.

getStyledTextBidi

StyledTextBidi getStyledTextBidi(String lineText,
                                 int lineOffset,
                                 GC gc,
                                 StyleRange[] styles)
Returns a StyledTextBidi object for the specified line.

Parameters:
lineText - the line that the StyledTextBidi object should work on.
lineOffset - offset of the beginning of the line, relative to the beginning of the document
gc - GC to use when creating a new StyledTextBidi object.
styles - StyleRanges to use when creating a new StyledTextBidi object.
Returns:
a StyledTextBidi object for the specified line.

getTabs

public int getTabs()
Enabled: Returns the tab width measured in characters.

Returns:
tab width measured in characters

getText

public String getText()
Enabled: Returns a copy of the widget content.

Returns:
copy of the widget content

getText

public String getText(int start,
                      int end)
Enabled: Returns the widget content between the two offsets.

Parameters:
start - offset of the first character in the returned String
end - offset of the last character in the returned String
Returns:
widget content starting at start and ending at end
See Also:
getTextRange(int,int)

getTextRange

public String getTextRange(int start,
                           int length)
Enabled: Returns the widget content starting at start for length characters.

Parameters:
start - offset of the first character in the returned String
length - number of characters to return
Returns:
widget content starting at start and extending length characters.

getTextLimit

public int getTextLimit()
Enabled: Gets the text limit. The text limit specifies the amount of text that the user can type into the widget.


getTextPosition

int getTextPosition(String line,
                    int lineIndex,
                    int length,
                    GC gc)
Returns the x position of the character at the specified offset relative to the first character in the line. Expands tabs to tab stops using the widget tab width.

Parameters:
line - line to be measured.
lineIndex - index of the line relative to the first kine of the document
length - number of characters to measure. Tabs are counted as one character in this parameter.
gc - GC to use for measuring text
Returns:
x position of the character at the specified offset with tabs expanded to tab stops. 0 if the length is outside the specified text.

getTopIndex

public int getTopIndex()
Enabled: Gets the top index. The top index is the index of the fully visible line that is currently at the top of the widget or the topmost partially visible line if no line is fully visible. The top index changes when the widget is scrolled. Indexing is zero based.

Returns:
the index of the top line

getTopPixel

public int getTopPixel()
Enabled: Gets the top pixel. The top pixel is the pixel position of the line that is currently at the top of the widget.The text widget can be scrolled by pixels by dragging the scroll thumb so that a partial line may be displayed at the top the widget. The top pixel changes when the widget is scrolled. The top pixel does not include the widget trimming.

Returns:
pixel position of the top line

getVerticalIncrement

int getVerticalIncrement()
Returns the vertical scroll increment.

Returns:
vertical scroll increment.

getCaretLine

int getCaretLine()
Returns the index of the line the caret is on. When in word wrap mode and at the end of one wrapped line/ beginning of the continuing wrapped line the caret offset is not sufficient to determine the caret line.

Returns:
the index of the line the caret is on.

getWordEnd

int getWordEnd(int offset)
Returns the offset of the character after the word at the specified offset.

There are two classes of words formed by a sequence of characters:

Space characters ' ' (ASCII 20) are special as they are treated as part of the word leading up to the space character. Line breaks are treated as one word.


getWordEndNoSpaces

int getWordEndNoSpaces(int offset)
Returns the offset of the character after the word at the specified offset.

There are two classes of words formed by a sequence of characters:

Spaces are ignored and do not represent a word. Line breaks are treated as one word.


getWordStart

int getWordStart(int offset)
Returns the start offset of the word at the specified offset. There are two classes of words formed by a sequence of characters:

Space characters ' ' (ASCII 20) are special as they are treated as part of the word leading up to the space character. Line breaks are treated as one word.


getWordWrap

public boolean getWordWrap()
Enabled: Returns whether the widget wraps lines.

Returns:
true if widget wraps lines, false otherwise
Since:
2.0

getXAtOffset

int getXAtOffset(String line,
                 int lineIndex,
                 int lineOffset)
Returns the x location of the character at the give offset in the line. NOTE: Does not return correct values for true italic fonts (vs. slanted fonts).

Returns:
x location of the character at the given offset in the line.

insert

public void insert(String string)
Enabled: Inserts a string. The old selection is replaced with the new text.

Parameters:
string - the string
See Also:
replaceTextRange(int,int,String)

installDefaultContent

void installDefaultContent()
Creates content change listeners and set the default content model.


installDefaultLineStyler

void installDefaultLineStyler()
Creates a default line style listener. Used to store line background colors and styles. Removed when the user sets a LineStyleListener.

See Also:
addLineStyleListener(org.eclipse.swt.custom.LineStyleListener)

installListeners

void installListeners()
Adds event listeners


internalGetContent

StyledTextContent internalGetContent()

internalGetHorizontalPixel

int internalGetHorizontalPixel()

internalGetLineCache

org.eclipse.swt.custom.StyledText.LineCache internalGetLineCache()

internalGetSelection

Point internalGetSelection()

internalGetWordWrap

boolean internalGetWordWrap()

internalRedraw

void internalRedraw()
Used by WordWrapCache to bypass StyledText.redraw which does an unwanted cache reset.


internalRedrawRange

void internalRedrawRange(int start,
                         int length,
                         boolean clearBackground)
Redraws the specified text range.

Parameters:
start - offset of the first character to redraw
length - number of characters to redraw
clearBackground - true if the background should be cleared as part of the redraw operation. If true, the entire redraw range will be cleared before anything is redrawn. If the redraw range includes the last character of a line (i.e., the entire line is redrawn) the line is cleared all the way to the right border of the widget. The redraw operation will be faster and smoother if clearBackground is set to false. Whether or not the flag can be set to false depends on the type of change that has taken place. If font styles or background colors for the redraw range have changed, clearBackground should be set to true. If only foreground colors have changed for the redraw range, clearBackground can be set to false.

getRtf

String getRtf()
Returns the widget text with style information encoded using RTF format specification version 1.5.

Returns:
the widget text with style information encoded using RTF format

handleDispose

void handleDispose()
Frees resources.


handleHorizontalScroll

void handleHorizontalScroll(Event event)
Scrolls the widget horizontally.


handleKey

void handleKey(Event event)
If an action has been registered for the key stroke execute the action. Otherwise, if a character has been entered treat it as new content.

Parameters:
event - keyboard event

handleKeyDown

void handleKeyDown(Event event)
If a VerifyKey listener exists, verify that the key that was entered should be processed.

Parameters:
event - keyboard event

handleMouseDoubleClick

void handleMouseDoubleClick(Event event)
Updates the caret location and selection if mouse button 1 has been pressed.


handleMouseDown

void handleMouseDown(Event event)
Updates the caret location and selection if mouse button 1 has been pressed.


handleMouseMove

void handleMouseMove(Event event)
Updates the caret location and selection if mouse button 1 is pressed during the mouse move.


handleMouseUp

void handleMouseUp(Event event)
Autoscrolling ends when the mouse button is released.


handlePaint

void handlePaint(Event event)
Renders the invalidated area specified in the paint event.

Parameters:
event - paint event

handleResize

void handleResize(Event event)
Recalculates the scroll bars. Rewraps all lines when in word wrap mode.

Parameters:
event - resize event

handleTextChanged

void handleTextChanged(TextChangedEvent event)
Updates the caret position and selection and the scroll bars to reflect the content change.


handleTextChanging

void handleTextChanging(TextChangingEvent event)
Updates the screen to reflect a pending content change.


handleTextSet

void handleTextSet(TextChangedEvent event)
Called when the widget content is set programatically, overwriting the old content. Resets the caret position, selection and scroll offsets. Recalculates the content width and scroll bars. Redraws the widget.

Parameters:
event - text change event.

handleTraverse

void handleTraverse(Event event)
Called when a traversal key is pressed. Allow tab next traversal to occur when the widget is in single line mode or in multi line and non-editable mode . When in editable multi line mode we want to prevent the tab traversal and receive the tab key event instead.

Parameters:
event - the event

handleVerticalScroll

void handleVerticalScroll(Event event)
Scrolls the widget vertically.


initializeRenderer

void initializeRenderer()
Initializes the fonts used to render font styles. Presently only regular and bold fonts are supported.


invokeAction

public void invokeAction(int action)
Suppressed: Executes the action.

Parameters:
action - one of the actions defined in ST.java

isBidi

boolean isBidi()
Temporary until SWT provides this


isLineDelimiter

boolean isLineDelimiter(int offset)
Returns whether the given offset is inside a multi byte line delimiter. Example: "Line1\r\n" isLineDelimiter(5) == false but isLineDelimiter(6) == true

Returns:
true if the given offset is inside a multi byte line delimiter. false if the given offset is before or after a line delimiter.

isAreaVisible

boolean isAreaVisible(int firstLine,
                      int lastLine)
Returns whether or not the given lines are visible.

Returns:
true if any of the lines is visible false if none of the lines is visible

isRedrawFirstLine

boolean isRedrawFirstLine(StyleRange[] ranges,
                          int firstLine,
                          int firstLineOffset)
Returns whether or not the given styles will necessitate a redraw for the given start line. A redraw is necessary when font style changes after the start of a style will take place. This method assumes ranges is in order and non-overlapping.

Returns:
true if a redraw of the given line is necessary, false otherwise

isRedrawLastLine

boolean isRedrawLastLine(StyleRange[] ranges,
                         int lastLine,
                         int lastLineOffset)
Returns whether or not the given styles will necessitate a redraw for the given end line. A redraw is necessary when font style changes after the start of a style will take place. This method assumes ranges is in order and non-overlapping.

Returns:
true if a redraw of the last line is necessary, false otherwise

isSingleLine

boolean isSingleLine()
Returns whether the widget can have only one line.

Returns:
true if widget can have only one line, false if widget can have multiple lines

isStyleChanging

boolean isStyleChanging(StyleRange range,
                        int start,
                        int end)
Returns whether the font style in the given style range is changing from SWT.NORMAL to SWT.BOLD or vice versa.

Parameters:
range - StyleRange to compare current font style with.
start - offset of the first font style to compare
end - offset behind the last font style to compare
Returns:
true if the font style is changing in the given style range, false if the font style is not changing in the given style range.

modifyContent

void modifyContent(Event event,
                   boolean updateCaret)
Sends the specified verify event, replace/insert text as defined by the event and send a modify event.

Parameters:
event - the text change event.
  • event.start - the replace start offset
  • event.end - the replace end offset
  • event.text - the new text
updateCaret - whether or not he caret should be set behind the new text

paste

public void paste()
Suppressed: Replaces the selection with the clipboard text or insert the text at the current caret offset if there is no selection. If the widget has the SWT.SINGLE style and the clipboard text contains more than one line, only the first line without line delimiters is inserted in the widget.


performPaint

void performPaint(GC gc,
                  int startLine,
                  int startY,
                  int renderHeight)
Render the specified area. Broken out as its own method to support direct drawing.

Parameters:
gc - GC to render on
startLine - first line to render
startY - y pixel location to start rendering at
renderHeight - renderHeight widget area that needs to be filled with lines

print

public void print()
Suppressed: Prints the widget's text to the default printer.


print

public Runnable print(org.eclipse.swt.printing.Printer printer)
Suppressed: Returns a runnable that will print the widget's text to the specified printer.

The runnable may be run in a non-UI thread.

Parameters:
printer - the printer to print to

print

public Runnable print(org.eclipse.swt.printing.Printer printer,
                      org.eclipse.swt.custom.StyledTextPrintOptions options)
Suppressed: Returns a runnable that will print the widget's text to the specified printer.

The runnable may be run in a non-UI thread.

Parameters:
printer - the printer to print to
options - print options to use during printing
Since:
2.1

redraw

public void redraw()
Enabled: Causes the entire bounds of the receiver to be marked as needing to be redrawn. The next time a paint request is processed, the control will be completely painted.

Recalculates the content width for all lines in the bounds. When a LineStyleListener is used a redraw call is the only notification to the widget that styles have changed and that the content width may have changed.

Overrides:
redraw in class Control
See Also:
Control.update()

redraw

public void redraw(int x,
                   int y,
                   int width,
                   int height,
                   boolean all)
Enabled: Causes the rectangular area of the receiver specified by the arguments to be marked as needing to be redrawn. The next time a paint request is processed, that area of the receiver will be painted. If the all flag is true, any children of the receiver which intersect with the specified area will also paint their intersecting areas. If the all flag is false, the children will not be painted.

Marks the content width of all lines in the specified rectangle as unknown. Recalculates the content width of all visible lines. When a LineStyleListener is used a redraw call is the only notification to the widget that styles have changed and that the content width may have changed.

Overrides:
redraw in class Control
Parameters:
x - the x coordinate of the area to draw
y - the y coordinate of the area to draw
width - the width of the area to draw
height - the height of the area to draw
all - true if children should redraw, and false otherwise
See Also:
Control.update()

redrawBidiLines

void redrawBidiLines(int firstLine,
                     int offsetInFirstLine,
                     int lastLine,
                     int endOffset,
                     boolean clearBackground)
Redraws a text range in the specified lines

Parameters:
firstLine - first line to redraw at the specified offset
offsetInFirstLine - offset in firstLine to start redrawing
lastLine - last line to redraw
endOffset - offset in the last where redrawing should stop
clearBackground - true=clear the background by invalidating the requested redraw range, false=draw the foreground directly without invalidating the redraw range.

redrawLine

void redrawLine(int line,
                int offset)
Redraw the given line.

Parameters:
line - index of the line to redraw
offset - offset in line to start redrawing

redrawLines

void redrawLines(int firstLine,
                 int offsetInFirstLine,
                 int lastLine,
                 int endOffset,
                 boolean clearBackground)
Redraws a text range in the specified lines

Parameters:
firstLine - first line to redraw at the specified offset
offsetInFirstLine - offset in firstLine to start redrawing
lastLine - last line to redraw
endOffset - offset in the last where redrawing should stop
clearBackground - true=clear the background by invalidating the requested redraw range. If the redraw range includes the last character of a line (i.e., the entire line is redrawn) the line is cleared all the way to the right border of the widget. false=draw the foreground directly without invalidating the redraw range.

redrawMultiLineChange

void redrawMultiLineChange(int y,
                           int newLineCount,
                           int replacedLineCount)
Fixes the widget to display a text change. Bit blitting and redrawing is done as necessary.

Parameters:
y - y location of the text change
newLineCount - number of new lines.
replacedLineCount - number of replaced lines.

redrawRange

public void redrawRange(int start,
                        int length,
                        boolean clearBackground)
Enabled: Redraws the specified text range.

Parameters:
start - offset of the first character to redraw
length - number of characters to redraw
clearBackground - true if the background should be cleared as part of the redraw operation. If true, the entire redraw range will be cleared before anything is redrawn. If the redraw range includes the last character of a line (i.e., the entire line is redrawn) the line is cleared all the way to the right border of the widget. The redraw operation will be faster and smoother if clearBackground is set to false. Whether or not the flag can be set to false depends on the type of change that has taken place. If font styles or background colors for the redraw range have changed, clearBackground should be set to true. If only foreground colors have changed for the redraw range, clearBackground can be set to false.

removeBidiSegmentListener

public void removeBidiSegmentListener(BidiSegmentListener listener)
Enabled: Removes the specified bidirectional segment listener.

Parameters:
listener - the listener
Since:
2.0

removeExtendedModifyListener

public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener)
Enabled: Removes the specified extended modify listener.


removeLineBackgroundListener

public void removeLineBackgroundListener(LineBackgroundListener listener)
Enabled: Removes the specified line background listener.

Parameters:
listener - the listener

removeLineStyleListener

public void removeLineStyleListener(LineStyleListener listener)
Enabled: Removes the specified line style listener.

Parameters:
listener - the listener

removeModifyListener

public void removeModifyListener(ModifyListener modifyListener)
Enabled: Removes the specified modify listener.


removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Enabled: Removes the specified selection listener.

Parameters:
listener - the listener

removeVerifyListener

public void removeVerifyListener(VerifyListener verifyListener)
Enabled: Removes the specified verify listener.


removeVerifyKeyListener

public void removeVerifyKeyListener(VerifyKeyListener listener)
Enabled: Removes the specified key verify listener.

Parameters:
listener - the listener

replaceStyleRanges

public void replaceStyleRanges(int start,
                               int length,
                               StyleRange[] ranges)
Enabled: Replaces the styles in the given range with new styles. This method effectively deletes the styles in the given range and then adds the the new styles.

Should not be called if a LineStyleListener has been set since the listener maintains the styles.

Parameters:
start - offset of first character where styles will be deleted
length - length of the range to delete styles in
ranges - StyleRange objects containing the new style information. The ranges should not overlap and should be within the specified start and length. The style rendering is undefined if the ranges do overlap or are ill-defined. Must not be null.
Since:
2.0

replaceTextRange

public void replaceTextRange(int start,
                             int length,
                             String text)
Enabled: Replaces the given text range with new text. If the widget has the SWT.SINGLE style and "text" contains more than one line, only the first line is rendered but the text is stored unchanged. A subsequent call to getText will return the same text that was set. Note that only a single line of text should be set when the SWT.SINGLE style is used.

NOTE: During the replace operation the current selection is changed as follows:

Parameters:
start - offset of first character to replace
length - number of characters to replace. Use 0 to insert text
text - new text. May be empty to delete text.

reset

void reset()
Resets the caret position, selection and scroll offsets. Recalculate the content width and scroll bars. Redraw the widget.


resetSelection

void resetSelection()
Resets the selection.


scrollHorizontal

void scrollHorizontal(int pixels)
Scrolls the widget horizontally.

Parameters:
pixels - number of pixels to scroll, > 0 = scroll left, < 0 scroll right

scrollHorizontalBar

boolean scrollHorizontalBar(int pixels)
Scrolls the widget horizontally and adjust the horizontal scroll bar to reflect the new horizontal offset..

Parameters:
pixels - number of pixels to scroll, > 0 = scroll left, < 0 scroll right
Returns:
true=the widget was scrolled false=the widget was not scrolled, the given offset is not valid.

selectAll

public void selectAll()
Enabled: Selects all the text.


sendKeyEvent

void sendKeyEvent(Event event)
Replaces/inserts text as defined by the event.

Parameters:
event - the text change event.
  • event.start - the replace start offset
  • event.end - the replace end offset
  • event.text - the new text

sendSelectionEvent

void sendSelectionEvent()
Sends the specified selection event.


setWordWrap

public void setWordWrap(boolean wrap)
Enabled: Sets whether the widget wraps lines. This overrides the creation style bit SWT.WRAP.

Parameters:
wrap - true=widget wraps lines, false=widget does not wrap lines
Since:
2.0

showBidiCaret

void showBidiCaret()
Sets the caret location and scrolls the caret offset into view.


setCaret

public void setCaret(Caret caret)
Enabled: Sets the receiver's caret. Set the caret's height and location.

Overrides:
setCaret in class Canvas
Parameters:
caret - the new caret for the receiver

setBackground

public void setBackground(Color color)
Enabled: @see org.eclipse.swt.widgets.Control#setBackground

Overrides:
setBackground in class Control
Parameters:
color - the new color (or null)

setBidiCaretDirection

void setBidiCaretDirection()
Set the caret to indicate the current typing direction.


setBidiCaretLocation

void setBidiCaretLocation(StyledTextBidi bidi)
Moves the Caret to the current caret offset.

Parameters:
bidi - StyledTextBidi object to use for measuring. May be left null in which case a new object will be created.

setBidiCaretLocation

void setBidiCaretLocation(StyledTextBidi bidi,
                          int caretLine)
Moves the Caret to the current caret offset.

Parameters:
bidi - StyledTextBidi object to use for measuring. May be left null in which case a new object will be created.
caretLine - line the caret should be placed on. Relative to first line in document

setBidiColoring

public void setBidiColoring(boolean mode)
Deprecated. use BidiSegmentListener instead.

Enabled: Sets the BIDI coloring mode. When true the BIDI text display algorithm is applied to segments of text that are the same color.

Parameters:
mode - the new coloring mode

setBidiKeyboardLanguage

void setBidiKeyboardLanguage()
Switches the keyboard language according to the current editing position and cursor direction.


setCaretLocation

void setCaretLocation(int newCaretX,
                      int line)
Moves the Caret to the current caret offset.

Parameters:
newCaretX - the new x location of the caret. passed in for better performance when it has already been calculated outside this method.
line - index of the line the caret is on. Relative to the first line in the document.

setCaretLocation

void setCaretLocation()
Moves the Caret to the current caret offset.


setCaretOffset

public void setCaretOffset(int offset)
Enabled: Sets the caret offset.

Parameters:
offset - caret offset, relative to the first character in the text.

setClipboardContent

void setClipboardContent(int start,
                         int length)
                   throws SWTError
Copies the specified text range to the clipboard. The text will be placed in the clipboard in plain text format and RTF format.

Parameters:
start - start index of the text
length - length of text to place in clipboard
SWTError
See Also:
org.eclipse.swt.dnd.Clipboard.setContents

setContent

public void setContent(StyledTextContent newContent)
Enabled: Sets the content implementation to use for text storage.


setCursor

public void setCursor(Cursor cursor)
Enabled: Sets the receiver's cursor to the cursor specified by the argument. Overridden to handle the null case since the StyledText widget uses an ibeam as its default cursor.

Overrides:
setCursor in class Control
Parameters:
cursor - the new cursor (or null)
See Also:
org.eclipse.swt.widgets.Control#setCursor

setDoubleClickEnabled

public void setDoubleClickEnabled(boolean enable)
Enabled: Sets whether the widget implements double click mouse behavior.

Parameters:
enable - if true double clicking a word selects the word, if false double clicks have the same effect as regular mouse clicks.

setEditable

public void setEditable(boolean editable)
Enabled: Sets whether the widget content can be edited.

Parameters:
editable - if true content can be edited, if false content can not be edited

setFont

public void setFont(Font font)
Enabled: Sets a new font to render text with.

NOTE: Italic fonts are not supported unless they have no overhang and the same baseline as regular fonts.

Overrides:
setFont in class Canvas
Parameters:
font - new font

setForeground

public void setForeground(Color color)
Enabled: @see org.eclipse.swt.widgets.Control#setForeground

Overrides:
setForeground in class Control
Parameters:
color - the new color (or null)

setHorizontalIndex

public void setHorizontalIndex(int offset)
Enabled: Sets the horizontal scroll offset relative to the start of the line. Do nothing if there is no text set.

NOTE: The horizontal index is reset to 0 when new text is set in the widget.

Parameters:
offset - horizontal scroll offset relative to the start of the line, measured in character increments starting at 0, if equal to 0 the content is not scrolled, if > 0 = the content is scrolled.

setHorizontalPixel

public void setHorizontalPixel(int pixel)
Enabled: Sets the horizontal pixel offset relative to the start of the line. Do nothing if there is no text set.

NOTE: The horizontal pixel offset is reset to 0 when new text is set in the widget.

Parameters:
pixel - horizontal pixel offset relative to the start of the line.
Since:
2.0

setHorizontalScrollBar

void setHorizontalScrollBar()
Adjusts the maximum and the page size of the horizontal scroll bar to reflect content width changes.


setLineBackground

public void setLineBackground(int startLine,
                              int lineCount,
                              Color background)
Enabled: Sets the background color of the specified lines. The background color is drawn for the width of the widget. All line background colors are discarded when setText is called. The text background color if defined in a StyleRange overlays the line background color. Should not be called if a LineBackgroundListener has been set since the listener maintains the line backgrounds.

Line background colors are maintained relative to the line text, not the line index that is specified in this method call. During text changes, when entire lines are inserted or removed, the line background colors that are associated with the lines after the change will "move" with their respective text. An entire line is defined as extending from the first character on a line to the last and including the line delimiter.

When two lines are joined by deleting a line delimiter, the top line background takes precedence and the color of the bottom line is deleted. For all other text changes line background colors will remain unchanged.

Parameters:
startLine - first line the color is applied to, 0 based
lineCount - number of lines the color applies to.
background - line background color

setMouseWordSelectionAnchor

void setMouseWordSelectionAnchor()
Flips selection anchor based on word selection direction.


setScrollBars

void setScrollBars()
Adjusts the maximum and the page size of the scroll bars to reflect content width/length changes.


setSelection

public void setSelection(int start)
Enabled: Sets the selection to the given position and scrolls it into view. Equivalent to setSelection(start,start).

Parameters:
start - new caret position
See Also:
setSelection(int,int)

setSelection

public void setSelection(Point point)
Enabled: Sets the selection and scrolls it into view.

Indexing is zero based. Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

Parameters:
point - x=selection start offset, y=selection end offset The caret will be placed at the selection start when x > y.
See Also:
setSelection(int,int)

setSelectionBackground

public void setSelectionBackground(Color color)
Suppressed: Sets the receiver's selection background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
color - the new color (or null)
Since:
2.1

setSelectionForeground

public void setSelectionForeground(Color color)
Suppressed: Sets the receiver's selection foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Parameters:
color - the new color (or null)
Since:
2.1

setSelection

public void setSelection(int start,
                         int end)
Enabled: Sets the selection and scrolls it into view.

Indexing is zero based. Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N

Parameters:
start - selection start offset. The caret will be placed at the selection start when start > end.
end - selection end offset
See Also:
setSelectionRange(int,int)

setSelectionRange

public void setSelectionRange(int start,
                              int length)
Enabled: Sets the selection. The new selection may not be visible. Call showSelection to scroll the selection into view.

Parameters:
start - offset of the first selected character, start >= 0 must be true.
length - number of characters to select, 0 <= start + length <= getCharCount() must be true. A negative length places the caret at the visual start of the selection.

internalSetSelection

void internalSetSelection(int start,
                          int length,
                          boolean sendEvent)
Sets the selection. The new selection may not be visible. Call showSelection to scroll the selection into view.

Parameters:
start - offset of the first selected character, start >= 0 must be true.
length - number of characters to select, 0 <= start + length <= getCharCount() must be true. A negative length places the caret at the selection start.
sendEvent - a Selection event is sent when set to true and when the selection is reset.

setStyleRange

public void setStyleRange(StyleRange range)
Enabled: Adds the specified style. The new style overwrites existing styles for the specified range. Existing style ranges are adjusted if they partially overlap with the new style, To clear an individual style, call setStyleRange with a StyleRange that has null attributes.

Should not be called if a LineStyleListener has been set since the listener maintains the styles.

Parameters:
range - StyleRange object containing the style information. Overwrites the old style in the given range. May be null to delete all styles.

setStyleRanges

public void setStyleRanges(StyleRange[] ranges)
Enabled: Sets styles to be used for rendering the widget content. All styles in the widget will be replaced with the given set of styles.

Should not be called if a LineStyleListener has been set since the listener maintains the styles.

Parameters:
ranges - StyleRange objects containing the style information. The ranges should not overlap. The style rendering is undefined if the ranges do overlap. Must not be null.

setTabs

public void setTabs(int tabs)
Enabled: Sets the tab width.

Parameters:
tabs - tab width measured in characters.

setText

public void setText(String text)
Enabled: Sets the widget content. If the widget has the SWT.SINGLE style and "text" contains more than one line, only the first line is rendered but the text is stored unchanged. A subsequent call to getText will return the same text that was set.

Note: Only a single line of text should be set when the SWT.SINGLE style is used.

Parameters:
text - new widget content. Replaces existing content. Line styles that were set using StyledText API are discarded. The current selection is also discarded.

setTextLimit

public void setTextLimit(int limit)
Enabled: Sets the text limit.

The text limit specifies the amount of text that the user can type into the widget.

Parameters:
limit - the new text limit.

setTopIndex

public void setTopIndex(int topIndex)
Enabled: Sets the top index. Do nothing if there is no text set.

The top index is the index of the line that is currently at the top of the widget. The top index changes when the widget is scrolled. Indexing starts from zero. Note: The top index is reset to 0 when new text is set in the widget.


setTopPixel

public void setTopPixel(int pixel)
Enabled: Sets the top pixel offset. Do nothing if there is no text set.

The top pixel offset is the vertical pixel offset of the widget. The widget is scrolled so that the given pixel position is at the top. The top index is adjusted to the corresponding top line. Note: The top pixel is reset to 0 when new text is set in the widget.

Parameters:
pixel - new top pixel offset. Must be between 0 and (getLineCount() - visible lines per page) / getLineHeight()). An out of range offset will be adjusted accordingly.
Since:
2.0

setVerticalScrollOffset

boolean setVerticalScrollOffset(int pixelOffset,
                                boolean adjustScrollBar)
Scrolls the widget vertically.

Parameters:
pixelOffset - the new vertical scroll offset
adjustScrollBar - true= the scroll thumb will be moved to reflect the new scroll offset. false = the scroll thumb will not be moved
Returns:
true=the widget was scrolled false=the widget was not scrolled, the given offset is not valid.

showLocation

boolean showLocation(int x,
                     int line)
Scrolls the specified location into view.

Parameters:
x - the x coordinate that should be made visible.
line - the line that should be made visible. Relative to the first line in the document.
Returns:
true=the widget was scrolled to make the specified location visible. false=the specified location is already visible, the widget was not scrolled.

showCaret

void showCaret()
Sets the caret location and scrolls the caret offset into view.


showCaret

void showCaret(int caretLine)
Sets the caret location and scrolls the caret offset into view.


showOffset

void showOffset(int offset)
Scrolls the specified offset into view.

Parameters:
offset - offset that should be scolled into view

showSelection

public void showSelection()
Enabled: /** Scrolls the selection into view. The end of the selection will be scrolled into view. Note that if a right-to-left selection exists, the end of the selection is the visual beginning of the selection (i.e., where the caret is located).


updateBidiDirection

void updateBidiDirection(boolean isBackspace,
                         boolean isDirectionBoundary)
Updates the caret direction when a delete operation occured based on the type of the delete operation (next/previous character) and the caret location (at a direction boundary or inside a direction segment). The intent is to place the caret at the visual location where a character was deleted.

Parameters:
isBackspace - true=the previous character was deleted, false=the character next to the caret location was deleted
isDirectionBoundary - true=the caret is between a R2L and L2R segment, false=the caret is within a direction segment

updateSelection

void updateSelection(int startOffset,
                     int replacedLength,
                     int newLength)
Updates the selection and caret position depending on the text change. If the selection intersects with the replaced text, the selection is reset and the caret moved to the end of the new text. If the selection is behind the replaced text it is moved so that the same text remains selected. If the selection is before the replaced text it is left unchanged.

Parameters:
startOffset - offset of the text change
replacedLength - length of text being replaced
newLength - length of new text

wordWrapResize

void wordWrapResize(int oldClientAreaWidth)
Rewraps all lines

Parameters:
oldClientAreaWidth - client area width before resize occurred


comments?