openshot-audio  0.1.4
Classes | Public Types | Public Member Functions | Friends | List of all members
CodeEditorComponent Class Reference

#include <juce_CodeEditorComponent.h>

Inheritance diagram for CodeEditorComponent:
Component ApplicationCommandTarget TextInputTarget MouseListener

Classes

class  CodeEditorLine
 
struct  ColourScheme
 
class  GutterComponent
 
class  Pimpl
 
struct  State
 

Public Types

enum  ColourIds {
  backgroundColourId = 0x1004500, highlightColourId = 0x1004502, defaultTextColourId = 0x1004503, lineNumberBackgroundId = 0x1004504,
  lineNumberTextId = 0x1004505
}
 
- Public Types inherited from Component
enum  FocusChangeType { focusChangedByMouseClick, focusChangedByTabKey, focusChangedDirectly }
 
- Public Types inherited from TextInputTarget
enum  VirtualKeyboardType {
  textKeyboard = 0, numericKeyboard, decimalKeyboard, urlKeyboard,
  emailAddressKeyboard, phoneNumberKeyboard
}
 

Public Member Functions

 CodeEditorComponent (CodeDocument &document, CodeTokeniser *codeTokeniser)
 
 ~CodeEditorComponent ()
 
CodeDocumentgetDocument () const noexcept
 
void loadContent (const String &newContent)
 
float getCharWidth () const noexcept
 
int getLineHeight () const noexcept
 
int getNumLinesOnScreen () const noexcept
 
int getFirstLineOnScreen () const noexcept
 
int getNumColumnsOnScreen () const noexcept
 
CodeDocument::Position getCaretPos () const
 
Rectangle< int > getCaretRectangle () override
 
void moveCaretTo (const CodeDocument::Position &newPos, bool selecting)
 
Rectangle< int > getCharacterBounds (const CodeDocument::Position &pos) const
 
CodeDocument::Position getPositionAt (int x, int y)
 
CodeDocument::Position getSelectionStart () const
 
CodeDocument::Position getSelectionEnd () const
 
void setLineNumbersShown (bool shouldBeShown)
 
bool moveCaretLeft (bool moveInWholeWordSteps, bool selecting)
 
bool moveCaretRight (bool moveInWholeWordSteps, bool selecting)
 
bool moveCaretUp (bool selecting)
 
bool moveCaretDown (bool selecting)
 
bool scrollDown ()
 
bool scrollUp ()
 
bool pageUp (bool selecting)
 
bool pageDown (bool selecting)
 
bool moveCaretToTop (bool selecting)
 
bool moveCaretToStartOfLine (bool selecting)
 
bool moveCaretToEnd (bool selecting)
 
bool moveCaretToEndOfLine (bool selecting)
 
bool deleteBackwards (bool moveInWholeWordSteps)
 
bool deleteForwards (bool moveInWholeWordSteps)
 
bool deleteWhitespaceBackwardsToTabStop ()
 
virtual bool copyToClipboard ()
 
virtual bool cutToClipboard ()
 
virtual bool pasteFromClipboard ()
 
bool undo ()
 
bool redo ()
 
void selectRegion (const CodeDocument::Position &start, const CodeDocument::Position &end)
 
bool selectAll ()
 
void deselectAll ()
 
void scrollToLine (int newFirstLineOnScreen)
 
void scrollBy (int deltaLines)
 
void scrollToColumn (int newFirstColumnOnScreen)
 
void scrollToKeepCaretOnScreen ()
 
void scrollToKeepLinesOnScreen (Range< int > linesToShow)
 
void insertTextAtCaret (const String &textToInsert) override
 
void insertTabAtCaret ()
 
void indentSelection ()
 
void unindentSelection ()
 
Range< int > getHighlightedRegion () const override
 
bool isHighlightActive () const noexcept
 
void setHighlightedRegion (const Range< int > &newRange) override
 
String getTextInRange (const Range< int > &range) const override
 
void setTabSize (int numSpacesPerTab, bool insertSpacesInsteadOfTabCharacters)
 
int getTabSize () const noexcept
 
bool areSpacesInsertedForTabs () const
 
String getTabString (int numSpaces) const
 
void setFont (const Font &newFont)
 
const FontgetFont () const noexcept
 
void setReadOnly (bool shouldBeReadOnly) noexcept
 
