69 void loadContent (
const String& newContent);
122 void setLineNumbersShown (
bool shouldBeShown);
128 int getCharIndexForPoint (
Point<int> point)
const override;
133 return getCharacterBounds ({ document, index });
145 bool moveCaretLeft (
bool moveInWholeWordSteps,
bool selecting);
146 bool moveCaretRight (
bool moveInWholeWordSteps,
bool selecting);
147 bool moveCaretUp (
bool selecting);
148 bool moveCaretDown (
bool selecting);
151 bool pageUp (
bool selecting);
152 bool pageDown (
bool selecting);
153 bool moveCaretToTop (
bool selecting);
154 bool moveCaretToStartOfLine (
bool selecting);
155 bool moveCaretToEnd (
bool selecting);
156 bool moveCaretToEndOfLine (
bool selecting);
157 bool deleteBackwards (
bool moveInWholeWordSteps);
158 bool deleteForwards (
bool moveInWholeWordSteps);
159 bool deleteWhitespaceBackwardsToTabStop();
160 virtual bool copyToClipboard();
161 virtual bool cutToClipboard();
162 virtual bool pasteFromClipboard();
170 void scrollToLine (
int newFirstLineOnScreen);
171 void scrollBy (
int deltaLines);
172 void scrollToColumn (
int newFirstColumnOnScreen);
173 void scrollToKeepCaretOnScreen();
174 void scrollToKeepLinesOnScreen (
Range<int> linesToShow);
176 void insertTextAtCaret (
const String& textToInsert)
override;
177 void insertTabAtCaret();
179 void indentSelection();
180 void unindentSelection();
183 Range<int> getHighlightedRegion()
const override;
184 bool isHighlightActive() const noexcept;
185 void setHighlightedRegion (const
Range<
int>& newRange) override;
186 String getTextInRange (const
Range<
int>& range) const override;
205 int lastTopLine, lastCaretPos, lastSelectionEnd;
213 void setTabSize (
int numSpacesPerTab,
bool insertSpacesInsteadOfTabCharacters);
226 String getTabString (
int numSpaces)
const;
231 void setFont (
const Font& newFont);
237 void setReadOnly (
bool shouldBeReadOnly)
noexcept;
272 Colour getColourForTokenType (
int tokenType)
const;
285 void retokenise (
int startIndex,
int endIndex);
297 backgroundColourId = 0x1004500,
298 highlightColourId = 0x1004502,
299 defaultTextColourId = 0x1004503,
300 lineNumberBackgroundId = 0x1004504,
301 lineNumberTextId = 0x1004505,
306 void setScrollbarThickness (
int thickness);
313 virtual void handleReturnKey();
315 virtual void handleTabKey();
317 virtual void handleEscapeKey();
320 virtual void editorViewportPositionChanged();
323 virtual void caretPositionMoved();
343 virtual void addPopupMenuItems (
PopupMenu& menuToAddTo,
357 virtual void performPopupMenuAction (
int menuItemID);
372 void resized()
override;
374 bool keyPressed (
const KeyPress&)
override;
382 void mouseDoubleClick (
const MouseEvent&)
override;
386 void focusGained (FocusChangeType)
override;
388 void focusLost (FocusChangeType)
override;
390 bool isTextInputActive()
const override;
400 bool perform (
const InvocationInfo&)
override;
402 void lookAndFeelChanged()
override;
411 int firstLineOnScreen = 0, spacesPerTab = 4;
413 int lineHeight = 0, linesOnScreen = 0, columnsOnScreen = 0;
414 int scrollbarThickness = 16, columnToTryToMaintain = -1;
415 bool readOnly =
false, useSpacesForTabs =
true, showLineNumbers =
false, shouldFollowDocumentChanges =
false;
420 ScrollBar verticalScrollBar {
true }, horizontalScrollBar {
false };
421 ApplicationCommandManager* appCommandManager =
nullptr;
426 class GutterComponent;
429 class CodeEditorAccessibilityHandler;
434 draggingSelectionStart,
438 DragType dragType = notDragging;
441 CodeTokeniser* codeTokeniser;
442 ColourScheme colourScheme;
444 class CodeEditorLine;
445 OwnedArray<CodeEditorLine> lines;
446 void rebuildLineTokens();
447 void rebuildLineTokensAsync();
448 void codeDocumentChanged (
int start,
int end);
450 Array<CodeDocument::Iterator> cachedIterators;
451 void clearCachedIterators (
int firstLineToBeInvalid);
452 void updateCachedIterators (
int maxLineNum);
453 void getIteratorForPosition (
int position, CodeDocument::Iterator&);
455 void moveLineDelta (
int delta,
bool selecting);
456 int getGutterSize() const noexcept;
459 void insertText (const String&);
460 virtual
void updateCaretPosition();
461 void updateScrollBars();
462 void scrollToLineInternal (
int line);
463 void scrollToColumnInternal (
double column);
464 void newTransaction();
466 void indentSelectedLines (
int spacesToAdd);
467 bool skipBackwardsToPreviousTab();
468 bool performCommand (CommandID);
469 void setSelection (CodeDocument::Position, CodeDocument::Position);
471 int indexToColumn (
int line,
int index) const noexcept;
472 int columnToIndex (
int line,
int column) const noexcept;
One of these objects holds a list of all the commands your app can perform, and despatches these comm...
A command target publishes a list of command IDs that it can perform.
Holds a resizable array of primitive or copy-by-value objects.
A position in a code document.
A class for storing and manipulating a source code file.
int getNumCharacters() const noexcept
Returns the number of characters in the document.
A text editor component designed specifically for source code.
int getFirstLineOnScreen() const noexcept
Returns the index of the first line that's visible at the top of the editor.
Rectangle< int > getCaretRectangleForCharIndex(int index) const override
Returns the bounds of the caret at a particular location in the text.
int getLineHeight() const noexcept
Returns the height of a line of text, in pixels.
int getNumLinesOnScreen() const noexcept
Returns the number of whole lines visible on the screen, This doesn't include a cut-off line that mig...
int getTotalNumChars() const override
Returns the total number of codepoints in the string.
bool areSpacesInsertedForTabs() const
Returns true if the tab key will insert spaces instead of actual tab characters.
CodeDocument::Position getCaretPos() const
Returns the current caret position.
float getCharWidth() const noexcept
Returns the standard character width.
int getScrollbarThickness() const noexcept
Returns the thickness of the scrollbars.
int getCaretPosition() const override
Returns the number of characters from the beginning of the document to the caret.
const ColourScheme & getColourScheme() const noexcept
Returns the current syntax highlighting colour scheme.
CodeDocument & getDocument() const noexcept
Returns the code document that this component is editing.
int getNumColumnsOnScreen() const noexcept
Returns the number of whole columns visible on the screen.
int getTabSize() const noexcept
Returns the current number of spaces per tab.
CodeDocument::Position getSelectionStart() const
Returns the start of the selection as a position.
CodeDocument::Position getSelectionEnd() const
Returns the end of the selection as a position.
bool isReadOnly() const noexcept
Returns true if the editor is set to be read-only.
const Font & getFont() const noexcept
Returns the font that the editor is using.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the editor.
A base class for tokenising code so that the syntax can be displayed in a code editor.
Represents a colour, also including a transparency value.
The base class for all JUCE user-interface objects.
Represents a particular font, including its size, style, etc.
A graphics context, used for drawing a component or image.
Represents a key press, including any modifier keys that are needed.
Contains position and status information about a mouse event.
A pair of (x, y) coordinates.
A general-purpose range object, that simply represents any linear range with a start and end point.
Maintains a set of rectangles as a complex region.
Manages a rectangle and allows geometric operations to be performed on it.
An abstract base class which can be implemented by components that function as text editors.
int CommandID
A type used to hold the unique ID for an application command.
Contains status information about a mouse wheel event.
Holds information describing an application command.
Defines a syntax highlighting colour scheme.
Defines a colour for a token type.
Can be used to save and restore the editor's caret position, selection state, etc.