X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..904a68b6f648fc7802b41a8d176c78394252a4b7:/src/stc/stc.cpp diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index aa7bf8dd98..3fde7ae05d 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -26,7 +26,7 @@ // 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; @@ -39,6 +39,7 @@ int wxForceScintillaLexers(void) extern LexerModule lmPython; extern LexerModule lmSQL; extern LexerModule lmVB; + extern LexerModule lmLua; if ( &lmCPP @@ -52,14 +53,11 @@ int wxForceScintillaLexers(void) && &lmPython && &lmSQL && &lmVB + && &lmLua ) { return 1; } - else - { - return 0; - } } //---------------------------------------------------------------------- @@ -131,7 +129,7 @@ wxString wxStyledTextCtrl::GetText() { 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; @@ -139,7 +137,7 @@ wxString wxStyledTextCtrl::GetText() { 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; } @@ -148,8 +146,7 @@ wxString wxStyledTextCtrl::GetLine(int line) { 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; @@ -157,12 +154,12 @@ wxString wxStyledTextCtrl::GetLine(int line) { 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; } @@ -175,18 +172,18 @@ bool wxStyledTextCtrl::GetReadOnly() { 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; @@ -194,7 +191,7 @@ wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { void wxStyledTextCtrl::GetStyledTextRange(int startPos, int endPos, char* buff) { - TEXTRANGE tr; + TextRange tr; tr.lpstrText = buff; tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; @@ -205,7 +202,7 @@ void wxStyledTextCtrl::GetStyledTextRange(int startPos, int endPos, char* buff) 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; @@ -257,27 +254,27 @@ int wxStyledTextCtrl::GetStyleBits() { 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); } @@ -286,17 +283,17 @@ void wxStyledTextCtrl::ClearClipbrd() { // 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); } @@ -340,12 +337,14 @@ void wxStyledTextCtrl::EndUndoAction() { 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); } @@ -356,16 +355,16 @@ wxString wxStyledTextCtrl::GetSelectedText() { 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); } @@ -375,46 +374,32 @@ bool wxStyledTextCtrl::GetHideSelection() { 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); } @@ -445,23 +430,14 @@ wxString wxStyledTextCtrl::GetCurrentLineText(int* linePos) { 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); } @@ -513,7 +489,7 @@ void wxStyledTextCtrl::PageMove(int cmdKey, bool extendSelection) { void wxStyledTextCtrl::ScrollBy(int columnDelta, int lineDelta) { - SendMsg(EM_LINESCROLL, columnDelta, lineDelta); + SendMsg(SCI_LINESCROLL, columnDelta, lineDelta); } void wxStyledTextCtrl::ScrollToLine(int line) { @@ -527,7 +503,7 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { void wxStyledTextCtrl::EnsureCaretVisible() { - SendMsg(EM_SCROLLCARET); + SendMsg(SCI_SCROLLCARET); } @@ -536,11 +512,6 @@ void wxStyledTextCtrl::SetCaretPolicy(int policy, int slop) { } -int wxStyledTextCtrl::GetSelectionType() { - return SendMsg(EM_SELECTIONTYPE); -} - - int wxStyledTextCtrl::GetLinesOnScreen() { return SendMsg(SCI_LINESONSCREEN); } @@ -568,18 +539,18 @@ bool wxStyledTextCtrl::GetUseHorizontalScrollBar() { // 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); } @@ -590,8 +561,8 @@ void wxStyledTextCtrl::SearchAnchor() { 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()); } @@ -599,8 +570,8 @@ int wxStyledTextCtrl::SearchNext(const wxString& text, bool caseSensitive, bool 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()); } @@ -836,29 +807,24 @@ void wxStyledTextCtrl::StyleSetUnderline(int styleNum, bool underline) { // 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); } @@ -1180,6 +1146,8 @@ void wxStyledTextCtrl::CallTipSetBackground(const wxColour& colour) { //---------------------------------------------------------------------- // 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); } @@ -1212,7 +1180,7 @@ wxStyledTextCtrl::FormatRange(bool doDraw, 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; @@ -1227,7 +1195,7 @@ wxStyledTextCtrl::FormatRange(bool doDraw, fr.chrg.cpMin = startPos; fr.chrg.cpMax = endPos; - return SendMsg(EM_FORMATRANGE, doDraw, (long)&fr); + return SendMsg(SCI_FORMATRANGE, doDraw, (long)&fr); }