bool isReadOnly () const noexcept
 
void setColourScheme (const ColourScheme &scheme)
 
const ColourSchemegetColourScheme () const noexcept
 
Colour getColourForTokenType (int tokenType) const
 
void setScrollbarThickness (int thickness)
 
int getScrollbarThickness () const noexcept
 
virtual void handleReturnKey ()
 
virtual void handleTabKey ()
 
virtual void handleEscapeKey ()
 
virtual void addPopupMenuItems (PopupMenu &menuToAddTo, const MouseEvent *mouseClickEvent)
 
virtual void performPopupMenuAction (int menuItemID)
 
void setCommandManager (ApplicationCommandManager *newManager) noexcept
 
void paint (Graphics &) override
 
void resized () override
 
bool keyPressed (const KeyPress &) override
 
void mouseDown (const MouseEvent &) override
 
void mouseDrag (const MouseEvent &) override
 
void mouseUp (const MouseEvent &) override
 
void mouseDoubleClick (const MouseEvent &) override
 
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) override
 
void focusGained (FocusChangeType) override
 
void focusLost (FocusChangeType) override
 
bool isTextInputActive () const override
 
void setTemporaryUnderlining (const Array< Range< int > > &) override
 
ApplicationCommandTargetgetNextCommandTarget () override
 
void getAllCommands (Array< CommandID > &) override
 
void getCommandInfo (CommandID, ApplicationCommandInfo &) override
 
bool perform (const InvocationInfo &) override
 
- Public Member Functions inherited from Component
 Component () noexcept
 
virtual ~Component ()
 
 Component (const String &componentName) noexcept
 
const StringgetName () const noexcept
 
virtual void setName (const String &newName)
 
const StringgetComponentID () const noexcept
 
void setComponentID (const String &newID)
 
virtual void setVisible (bool shouldBeVisible)
 
bool isVisible () const noexcept
 
virtual void visibilityChanged ()
 
bool isShowing () const
 
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
 
void removeFromDesktop ()
 
bool isOnDesktop () const noexcept
 
ComponentPeergetPeer () const
 
virtual void userTriedToCloseWindow ()
 
virtual void minimisationStateChanged (bool isNowMinimised)
 
virtual float getDesktopScaleFactor () const
 
void toFront (bool shouldAlsoGainFocus)
 
void toBack ()
 
void toBehind (Component *other)
 
void setAlwaysOnTop (bool shouldStayOnTop)
 
bool isAlwaysOnTop () const noexcept
 
int getX () const noexcept
 
int getY () const noexcept
 
int getWidth () const noexcept
 
int getHeight () const noexcept
 
int getRight () const noexcept
 
Point< int > getPosition () const noexcept
 
int getBottom () const noexcept
 
const Rectangle< int > & getBounds () const noexcept
 
Rectangle< int > getLocalBounds () const noexcept
 
Rectangle< int > getBoundsInParent () const noexcept
 
int getScreenX () const
 
int getScreenY () const
 
Point< int > getScreenPosition () const
 
Rectangle< int > getScreenBounds () const
 
Point< int > getLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
 
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
 
Rectangle< int > getLocalArea (const Component *sourceComponent, const Rectangle< int > &areaRelativeToSourceComponent) const
 
Point< int > localPointToGlobal (Point< int > localPoint) const
 
Point< float > localPointToGlobal (Point< float > localPoint) const
 
Rectangle< int > localAreaToGlobal (const Rectangle< int > &localArea) const
 
void setTopLeftPosition (int x, int y)
 
void setTopLeftPosition (Point< int > newTopLeftPosition)
 
void setTopRightPosition (int x, int y)
 
void setSize (int newWidth, int newHeight)
 
void setBounds (int x, int y, int width, int height)
 
void setBounds (const Rectangle< int > &newBounds)
 
void setBounds (const RelativeRectangle &newBounds)
 
void setBounds (const String &newBoundsExpression)
 
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
 
void setBoundsInset (const BorderSize< int > &borders)
 
void setBoundsToFit (int x, int y, int width, int height, Justification justification, bool onlyReduceInSize)
 
void setCentrePosition (int x, int y)
 
void setCentreRelative (float x, float y)
 
void centreWithSize (int width, int height)
 
void setTransform (const AffineTransform &transform)
 
AffineTransform getTransform () const
 
bool isTransformed () const noexcept
 
