JX Application Framework
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
JTextEditor Class Referenceabstract

#include <JTextEditor.h>

Inheritance diagram for JTextEditor:
[legend]

Classes

struct  CaretLocation
 
class  CaretLocationChanged
 
struct  LineGeometry
 
class  TypeChanged
 

Public Types

enum  Type {
  kFullEditor ,
  kSelectableText ,
  kStaticText
}
 
enum  CmdIndex {
  kSeparatorCmd = 1 ,
  kUndoCmd ,
  kRedoCmd ,
  kCutCmd ,
  kCopyCmd ,
  kPasteCmd ,
  kDeleteSelCmd ,
  kSelectAllCmd ,
  kCheckSpellingCmd ,
  kCheckSpellingSelCmd ,
  kCleanRightMarginCmd ,
  kCoerceRightMarginCmd ,
  kShiftSelLeftCmd ,
  kShiftSelRightCmd ,
  kForceShiftSelLeftCmd ,
  kShowWhitespaceCmd ,
  kCleanAllWhitespaceCmd ,
  kCleanWhitespaceSelCmd ,
  kCleanAllWSAlignCmd ,
  kCleanWSAlignSelCmd ,
  kToggleReadOnlyCmd ,
  kFindDialogCmd ,
  kFindPreviousCmd ,
  kFindNextCmd ,
  kEnterSearchTextCmd ,
  kEnterReplaceTextCmd ,
  kFindSelectionBackwardCmd ,
  kFindSelectionForwardCmd ,
  kFindClipboardBackwardCmd ,
  kFindClipboardForwardCmd ,
  kReplaceSelectionCmd ,
  kReplaceFindPrevCmd ,
  kReplaceFindNextCmd ,
  kReplaceAllCmd ,
  kReplaceAllInSelectionCmd ,
  kCmdCount = kReplaceAllInSelectionCmd
}
 
enum  CaretMode {
  kLineCaret ,
  kBlockCaret
}
 
enum  CaretMotion {
  kMoveByCharacter ,
  kMoveByPartialWord ,
  kMoveByWord ,
  kMoveByLine
}
 
enum  { kMinLeftMarginWidth = 2 }
 

Public Member Functions

 JTextEditor (const Type type, JStyledText *text, const bool ownsText, JFontManager *fontManager, const bool breakCROnly, const JColorID caretColor, const JColorID selectionColor, const JColorID outlineColor, const JColorID wsColor, const JCoordinate width)
 
 JTextEditor (const JTextEditor &source, JStyledText *text)
 
 ~JTextEditor () override
 
Type GetType () const
 
bool IsReadOnly () const
 
bool WillBreakCROnly () const
 
void SetBreakCROnly (const bool breakCROnly)
 
JStyledTextGetText ()
 
const JStyledTextGetText () const
 
JStringMatch SearchForward (const JRegex &regex, const bool entireWord, const bool wrapSearch, bool *wrapped)
 
JStringMatch SearchBackward (const JRegex &regex, const bool entireWord, const bool wrapSearch, bool *wrapped)
 
JStringMatch SelectionMatches (const JRegex &regex, const bool entireWord)
 
bool ReplaceAll (const JRegex &regex, const bool entireWord, const JString &replaceStr, JInterpolate *interpolator, const bool preserveCase, const bool restrictToSelection=false)
 
bool SearchForward (std::function< bool(const JFont &)> match, const bool wrapSearch, bool *wrapped)
 
bool SearchBackward (std::function< bool(const JFont &)> match, const bool wrapSearch, bool *wrapped)
 
virtual bool TEHasSearchText () const =0
 
JIndex GetInsertionCharIndex () const
 
JStringIteratorGetConstIteratorAtInsertionIndex () const
 
void DisposeConstIterator (JStringIterator *iter) const
 
bool GetCaretLocation (JIndex *charIndex) const
 
void SetCaretLocation (const JIndex charIndex)
 
void SetCaretLocation (const JPoint &pt)
 
bool HasSelection () const
 
bool GetSelection (JCharacterRange *range) const
 
bool GetSelection (JString *text) const
 
bool GetSelection (JString *text, JRunArray< JFont > *style) const
 
void SetSelection (const JCharacterRange &range, const bool needCaretBcast=true)
 
bool TEScrollToSelection (const bool centerInDisplay)
 
void GoToBeginningOfLine ()
 
void GoToEndOfLine ()
 
JFont GetCurrentFont () const
 
void SetCurrentFontName (const JString &name)
 
void SetCurrentFontSize (const JSize size)
 
void SetCurrentFontBold (const bool bold)
 
void SetCurrentFontItalic (const bool italic)
 
void SetCurrentFontUnderline (const JSize count)
 
void SetCurrentFontStrike (const bool strike)
 
void SetCurrentFontColor (const JColorID color)
 
void SetCurrentFontStyle (const JFontStyle &style)
 
void SetCurrentFont (const JFont &font)
 
bool CleanRightMargin (const bool coerce)
 
JCoordinate GetDefaultTabWidth () const
 
void SetDefaultTabWidth (const JCoordinate width)
 
void TabSelectionLeft (const JSize tabCount=1, const bool force=false)
 
void TabSelectionRight (const JSize tabCount=1)
 
void CleanAllWhitespace (const bool align)
 
void CleanSelectedWhitespace (const bool align)
 
void AnalyzeWhitespace (JSize *tabWidth)
 
bool WillShowWhitespace () const
 
void ShouldShowWhitespace (const bool show)
 
bool WillAlwaysShowSelection () const
 
void ShouldAlwaysShowSelection (const bool show)
 
bool WillMoveToFrontOfText () const
 
void ShouldMoveToFrontOfText (const bool moveToFront)
 
JSize GetLineCount () const
 
JIndex GetLineCharStart (const JIndex lineIndex) const
 
JIndex GetLineCharEnd (const JIndex lineIndex) const
 
JIndex GetLineForChar (const JIndex charIndex) const
 
