+// Set the lexing language of the document based on string name.
+void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
+ SendMsg(4006, 0, (long)(const char*)wx2stc(language));
+}
+
+// END of generated section
+//----------------------------------------------------------------------
+
+
+// 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"))
+ StyleSetForeground(styleNum, wxColourFromSpec(val));
+
+ else if (option == wxT("back"))
+ StyleSetBackground(styleNum, wxColourFromSpec(val));
+ }
+}
+
+
+// Set style size, face, bold, italic, and underline attributes from
+// a wxFont's attributes.
+void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
+#ifdef __WXGTK__
+ // Ensure that the native font is initialized
+ int x, y;
+ GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
+#endif
+ int size = font.GetPointSize();
+ wxString faceName = font.GetFaceName();
+ bool bold = font.GetWeight() == wxBOLD;
+ bool italic = font.GetStyle() != wxNORMAL;
+ bool under = font.GetUnderlined();
+ wxFontEncoding encoding = font.GetDefaultEncoding();
+
+ StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
+}
+
+// Set all font style attributes at once.
+void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
+ const wxString& faceName,
+ bool bold, bool italic,
+ bool underline,
+ wxFontEncoding encoding) {
+ StyleSetSize(styleNum, size);
+ StyleSetFaceName(styleNum, faceName);
+ StyleSetBold(styleNum, bold);
+ StyleSetItalic(styleNum, italic);
+ StyleSetUnderline(styleNum, underline);
+ StyleSetFontEncoding(styleNum, encoding);
+}
+
+
+// Set the character set of the font in a style. Converts the Scintilla
+// character set values to a wxFontEncoding.
+void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
+{
+ wxFontEncoding encoding;
+
+ // Translate the Scintilla characterSet to a wxFontEncoding
+ switch (characterSet) {
+ default:
+ case wxSTC_CHARSET_ANSI:
+ case wxSTC_CHARSET_DEFAULT:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_BALTIC:
+ encoding = wxFONTENCODING_ISO8859_13;
+ break;
+
+ case wxSTC_CHARSET_CHINESEBIG5:
+ encoding = wxFONTENCODING_CP950;
+ break;
+
+ case wxSTC_CHARSET_EASTEUROPE:
+ encoding = wxFONTENCODING_ISO8859_2;
+ break;
+
+ case wxSTC_CHARSET_GB2312:
+ encoding = wxFONTENCODING_CP936;
+ break;
+
+ case wxSTC_CHARSET_GREEK:
+ encoding = wxFONTENCODING_ISO8859_7;
+ break;
+
+ case wxSTC_CHARSET_HANGUL:
+ encoding = wxFONTENCODING_CP949;
+ break;
+
+ case wxSTC_CHARSET_MAC:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_OEM:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_RUSSIAN:
+ encoding = wxFONTENCODING_KOI8;
+ break;
+
+ case wxSTC_CHARSET_SHIFTJIS:
+ encoding = wxFONTENCODING_CP932;
+ break;
+
+ case wxSTC_CHARSET_SYMBOL:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_TURKISH:
+ encoding = wxFONTENCODING_ISO8859_9;
+ break;
+
+ case wxSTC_CHARSET_JOHAB:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_HEBREW:
+ encoding = wxFONTENCODING_ISO8859_8;
+ break;
+
+ case wxSTC_CHARSET_ARABIC:
+ encoding = wxFONTENCODING_ISO8859_6;
+ break;
+
+ case wxSTC_CHARSET_VIETNAMESE:
+ encoding = wxFONTENCODING_DEFAULT;
+ break;
+
+ case wxSTC_CHARSET_THAI:
+ encoding = wxFONTENCODING_ISO8859_11;
+ break;
+ }
+
+ // We just have Scintilla track the wxFontEncoding for us. It gets used
+ // in Font::Create in PlatWX.cpp. We add one to the value so that the
+ // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
+ // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
+ // to wxFONENCODING_DEFAULT in Font::Create.
+ SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Set the font encoding to be used by a style.
+void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
+{
+ SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Perform one of the operations defined by the wxSTC_CMD_* constants.
+void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
+ SendMsg(cmd);
+}
+
+
+// Set the left and right margin in the edit area, measured in pixels.
+void wxStyledTextCtrl::SetMargins(int left, int right) {
+ SetMarginLeft(left);
+ SetMarginRight(right);
+}
+
+
+// Retrieve the start and end positions of the current selection.
+void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
+ if (startPos != NULL)
+ *startPos = SendMsg(SCI_GETSELECTIONSTART);
+ if (endPos != NULL)
+ *endPos = SendMsg(SCI_GETSELECTIONEND);
+}
+
+
+// Retrieve the point in the window where a position is displayed.
+wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
+ int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
+ int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
+ return wxPoint(x, y);
+}
+
+// Scroll enough to make the given line visible
+void wxStyledTextCtrl::ScrollToLine(int line) {
+ m_swx->DoScrollToLine(line);
+}
+
+
+// Scroll enough to make the given column visible
+void wxStyledTextCtrl::ScrollToColumn(int column) {
+ m_swx->DoScrollToColumn(column);
+}
+
+
+bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+{
+ wxFile file(filename, wxFile::write);
+
+ if (!file.IsOpened())
+ return false;
+
+ bool success = file.Write(GetText(), *wxConvCurrent);
+
+ if (success)
+ SetSavePoint();
+
+ return success;
+}
+
+bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+{
+ bool success = false;
+ wxFile file(filename, wxFile::read);
+
+ if (file.IsOpened())
+ {
+ wxString contents;
+ // get the file size (assume it is not huge file...)
+ ssize_t len = (ssize_t)file.Length();
+
+ if (len > 0)
+ {
+#if wxUSE_UNICODE
+ wxMemoryBuffer buffer(len+1);
+ success = (file.Read(buffer.GetData(), len) == len);
+ if (success) {
+ ((char*)buffer.GetData())[len] = 0;
+ contents = wxString(buffer, *wxConvCurrent, len);
+ }
+#else
+ wxString buffer;
+ success = (file.Read(wxStringBuffer(buffer, len), len) == len);
+ contents = buffer;
+#endif
+ }
+ else
+ {
+ if (len == 0)
+ success = true; // empty file is ok
+ else
+ success = false; // len == wxInvalidOffset
+ }
+
+ if (success)
+ {
+ SetText(contents);
+ EmptyUndoBuffer();
+ SetSavePoint();
+ }
+ }
+
+ return success;
+}
+
+
+#if wxUSE_DRAG_AND_DROP
+wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
+ return m_swx->DoDragOver(x, y, def);
+}
+
+
+bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
+ return m_swx->DoDropText(x, y, data);
+}
+#endif
+
+
+void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
+ m_swx->SetUseAntiAliasing(useAA);
+}
+
+bool wxStyledTextCtrl::GetUseAntiAliasing() {
+ return m_swx->GetUseAntiAliasing();
+}
+
+
+
+
+
+void wxStyledTextCtrl::AddTextRaw(const char* text)
+{
+ SendMsg(SCI_ADDTEXT, strlen(text), (long)text);
+}
+
+void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
+{
+ SendMsg(SCI_INSERTTEXT, pos, (long)text);
+}
+
+wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
+{
+ int len = LineLength(GetCurrentLine());
+ if (!len) {
+ if (linePos) *linePos = 0;
+ wxCharBuffer empty;
+ return empty;
+ }