int proportionOfWidth (float proportion) const noexcept
 
int proportionOfHeight (float proportion) const noexcept
 
int getParentWidth () const noexcept
 
int getParentHeight () const noexcept
 
Rectangle< int > getParentMonitorArea () const
 
int getNumChildComponents () const noexcept
 
ComponentgetChildComponent (int index) const noexcept
 
int getIndexOfChildComponent (const Component *child) const noexcept
 
ComponentfindChildWithID (StringRef componentID) const noexcept
 
void addChildComponent (Component *child, int zOrder=-1)
 
void addChildComponent (Component &child, int zOrder=-1)
 
void addAndMakeVisible (Component *child, int zOrder=-1)
 
void addAndMakeVisible (Component &child, int zOrder=-1)
 
void addChildAndSetID (Component *child, const String &componentID)
 
void removeChildComponent (Component *childToRemove)
 
ComponentremoveChildComponent (int childIndexToRemove)
 
void removeAllChildren ()
 
void deleteAllChildren ()
 
ComponentgetParentComponent () const noexcept
 
template<class TargetClass >
TargetClass * findParentComponentOfClass () const
 
ComponentgetTopLevelComponent () const noexcept
 
bool isParentOf (const Component *possibleChild) const noexcept
 
virtual void parentHierarchyChanged ()
 
virtual void childrenChanged ()
 
virtual bool hitTest (int x, int y)
 
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
 
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
 
bool contains (Point< int > localPoint)
 
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
 
ComponentgetComponentAt (int x, int y)
 
ComponentgetComponentAt (Point< int > position)
 
void repaint ()
 
void repaint (int x, int y, int width, int height)
 
void repaint (const Rectangle< int > &area)
 
void setBufferedToImage (bool shouldBeBuffered)
 