void GoToLine (const JIndex lineIndex)
 
void SelectLine (const JIndex lineIndex)
 
JCoordinate GetLineTop (const JIndex lineIndex) const
 
JCoordinate GetLineBottom (const JIndex lineIndex) const
 
JSize GetLineHeight (const JIndex lineIndex) const
 
JIndex CRLineIndexToVisualLineIndex (const JIndex crLineIndex) const
 
JIndex VisualLineIndexToCRLineIndex (const JIndex visualLineIndex) const
 
JCoordinate GetCharLeft (const JIndex charIndex) const
 
JCoordinate GetCharRight (const JIndex charIndex) const
 
JIndex GetColumnForChar (const JIndex charIndex) const
 
void GoToColumn (const JIndex lineIndex, const JIndex columnIndex)
 
void DeleteSelection ()
 
void SelectAll ()
 
void Cut ()
 
void Copy () const
 
void Paste ()
 
void Paste (const JString &text, const JRunArray< JFont > *style=nullptr)
 
bool GetClipboard (JString *text, JRunArray< JFont > *style=nullptr) const
 
void Paginate (const JCoordinate pageHeight, JArray< JCoordinate > *breakpts) const
 
void Print (JPagePrinter &p)
 
JTEKeyHandlerGetKeyHandler () const
 
void SetKeyHandler (JTEKeyHandler *handler)
 
bool AllowsDragAndDrop () const
 
void ShouldAllowDragAndDrop (const bool allow)
 
JCoordinate TEGetMinPreferredGUIWidth () const
 
JCoordinate TEGetLeftMarginWidth () const
 
void TESetLeftMarginWidth (const JCoordinate width)
 
JColorID GetCaretColor () const
 
void SetCaretColor (const JColorID color)
 
JColorID GetSelectionColor () const
 
void SetSelectionColor (const JColorID color)
 
JColorID GetSelectionOutlineColor () const
 
void SetSelectionOutlineColor (const JColorID color)
 
JColorID GetWhitespaceColor () const
 
void SetWhitespaceColor (const JColorID color)
 
CaretMode GetCaretMode () const
 
void SetCaretMode (const CaretMode mode)
 
JFontManagerTEGetFontManager () const
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
virtual JString ToString () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Static Public Member Functions

static bool WillCopyWhenSelect ()
 
static void ShouldCopyWhenSelect (const bool copy)
 

Static Public Attributes

static const JUtf8BytekTypeChanged = "TypeChanged::JTextEditor"
 
static const JUtf8BytekCaretLocationChanged = "CaretLocationChanged::JTextEditor"
 

Protected Member Functions

bool TEIsActive () const
 
void TEActivate ()
 
void TEDeactivate ()
 
bool TESelectionIsActive () const
 
void TEActivateSelection ()
 
void TEDeactivateSelection ()
 
bool TECaretIsVisible () const
 
void TEShowCaret ()
 
void TEHideCaret ()
 
void SetType (const Type type)
 
void RecalcAll (const bool broadcastCaretMessages=true)
 
JArray< boolGetCmdStatus (JString *crmActionText, JString *crm2ActionText, bool *isReadOnly) const
 
void TEDraw (JPainter &p, const JRect &rect)
 
virtual void TEDrawInMargin (JPainter &p, const JPoint &topLeft, const LineGeometry &geom, const JIndex lineIndex)
 
bool TEWillDragAndDrop (const JPoint &pt, const bool extendSelection, const bool dropCopy) const
 
void TEHandleMouseDown (const JPoint &pt, const JSize clickCount, const bool extendSelection, const bool partialWord)
 
void TEHandleMouseDrag (const JPoint &pt)
 
void TEHandleMouseUp ()
 
bool TEHitSamePart (const JPoint &pt1, const JPoint &pt2) const
 
virtual bool TEBeginDND ()=0
 
void TEDNDFinished ()
 
void TEHandleDNDEnter ()
 
void TEHandleDNDHere (const JPoint &pt, const bool dropOnSelf)
 
void TEHandleDNDLeave ()
 
void TEHandleDNDDrop (const JPoint &pt, const bool dropOnSelf, const bool dropCopy)
 
virtual void TEPasteDropData ()=0
 
bool TEIsDragging () const
 
bool TEHandleKeyPress (const JUtf8Character &key, const bool selectText, const CaretMotion motion, const bool deleteToTabStop)
 
JCoordinate TEGetBoundsWidth () const
 
void TESetBoundsWidth (const JCoordinate width)
 
virtual void TERefresh ()=0
 
virtual void TERefreshRect (const JRect &rect)=0
 
void TERefreshLines (const JIndex first, const JIndex last)
 
virtual void TEUpdateDisplay ()
 
virtual void TERedraw ()=0
 
virtual void TESetGUIBounds (const JCoordinate w, const JCoordinate h, const JCoordinate changeY)=0
 
virtual bool TEWidthIsBeyondDisplayCapacity (const JSize width) const =0
 
virtual bool TEScrollToRect (const JRect &rect, const bool centerInDisplay)=0
 
virtual bool TEScrollForDrag (const JPoint &pt)=0
 
virtual bool TEScrollForDND (const JPoint &pt)=0
 
virtual void TESetVertScrollStep (const JCoordinate vStep)=0
 
virtual void TEUpdateClipboard (const JString &text, const JRunArray< JFont > &style) const =0
 
virtual bool TEGetClipboard (JString *text, JRunArray< JFont > *style) const =0
 
virtual void TECaretShouldBlink (const bool blink)=0
 
virtual JCoordinate GetTabWidth (const JIndex charIndex, const JCoordinate x) const
 
virtual JCoordinate GetPrintHeaderHeight (JPagePrinter &p) const
 
virtual JCoordinate GetPrintFooterHeight (JPagePrinter &p) const
 
virtual void DrawPrintHeader (JPagePrinter &p, const JCoordinate headerHeight)
 
