// Created: 13-Jan-2000
// RCS-ID: $Id$
// Copyright: (c) 2000 by Total Control Software
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
#include "wx/tokenzr.h"
#include "wx/mstream.h"
#include "wx/image.h"
-#include "wx/ffile.h"
+#if wxUSE_FFILE
+ #include "wx/ffile.h"
+#elif wxUSE_FILE
+ #include "wx/ffile.h"
+#endif
+
+#ifdef __WXGTK__
+ #include "wx/dcbuffer.h"
+#endif
#include "ScintillaWX.h"
wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent );
wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent );
wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent );
+wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent );
+wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent );
+wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent );
m_swx = new ScintillaWX(this);
m_stopWatch.Start();
m_lastKeyDownConsumed = false;
- m_lastWheelTimestamp = 0;
m_vScrollBar = NULL;
m_hScrollBar = NULL;
#if wxUSE_UNICODE
SetInitialSize(size);
// Reduces flicker on GTK+/X11
- SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+ SetBackgroundStyle(wxBG_STYLE_PAINT);
// Make sure it can take the focus
SetCanFocus(true);
// Add text to the document at current position.
void wxStyledTextCtrl::AddText(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- SendMsg(2001, strlen(buf), (sptr_t)(const char*)buf);
+ const wxWX2MBbuf buf = wx2stc(text);
+ SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf);
}
// Add array of cells to document.
SendMsg(2004, 0, 0);
}
+// Delete a range of text in the document.
+void wxStyledTextCtrl::DeleteRange(int pos, int deleteLength)
+{
+ SendMsg(2645, pos, deleteLength);
+}
+
// Set all style bytes to 0, remove all folding information.
void wxStyledTextCtrl::ClearDocumentStyle()
{
SendMsg(2005, 0, 0);
}
-// Returns the number of characters in the document.
+// Returns the number of bytes in the document.
int wxStyledTextCtrl::GetLength() const
{
return SendMsg(2006, 0, 0);
const wxColour& background) {
SendMsg(2040, markerNumber, markerSymbol);
- if (foreground.Ok())
+ if (foreground.IsOk())
MarkerSetForeground(markerNumber, foreground);
- if (background.Ok())
+ if (background.IsOk())
MarkerSetBackground(markerNumber, background);
}
SendMsg(2042, markerNumber, wxColourAsLong(back));
}
+// Set the background colour used for a particular marker number when its folding block is selected.
+void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back)
+{
+ SendMsg(2292, markerNumber, wxColourAsLong(back));
+}
+
+// Enable/disable highlight for current folding bloc (smallest one that contains the caret)
+void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled)
+{
+ SendMsg(2293, enabled, 0);
+}
+
// Add a marker to a line, returning an ID which can be used to find or delete the marker.
int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
{
return SendMsg(2046, line, 0);
}
-// Find the next line after lineStart that includes a marker in mask.
+// Find the next line at or after lineStart that includes a marker in mask.
+// Return -1 when no more lines.
int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
{
return SendMsg(2047, lineStart, markerMask);
return SendMsg(2247, margin, 0) != 0;
}
+// Set the cursor shown when the mouse is inside a margin.
+void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor)
+{
+ SendMsg(2248, margin, cursor);
+}
+
+// Retrieve the cursor shown in a margin.
+int wxStyledTextCtrl::GetMarginCursor(int margin) const
+{
+ return SendMsg(2249, margin, 0);
+}
+
// Clear all the styles and make equivalent to the global default style.
void wxStyledTextCtrl::StyleClearAll()
{
SendMsg(2060, style, caseForce);
}
+// Set the size of characters of a style. Size is in points multiplied by 100.
+void wxStyledTextCtrl::StyleSetSizeFractional(int style, int caseForce)
+{
+ SendMsg(2061, style, caseForce);
+}
+
+// Get the size of characters of a style in points multiplied by 100
+int wxStyledTextCtrl::StyleGetSizeFractional(int style) const
+{
+ return SendMsg(2062, style, 0);
+}
+
+// Set the weight of characters of a style.
+void wxStyledTextCtrl::StyleSetWeight(int style, int weight)
+{
+ SendMsg(2063, style, weight);
+}
+
+// Get the weight of characters of a style.
+int wxStyledTextCtrl::StyleGetWeight(int style) const
+{
+ return SendMsg(2064, style, 0);
+}
+
// Set a style to be a hotspot or not.
void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
{
SendMsg(2409, style, hotspot);
}
-// Set the foreground colour of the selection and whether to use this setting.
+// Set the foreground colour of the main and additional selections and whether to use this setting.
void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
{
SendMsg(2067, useSetting, wxColourAsLong(fore));
}
-// Set the background colour of the selection and whether to use this setting.
+// Set the background colour of the main and additional selections and whether to use this setting.
void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
{
SendMsg(2068, useSetting, wxColourAsLong(back));
}
// Set the set of characters making up words for when moving or selecting by word.
-// First sets deaults like SetCharsDefault.
+// First sets defaults like SetCharsDefault.
void wxStyledTextCtrl::SetWordChars(const wxString& characters)
{
SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters));
}
+// Get the set of characters making up words for when moving or selecting by word.
+wxString wxStyledTextCtrl::GetWordChars() const {
+ int msg = 2646;
+ int len = SendMsg(msg, 0, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, 0, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
// Start a sequence of actions that is undone and redone as a unit.
// May be nested.
void wxStyledTextCtrl::BeginUndoAction()
SendMsg(2085, useSetting, wxColourAsLong(back));
}
+// Set the size of the dots used to mark space characters.
+void wxStyledTextCtrl::SetWhitespaceSize(int size)
+{
+ SendMsg(2086, size, 0);
+}
+
+// Get the size of the dots used to mark space characters.
+int wxStyledTextCtrl::GetWhitespaceSize() const
+{
+ return SendMsg(2087, 0, 0);
+}
+
// Divide each styling byte into lexical class bits (default: 5) and indicator
// bits (default: 3). If a lexer requires more than 32 lexical states, then this
// is used to expand the possible states.
return SendMsg(2129, pos, 0);
}
+// Count characters between two positions.
+int wxStyledTextCtrl::CountCharacters(int startPos, int endPos)
+{
+ return SendMsg(2633, startPos, endPos);
+}
+
// Show or hide the horizontal scroll bar.
void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show)
{
return SendMsg(2145, 0, 0);
}
+// Set caret to a position, while removing any existing selection.
+void wxStyledTextCtrl::SetEmptySelection(int pos)
+{
+ SendMsg(2556, pos, 0);
+}
+
// Sets the print magnification added to the point size of each style for printing.
void wxStyledTextCtrl::SetPrintMagnification(int magnification)
{
TextToFind ft;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+ const wxWX2MBbuf buf = wx2stc(text);
ft.lpstrText = (char*)(const char*)buf;
return SendMsg(2150, flags, (sptr_t)&ft);
// Retrieve the selected text.
wxString wxStyledTextCtrl::GetSelectedText() {
- long start;
- long end;
-
- GetSelection(&start, &end);
- int len = end - start;
+ const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
if (!len) return wxEmptyString;
wxMemoryBuffer mbuf(len+2);
// Returns the length of the replacement text.
int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- return SendMsg(2194, strlen(buf), (sptr_t)(const char*)buf);
+ const wxWX2MBbuf buf = wx2stc(text);
+ return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf);
}
// Replace the target text with the argument text after \d processing.
// caused by processing the \d patterns.
int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- return SendMsg(2195, strlen(buf), (sptr_t)(const char*)buf);
+ const wxWX2MBbuf buf = wx2stc(text);
+ return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf);
}
// Search for a counted string in the target and set the target to the found
// Returns length of range or -1 for failure in which case target is not moved.
int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- return SendMsg(2197, strlen(buf), (sptr_t)(const char*)buf);
+ const wxWX2MBbuf buf = wx2stc(text);
+ return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf);
}
// Set the search flags used by SearchInTarget.
SendMsg(2212, tabSize, 0);
}
+// Set position of calltip, above or below text.
+void wxStyledTextCtrl::CallTipSetPosition(bool above)
+{
+ SendMsg(2213, above, 0);
+}
+
// Find the display line of a document line taking hidden lines into account.
int wxStyledTextCtrl::VisibleFromDocLine(int line)
{
return SendMsg(2228, line, 0) != 0;
}
+// Are all lines visible?
+bool wxStyledTextCtrl::GetAllLinesVisible() const
+{
+ return SendMsg(2236, 0, 0) != 0;
+}
+
// Show the children of a header line.
void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
{
return SendMsg(2465, 0, 0);
}
+// Sets how wrapped sublines are placed. Default is fixed.
+void wxStyledTextCtrl::SetWrapIndentMode(int mode)
+{
+ SendMsg(2472, mode, 0);
+}
+
+// Retrieve how wrapped sublines are placed. Default is fixed.
+int wxStyledTextCtrl::GetWrapIndentMode() const
+{
+ return SendMsg(2473, 0, 0);
+}
+
// Sets the degree of caching of layout information.
void wxStyledTextCtrl::SetLayoutCache(int mode)
{
// Append a string to the end of the document without changing the selection.
void wxStyledTextCtrl::AppendText(const wxString& text) {
- wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- SendMsg(2282, strlen(buf), (sptr_t)(const char*)buf);
+ const wxWX2MBbuf buf = wx2stc(text);
+ SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf);
}
// Is drawing done in two phases with backgrounds drawn before foregrounds?
SendMsg(2284, twoPhase, 0);
}
+// Scroll so that a display line is at the top of the display.
+void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay)
+{
+ SendMsg(2613, lineDisplay, 0);
+}
+
+// Change the effect of pasting when there are multiple selections.
+void wxStyledTextCtrl::SetMultiPaste(int multiPaste)
+{
+ SendMsg(2614, multiPaste, 0);
+}
+
+// Retrieve the effect of pasting when there are multiple selections..
+int wxStyledTextCtrl::GetMultiPaste() const
+{
+ return SendMsg(2615, 0, 0);
+}
+
+// Retrieve the value of a tag from a regular expression search.
+wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
+ int msg = 2616;
+ int len = SendMsg(msg, tagNumber, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, tagNumber, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
// Make the target range start and end be the same as the selection range start and end.
void wxStyledTextCtrl::TargetFromSelection()
{
SendMsg(2401, 0, 0);
}
-// How many characters are on a line, not including end of line characters?
+// How many characters are on a line, including end of line characters?
int wxStyledTextCtrl::LineLength(int line) const
{
return SendMsg(2350, line, 0);
SendMsg(2351, pos1, pos2);
}
+// Use specified indicator to highlight matching braces instead of changing their style.
+void wxStyledTextCtrl::BraceHighlightIndicator(bool useBraceHighlightIndicator, int indicator)
+{
+ SendMsg(2498, useBraceHighlightIndicator, indicator);
+}
+
// Highlight the character at a position indicating there is no matching brace.
void wxStyledTextCtrl::BraceBadLight(int pos)
{
SendMsg(2352, pos, 0);
}
+// Use specified indicator to highlight non matching brace instead of changing its style.
+void wxStyledTextCtrl::BraceBadLightIndicator(bool useBraceBadLightIndicator, int indicator)
+{
+ SendMsg(2499, useBraceBadLightIndicator, indicator);
+}
+
// Find the position of a matching brace or INVALID_POSITION if no match.
int wxStyledTextCtrl::BraceMatch(int pos)
{
SendMsg(2396, 0, 0);
}
-// Get and Set the xOffset (ie, horizonal scroll position).
+// Get and Set the xOffset (ie, horizontal scroll position).
void wxStyledTextCtrl::SetXOffset(int newOffset)
{
SendMsg(2397, newOffset, 0);
SendMsg(2399, 0, 0);
}
-// Set the way the caret is kept visible when going sideway.
+// Set the way the caret is kept visible when going sideways.
// The exclusion zone is given in pixels.
void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
{
SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
}
-// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
+// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
// by lines (SC_SEL_LINES).
void wxStyledTextCtrl::SetSelectionMode(int mode)
{
SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
}
+// Get the set of characters making up whitespace for when moving or selecting by word.
+wxString wxStyledTextCtrl::GetWhitespaceChars() const {
+ int msg = 2647;
+ int len = SendMsg(msg, 0, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, 0, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Set the set of characters making up punctuation characters
+// Should be called after SetWordChars.
+void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters)
+{
+ SendMsg(2648, 0, (sptr_t)(const char*)wx2stc(characters));
+}
+
+// Get the set of characters making up punctuation characters
+wxString wxStyledTextCtrl::GetPunctuationChars() const {
+ int msg = 2649;
+ int len = SendMsg(msg, 0, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, 0, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
// Reset the set of characters for whitespace and word characters to the defaults.
void wxStyledTextCtrl::SetCharsDefault()
{
}
// Get currently selected item position in the auto-completion list
-int wxStyledTextCtrl::AutoCompGetCurrent()
+int wxStyledTextCtrl::AutoCompGetCurrent() const
{
return SendMsg(2445, 0, 0);
}
+// Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
+void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour)
+{
+ SendMsg(2634, behaviour, 0);
+}
+
+// Get auto-completion case insensitive behaviour.
+int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const
+{
+ return SendMsg(2635, 0, 0);
+}
+
// Enlarge the document to a particular size of text bytes.
void wxStyledTextCtrl::Allocate(int bytes)
{
}
// Can the caret preferred x position only be changed by explicit movement commands?
-bool wxStyledTextCtrl::GetCaretSticky() const
+int wxStyledTextCtrl::GetCaretSticky() const
{
- return SendMsg(2457, 0, 0) != 0;
+ return SendMsg(2457, 0, 0);
}
// Stop the caret preferred x position changing when the user types.
-void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour)
+void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour)
{
SendMsg(2458, useCaretStickyBehaviour, 0);
}
SendMsg(2502, value, 0);
}
-// Get the current indicator vaue
+// Get the current indicator value
int wxStyledTextCtrl::GetIndicatorValue() const
{
return SendMsg(2503, 0, 0);
return SendMsg(2515, 0, 0);
}
-// Start notifying the container of all key presses and commands.
-void wxStyledTextCtrl::StartRecord()
+// Copy the selection, if selection empty copy the line with the caret
+void wxStyledTextCtrl::CopyAllowLine()
{
- SendMsg(3001, 0, 0);
+ SendMsg(2519, 0, 0);
}
-// Stop notifying the container of all key presses and commands.
-void wxStyledTextCtrl::StopRecord()
+// Compact the document buffer and return a read-only pointer to the
+// characters in the document.
+const char* wxStyledTextCtrl::GetCharacterPointer() const {
+ return (const char*)SendMsg(2520, 0, 0);
+}
+
+// Return a read-only pointer to a range of characters in the document.
+// May move the gap so that the range is contiguous, but will only move up
+// to rangeLength bytes.
+const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const {
+ return (const char*)SendMsg(2643, position, rangeLength);
+}
+
+// Return a position which, to avoid performance costs, should not be within
+// the range of a call to GetRangePointer.
+int wxStyledTextCtrl::GetGapPosition() const
{
- SendMsg(3002, 0, 0);
+ return SendMsg(2644, 0, 0);
}
-// Set the lexing language of the document.
-void wxStyledTextCtrl::SetLexer(int lexer)
+// Always interpret keyboard input as Unicode
+void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
{
- SendMsg(4001, lexer, 0);
+ SendMsg(2521, keysUnicode, 0);
}
-// Retrieve the lexing language of the document.
-int wxStyledTextCtrl::GetLexer() const
+// Are keys always interpreted as Unicode?
+bool wxStyledTextCtrl::GetKeysUnicode() const
{
- return SendMsg(4002, 0, 0);
+ return SendMsg(2522, 0, 0) != 0;
}
-// Colourise a segment of the document using the current lexing language.
-void wxStyledTextCtrl::Colourise(int start, int end)
+// Set the alpha fill colour of the given indicator.
+void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
{
- SendMsg(4003, start, end);
+ SendMsg(2523, indicator, alpha);
}
-// Set up a value that may be used by a lexer for some optional feature.
-void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
+// Get the alpha fill colour of the given indicator.
+int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
{
- SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
+ return SendMsg(2524, indicator, 0);
}
-// Set up the key words used by the lexer.
-void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
+// Set the alpha outline colour of the given indicator.
+void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha)
{
- SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
+ SendMsg(2558, indicator, alpha);
}
-// Set the lexing language of the document based on string name.
-void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
+// Get the alpha outline colour of the given indicator.
+int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const
{
- SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
+ return SendMsg(2559, indicator, 0);
}
-// Retrieve a 'property' value previously set with SetProperty.
-wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
- int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
- if (!len) return wxEmptyString;
+// Set extra ascent for each line
+void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
+{
+ SendMsg(2525, extraAscent, 0);
+}
+
+// Get extra ascent for each line
+int wxStyledTextCtrl::GetExtraAscent() const
+{
+ return SendMsg(2526, 0, 0);
+}
+
+// Set extra descent for each line
+void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
+{
+ SendMsg(2527, extraDescent, 0);
+}
+
+// Get extra descent for each line
+int wxStyledTextCtrl::GetExtraDescent() const
+{
+ return SendMsg(2528, 0, 0);
+}
+
+// Which symbol was defined for markerNumber with MarkerDefine
+int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
+{
+ return SendMsg(2529, markerNumber, 0);
+}
+
+// Set the text in the text margin for a line
+void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
+{
+ SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text));
+}
+
+// Get the text in the text margin for a line
+wxString wxStyledTextCtrl::MarginGetText(int line) const {
+ long msg = 2531;
+ long len = SendMsg(msg, line, 0);
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
- SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
+ SendMsg(msg, line, (sptr_t)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf);
}
-// Retrieve a 'property' value previously set with SetProperty,
-// with '$()' variable replacement on returned buffer.
-wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
- int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
- if (!len) return wxEmptyString;
+// Set the style number for the text margin for a line
+void wxStyledTextCtrl::MarginSetStyle(int line, int style)
+{
+ SendMsg(2532, line, style);
+}
+
+// Get the style number for the text margin for a line
+int wxStyledTextCtrl::MarginGetStyle(int line) const
+{
+ return SendMsg(2533, line, 0);
+}
+
+// Set the style in the text margin for a line
+void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
+{
+ SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles));
+}
+
+// Get the styles in the text margin for a line
+wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
+ long msg = 2535;
+ long len = SendMsg(msg, line, 0);
wxMemoryBuffer mbuf(len+1);
char* buf = (char*)mbuf.GetWriteBuf(len+1);
- SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
+ SendMsg(msg, line, (sptr_t)buf);
mbuf.UngetWriteBuf(len);
mbuf.AppendByte(0);
return stc2wx(buf);
}
-// Retrieve a 'property' value previously set with SetProperty,
-// interpreted as an int AFTER any '$()' variable replacement.
-int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
+// Clear the margin text on all lines
+void wxStyledTextCtrl::MarginTextClearAll()
{
- return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
+ SendMsg(2536, 0, 0);
}
-// Retrieve the number of bits the current lexer needs for styling.
-int wxStyledTextCtrl::GetStyleBitsNeeded() const
+// Get the start of the range of style numbers used for margin text
+void wxStyledTextCtrl::MarginSetStyleOffset(int style)
{
- return SendMsg(4011, 0, 0);
+ SendMsg(2537, style, 0);
}
-//}}}
-//----------------------------------------------------------------------
+// Get the start of the range of style numbers used for margin text
+int wxStyledTextCtrl::MarginGetStyleOffset() const
+{
+ return SendMsg(2538, 0, 0);
+}
+// Set the margin options.
+void wxStyledTextCtrl::SetMarginOptions(int marginOptions)
+{
+ SendMsg(2539, marginOptions, 0);
+}
-// Returns the line number of the line with the caret.
-int wxStyledTextCtrl::GetCurrentLine() {
- int line = LineFromPosition(GetCurrentPos());
- return line;
+// Get the margin options.
+int wxStyledTextCtrl::GetMarginOptions() const
+{
+ return SendMsg(2557, 0, 0);
}
+// Set the annotation text for a line
+void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
+{
+ SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text));
+}
-// Extract style settings from a spec-string which is composed of one or
-// more of the following comma separated elements:
-//
-// bold turns on bold
-// italic turns on italics
-// fore:[name or #RRGGBB] sets the foreground colour
-// back:[name or #RRGGBB] sets the background colour
-// face:[facename] sets the font face name to use
-// size:[num] sets the font size in points
-// eol turns on eol filling
-// underline turns on underlining
-//
-void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
+// Get the annotation text for a line
+wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
+ long msg = 2541;
+ long len = SendMsg(msg, line, 0);
- wxStringTokenizer tkz(spec, wxT(","));
- while (tkz.HasMoreTokens()) {
- wxString token = tkz.GetNextToken();
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, line, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
- wxString option = token.BeforeFirst(':');
- wxString val = token.AfterFirst(':');
+// Set the style number for the annotations for a line
+void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
+{
+ SendMsg(2542, line, style);
+}
- if (option == wxT("bold"))
- StyleSetBold(styleNum, true);
+// Get the style number for the annotations for a line
+int wxStyledTextCtrl::AnnotationGetStyle(int line) const
+{
+ return SendMsg(2543, line, 0);
+}
- else if (option == wxT("italic"))
- StyleSetItalic(styleNum, true);
+// Set the annotation styles for a line
+void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
+{
+ SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles));
+}
- else if (option == wxT("underline"))
- StyleSetUnderline(styleNum, true);
+// Get the annotation styles for a line
+wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
+ long msg = 2545;
+ long len = SendMsg(msg, line, 0);
- else if (option == wxT("eol"))
- StyleSetEOLFilled(styleNum, true);
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, line, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
- else if (option == wxT("size")) {
- long points;
- if (val.ToLong(&points))
- StyleSetSize(styleNum, points);
- }
+// Get the number of annotation lines for a line
+int wxStyledTextCtrl::AnnotationGetLines(int line) const
+{
+ return SendMsg(2546, line, 0);
+}
- else if (option == wxT("face"))
+// Clear the annotations from all lines
+void wxStyledTextCtrl::AnnotationClearAll()
+{
+ SendMsg(2547, 0, 0);
+}
+
+// Set the visibility for the annotations for a view
+void wxStyledTextCtrl::AnnotationSetVisible(int visible)
+{
+ SendMsg(2548, visible, 0);
+}
+
+// Get the visibility for the annotations for a view
+int wxStyledTextCtrl::AnnotationGetVisible() const
+{
+ return SendMsg(2549, 0, 0);
+}
+
+// Get the start of the range of style numbers used for annotations
+void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
+{
+ SendMsg(2550, style, 0);
+}
+
+// Get the start of the range of style numbers used for annotations
+int wxStyledTextCtrl::AnnotationGetStyleOffset() const
+{
+ return SendMsg(2551, 0, 0);
+}
+
+// Add a container action to the undo stack
+void wxStyledTextCtrl::AddUndoAction(int token, int flags)
+{
+ SendMsg(2560, token, flags);
+}
+
+// Find the position of a character from a point within the window.
+int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
+{
+ return SendMsg(2561, x, y);
+}
+
+// Find the position of a character from a point within the window.
+// Return INVALID_POSITION if not close to text.
+int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
+{
+ return SendMsg(2562, x, y);
+}
+
+// Set whether multiple selections can be made
+void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
+{
+ SendMsg(2563, multipleSelection, 0);
+}
+
+// Whether multiple selections can be made
+bool wxStyledTextCtrl::GetMultipleSelection() const
+{
+ return SendMsg(2564, 0, 0) != 0;
+}
+
+// Set whether typing can be performed into multiple selections
+void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
+{
+ SendMsg(2565, additionalSelectionTyping, 0);
+}
+
+// Whether typing can be performed into multiple selections
+bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
+{
+ return SendMsg(2566, 0, 0) != 0;
+}
+
+// Set whether additional carets will blink
+void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
+{
+ SendMsg(2567, additionalCaretsBlink, 0);
+}
+
+// Whether additional carets will blink
+bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
+{
+ return SendMsg(2568, 0, 0) != 0;
+}
+
+// Set whether additional carets are visible
+void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink)
+{
+ SendMsg(2608, additionalCaretsBlink, 0);
+}
+
+// Whether additional carets are visible
+bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
+{
+ return SendMsg(2609, 0, 0) != 0;
+}
+
+// How many selections are there?
+int wxStyledTextCtrl::GetSelections() const
+{
+ return SendMsg(2570, 0, 0);
+}
+
+// Clear selections to a single empty stream selection
+void wxStyledTextCtrl::ClearSelections()
+{
+ SendMsg(2571, 0, 0);
+}
+
+// Add a selection
+int wxStyledTextCtrl::AddSelection(int caret, int anchor)
+{
+ return SendMsg(2573, caret, anchor);
+}
+
+// Set the main selection
+void wxStyledTextCtrl::SetMainSelection(int selection)
+{
+ SendMsg(2574, selection, 0);
+}
+
+// Which selection is the main selection
+int wxStyledTextCtrl::GetMainSelection() const
+{
+ return SendMsg(2575, 0, 0);
+}
+void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos)
+{
+ SendMsg(2576, selection, pos);
+}
+int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
+{
+ return SendMsg(2577, selection, 0);
+}
+void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor)
+{
+ SendMsg(2578, selection, posAnchor);
+}
+int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
+{
+ return SendMsg(2579, selection, 0);
+}
+void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
+{
+ SendMsg(2580, selection, space);
+}
+int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
+{
+ return SendMsg(2581, selection, 0);
+}
+void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
+{
+ SendMsg(2582, selection, space);
+}
+int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
+{
+ return SendMsg(2583, selection, 0);
+}
+
+// Sets the position that starts the selection - this becomes the anchor.
+void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos)
+{
+ SendMsg(2584, selection, pos);
+}
+
+// Returns the position at the start of the selection.
+int wxStyledTextCtrl::GetSelectionNStart(int selection) const
+{
+ return SendMsg(2585, selection, 0);
+}
+
+// Sets the position that ends the selection - this becomes the currentPosition.
+void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos)
+{
+ SendMsg(2586, selection, pos);
+}
+
+// Returns the position at the end of the selection.
+int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
+{
+ return SendMsg(2587, selection, 0);
+}
+void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos)
+{
+ SendMsg(2588, pos, 0);
+}
+int wxStyledTextCtrl::GetRectangularSelectionCaret() const
+{
+ return SendMsg(2589, 0, 0);
+}
+void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor)
+{
+ SendMsg(2590, posAnchor, 0);
+}
+int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
+{
+ return SendMsg(2591, 0, 0);
+}
+void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
+{
+ SendMsg(2592, space, 0);
+}
+int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
+{
+ return SendMsg(2593, 0, 0);
+}
+void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
+{
+ SendMsg(2594, space, 0);
+}
+int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
+{
+ return SendMsg(2595, 0, 0);
+}
+void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
+{
+ SendMsg(2596, virtualSpaceOptions, 0);
+}
+int wxStyledTextCtrl::GetVirtualSpaceOptions() const
+{
+ return SendMsg(2597, 0, 0);
+}
+
+// On GTK+, allow selecting the modifier key to use for mouse-based
+// rectangular selection. Often the window manager requires Alt+Mouse Drag
+// for moving windows.
+// Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
+void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
+{
+ SendMsg(2598, modifier, 0);
+}
+
+// Get the modifier key used for rectangular selection.
+int wxStyledTextCtrl::GetRectangularSelectionModifier() const
+{
+ return SendMsg(2599, 0, 0);
+}
+
+// Set the foreground colour of additional selections.
+// Must have previously called SetSelFore with non-zero first argument for this to have an effect.
+void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
+{
+ SendMsg(2600, wxColourAsLong(fore), 0);
+}
+
+// Set the background colour of additional selections.
+// Must have previously called SetSelBack with non-zero first argument for this to have an effect.
+void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
+{
+ SendMsg(2601, wxColourAsLong(back), 0);
+}
+
+// Set the alpha of the selection.
+void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
+{
+ SendMsg(2602, alpha, 0);
+}
+
+// Get the alpha of the selection.
+int wxStyledTextCtrl::GetAdditionalSelAlpha() const
+{
+ return SendMsg(2603, 0, 0);
+}
+
+// Set the foreground colour of additional carets.
+void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
+{
+ SendMsg(2604, wxColourAsLong(fore), 0);
+}
+
+// Get the foreground colour of additional carets.
+wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
+{
+ long c = SendMsg(2605, 0, 0);
+ return wxColourFromLong(c);
+}
+
+// Set the main selection to the next selection.
+void wxStyledTextCtrl::RotateSelection()
+{
+ SendMsg(2606, 0, 0);
+}
+
+// Swap that caret and anchor of the main selection.
+void wxStyledTextCtrl::SwapMainAnchorCaret()
+{
+ SendMsg(2607, 0, 0);
+}
+
+// Indicate that the internal state of a lexer has changed over a range and therefore
+// there may be a need to redraw.
+int wxStyledTextCtrl::ChangeLexerState(int start, int end)
+{
+ return SendMsg(2617, start, end);
+}
+
+// Find the next line at or after lineStart that is a contracted fold header line.
+// Return -1 when no more lines.
+int wxStyledTextCtrl::ContractedFoldNext(int lineStart)
+{
+ return SendMsg(2618, lineStart, 0);
+}
+
+// Centre current line in window.
+void wxStyledTextCtrl::VerticalCentreCaret()
+{
+ SendMsg(2619, 0, 0);
+}
+
+// Move the selected lines up one line, shifting the line above after the selection
+void wxStyledTextCtrl::MoveSelectedLinesUp()
+{
+ SendMsg(2620, 0, 0);
+}
+
+// Move the selected lines down one line, shifting the line below before the selection
+void wxStyledTextCtrl::MoveSelectedLinesDown()
+{
+ SendMsg(2621, 0, 0);
+}
+
+// Set the identifier reported as idFrom in notification messages.
+void wxStyledTextCtrl::SetIdentifier(int identifier)
+{
+ SendMsg(2622, identifier, 0);
+}
+
+// Get the identifier.
+int wxStyledTextCtrl::GetIdentifier() const
+{
+ return SendMsg(2623, 0, 0);
+}
+
+// Set the width for future RGBA image data.
+void wxStyledTextCtrl::RGBAImageSetWidth(int width)
+{
+ SendMsg(2624, width, 0);
+}
+
+// Set the height for future RGBA image data.
+void wxStyledTextCtrl::RGBAImageSetHeight(int height)
+{
+ SendMsg(2625, height, 0);
+}
+
+// Define a marker from RGBA data.
+// It has the width and height from RGBAImageSetWidth/Height
+void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) {
+ SendMsg(2626, markerNumber, (sptr_t)pixels);
+}
+
+// Register an RGBA image for use in autocompletion lists.
+// It has the width and height from RGBAImageSetWidth/Height
+void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) {
+ SendMsg(2627, type, (sptr_t)pixels);
+}
+
+// Scroll to start of document.
+void wxStyledTextCtrl::ScrollToStart()
+{
+ SendMsg(2628, 0, 0);
+}
+
+// Scroll to end of document.
+void wxStyledTextCtrl::ScrollToEnd()
+{
+ SendMsg(2629, 0, 0);
+}
+
+// Set the technology used.
+void wxStyledTextCtrl::SetTechnology(int technology)
+{
+ SendMsg(2630, technology, 0);
+}
+
+// Get the tech.
+int wxStyledTextCtrl::GetTechnology() const
+{
+ return SendMsg(2631, 0, 0);
+}
+
+// Create an ILoader*.
+void* wxStyledTextCtrl::CreateLoader(int bytes) const {
+ return (void*)(sptr_t)SendMsg(2632, bytes);
+}
+
+// Start notifying the container of all key presses and commands.
+void wxStyledTextCtrl::StartRecord()
+{
+ SendMsg(3001, 0, 0);
+}
+
+// Stop notifying the container of all key presses and commands.
+void wxStyledTextCtrl::StopRecord()
+{
+ SendMsg(3002, 0, 0);
+}
+
+// Set the lexing language of the document.
+void wxStyledTextCtrl::SetLexer(int lexer)
+{
+ SendMsg(4001, lexer, 0);
+}
+
+// Retrieve the lexing language of the document.
+int wxStyledTextCtrl::GetLexer() const
+{
+ return SendMsg(4002, 0, 0);
+}
+
+// Colourise a segment of the document using the current lexing language.
+void wxStyledTextCtrl::Colourise(int start, int end)
+{
+ SendMsg(4003, start, end);
+}
+
+// Set up a value that may be used by a lexer for some optional feature.
+void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
+{
+ SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
+}
+
+// Set up the key words used by the lexer.
+void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
+{
+ SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
+}
+
+// Set the lexing language of the document based on string name.
+void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
+{
+ SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
+}
+
+// Retrieve a 'property' value previously set with SetProperty.
+wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
+ int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Retrieve a 'property' value previously set with SetProperty,
+// with '$()' variable replacement on returned buffer.
+wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
+ int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Retrieve a 'property' value previously set with SetProperty,
+// interpreted as an int AFTER any '$()' variable replacement.
+int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
+{
+ return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
+}
+
+// Retrieve the number of bits the current lexer needs for styling.
+int wxStyledTextCtrl::GetStyleBitsNeeded() const
+{
+ return SendMsg(4011, 0, 0);
+}
+
+// For private communication between an application and a known lexer.
+void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
+ return (void*)(sptr_t)SendMsg(4013, operation, (sptr_t)pointer);
+}
+
+// Retrieve a '\n' separated list of properties understood by the current lexer.
+wxString wxStyledTextCtrl::PropertyNames() const {
+ int msg = 4014;
+ int len = SendMsg(msg, 0, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, 0, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Retrieve the type of a property.
+int wxStyledTextCtrl::PropertyType(const wxString& name)
+{
+ return SendMsg(4015, (sptr_t)(const char*)wx2stc(name), 0);
+}
+
+// Describe a property.
+wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
+ int msg = 4016;
+ int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
+wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
+ int msg = 4017;
+ int len = SendMsg(msg, 0, (sptr_t)NULL);
+ if (!len) return wxEmptyString;
+
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, 0, (sptr_t)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+//}}}
+//----------------------------------------------------------------------
+
+
+// Returns the line number of the line with the caret.
+int wxStyledTextCtrl::GetCurrentLine() {
+ int line = LineFromPosition(GetCurrentPos());
+ return line;
+}
+
+
+// Extract style settings from a spec-string which is composed of one or
+// more of the following comma separated elements:
+//
+// bold turns on bold
+// italic turns on italics
+// fore:[name or #RRGGBB] sets the foreground colour
+// back:[name or #RRGGBB] sets the background colour
+// face:[facename] sets the font face name to use
+// size:[num] sets the font size in points
+// eol turns on eol filling
+// underline turns on underlining
+//
+void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
+
+ wxStringTokenizer tkz(spec, wxT(","));
+ while (tkz.HasMoreTokens()) {
+ wxString token = tkz.GetNextToken();
+
+ wxString option = token.BeforeFirst(':');
+ wxString val = token.AfterFirst(':');
+
+ if (option == wxT("bold"))
+ StyleSetBold(styleNum, true);
+
+ else if (option == wxT("italic"))
+ StyleSetItalic(styleNum, true);
+
+ else if (option == wxT("underline"))
+ StyleSetUnderline(styleNum, true);
+
+ else if (option == wxT("eol"))
+ StyleSetEOLFilled(styleNum, true);
+
+ else if (option == wxT("size")) {
+ long points;
+ if (val.ToLong(&points))
+ StyleSetSize(styleNum, points);
+ }
+
+ else if (option == wxT("face"))
StyleSetFaceName(styleNum, val);
else if (option == wxT("fore"))
}
-#if wxUSE_TEXTCTRL
-bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType)
+void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags)
{
- bool ok = wxTextAreaBase::DoSaveFile(filename, fileType);
-#else
-bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+ if ( flags & SetValue_SelectionOnly )
+ ReplaceSelection(value);
+ else
+ SetText(value);
+
+ // We don't send wxEVT_COMMAND_TEXT_UPDATED anyhow, so ignore the
+ // SetValue_SendEvent bit of the flags
+}
+
+bool
+wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
{
+#if wxUSE_FFILE || wxUSE_FILE
+
#if wxUSE_FFILE
- wxFFile file(filename, wxT("w"));
- bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
-#else
- bool ok = false;
-#endif // wxUSE_FFILE
+ // Take care to use "b" to ensure that possibly non-native EOLs in the file
+ // contents are not mangled when saving it.
+ wxFFile file(filename, wxS("wb"));
+#elif wxUSE_FILE
+ wxFile file(filename, wxFile::write);
#endif
- if (ok)
+
+ if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
{
SetSavePoint();
+
+ return true;
}
- return ok;
+
+#endif // !wxUSE_FFILE && !wxUSE_FILE
+
+ return false;
}
-#if wxUSE_TEXTCTRL
-bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType)
-{
- bool ok = wxTextAreaBase::DoLoadFile(filename, fileType);
-#else
-bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+bool
+wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
{
+#if wxUSE_FFILE || wxUSE_FILE
+
#if wxUSE_FFILE
- wxFFile file(filename);
- bool ok = file.IsOpened();
- if (ok)
+ // As above, we want to read the real EOLs from the file, e.g. without
+ // translating them to just LFs under Windows, so that the original CR LF
+ // are preserved when it's written back.
+ wxFFile file(filename, wxS("rb"));
+#else
+ wxFile file(filename);
+#endif
+
+ if ( file.IsOpened() )
{
wxString text;
- ok = file.ReadAll(&text, *wxConvCurrent);
- if (ok)
+ if ( file.ReadAll(&text, *wxConvCurrent) )
{
+ // Detect the EOL: we use just the first line because there is not
+ // much we can do if the file uses inconsistent EOLs anyhow, we'd
+ // need to ask the user about the one we should really use and we
+ // don't currently provide a way to do it.
+ //
+ // We also only check for Unix and DOS EOLs but not classic Mac
+ // CR-only one as it's obsolete by now.
+ const wxString::size_type posLF = text.find('\n');
+ if ( posLF != wxString::npos )
+ {
+ // Set EOL mode to ensure that the new lines inserted into the
+ // text use the same EOLs as the existing ones.
+ if ( posLF > 0 && text[posLF - 1] == '\r' )
+ SetEOLMode(wxSTC_EOL_CRLF);
+ else
+ SetEOLMode(wxSTC_EOL_LF);
+ }
+ //else: Use the default EOL for the current platform.
+
SetValue(text);
+ EmptyUndoBuffer();
+ SetSavePoint();
+
+ return true;
}
}
-#else
- bool ok = false;
-#endif // wxUSE_FFILE
-#endif
- if (ok)
- {
- EmptyUndoBuffer();
- SetSavePoint();
- }
- return ok;
+#endif // !wxUSE_FFILE && !wxUSE_FILE
+
+ return false;
+}
+
+// If we don't derive from wxTextAreaBase, we need to implement these methods
+// ourselves, otherwise we already inherit them.
+#if !wxUSE_TEXTCTRL
+
+bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+{
+ if ( filename.empty() )
+ return false;
+
+ return DoSaveFile(filename, wxTEXT_TYPE_ANY);
+}
+
+bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+{
+ if ( filename.empty() )
+ return false;
+
+ return DoLoadFile(filename, wxTEXT_TYPE_ANY);
}
+#endif // !wxUSE_TEXTCTRL
+
#if wxUSE_DRAG_AND_DROP
wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
return m_swx->DoDragOver(x, y, def);
return m_swx->GetUseAntiAliasing();
}
+void wxStyledTextCtrl::AnnotationClearLine(int line) {
+ SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL);
+}
-void wxStyledTextCtrl::AddTextRaw(const char* text)
+void wxStyledTextCtrl::AddTextRaw(const char* text, int length)
{
- SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text);
+ if (length == -1)
+ length = strlen(text);
+ SendMsg(SCI_ADDTEXT, length, (sptr_t)text);
}
void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
{
- long start;
- long end;
-
- GetSelection(&start, &end);
- int len = end - start;
- if (!len) {
- wxCharBuffer empty;
- return empty;
- }
+ // Calculate the length needed first.
+ const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
+ // And then really get the data.
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
return buf;
return buf;
}
-void wxStyledTextCtrl::AppendTextRaw(const char* text)
+void wxStyledTextCtrl::AppendTextRaw(const char* text, int length)
{
- SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text);
+ if (length == -1)
+ length = strlen(text);
+ SendMsg(SCI_APPENDTEXT, length, (sptr_t)text);
}
// Event handlers
void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
+#ifdef __WXGTK__
+ wxBufferedPaintDC dc(this);
+#else
wxPaintDC dc(this);
+#endif
m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
}
void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
{
- // prevent having an event queue with wheel events that cannot be processed
- // reasonably fast (see ticket #9057)
- if ( m_lastWheelTimestamp <= evt.GetTimestamp() )
- {
- m_lastWheelTimestamp = m_stopWatch.Time();
- m_swx->DoMouseWheel(evt.GetWheelRotation(),
- evt.GetWheelDelta(),
- evt.GetLinesPerAction(),
- evt.ControlDown(),
- evt.IsPageScroll());
- m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
- m_lastWheelTimestamp += evt.GetTimestamp();
- }
+ m_swx->DoMouseWheel(evt.GetWheelRotation(),
+ evt.GetWheelDelta(),
+ evt.GetLinesPerAction(),
+ evt.ControlDown(),
+ evt.IsPageScroll());
}
case SCN_DOUBLECLICK:
evt.SetEventType(wxEVT_STC_DOUBLECLICK);
+ evt.SetLine(scn.line);
break;
case SCN_UPDATEUI:
evt.SetEventType(wxEVT_STC_UPDATEUI);
+ evt.SetUpdated(scn.updated);
break;
case SCN_MODIFIED:
evt.SetLine(scn.line);
evt.SetFoldLevelNow(scn.foldLevelNow);
evt.SetFoldLevelPrev(scn.foldLevelPrev);
+ evt.SetToken(scn.token);
+ evt.SetAnnotationLinesAdded(scn.annotationLinesAdded);
break;
case SCN_MACRORECORD:
evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
break;
+ case SCN_AUTOCCANCELLED:
+ evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED);
+ break;
+
+ case SCN_AUTOCCHARDELETED:
+ evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED);
+ break;
+
+ case SCN_HOTSPOTRELEASECLICK:
+ evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK);
+ break;
+
default:
return;
}
m_listType = 0;
m_x = 0;
m_y = 0;
- m_dragAllowMove = false;
+ m_token = 0;
+ m_annotationLinesAdded = 0;
+ m_updated = 0;
+
#if wxUSE_DRAG_AND_DROP
+ m_dragFlags = wxDrag_CopyOnly;
m_dragResult = wxDragNone;
#endif
}
m_x = event.m_x;
m_y = event.m_y;
- m_dragText = event.m_dragText;
- m_dragAllowMove =event.m_dragAllowMove;
+ m_token = event.m_token;
+ m_annotationLinesAdded = event.m_annotationLinesAdded;
+ m_updated = event.m_updated;
+
#if wxUSE_DRAG_AND_DROP
+ m_dragText = event.m_dragText;
+ m_dragFlags = event.m_dragFlags;
m_dragResult = event.m_dragResult;
#endif
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
+/*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
+{
+ return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21");
+}
+
#endif // wxUSE_STC