Image createComponentSnapshot (const Rectangle< int > &areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
 
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
 
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
 
void setComponentEffect (ImageEffectFilter *newEffect)
 
ImageEffectFiltergetComponentEffect () const noexcept
 
LookAndFeelgetLookAndFeel () const noexcept
 
void setLookAndFeel (LookAndFeel *newLookAndFeel)
 
virtual void lookAndFeelChanged ()
 
void sendLookAndFeelChange ()
 
void setOpaque (bool shouldBeOpaque)
 
bool isOpaque () const noexcept
 
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
 
bool isBroughtToFrontOnMouseClick () const noexcept
 
void setWantsKeyboardFocus (bool wantsFocus) noexcept
 
bool getWantsKeyboardFocus () const noexcept
 
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
 
bool getMouseClickGrabsKeyboardFocus () const noexcept
 
void grabKeyboardFocus ()
 
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
 
void moveKeyboardFocusToSibling (bool moveToNext)
 
virtual KeyboardFocusTraversercreateFocusTraverser ()
 
int getExplicitFocusOrder () const
 
void setExplicitFocusOrder (int newFocusOrderIndex)
 
void setFocusContainer (bool shouldBeFocusContainer) noexcept
 
bool isFocusContainer () const noexcept
 
bool isEnabled () const noexcept
 
void setEnabled (bool shouldBeEnabled)
 
virtual void enablementChanged ()
 
void setAlpha (float newAlpha)
 
float getAlpha () const
 
void setMouseCursor (const MouseCursor &cursorType)
 
virtual MouseCursor getMouseCursor ()
 
void updateMouseCursor () const
 
virtual void paintOverChildren (Graphics &g)
 
virtual void mouseMove (const MouseEvent &event) override
 
virtual void mouseEnter (const MouseEvent &event) override
 
virtual void mouseExit (const MouseEvent &event) override
 
virtual void mouseMagnify (const MouseEvent &event, float scaleFactor)
 
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
 
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
 
void removeMouseListener (MouseListener *listenerToRemove)
 
void addKeyListener (KeyListener *newListener)
 
void removeKeyListener (KeyListener *listenerToRemove)
 
virtual bool keyStateChanged (bool isKeyDown)
 
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
 
virtual void focusOfChildComponentChanged (FocusChangeType cause)
 
bool isMouseOver (bool includeChildren=false) const
 
bool isMouseButtonDown () const
 
bool isMouseOverOrDragging () const
 
Point< int > getMouseXYRelative () const
 
virtual void moved ()
 
virtual void childBoundsChanged (Component *child)
 
virtual void parentSizeChanged ()
 
virtual void broughtToFront ()
 
void addComponentListener (ComponentListener *newListener)
 
void removeComponentListener (ComponentListener *listenerToRemove)
 
void postCommandMessage (int commandId)
 
virtual void handleCommandMessage (int commandId)
 
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
 
void exitModalState (int returnValue)
 
bool isCurrentlyModal () const noexcept
 
bool isCurrentlyBlockedByAnotherModalComponent () const
 
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
 
virtual void inputAttemptWhenModal ()
 
NamedValueSetgetProperties () noexcept
 
const NamedValueSetgetProperties () const noexcept
 
Colour findColour (int colourId, bool inheritFromParent=false) const
 
void setColour (int colourId, Colour newColour)
 
void removeColour (int colourId)
 
bool isColourSpecified (int colourId) const
 
void copyAllExplicitColoursTo (Component &target) const
 
virtual void colourChanged ()
 
virtual MarkerListgetMarkers (bool xAxis)
 
void * getWindowHandle () const
 
PositionergetPositioner () const noexcept
 
void setPositioner (Positioner *newPositioner)
 
void setCachedComponentImage (CachedComponentImage *newCachedImage)
 
CachedComponentImagegetCachedComponentImage () const noexcept
 
 JUCE_DEPRECATED (Point< int > relativePositionToGlobal(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > globalPositionToRelative(Point< int >) const)
 
 JUCE_DEPRECATED (Point< int > relativePositionToOtherComponent(const Component *, Point< int >) const)
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
- Public Member Functions inherited from ApplicationCommandTarget
 ApplicationCommandTarget ()
 
virtual ~ApplicationCommandTarget ()
 
bool invoke (const InvocationInfo &invocationInfo, const bool asynchronously)
 
bool invokeDirectly (const CommandID commandID, const bool asynchronously)
 
ApplicationCommandTargetgetTargetForCommand (const CommandID commandID)
 
bool isCommandActive (const CommandID commandID)
 
ApplicationCommandTargetfindFirstTargetParentComponent ()
 
- Public Member Functions inherited from TextInputTarget
 TextInputTarget ()
 
virtual ~TextInputTarget ()
 
virtual VirtualKeyboardType getKeyboardType ()
 

Friends

class Pimpl
 
struct ContainerDeletePolicy< Pimpl >
 
class GutterComponent
 
struct ContainerDeletePolicy< GutterComponent >
 

Additional Inherited Members

- Static Public Member Functions inherited from Component
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
 
static void JUCE_CALLTYPE unfocusAllComponents ()
 
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
 
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
 
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
 
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept
 
- Protected Member Functions inherited from Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
 

Detailed Description

A text editor component designed specifically for source code.

This is designed to handle syntax highlighting and fast editing of very large files.

Member Enumeration Documentation

◆ ColourIds

A set of colour IDs to use to change the colour of various aspects of the editor.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

A colour to use to fill the editor's background.

highlightColourId 

The colour to use for the highlighted background under selected text.

defaultTextColourId 

The colour to use for text when no syntax colouring is enabled.

lineNumberBackgroundId 

The colour to use for filling the background of the line-number gutter.

lineNumberTextId 

The colour to use for drawing the line numbers.

Constructor & Destructor Documentation

◆ CodeEditorComponent()

CodeEditorComponent::CodeEditorComponent ( CodeDocument document,
CodeTokeniser codeTokeniser 
)

Creates an editor for a document.

The tokeniser object is optional - pass nullptr to disable syntax highlighting. The object that you pass in is not owned or deleted by the editor - you must make sure that it doesn't get deleted while this component is still using it.

See also
CodeDocument

◆ ~CodeEditorComponent()

CodeEditorComponent::~CodeEditorComponent ( )

Destructor.

Member Function Documentation

◆ addPopupMenuItems()

void CodeEditorComponent::addPopupMenuItems ( PopupMenu menuToAddTo,
const MouseEvent mouseClickEvent 
)
virtual

This adds the items to the popup menu.

By default it adds the cut/copy/paste items, but you can override this if you need to replace these with your own items.

If you want to add your own items to the existing ones, you can override this, call the base class's addPopupMenuItems() method, then append your own items.

When the menu has been shown, performPopupMenuAction() will be called to perform the item that the user has chosen.

If this was triggered by a mouse-click, the mouseClickEvent parameter will be a pointer to the info about it, or may be null if the menu is being triggered by some other means.

See also
performPopupMenuAction, setPopupMenuEnabled, isPopupMenuEnabled

◆ areSpacesInsertedForTabs()

bool CodeEditorComponent::areSpacesInsertedForTabs ( ) const
inline

Returns true if the tab key will insert spaces instead of actual tab characters.

See also
setTabSize

◆ copyToClipboard()

bool CodeEditorComponent::copyToClipboard ( )
virtual

◆ cutToClipboard()

bool CodeEditorComponent::cutToClipboard ( )
virtual

◆ deleteBackwards()

bool CodeEditorComponent::deleteBackwards ( bool  moveInWholeWordSteps)

◆ deleteForwards()

bool CodeEditorComponent::deleteForwards ( bool  moveInWholeWordSteps)

◆ deleteWhitespaceBackwardsToTabStop()

bool CodeEditorComponent::deleteWhitespaceBackwardsToTabStop ( )

◆ deselectAll()

void CodeEditorComponent::deselectAll ( )

◆ focusGained()

void CodeEditorComponent::focusGained ( FocusChangeType  cause)
overridevirtual

Called to indicate that this component has just acquired the keyboard focus.

See also
focusLost, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus

Reimplemented from Component.

◆ focusLost()

void CodeEditorComponent::focusLost ( FocusChangeType  cause)
overridevirtual

Called to indicate that this component has just lost the keyboard focus.

See also
focusGained, setWantsKeyboardFocus, getCurrentlyFocusedComponent, hasKeyboardFocus

Reimplemented from Component.

◆ getAllCommands()

void CodeEditorComponent::getAllCommands ( Array< CommandID > &  commands)
overridevirtual

This must return a complete list of commands that this target can handle.

Your target should add all the command IDs that it handles to the array that is passed-in.

Implements ApplicationCommandTarget.

◆ getCaretPos()

CodeDocument::Position CodeEditorComponent::getCaretPos ( ) const
inline

Returns the current caret position.

◆ getCaretRectangle()

Rectangle< int > CodeEditorComponent::getCaretRectangle ( )
overridevirtual

Returns the position of the caret, relative to the editor's origin.

Implements TextInputTarget.

◆ getCharacterBounds()

Rectangle< int > CodeEditorComponent::getCharacterBounds ( const CodeDocument::Position pos) const

Returns the on-screen position of a character in the document. The rectangle returned is relative to this component's top-left origin.

◆ getCharWidth()

float CodeEditorComponent::getCharWidth ( ) const
inlinenoexcept

Returns the standard character width.

◆ getColourForTokenType()

Colour CodeEditorComponent::getColourForTokenType ( int  tokenType) const

Returns one the syntax highlighting colour for the given token. The token type values are dependent on the tokeniser being used.

See also
setColourScheme

◆ getColourScheme()

const ColourScheme& CodeEditorComponent::getColourScheme ( ) const
inlinenoexcept

Returns the current syntax highlighting colour scheme.

◆ getCommandInfo()

void CodeEditorComponent::getCommandInfo ( CommandID  commandID,
ApplicationCommandInfo result 
)
overridevirtual

This must provide details about one of the commands that this target can perform.

This will be called with one of the command IDs that the target provided in its getAllCommands() methods.

It should fill-in all appropriate fields of the ApplicationCommandInfo structure with suitable information about the command. (The commandID field will already have been filled-in by the caller).

The easiest way to set the info is using the ApplicationCommandInfo::setInfo() method to set all the fields at once.

If the command is currently inactive for some reason, this method must use ApplicationCommandInfo::setActive() to make that clear, (or it should set the isDisabled bit of the ApplicationCommandInfo::flags field).

Any default key-presses for the command should be appended to the ApplicationCommandInfo::defaultKeypresses field.

Note that if you change something that affects the status of the commands that would be returned by this method (e.g. something that makes some commands active or inactive), you should call ApplicationCommandManager::commandStatusChanged() to cause the manager to refresh its status.

Implements ApplicationCommandTarget.

◆ getDocument()

CodeDocument& CodeEditorComponent::getDocument ( ) const
inlinenoexcept

Returns the code document that this component is editing.

◆ getFirstLineOnScreen()

int CodeEditorComponent::getFirstLineOnScreen ( ) const
inlinenoexcept

Returns the index of the first line that's visible at the top of the editor.

◆ getFont()

const Font& CodeEditorComponent::getFont ( ) const
inlinenoexcept

Returns the font that the editor is using.

◆ getHighlightedRegion()

Range< int > CodeEditorComponent::getHighlightedRegion ( ) const
overridevirtual

Returns the extents of the selected text region, or an empty range if nothing is selected,

Implements TextInputTarget.

◆ getLineHeight()

int CodeEditorComponent::getLineHeight ( ) const
inlinenoexcept

Returns the height of a line of text, in pixels.

◆ getNextCommandTarget()

ApplicationCommandTarget * CodeEditorComponent::getNextCommandTarget ( )
overridevirtual

This must return the next target to try after this one.

When a command is being sent, and the first target can't handle that command, this method is used to determine the next target that should be tried.

It may return nullptr if it doesn't know of another target.

If your target is a Component, you would usually use the findFirstTargetParentComponent() method to return a parent component that might want to handle it.

See also
invoke

Implements ApplicationCommandTarget.

◆ getNumColumnsOnScreen()

int CodeEditorComponent::getNumColumnsOnScreen ( ) const
inlinenoexcept

Returns the number of whole columns visible on the screen. This doesn't include any cut-off columns at the right-hand edge.

◆ getNumLinesOnScreen()

int CodeEditorComponent::getNumLinesOnScreen ( ) const
inlinenoexcept

Returns the number of whole lines visible on the screen, This doesn't include a cut-off line that might be visible at the bottom if the component's height isn't an exact multiple of the line-height.

◆ getPositionAt()

CodeDocument::Position CodeEditorComponent::getPositionAt ( int  x,
int  y 
)

Finds the character at a given on-screen position. The coordinates are relative to this component's top-left origin.

◆ getScrollbarThickness()

int CodeEditorComponent::getScrollbarThickness ( ) const
inlinenoexcept

Returns the thickness of the scrollbars.

◆ getSelectionEnd()

CodeDocument::Position CodeEditorComponent::getSelectionEnd ( ) const
inline

Returns the end of the selection as a position.

◆ getSelectionStart()

CodeDocument::Position CodeEditorComponent::getSelectionStart ( ) const
inline

Returns the start of the selection as a position.

◆ getTabSize()

int CodeEditorComponent::getTabSize ( ) const
inlinenoexcept

Returns the current number of spaces per tab.

See also
setTabSize

◆ getTabString()

String CodeEditorComponent::getTabString ( int  numSpaces) const

Returns a string containing spaces or tab characters to generate the given number of spaces.

◆ getTextInRange()

String CodeEditorComponent::getTextInRange ( const Range< int > &  range) const
overridevirtual

Returns a specified sub-section of the text.

Implements TextInputTarget.

◆ handleEscapeKey()

void CodeEditorComponent::handleEscapeKey ( )
virtual

Called when the escape key is pressed - this can be overridden for custom behaviour.

◆ handleReturnKey()

void CodeEditorComponent::handleReturnKey ( )
virtual

Called when the return key is pressed - this can be overridden for custom behaviour.

◆ handleTabKey()

void CodeEditorComponent::handleTabKey ( )
virtual

Called when the tab key is pressed - this can be overridden for custom behaviour.

◆ indentSelection()

void CodeEditorComponent::indentSelection ( )

◆ insertTabAtCaret()

void CodeEditorComponent::insertTabAtCaret ( )

◆ insertTextAtCaret()

void CodeEditorComponent::insertTextAtCaret ( const String textToInsert)
overridevirtual

Inserts some text, overwriting the selected text region, if there is one.

Implements TextInputTarget.

◆ isHighlightActive()

bool CodeEditorComponent::isHighlightActive ( ) const
noexcept

◆ isReadOnly()

bool CodeEditorComponent::isReadOnly ( ) const
inlinenoexcept

Returns true if the editor is set to be read-only.

◆ isTextInputActive()

bool CodeEditorComponent::isTextInputActive ( ) const
overridevirtual

Returns true if this input target is currently accepting input. For example, a text editor might return false if it's in read-only mode.

Implements TextInputTarget.

◆ keyPressed()

bool CodeEditorComponent::keyPressed ( const KeyPress key)
overridevirtual

Called when a key is pressed.

When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.

If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.

The default implementation of this method does nothing and returns false.

See also
keyStateChanged, getCurrentlyFocusedComponent, addKeyListener

Reimplemented from Component.

◆ loadContent()

void CodeEditorComponent::loadContent ( const String newContent)

Loads the given content into the document. This will completely reset the CodeDocument object, clear its undo history, and fill it with this text.

◆ mouseDoubleClick()

void CodeEditorComponent::mouseDoubleClick ( const MouseEvent event)
overridevirtual

Called when a mouse button has been double-clicked on a component.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Parameters
eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp

Reimplemented from Component.

◆ mouseDown()

void CodeEditorComponent::mouseDown ( const MouseEvent event)
overridevirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from Component.

◆ mouseDrag()

void CodeEditorComponent::mouseDrag ( const MouseEvent event)
overridevirtual

Called when the mouse is moved while a button is held down.

When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.

Parameters
eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseUp, mouseMove, contains, setDragRepeatInterval

Reimplemented from Component.

◆ mouseUp()

void CodeEditorComponent::mouseUp ( const MouseEvent event)
overridevirtual

Called when a mouse button is released.

A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.

The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.

Parameters
eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseDown, mouseDrag, mouseDoubleClick, contains

Reimplemented from Component.

◆ mouseWheelMove()

void CodeEditorComponent::mouseWheelMove ( const MouseEvent event,
const MouseWheelDetails wheel 
)
overridevirtual

Called when the mouse-wheel is moved.

This callback is sent to the component that the mouse is over when the wheel is moved.

If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. (Bear in mind that if you attach a component as a mouse-listener to other components, then those wheel moves will also end up calling this method and being passed up to the parents, which may not be what you intended to happen).

Parameters
eventdetails about the mouse event
wheeldetails about the mouse wheel movement

Reimplemented from Component.

◆ moveCaretDown()

bool CodeEditorComponent::moveCaretDown ( bool  selecting)

◆ moveCaretLeft()

bool CodeEditorComponent::moveCaretLeft ( bool  moveInWholeWordSteps,
bool  selecting 
)

◆ moveCaretRight()

bool CodeEditorComponent::moveCaretRight ( bool  moveInWholeWordSteps,
bool  selecting 
)

◆ moveCaretTo()

void CodeEditorComponent::moveCaretTo ( const CodeDocument::Position newPos,
bool  selecting 
)

Moves the caret. If selecting is true, the section of the document between the current caret position and the new one will become selected. If false, any currently selected region will be deselected.

◆ moveCaretToEnd()

bool CodeEditorComponent::moveCaretToEnd ( bool  selecting)

◆ moveCaretToEndOfLine()

bool CodeEditorComponent::moveCaretToEndOfLine ( bool  selecting)

◆ moveCaretToStartOfLine()

bool CodeEditorComponent::moveCaretToStartOfLine ( bool  selecting)

◆ moveCaretToTop()

bool CodeEditorComponent::moveCaretToTop ( bool  selecting)

◆ moveCaretUp()

bool CodeEditorComponent::moveCaretUp ( bool  selecting)

◆ pageDown()

bool CodeEditorComponent::pageDown ( bool  selecting)

◆ pageUp()

bool CodeEditorComponent::pageUp ( bool  selecting)

◆ paint()

void CodeEditorComponent::paint ( Graphics g)
overridevirtual

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In Juce (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from Component.

◆ pasteFromClipboard()

bool CodeEditorComponent::pasteFromClipboard ( )
virtual

◆ perform()

bool CodeEditorComponent::perform ( const InvocationInfo info)
overridevirtual

This must actually perform the specified command.

If this target is able to perform the command specified by the commandID field of the InvocationInfo structure, then it should do so, and must return true.

If it can't handle this command, it should return false, which tells the caller to pass the command on to the next target in line.

See also
invoke, ApplicationCommandManager::invoke

Implements ApplicationCommandTarget.

◆ performPopupMenuAction()

void CodeEditorComponent::performPopupMenuAction ( int  menuItemID)
virtual

This is called to perform one of the items that was shown on the popup menu.

If you've overridden addPopupMenuItems(), you should also override this to perform the actions that you've added.

If you've overridden addPopupMenuItems() but have still left the default items on the menu, remember to call the superclass's performPopupMenuAction() so that it can perform the default actions if that's what the user clicked on.

See also
addPopupMenuItems, setPopupMenuEnabled, isPopupMenuEnabled

◆ redo()

bool CodeEditorComponent::redo ( )

◆ resized()

void CodeEditorComponent::resized ( )
overridevirtual

Called when this component's size has been changed.

A component can implement this method to do things such as laying out its child components when its width or height changes.

The method is called synchronously as a result of the setBounds or setSize methods, so repeatedly changing a components size will repeatedly call its resized method (unlike things like repainting, where multiple calls to repaint are coalesced together).

If the component is a top-level window on the desktop, its size could also be changed by operating-system factors beyond the application's control.

See also
moved, setSize

Reimplemented from Component.

◆ scrollBy()

void CodeEditorComponent::scrollBy ( int  deltaLines)

◆ scrollDown()

bool CodeEditorComponent::scrollDown ( )

◆ scrollToColumn()

void CodeEditorComponent::scrollToColumn ( int  newFirstColumnOnScreen)

◆ scrollToKeepCaretOnScreen()

void CodeEditorComponent::scrollToKeepCaretOnScreen ( )

◆ scrollToKeepLinesOnScreen()

void CodeEditorComponent::scrollToKeepLinesOnScreen ( Range< int >  linesToShow)

◆ scrollToLine()

void CodeEditorComponent::scrollToLine ( int  newFirstLineOnScreen)

◆ scrollUp()

bool CodeEditorComponent::scrollUp ( )

◆ selectAll()

bool CodeEditorComponent::selectAll ( )

◆ selectRegion()

void CodeEditorComponent::selectRegion ( const CodeDocument::Position start,
const CodeDocument::Position end 
)

◆ setColourScheme()

void CodeEditorComponent::setColourScheme ( const ColourScheme scheme)

Changes the syntax highlighting scheme. The token type values are dependent on the tokeniser being used - use CodeTokeniser::getTokenTypes() to get a list of the token types.

See also
getColourForTokenType

◆ setCommandManager()

void CodeEditorComponent::setCommandManager ( ApplicationCommandManager newManager)
noexcept

Specifies a commmand-manager which the editor will notify whenever the state of any of its commands changes. If you're making use of the editor's ApplicationCommandTarget interface, then you should also use this to tell it which command manager it should use. Make sure that the manager does not go out of scope while the editor is using it. You can pass a nullptr here to disable this.

◆ setFont()

void CodeEditorComponent::setFont ( const Font newFont)

Changes the font. Make sure you only use a fixed-width font, or this component will look pretty nasty!

◆ setHighlightedRegion()

void CodeEditorComponent::setHighlightedRegion ( const Range< int > &  newRange)
overridevirtual

Sets the currently-selected text region.

Implements TextInputTarget.

◆ setLineNumbersShown()

void CodeEditorComponent::setLineNumbersShown ( bool  shouldBeShown)

Enables or disables the line-number display in the gutter.

◆ setReadOnly()

void CodeEditorComponent::setReadOnly ( bool  shouldBeReadOnly)
noexcept

Makes the editor read-only.

◆ setScrollbarThickness()

void CodeEditorComponent::setScrollbarThickness ( int  thickness)

Changes the size of the scrollbars.

◆ setTabSize()

void CodeEditorComponent::setTabSize ( int  numSpacesPerTab,
bool  insertSpacesInsteadOfTabCharacters 
)

Changes the current tab settings. This lets you change the tab size and whether pressing the tab key inserts a tab character, or its equivalent number of spaces.

◆ setTemporaryUnderlining()

void CodeEditorComponent::setTemporaryUnderlining ( const Array< Range< int > > &  underlinedRegions)
overridevirtual

Sets a number of temporarily underlined sections. This is needed by MS Windows input method UI.

Implements TextInputTarget.

◆ undo()

bool CodeEditorComponent::undo ( )

◆ unindentSelection()

void CodeEditorComponent::unindentSelection ( )

Friends And Related Function Documentation

◆ ContainerDeletePolicy< GutterComponent >

friend struct ContainerDeletePolicy< GutterComponent >
friend

◆ ContainerDeletePolicy< Pimpl >

friend struct ContainerDeletePolicy< Pimpl >
friend

◆ GutterComponent

friend class GutterComponent
friend

◆ Pimpl

friend class Pimpl
friend

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