virtual void DrawPrintFooter (JPagePrinter &p, const JCoordinate footerHeight)
 
bool GetCaretLocation (CaretLocation *caretLoc) const
 
void SetCaretLocation (const JStyledText::TextIndex &caretLoc)
 
void SetCaretLocation (const CaretLocation &caretLoc)
 
CaretLocation CalcCaretLocation (const JPoint &pt) const
 
CaretLocation CalcCaretLocation (const JStyledText::TextIndex &index) const
 
bool PointInSelection (const JPoint &pt) const
 
void MoveCaretVert (const JInteger deltaLines)
 
JIndex GetColumnForChar (const CaretLocation &caretLoc) const
 
JStyledText::TextIndex GetInsertionIndex () const
 
JStyledText::TextIndex GetLineStart (const JIndex lineIndex) const
 
JStyledText::TextIndex GetLineEnd (const JIndex lineIndex) const
 
JStyledText::TextCount GetLineLength (const JIndex lineIndex) const
 
bool GetSelection (JStyledText::TextRange *range) const
 
void SetSelection (const JStyledText::TextRange &range, const bool needCaretBcast=true, const bool ignoreCopyWhenSelect=false)
 
void TEGetDoubleClickSelection (const JStyledText::TextIndex &charIndex, const bool partialWord, const bool dragging, JStyledText::TextRange *range) const
 
void SetAllFontNameAndSize (const JString &name, const JSize size, const JCoordinate tabWidth, const bool breakCROnly, const bool clearUndo)
 
void ReplaceSelection (const JStringMatch &match, const JString &replaceStr, JInterpolate *interpolator, const bool preserveCase)
 
void Receive (JBroadcaster *sender, const Message &message) override
 
void ReceiveGoingAway (JBroadcaster *sender) override
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 

Friends

class JTEKeyHandler
 
class JTEDefaultKeyHandler
 
class JVIKeyHandler
 

Detailed Description

Class to edit styled text.  This class only manages the view (layout
and caret location / selection) and controller (pointer and key
actions).  The underlying JStyledText maintains the model (data
and styles).

The only functions that are shadowed from JStyledText are those
that perform operations based on the view, e.g, modify the currently
selected text / styles.  Modifications can always safely be done
directly on the JStyledText, assuming you have the required data.

When the text ends with a newline, we have to draw the caret on the
next line.  This is a special case because (charIndex == bufLength+1)
would normally catch this.  We handle this special case internally
rather than appending an extra item to itsLineStarts because this keeps
the issue internal rather than forcing clients to deal with it.

Derived classes must implement the following functions:

    TERefresh
        Put an update event in the queue to redraw the text.

    TERefreshRect
        Put an update event in the queue to redraw part of the text.

    TEUpdateDisplay
        Redraw whatever was requested by TERefresh() and TERefreshRect().
        (This is not pure virtual because some systems automatically
         update the window after each event.)

    TERedraw
        Redraw the text immediately.

    TESetGUIBounds
        Set the bounds of the GUI object to match our size.  The original
        height and vertical position of the change can be used to update
        scrolltabs.  If change position is negative, don't update the
        scrolltabs.

    TEWidthIsBeyondDisplayCapacity
        Returns true if the given bounds width is too wide for the
        current graphics system to handle.  If so, breakCROnly is
        turned off.

    TEScrollToRect
        Scroll the text to make the given rectangle visible, possibly
        centering it in the middle of the display.  Return true
        if scrolling was necessary.

    TEScrollForDrag
        Scroll the text to make the given point visible.  Return true
        if scrolling was necessary.

    TEScrollForDND
        Same as TEScrollForDrag(), but separate, since some frameworks
        do the scrolling automatically.

    TESetVertScrollStep
        Set the vertical step size and page context used when scrolling
        the text.

    TECaretShouldBlink
        If blink is true, reset the timer and make the caret blink by
        calling TEShow/HideCaret().  Otherwise, call TEHideCaret().
        The derived class constructor must call TECaretShouldBlink(true)
        because it is pure virtual for us.

    TEUpdateClipboard
        Update the system clipboard with the given text/style.

    TEGetClipboard
        Returns true if there is something pasteable on the system
        clipboard.

    TEBeginDND
        Returns true if it is able to start a Drag-And-Drop session
        with the OS.  From then on, the derived class should call the
        TEHandleDND*() functions.  It must also call TEDNDFinished()
        when the drag ends.  If TEBeginDND() returns false, then we
        will manage an internal DND session.  In this case, the derived
        class should continue to call the usual TEHandleMouse*()
        functions.

    TEPasteDropData
        Get the data that was dropped and use Paste(text,style)
        to insert it.  (Before this is called, the insertion point
        is set so that Paste() will work correctly.)

    TEHasSearchText
        Return true if the user has entered any text for which to search.

To draw page headers and footers while printing, override the
following routines:

    GetPrintHeaderHeight
        Return the height required for the page header.

    DrawPrintHeader
        Draw the page header.  JTable will lock the header afterwards.

    GetPrintFooterHeight
        Return the height required for the page footer.

    DrawPrintFooter
        Draw the page footer.  JTable will lock the footer afterwards.

The default implementation of tabs rounds the location up to the nearest
multiple of itsDefTabWidth.  To implement non-uniform tabs or tabs on a
line-by-line basis, override the following function:

    GetTabWidth
        Given the index of the tab character (charIndex) and the horizontal
        position on the line (in pixels) where the tab character starts (x),
        return the width of the tab character.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kMinLeftMarginWidth 

◆ CaretMode

Enumerator
kLineCaret 
kBlockCaret 

◆ CaretMotion

Enumerator
kMoveByCharacter 
kMoveByPartialWord 
kMoveByWord 
kMoveByLine 

◆ CmdIndex

