// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)
-int wxForceScintillaLexers(void)
+static int wxForceScintillaLexers(void)
{
extern LexerModule lmCPP;
extern LexerModule lmHTML;
extern LexerModule lmPython;
extern LexerModule lmSQL;
extern LexerModule lmVB;
+ extern LexerModule lmLua;
if (
&lmCPP
&& &lmPython
&& &lmSQL
&& &lmVB
+ && &lmLua
)
{
return 1;
}
- else
- {
- return 0;
- }
}
//----------------------------------------------------------------------
int len = GetTextLength();
char* buff = text.GetWriteBuf(len+1);
- SendMsg(WM_GETTEXT, len, (long)buff);
+ SendMsg(SCI_GETTEXT, len, (long)buff);
buff[len] = 0;
text.UngetWriteBuf();
return text;
bool wxStyledTextCtrl::SetText(const wxString& text) {
- return SendMsg(WM_SETTEXT, 0, (long)text.c_str()) != 0;
+ return SendMsg(SCI_SETTEXT, 0, (long)text.c_str()) != 0;
}
int len = GetLineLength(line);
char* buff = text.GetWriteBuf(len+1);
- *((WORD*)buff) = len;
- SendMsg(EM_GETLINE, line, (long)buff);
+ SendMsg(SCI_GETLINE, line, (long)buff);
buff[len] = 0;
text.UngetWriteBuf();
return text;
void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
- SendMsg(EM_REPLACESEL, 0, (long)text.c_str());
+ SendMsg(SCI_REPLACESEL, 0, (long)text.c_str());
}
void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
- SendMsg(EM_SETREADONLY, (long)readOnly);
+ SendMsg(SCI_SETREADONLY, (long)readOnly);
m_readOnly = readOnly;
}
void wxStyledTextCtrl::GetTextRange(int startPos, int endPos, char* buff) {
- TEXTRANGE tr;
+ TextRange tr;
tr.lpstrText = buff;
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
- SendMsg(EM_GETTEXTRANGE, 0, (long)&tr);
+ SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
}
wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
wxString text;
int len = endPos - startPos;
- char* buff = text.GetWriteBuf(len);
+ char* buff = text.GetWriteBuf(len+1);
GetTextRange(startPos, endPos, buff);
text.UngetWriteBuf();
return text;
void wxStyledTextCtrl::GetStyledTextRange(int startPos, int endPos, char* buff) {
- TEXTRANGE tr;
+ TextRange tr;
tr.lpstrText = buff;
tr.chrg.cpMin = startPos;
tr.chrg.cpMax = endPos;
wxString wxStyledTextCtrl::GetStyledTextRange(int startPos, int endPos) {
wxString text;
int len = endPos - startPos;
- char* buff = text.GetWriteBuf(len*2);
+ char* buff = text.GetWriteBuf(len*2+1);
GetStyledTextRange(startPos, endPos, buff);
text.UngetWriteBuf(len*2);
return text;
void wxStyledTextCtrl::Cut() {
- SendMsg(WM_CUT);
+ SendMsg(SCI_CUT);
}
void wxStyledTextCtrl::Copy() {
- SendMsg(WM_COPY);
+ SendMsg(SCI_COPY);
}
void wxStyledTextCtrl::Paste() {
- SendMsg(WM_PASTE);
+ SendMsg(SCI_PASTE);
}
bool wxStyledTextCtrl::CanPaste() {
- return SendMsg(EM_CANPASTE) != 0;
+ return SendMsg(SCI_CANPASTE) != 0;
}
void wxStyledTextCtrl::ClearClipbrd() {
- SendMsg(WM_CLEAR);
+ SendMsg(SCI_CLEAR);
}
// Undo and Redo
void wxStyledTextCtrl::Undo() {
- SendMsg(WM_UNDO);
+ SendMsg(SCI_UNDO);
}
bool wxStyledTextCtrl::CanUndo() {
- return SendMsg(EM_CANUNDO) != 0;
+ return SendMsg(SCI_CANUNDO) != 0;
}
void wxStyledTextCtrl::EmptyUndoBuffer() {
- SendMsg(EM_EMPTYUNDOBUFFER);
+ SendMsg(SCI_EMPTYUNDOBUFFER);
}
void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
- SendMsg(EM_GETSEL, (long)startPos, (long)endPos);
+// SendMsg(EM_GETSEL, (long)startPos, (long)endPos);
+ *startPos = SendMsg(SCI_GETSELECTIONSTART);
+ *endPos = SendMsg(SCI_GETSELECTIONEND);
}
void wxStyledTextCtrl::SetSelection(int startPos, int endPos) {
- SendMsg(EM_SETSEL, startPos, endPos);
+ SendMsg(SCI_SETSEL, startPos, endPos);
}
GetSelection(&start, &end);
int len = end - start;
- char* buff = text.GetWriteBuf(len);
+ char* buff = text.GetWriteBuf(len+1);
- SendMsg(EM_GETSELTEXT, 0, (long)buff);
+ SendMsg(SCI_GETSELTEXT, 0, (long)buff);
text.UngetWriteBuf();
return text;
}
void wxStyledTextCtrl::HideSelection(bool hide) {
- SendMsg(EM_HIDESELECTION, hide);
+ SendMsg(SCI_HIDESELECTION, hide);
}
int wxStyledTextCtrl::GetTextLength() {
- return SendMsg(WM_GETTEXTLENGTH);
+ return SendMsg(SCI_GETTEXTLENGTH);
}
int wxStyledTextCtrl::GetFirstVisibleLine() {
- return SendMsg(EM_GETFIRSTVISIBLELINE);
+ return SendMsg(SCI_GETFIRSTVISIBLELINE);
}
int wxStyledTextCtrl::GetLineCount() {
- return SendMsg(EM_GETLINECOUNT);
+ return SendMsg(SCI_GETLINECOUNT);
}
bool wxStyledTextCtrl::GetModified() {
- return SendMsg(EM_GETMODIFY) != 0;
-}
-
-
-wxRect wxStyledTextCtrl::GetRect() {
- PRectangle pr;
- SendMsg(EM_GETRECT, 0, (long)&pr);
-
- wxRect rect = wxRectFromPRectangle(pr);
- return rect;
+ return SendMsg(SCI_GETMODIFY) != 0;
}
int wxStyledTextCtrl::GetLineFromPos(int pos) {
- return SendMsg(EM_LINEFROMCHAR, pos);
+ return SendMsg(SCI_LINEFROMPOSITION, pos);
}
int wxStyledTextCtrl::GetLineStartPos(int line) {
- return SendMsg(EM_LINEINDEX, line);
-}
-
-
-int wxStyledTextCtrl::GetLineLengthAtPos(int pos) {
- return SendMsg(EM_LINELENGTH, pos);
+ return SendMsg(SCI_POSITIONFROMLINE, line);
}
int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
- Point spt(pt.x, pt.y);
- long rv = SendMsg(EM_CHARFROMPOS, 0, (long)&spt);
- return LOWORD(rv);
-}
-
-
-int wxStyledTextCtrl::LineFromPoint(wxPoint pt) {
- Point spt(pt.x, pt.y);
- long rv = SendMsg(EM_CHARFROMPOS, 0, (long)&spt);
- return HIWORD(rv);
+ return SendMsg(SCI_POSITIONFROMPOINT, pt.x, pt.y);
}
wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
- Point pt;
- SendMsg(EM_POSFROMCHAR, (long)&pt, pos);
- return wxPoint(pt.x, pt.y);
+ int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
+ int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
+ return wxPoint(x, y);
}
void wxStyledTextCtrl::ScrollBy(int columnDelta, int lineDelta) {
- SendMsg(EM_LINESCROLL, columnDelta, lineDelta);
+ SendMsg(SCI_LINESCROLL, columnDelta, lineDelta);
}
void wxStyledTextCtrl::ScrollToLine(int line) {
void wxStyledTextCtrl::EnsureCaretVisible() {
- SendMsg(EM_SCROLLCARET);
+ SendMsg(SCI_SCROLLCARET);
}
}
-int wxStyledTextCtrl::GetSelectionType() {
- return SendMsg(EM_SELECTIONTYPE);
-}
-
-
int wxStyledTextCtrl::GetLinesOnScreen() {
return SendMsg(SCI_LINESONSCREEN);
}
// Searching
int wxStyledTextCtrl::FindText(int minPos, int maxPos,
- const wxString& text,
- bool caseSensitive, bool wholeWord) {
- FINDTEXTEX ft;
+ const wxString& text,
+ bool caseSensitive, bool wholeWord) {
+ TextToFind ft;
int flags = 0;
- flags |= caseSensitive ? FR_MATCHCASE : 0;
- flags |= wholeWord ? FR_WHOLEWORD : 0;
+ flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
+ flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
ft.chrg.cpMin = minPos;
ft.chrg.cpMax = maxPos;
ft.lpstrText = (char*)text.c_str();
- return SendMsg(EM_FINDTEXT, flags, (long)&ft);
+ return SendMsg(SCI_FINDTEXT, flags, (long)&ft);
}
int wxStyledTextCtrl::SearchNext(const wxString& text, bool caseSensitive, bool wholeWord) {
int flags = 0;
- flags |= caseSensitive ? FR_MATCHCASE : 0;
- flags |= wholeWord ? FR_WHOLEWORD : 0;
+ flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
+ flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
return SendMsg(SCI_SEARCHNEXT, flags, (long)text.c_str());
}
int wxStyledTextCtrl::SearchPrev(const wxString& text, bool caseSensitive, bool wholeWord) {
int flags = 0;
- flags |= caseSensitive ? FR_MATCHCASE : 0;
- flags |= wholeWord ? FR_WHOLEWORD : 0;
+ flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
+ flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
return SendMsg(SCI_SEARCHPREV, flags, (long)text.c_str());
}
// Margins in the edit area
int wxStyledTextCtrl::GetLeftMargin() {
- return LOWORD(SendMsg(EM_GETMARGINS));
+ return SendMsg(SCI_GETMARGINLEFT);
}
int wxStyledTextCtrl::GetRightMargin() {
- return HIWORD(SendMsg(EM_GETMARGINS));
+ return SendMsg(SCI_GETMARGINRIGHT);
}
void wxStyledTextCtrl::SetMargins(int left, int right) {
int flag = 0;
- int val = 0;
if (right != -1) {
- flag |= EC_RIGHTMARGIN;
- val = right << 16;
+ SendMsg(SCI_SETMARGINRIGHT, 0, right);
}
if (left != -1) {
- flag |= EC_LEFTMARGIN;
- val |= (left & 0xffff);
+ SendMsg(SCI_SETMARGINLEFT, 0, left);
}
-
- SendMsg(EM_SETMARGINS, flag, val);
}
//----------------------------------------------------------------------
// Key bindings
+#define MAKELONG(a, b) ((a) | ((b) << 16))
+
void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
SendMsg(SCI_ASSIGNCMDKEY, MAKELONG(key, modifiers), cmd);
}
wxDC* target, // Why does it use two? Can they be the same?
wxRect renderRect,
wxRect pageRect) {
- FORMATRANGE fr;
+ RangeToFormat fr;
fr.hdc = draw;
fr.hdcTarget = target;
fr.chrg.cpMin = startPos;
fr.chrg.cpMax = endPos;
- return SendMsg(EM_FORMATRANGE, doDraw, (long)&fr);
+ return SendMsg(SCI_FORMATRANGE, doDraw, (long)&fr);
}