#include <ctype.h>
-#include "wx/stc/stc.h"
-#include "ScintillaWX.h"
-
#include <wx/wx.h>
#include <wx/tokenzr.h>
#include <wx/mstream.h>
#include <wx/image.h>
#include <wx/file.h>
+#include "wx/stc/stc.h"
+#include "ScintillaWX.h"
//----------------------------------------------------------------------
}
-void wxStyledTextCtrl::Create(wxWindow *parent,
- wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+bool wxStyledTextCtrl::Create(wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
#ifdef __WXMAC__
style |= wxVSCROLL | wxHSCROLL;
#endif
- wxControl::Create(parent, id, pos, size,
- style | wxWANTS_CHARS | wxCLIP_CHILDREN,
- wxDefaultValidator, name);
+ if (!wxControl::Create(parent, id, pos, size,
+ style | wxWANTS_CHARS | wxCLIP_CHILDREN,
+ wxDefaultValidator, name))
+ return false;
#ifdef LINK_LEXERS
Scintilla_LinkLexers();
#endif
SetBestFittingSize(size);
+
+ // Reduces flicker on GTK+/X11
+ SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+ return true;
}
}
// Append a string to the end of the document without changing the selection.
-void wxStyledTextCtrl::AppendText(int length, const wxString& text) {
- SendMsg(2282, length, (long)(const char*)wx2stc(text));
+void wxStyledTextCtrl::AppendText(const wxString& text) {
+ wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
+ SendMsg(2282, strlen(buf), (long)(const char*)buf);
}
// Is drawing done in two phases with backgrounds drawn before foregrounds?
SendMsg(2446, bytes, 0);
}
+// Find the position of a column on a line taking into account tabs and
+// multi-byte characters. If beyond end of line, return line end position.
+int wxStyledTextCtrl::FindColumn(int line, int column) {
+ return SendMsg(2456, line, column);
+}
+
// Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
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;
+ }
+
+ wxCharBuffer buf(len);
+ int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data());
+ if (linePos) *linePos = pos;
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
+{
+ int len = LineLength(line);
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETLINE, line, (long)buf.data());
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
+{
+ int start;
+ int end;
+
+ GetSelection(&start, &end);
+ int len = end - start;
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
+{
+ if (endPos < startPos) {
+ int temp = startPos;
+ startPos = endPos;
+ endPos = temp;
+ }
+ int len = endPos - startPos;
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ TextRange tr;
+ tr.lpstrText = buf.data();
+ tr.chrg.cpMin = startPos;
+ tr.chrg.cpMax = endPos;
+ SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
+ return buf;
+}
+
+void wxStyledTextCtrl::SetTextRaw(const char* text)
+{
+ SendMsg(SCI_SETTEXT, 0, (long)text);
+}
+
+wxCharBuffer wxStyledTextCtrl::GetTextRaw()
+{
+ int len = GetTextLength();
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETTEXT, len, (long)buf.data());
+ return buf;
+}
+
+void wxStyledTextCtrl::AppendTextRaw(const char* text)
+{
+ SendMsg(SCI_APPENDTEXT, strlen(text), (long)text);
+}
+
+
+
+
+
//----------------------------------------------------------------------
// Event handlers
// be a function key or etc., the platforms appear to always give us a
// small value in this case) then fallback to the ascii key code but
// don't do anything for function keys or etc.
- if (key <= 255) {
+ if (key <= 127) {
key = evt.GetKeyCode();
- keyOk = (key <= 255);
+ keyOk = (key <= 127);
}
if (keyOk) {
m_swx->DoAddChar(key);