Enumerator
kSeparatorCmd 
kUndoCmd 
kRedoCmd 
kCutCmd 
kCopyCmd 
kPasteCmd 
kDeleteSelCmd 
kSelectAllCmd 
kCheckSpellingCmd 
kCheckSpellingSelCmd 
kCleanRightMarginCmd 
kCoerceRightMarginCmd 
kShiftSelLeftCmd 
kShiftSelRightCmd 
kForceShiftSelLeftCmd 
kShowWhitespaceCmd 
kCleanAllWhitespaceCmd 
kCleanWhitespaceSelCmd 
kCleanAllWSAlignCmd 
kCleanWSAlignSelCmd 
kToggleReadOnlyCmd 
kFindDialogCmd 
kFindPreviousCmd 
kFindNextCmd 
kEnterSearchTextCmd 
kEnterReplaceTextCmd 
kFindSelectionBackwardCmd 
kFindSelectionForwardCmd 
kFindClipboardBackwardCmd 
kFindClipboardForwardCmd 
kReplaceSelectionCmd 
kReplaceFindPrevCmd 
kReplaceFindNextCmd 
kReplaceAllCmd 
kReplaceAllInSelectionCmd 
kCmdCount 

◆ Type

Enumerator
kFullEditor 
kSelectableText 
kStaticText 

Constructor & Destructor Documentation

◆ JTextEditor() [1/2]

JTextEditor::JTextEditor ( const Type  type,
JStyledText text,
const bool  ownsText,
JFontManager fontManager,
const bool  breakCROnly,
const JColorID  caretColor,
const JColorID  selectionColor,
const JColorID  outlineColor,
const JColorID  wsColor,
const JCoordinate  width 
)

Colors must be from the same colorManager given to JStyledText.

Derived classes must call RecalcAll().  We can't call it due to
pure virtual functions.

◆ JTextEditor() [2/2]

JTextEditor::JTextEditor ( const JTextEditor source,
JStyledText text 
)

if text is not nullptr, we take ownership of it.

If text is nullptr and the source does not own the JStyledText, we will share it.

◆ ~JTextEditor()

JTextEditor::~JTextEditor ( )
override

Member Function Documentation

◆ AllowsDragAndDrop()

bool JTextEditor::AllowsDragAndDrop ( ) const
inline

◆ AnalyzeWhitespace()

void JTextEditor::AnalyzeWhitespace ( JSize tabWidth)

Check all indent whitespace.

If default is tabs, check for indent containing spaces. Allow up to N-1 spaces at the end of the line, where N = tab width.

If default is spaces, check for any indent containing tabs.

If mixed indentation, show whitespace. Set mode based on majority of indentation.

Updates tabWidth value if it decides that spaces should be used for indentation.

◆ CalcCaretLocation() [1/2]

JTextEditor::CaretLocation JTextEditor::CalcCaretLocation ( const JPoint pt) const
protected

Return the closest insertion point. If the line ends with a space, the last possible insertion point is in front of this space

◆ CalcCaretLocation() [2/2]

JTextEditor::CaretLocation JTextEditor::CalcCaretLocation ( const JStyledText::TextIndex index) const
protected

byteIndex can be zero.

◆ CleanAllWhitespace()

void JTextEditor::CleanAllWhitespace ( const bool  align)
inline

Clean up the indentation whitespace and strip trailing whitespace.

◆ CleanRightMargin()

bool JTextEditor::CleanRightMargin ( const bool  coerce)

If there is a selection, cleans up the right margin of each paragraph touched by the selection. Otherwise, cleans up the right margin of the paragraph containing the caret and maintain the caret position.

◆ CleanSelectedWhitespace()

void JTextEditor::CleanSelectedWhitespace ( const bool  align)

Clean up the indentation whitespace and strip trailing whitespace in the selected range.

◆ Copy()

void JTextEditor::Copy ( ) const

◆ CRLineIndexToVisualLineIndex()

JIndex JTextEditor::CRLineIndexToVisualLineIndex ( const JIndex  crLineIndex) const

Returns the index that the user sees that corresponds to the given index that would be seen without word wrap.

This function is required to work for arbitrarily large, invalid line indices.

◆ Cut()

void JTextEditor::Cut ( )

◆ DeleteSelection()

void JTextEditor::DeleteSelection ( )

◆ DisposeConstIterator()

void JTextEditor::DisposeConstIterator ( JStringIterator iter) const
inline

◆ DrawPrintFooter()

void JTextEditor::DrawPrintFooter ( JPagePrinter p,
const JCoordinate  footerHeight 
)
protectedvirtual

Reimplemented in JXTEBase.

◆ DrawPrintHeader()

void JTextEditor::DrawPrintHeader ( JPagePrinter p,
const JCoordinate  headerHeight 
)
protectedvirtual

◆ GetCaretColor()

JColorID JTextEditor::GetCaretColor ( ) const
inline

◆ GetCaretLocation() [1/2]

bool JTextEditor::GetCaretLocation ( CaretLocation caretLoc) const
inlineprotected

◆ GetCaretLocation() [2/2]

bool JTextEditor::GetCaretLocation ( JIndex charIndex) const
inline

◆ GetCaretMode()

JTextEditor::CaretMode JTextEditor::GetCaretMode ( ) const
inline

◆ GetCharLeft()

JCoordinate JTextEditor::GetCharLeft ( const JIndex  charIndex) const
inline

Returns the starting x coordinate of the specified character, including the left margin width

◆ GetCharRight()

JCoordinate JTextEditor::GetCharRight ( const JIndex  charIndex) const
inline

Returns the ending x coordinate of the specified character, including the left margin width

◆ GetClipboard()

bool JTextEditor::GetClipboard ( JString text,
JRunArray< JFont > *  style = nullptr 
) const

Returns the text and style that would be pasted if Paste() were called.

style can be nullptr. If it is not nullptr, it can come back empty even if the function returns true.

◆ GetCmdStatus()

JArray< bool > JTextEditor::GetCmdStatus ( JString crmActionText,
JString crm2ActionText,
bool isReadOnly 
) const
protected

Returns an array indicating which commands can be performed in the current state.

◆ GetColumnForChar() [1/2]

JIndex JTextEditor::GetColumnForChar ( const CaretLocation caretLoc) const
inlineprotected

◆ GetColumnForChar() [2/2]

JIndex JTextEditor::GetColumnForChar ( const JIndex  charIndex) const
inline

Returns the column that the specified character is in. If the caret is at the far left, it is column 1.

Given that this is only useful with monospace fonts, the CRM tab width is used to calculate the column when tabs are encountered, by calling CRMGetTabWidth().

◆ GetConstIteratorAtInsertionIndex()

JStringIterator * JTextEditor::GetConstIteratorAtInsertionIndex ( ) const
inline

◆ GetCurrentFont()

JFont JTextEditor::GetCurrentFont ( ) const
inline

◆ GetDefaultTabWidth()

JCoordinate JTextEditor::GetDefaultTabWidth ( ) const
inline

◆ GetInsertionCharIndex()

JIndex JTextEditor::GetInsertionCharIndex ( ) const
inline

Return the index where new text will be typed or pasted.

◆ GetInsertionIndex()

JStyledText::TextIndex JTextEditor::GetInsertionIndex ( ) const
inlineprotected

Return the index where new text will be typed or pasted.

◆ GetKeyHandler()

JTEKeyHandler * JTextEditor::GetKeyHandler ( ) const
inline

◆ GetLineBottom()

JCoordinate JTextEditor::GetLineBottom ( const JIndex  lineIndex) const
inline

Returns the bottom of the specified line.

◆ GetLineCharEnd()

JIndex JTextEditor::GetLineCharEnd ( const JIndex  lineIndex) const
inline

Returns the first character on the specified line.

◆ GetLineCharStart()

JIndex JTextEditor::GetLineCharStart ( const JIndex  lineIndex) const
inline

Returns the first character on the specified line.

◆ GetLineCount()

JSize JTextEditor::GetLineCount ( ) const
inline

◆ GetLineEnd()

JStyledText::TextIndex JTextEditor::GetLineEnd ( const JIndex  lineIndex) const
protected

Returns the last character on the specified line.

◆ GetLineForChar()

JIndex JTextEditor::GetLineForChar ( const JIndex  charIndex) const

Returns the line that contains the specified character. Since the array is sorted, we can use a binary search. We can use kAnyMatch because we know the values are unique.

◆ GetLineHeight()

JSize JTextEditor::GetLineHeight ( const JIndex  lineIndex) const
inline

◆ GetLineLength()

JStyledText::TextCount JTextEditor::GetLineLength ( const JIndex  lineIndex) const
inlineprotected

Returns the number of characters on the specified line.

◆ GetLineStart()

JStyledText::TextIndex JTextEditor::GetLineStart ( const JIndex  lineIndex) const
inlineprotected

Returns the first character on the specified line.

◆ GetLineTop()

JCoordinate JTextEditor::GetLineTop ( const JIndex  endLineIndex) const

Returns the top of the specified line.

◆ GetPrintFooterHeight()

JCoordinate JTextEditor::GetPrintFooterHeight ( JPagePrinter p) const
protectedvirtual

Reimplemented in JXTEBase.

◆ GetPrintHeaderHeight()

JCoordinate JTextEditor::GetPrintHeaderHeight ( JPagePrinter p) const
protectedvirtual

Derived classes can override these functions if they want to print a header or a footer.

◆ GetSelection() [1/4]

bool JTextEditor::GetSelection ( JCharacterRange range) const
inline

◆ GetSelection() [2/4]

bool JTextEditor::GetSelection ( JString text) const
inline

◆ GetSelection() [3/4]

bool JTextEditor::GetSelection ( JString text,
JRunArray< JFont > *  style 
) const
inline

◆ GetSelection() [4/4]

bool JTextEditor::GetSelection ( JStyledText::TextRange range) const
inlineprotected

◆ GetSelectionColor()

JColorID JTextEditor::GetSelectionColor ( ) const
inline

◆ GetSelectionOutlineColor()

JColorID JTextEditor::GetSelectionOutlineColor ( ) const
inline

◆ GetTabWidth()

JCoordinate JTextEditor::GetTabWidth ( const JIndex  charIndex,
const JCoordinate  x 
) const
protectedvirtual

Given the index of the tab character (charIndex) and the horizontal position on the line (in pixels) where the tab character starts (x), return the width of the tab character.

This default implementation rounds the location up to the nearest multiple of itsDefTabWidth.

◆ GetText() [1/2]

JStyledText * JTextEditor::GetText ( )
inline

◆ GetText() [2/2]

const JStyledText & JTextEditor::GetText ( ) const
inline

◆ GetType()

JTextEditor::Type JTextEditor::GetType ( ) const
inline

◆ GetWhitespaceColor()

JColorID JTextEditor::GetWhitespaceColor ( ) const
inline

◆ GoToBeginningOfLine()

void JTextEditor::GoToBeginningOfLine ( )

◆ GoToColumn()

void JTextEditor::GoToColumn ( const JIndex  lineIndex,
const JIndex  columnIndex 
)

◆ GoToEndOfLine()

void JTextEditor::GoToEndOfLine ( )

◆ GoToLine()

void JTextEditor::GoToLine ( const JIndex  lineIndex)

◆ HasSelection()

bool JTextEditor::HasSelection ( ) const
inline

◆ IsReadOnly()

bool JTextEditor::IsReadOnly ( ) const
inline

◆ MoveCaretVert()

void JTextEditor::MoveCaretVert ( const JInteger  deltaLines)
protected

Moves the caret up or down the specified number of lines.

◆ Paginate()

void JTextEditor::Paginate ( const JCoordinate  pageHeight,
JArray< JCoordinate > *  breakpts 
) const

Returns breakpoints for cutting text into pages. The first breakpoint is always zero, and the last breakpoint is the height of the text. Thus, it is easy to calculate the width of what is printed on each page from (breakpt->GetItem(i+1) - breakpt->GetItem(i) + 1).

◆ Paste() [1/2]

void JTextEditor::Paste ( )

◆ Paste() [2/2]

void JTextEditor::Paste ( const JString text,
const JRunArray< JFont > *  style = nullptr 
)

style can be nullptr

◆ PointInSelection()

bool JTextEditor::PointInSelection ( const JPoint pt) const
protected

◆ Print()

void JTextEditor::Print ( JPagePrinter p)

This function could be optimized to save the necessary state so TESetBoundsWidth() doesn't have to be called again at the end.

◆ RecalcAll()

void JTextEditor::RecalcAll ( const bool  broadcastCaretMessages = true)
protected

◆ Receive()

void JTextEditor::Receive ( JBroadcaster sender,
const Message message 
)
overrideprotectedvirtual

Process the given message from the given sender. This function is not pure virtual because not all classes will want to implement it.

Reimplemented from JBroadcaster.

Reimplemented in JXFileNameDisplay, JXFSInputBase, JXTEBase, and JXTextEditor.

◆ ReceiveGoingAway()

void JTextEditor::ReceiveGoingAway ( JBroadcaster sender)
overrideprotectedvirtual

The given sender has been deleted.

Warning: Since this function may be called from within a -chain- of destructors, it is not usually safe to do anything inside this function other than directly changing instance variables (e.g. setting pointers to nullptr).

This function is not pure virtual because not all classes will want to implement it.

Reimplemented from JBroadcaster.

◆ ReplaceAll()

bool JTextEditor::ReplaceAll ( const JRegex regex,
const bool  entireWord,
const JString replaceStr,
JInterpolate interpolator,
const bool  preserveCase,
const bool  restrictToSelection = false 
)

Replace every occurrence of the search pattern with the replace string. Returns true if it modified the text.

◆ ReplaceSelection()

void JTextEditor::ReplaceSelection ( const JStringMatch match,
const JString replaceStr,
JInterpolate interpolator,
const bool  preserveCase 
)
protected

Replace the current selection with the given replace text.

Something must be selected.
We do not check that it matches the search string.

◆ SearchBackward() [1/2]

JStringMatch JTextEditor::SearchBackward ( const JRegex regex,
const bool  entireWord,
const bool  wrapSearch,
bool wrapped 
)

Look for the match before the current position. If we find it, we select it and return true.

◆ SearchBackward() [2/2]

bool JTextEditor::SearchBackward ( std::function< bool(const JFont &)>  match,
const bool  wrapSearch,
bool wrapped 
)

Look for the match before the current position. If we find it, we select it and return true.

◆ SearchForward() [1/2]

JStringMatch JTextEditor::SearchForward ( const JRegex regex,
const bool  entireWord,
const bool  wrapSearch,
bool wrapped 
)

We only support regular expressions because there is no advantage in optimizing for literal strings. Look for the next match beyond the current position. If we find it, we select it and return true.

◆ SearchForward() [2/2]

bool JTextEditor::SearchForward ( std::function< bool(const JFont &)>  match,
const bool  wrapSearch,
bool wrapped 
)

Look for the next match beyond the current position. If we find it, we select it and return true.

◆ SelectAll()

void JTextEditor::SelectAll ( )
inline

◆ SelectionMatches()

JStringMatch JTextEditor::SelectionMatches ( const JRegex regex,
const bool  entireWord 
)

Returns true if the current selection matches the given search criteria. This returns the JStringMatch required for a replace.

◆ SelectLine()

void JTextEditor::SelectLine ( const JIndex  lineIndex)

◆ SetAllFontNameAndSize()

void JTextEditor::SetAllFontNameAndSize ( const JString name,
const JSize  size,
const JCoordinate  tabWidth,
const bool  breakCROnly,
const bool  clearUndo 
)
protected

This function is useful for unstyled text editors that allow the user to change the font and size.

It preserves the styles, in case they are controlled by the program. (e.g. context sensitive hilighting)

You can choose whether or not to throw out all Undo information. Unstyled text editors can usually preserve Undo, since they will not allow the user to modify styles. (We explicitly ask for this because it is too easy to forget about the issue.)

◆ SetBreakCROnly()

void JTextEditor::SetBreakCROnly ( const bool  breakCROnly)
inline

◆ SetCaretColor()

void JTextEditor::SetCaretColor ( const JColorID  color)
inline

◆ SetCaretLocation() [1/4]

void JTextEditor::SetCaretLocation ( const CaretLocation caretLoc)
protected

◆ SetCaretLocation() [2/4]

void JTextEditor::SetCaretLocation ( const JIndex  origCharIndex)

Move the caret in front of to the specified character.

◆ SetCaretLocation() [3/4]

void JTextEditor::SetCaretLocation ( const JPoint pt)
inline

◆ SetCaretLocation() [4/4]

void JTextEditor::SetCaretLocation ( const JStyledText::TextIndex caretLoc)
inlineprotected

◆ SetCaretMode()

void JTextEditor::SetCaretMode ( const CaretMode  mode)
inline

◆ SetCurrentFont()

void JTextEditor::SetCurrentFont ( const JFont font)
inline

◆ SetCurrentFontBold()

void JTextEditor::SetCurrentFontBold ( const bool  bold)
inline

◆ SetCurrentFontColor()

void JTextEditor::SetCurrentFontColor ( const JColorID  color)
inline

◆ SetCurrentFontItalic()

void JTextEditor::SetCurrentFontItalic ( const bool  italic)
inline

◆ SetCurrentFontName()

void JTextEditor::SetCurrentFontName ( const JString name)
inline

◆ SetCurrentFontSize()

void JTextEditor::SetCurrentFontSize ( const JSize  size)
inline

◆ SetCurrentFontStrike()

void JTextEditor::SetCurrentFontStrike ( const bool  strike)
inline

◆ SetCurrentFontStyle()

void JTextEditor::SetCurrentFontStyle ( const JFontStyle style)
inline

◆ SetCurrentFontUnderline()

void JTextEditor::SetCurrentFontUnderline ( const JSize  count)
inline

◆ SetDefaultTabWidth()

void JTextEditor::SetDefaultTabWidth ( const JCoordinate  width)
inline

◆ SetKeyHandler()

void JTextEditor::SetKeyHandler ( JTEKeyHandler handler)

Passing nullptr resets to the default key handler

◆ SetSelection() [1/2]

void JTextEditor::SetSelection ( const JCharacterRange range,
const bool  needCaretBcast = true 
)
inline

◆ SetSelection() [2/2]

void JTextEditor::SetSelection ( const JStyledText::TextRange range,
const bool  needCaretBcast = true,
const bool  ignoreCopyWhenSelect = false 
)
protected

◆ SetSelectionColor()

void JTextEditor::SetSelectionColor ( const JColorID  color)
inline

◆ SetSelectionOutlineColor()

void JTextEditor::SetSelectionOutlineColor ( const JColorID  color)
inline

◆ SetType()

void JTextEditor::SetType ( const Type  type)
protected

This is protected because most derived classes will not be written to expect the type to change.

Broadcasts TypeChanged.

◆ SetWhitespaceColor()

void JTextEditor::SetWhitespaceColor ( const JColorID  color)
inline

◆ ShouldAllowDragAndDrop()

void JTextEditor::ShouldAllowDragAndDrop ( const bool  allow)
inline

◆ ShouldAlwaysShowSelection()

void JTextEditor::ShouldAlwaysShowSelection ( const bool  show)
inline

◆ ShouldCopyWhenSelect()

void JTextEditor::ShouldCopyWhenSelect ( const bool  copy)
inlinestatic

◆ ShouldMoveToFrontOfText()

void JTextEditor::ShouldMoveToFrontOfText ( const bool  moveToFront)
inline

◆ ShouldShowWhitespace()

void JTextEditor::ShouldShowWhitespace ( const bool  show)
inline

◆ TabSelectionLeft()

void JTextEditor::TabSelectionLeft ( const JSize  tabCount = 1,
const bool  force = false 
)

Remove tabs from the beginning of every selected line. If nothing is selected, we select the line that the caret is on.

◆ TabSelectionRight()

void JTextEditor::TabSelectionRight ( const JSize  tabCount = 1)

Insert a tab at the beginning of every selected line. If nothing is selected, we select the line that the caret is on.

◆ TEActivate()

void JTextEditor::TEActivate ( )
inlineprotected

◆ TEActivateSelection()

void JTextEditor::TEActivateSelection ( )
inlineprotected

◆ TEBeginDND()

virtual bool JTextEditor::TEBeginDND ( )
protectedpure virtual

Implemented in JXTEBase.

◆ TECaretIsVisible()

bool JTextEditor::TECaretIsVisible ( ) const
inlineprotected

◆ TECaretShouldBlink()

virtual void JTextEditor::TECaretShouldBlink ( const bool  blink)
protectedpure virtual

Implemented in JXTEBase.

◆ TEDeactivate()

void JTextEditor::TEDeactivate ( )
inlineprotected

◆ TEDeactivateSelection()

void JTextEditor::TEDeactivateSelection ( )
inlineprotected

◆ TEDNDFinished()

void JTextEditor::TEDNDFinished ( )
inlineprotected

◆ TEDraw()

void JTextEditor::TEDraw ( JPainter p,
const JRect rect 
)
protected

Draw everything that is visible in the given rectangle.

◆ TEDrawInMargin()

void JTextEditor::TEDrawInMargin ( JPainter p,
const JPoint topLeft,
const LineGeometry geom,
const JIndex  lineIndex 
)
protectedvirtual

Scribble in the margins, e.g., bookmarks, line numbers, etc.

◆ TEGetBoundsWidth()

JCoordinate JTextEditor::TEGetBoundsWidth ( ) const
inlineprotected

◆ TEGetClipboard()

virtual bool JTextEditor::TEGetClipboard ( JString text,
JRunArray< JFont > *  style 
) const
protectedpure virtual

Implemented in JXTEBase.

◆ TEGetDoubleClickSelection()

void JTextEditor::TEGetDoubleClickSelection ( const JStyledText::TextIndex charIndex,
const bool  partialWord,
const bool  dragging,
JStyledText::TextRange range 
) const
protected

Select the word that was clicked on. By computing the end of the word found by GetWordStart(), we avoid selecting two words when the user double clicks on the space between them.

◆ TEGetFontManager()

JFontManager * JTextEditor::TEGetFontManager ( ) const
inline

◆ TEGetLeftMarginWidth()

JCoordinate JTextEditor::TEGetLeftMarginWidth ( ) const
inline

◆ TEGetMinPreferredGUIWidth()

JCoordinate JTextEditor::TEGetMinPreferredGUIWidth ( ) const

◆ TEHandleDNDDrop()

void JTextEditor::TEHandleDNDDrop ( const JPoint pt,
const bool  dropOnSelf,
const bool  dropCopy 
)
protected

If we are not the source, the derived class has to figure out how to get the data from the target. Once it has the data, it should call Paste(text,style).

◆ TEHandleDNDEnter()

void JTextEditor::TEHandleDNDEnter ( )
protected

◆ TEHandleDNDHere()

void JTextEditor::TEHandleDNDHere ( const JPoint pt,
const bool  dropOnSelf 
)
protected

◆ TEHandleDNDLeave()

void JTextEditor::TEHandleDNDLeave ( )
protected

◆ TEHandleKeyPress()

bool JTextEditor::TEHandleKeyPress ( const JUtf8Character origKey,
const bool  selectText,
const CaretMotion  motion,
const bool  deleteToTabStop 
)
protected

Returns true if the key was processed.

◆ TEHandleMouseDown()

void JTextEditor::TEHandleMouseDown ( const JPoint pt,
const JSize  clickCount,
const bool  extendSelection,
const bool  partialWord 
)
protected

◆ TEHandleMouseDrag()

void JTextEditor::TEHandleMouseDrag ( const JPoint pt)
protected

◆ TEHandleMouseUp()

void JTextEditor::TEHandleMouseUp ( )
protected

◆ TEHasSearchText()

virtual bool JTextEditor::TEHasSearchText ( ) const
pure virtual

Implemented in JXTEBase.

◆ TEHideCaret()

void JTextEditor::TEHideCaret ( )
inlineprotected

◆ TEHitSamePart()

bool JTextEditor::TEHitSamePart ( const JPoint pt1,
const JPoint pt2 
) const
protected

◆ TEIsActive()

bool JTextEditor::TEIsActive ( ) const
inlineprotected

◆ TEIsDragging()

bool JTextEditor::TEIsDragging ( ) const
inlineprotected

◆ TEPasteDropData()

virtual void JTextEditor::TEPasteDropData ( )
protectedpure virtual

Implemented in JXTEBase.

◆ TERedraw()

virtual void JTextEditor::TERedraw ( )
protectedpure virtual

Implemented in JXTEBase.

◆ TERefresh()

virtual void JTextEditor::TERefresh ( )
protectedpure virtual

Implemented in JXTEBase.

◆ TERefreshLines()

void JTextEditor::TERefreshLines ( const JIndex  firstLine,
const JIndex  lastLine 
)
protected

Redraw the specified range of lines.

◆ TERefreshRect()

virtual void JTextEditor::TERefreshRect ( const JRect rect)
protectedpure virtual

Implemented in JXPasswordInput, and JXTEBase.

◆ TEScrollForDND()

virtual bool JTextEditor::TEScrollForDND ( const JPoint pt)
protectedpure virtual

Implemented in JXTEBase.

◆ TEScrollForDrag()

virtual bool JTextEditor::TEScrollForDrag ( const JPoint pt)
protectedpure virtual

Implemented in JXTEBase.

◆ TEScrollToRect()

virtual bool JTextEditor::TEScrollToRect ( const JRect rect,
const bool  centerInDisplay 
)
protectedpure virtual

Implemented in JXTEBase.

◆ TEScrollToSelection()

bool JTextEditor::TEScrollToSelection ( const bool  centerInDisplay)

Scroll to make the selection or caret visible. Returns true if scrolling was actually necessary.

◆ TESelectionIsActive()

bool JTextEditor::TESelectionIsActive ( ) const
inlineprotected

◆ TESetBoundsWidth()

void JTextEditor::TESetBoundsWidth ( const JCoordinate  width)
protected

Call this to notify us of a change in aperture width.

◆ TESetGUIBounds()

virtual void JTextEditor::TESetGUIBounds ( const JCoordinate  w,
const JCoordinate  h,
const JCoordinate  changeY 
)
protectedpure virtual

Implemented in JXTEBase.

◆ TESetLeftMarginWidth()

void JTextEditor::TESetLeftMarginWidth ( const JCoordinate  origWidth)

For multi-line input areas it helps to have a wide left margin where one can click and drag down to select entire lines.

◆ TESetVertScrollStep()

virtual void JTextEditor::TESetVertScrollStep ( const JCoordinate  vStep)
protectedpure virtual

Implemented in JXTEBase.

◆ TEShowCaret()

void JTextEditor::TEShowCaret ( )
inlineprotected

◆ TEUpdateClipboard()

virtual void JTextEditor::TEUpdateClipboard ( const JString text,
const JRunArray< JFont > &  style 
) const
protectedpure virtual

Implemented in JXTEBase.

◆ TEUpdateDisplay()

void JTextEditor::TEUpdateDisplay ( )
protectedvirtual

Called to update the window after mouse and keyboard events. Not pure virtual because some systems do this automatically.

◆ TEWidthIsBeyondDisplayCapacity()

virtual bool JTextEditor::TEWidthIsBeyondDisplayCapacity ( const JSize  width) const
protectedpure virtual

Implemented in JXTEBase.

◆ TEWillDragAndDrop()

bool JTextEditor::TEWillDragAndDrop ( const JPoint pt,
const bool  extendSelection,
const bool  dropCopy 
) const
protected

◆ VisualLineIndexToCRLineIndex()

JIndex JTextEditor::VisualLineIndexToCRLineIndex ( const JIndex  origVisualLineIndex) const

Returns the index that would be seen without word wrap that corresponds to the given index that the user sees.

This function is required to work for arbitrarily large, invalid line indices.

◆ WillAlwaysShowSelection()

bool JTextEditor::WillAlwaysShowSelection ( ) const
inline

◆ WillBreakCROnly()

bool JTextEditor::WillBreakCROnly ( ) const
inline

◆ WillCopyWhenSelect()

bool JTextEditor::WillCopyWhenSelect ( )
inlinestatic

This is primarily useful under the X Window System. It is static because all text should work the same way.

◆ WillMoveToFrontOfText()

bool JTextEditor::WillMoveToFrontOfText ( ) const
inline

◆ WillShowWhitespace()

bool JTextEditor::WillShowWhitespace ( ) const
inline

Friends And Related Symbol Documentation

◆ JTEDefaultKeyHandler

friend class JTEDefaultKeyHandler
friend

◆ JTEKeyHandler

friend class JTEKeyHandler
friend

◆ JVIKeyHandler

friend class JVIKeyHandler
friend

Member Data Documentation

◆ kCaretLocationChanged

const JUtf8Byte * JTextEditor::kCaretLocationChanged = "CaretLocationChanged::JTextEditor"
static

◆ kTypeChanged

const JUtf8Byte * JTextEditor::kTypeChanged = "TypeChanged::JTextEditor"
static

The documentation for this class was generated from the following files: