📄 wxscintilla.cpp
字号:
int wxScintilla::AutoCompPosStart() { return SendMsg (SCI_AUTOCPOSSTART, 0, 0);}// User has selected an item so remove the list and insert the selection.void wxScintilla::AutoCompComplete() { SendMsg (SCI_AUTOCCOMPLETE, 0, 0);}// Define a set of character that when typed cancel the auto-completion list.void wxScintilla::AutoCompStops (const wxString& characterSet) { SendMsg (SCI_AUTOCSTOPS, 0, (long)(const char*)wx2sci(characterSet));}// Change the separator character in the string setting up an auto-completion list.// Default is space but can be changed if items contain space.void wxScintilla::AutoCompSetSeparator (int separatorCharacter) { SendMsg (SCI_AUTOCSETSEPARATOR, separatorCharacter, 0);}// Retrieve the auto-completion list separator character.int wxScintilla::AutoCompGetSeparator() { return SendMsg (SCI_AUTOCGETSEPARATOR, 0, 0);}// Select the item in the auto-completion list that starts with a string.void wxScintilla::AutoCompSelect (const wxString& text) { SendMsg (SCI_AUTOCSELECT, 0, (long)(const char*)wx2sci(text));}// Should the auto-completion list be cancelled if the user backspaces to a// position before where the box was created.void wxScintilla::AutoCompSetCancelAtStart (bool cancel) { SendMsg (SCI_AUTOCSETCANCELATSTART, cancel, 0);}// Retrieve whether auto-completion cancelled by backspacing before start.bool wxScintilla::AutoCompGetCancelAtStart() { return SendMsg (SCI_AUTOCGETCANCELATSTART, 0, 0) != 0;}// Define a set of characters that when typed will cause the autocompletion to// choose the selected item.void wxScintilla::AutoCompSetFillUps (const wxString& characterSet) { SendMsg (SCI_AUTOCSETFILLUPS, 0, (long)(const char*)wx2sci(characterSet));}// Should a single item auto-completion list automatically choose the item.void wxScintilla::AutoCompSetChooseSingle (bool chooseSingle) { SendMsg (SCI_AUTOCSETCHOOSESINGLE, chooseSingle, 0);}// Retrieve whether a single item auto-completion list automatically choose the item.bool wxScintilla::AutoCompGetChooseSingle() { return SendMsg (SCI_AUTOCGETCHOOSESINGLE, 0, 0) != 0;}// Set whether case is significant when performing auto-completion searches.void wxScintilla::AutoCompSetIgnoreCase (bool ignoreCase) { SendMsg (SCI_AUTOCSETIGNORECASE, ignoreCase, 0);}// Retrieve state of ignore case flag.bool wxScintilla::AutoCompGetIgnoreCase() { return SendMsg (SCI_AUTOCGETIGNORECASE, 0, 0) != 0;}// Display a list of strings and send notification when user chooses one.void wxScintilla::UserListShow (int listType, const wxString& itemList) { SendMsg (SCI_USERLISTSHOW, listType, (long)(const char*)wx2sci(itemList));}// Set whether or not autocompletion is hidden automatically when nothing matches.void wxScintilla::AutoCompSetAutoHide (bool autoHide) { SendMsg (SCI_AUTOCSETAUTOHIDE, autoHide, 0);}// Retrieve whether or not autocompletion is hidden automatically when nothing matches.bool wxScintilla::AutoCompGetAutoHide() { return SendMsg (SCI_AUTOCGETAUTOHIDE, 0, 0) != 0;}// Set whether or not autocompletion deletes any word characters// after the inserted text upon completion.void wxScintilla::AutoCompSetDropRestOfWord (bool dropRestOfWord) { SendMsg (SCI_AUTOCSETDROPRESTOFWORD, dropRestOfWord, 0);}// Retrieve whether or not autocompletion deletes any word characters// after the inserted text upon completion.bool wxScintilla::AutoCompGetDropRestOfWord() { return SendMsg (SCI_AUTOCGETDROPRESTOFWORD, 0, 0) != 0;}// Register an image for use in autocompletion lists.void wxScintilla::RegisterImage (int type, const wxBitmap& bmp) { // convert bmp to a xpm in a string wxMemoryOutputStream strm; wxImage img = bmp.ConvertToImage();#if wxCHECK_VERSION(2, 5, 0) if (img.HasAlpha()) img.ConvertAlphaToMask();#endif img.SaveFile(strm, wxBITMAP_TYPE_XPM); size_t len = strm.GetSize(); char* buff = new char[len+1]; strm.CopyTo(buff, len); buff[len] = 0; SendMsg(SCI_REGISTERIMAGE, type, (long)buff); delete [] buff;}// Clear all the registered images.void wxScintilla::ClearRegisteredImages() { SendMsg (SCI_CLEARREGISTEREDIMAGES, 0, 0);}// Retrieve the auto-completion list type-separator character.int wxScintilla::AutoCompGetTypeSeparator() { return SendMsg (SCI_AUTOCGETTYPESEPARATOR, 0, 0);}// Change the type-separator character in the string setting up an auto-completion list.// Default is '?' but can be changed if items contain '?'.void wxScintilla::AutoCompSetTypeSeparator (int separatorCharacter) { SendMsg (SCI_AUTOCSETTYPESEPARATOR, separatorCharacter, 0);}// Set the maximum width, in characters, of auto-completion and user lists.// Set to 0 to autosize to fit longest item, which is the default.void wxScintilla::AutoCompSetMaxWidth (int characterCount) { SendMsg (SCI_AUTOCSETMAXWIDTH, characterCount, 0);}// Get the maximum width, in characters, of auto-completion and user lists.int wxScintilla::AutoCompGetMaxWidth() { return SendMsg (SCI_AUTOCGETMAXWIDTH, 0, 0);}// Set the maximum height, in rows, of auto-completion and user lists.// The default is 5 rows.void wxScintilla::AutoCompSetMaxHeight (int rowCount) { SendMsg (SCI_AUTOCSETMAXHEIGHT, rowCount, 0);}// Set the maximum height, in rows, of auto-completion and user lists.int wxScintilla::AutoCompGetMaxHeight() { return SendMsg (SCI_AUTOCGETMAXHEIGHT, 0, 0);}// Set the number of spaces used for one level of indentation.void wxScintilla::SetIndent (int indentSize) { SendMsg (SCI_SETINDENT, indentSize, 0);}// Retrieve indentation size.int wxScintilla::GetIndent() { return SendMsg (SCI_GETINDENT, 0, 0);}// Indentation will only use space characters if useTabs is false, otherwise// it will use a combination of tabs and spaces.void wxScintilla::SetUseTabs (bool useTabs) { SendMsg (SCI_SETUSETABS, useTabs, 0);}// Retrieve whether tabs will be used in indentation.bool wxScintilla::GetUseTabs() { return SendMsg (SCI_GETUSETABS, 0, 0) != 0;}// Change the indentation of a line to a number of columns.void wxScintilla::SetLineIndentation (int line, int indentSize) { SendMsg (SCI_SETLINEINDENTATION, line, indentSize);}// Retrieve the number of columns that a line is indented.int wxScintilla::GetLineIndentation (int line) { return SendMsg (SCI_GETLINEINDENTATION, line, 0);}// Retrieve the position before the first non indentation character on a line.int wxScintilla::GetLineIndentPosition (int line) { return SendMsg (SCI_GETLINEINDENTPOSITION, line, 0);}// Retrieve the column number of a position, taking tab width into account.int wxScintilla::GetColumn (int pos) { return SendMsg (SCI_GETCOLUMN, pos, 0);}// Show or hide the horizontal scroll bar.void wxScintilla::SetUseHorizontalScrollBar (bool show) { SendMsg (SCI_SETHSCROLLBAR, show, 0);}// Is the horizontal scroll bar visible?bool wxScintilla::GetUseHorizontalScrollBar() { return SendMsg (SCI_GETHSCROLLBAR, 0, 0) != 0;}// Show or hide indentation guides.void wxScintilla::SetIndentationGuides (bool show) { SendMsg (SCI_SETINDENTATIONGUIDES, show, 0);}// Are the indentation guides visible?bool wxScintilla::GetIndentationGuides() { return SendMsg (SCI_GETINDENTATIONGUIDES, 0, 0) != 0;}// Set the highlighted indentation guide column.// 0 = no highlighted guide.void wxScintilla::SetHighlightGuide (int column) { SendMsg (SCI_SETHIGHLIGHTGUIDE, column, 0);}// Get the highlighted indentation guide column.int wxScintilla::GetHighlightGuide() { return SendMsg (SCI_GETHIGHLIGHTGUIDE, 0, 0);}// Get the position after the last visible characters on a line.int wxScintilla::GetLineEndPosition (int line) { return SendMsg (SCI_GETLINEENDPOSITION, line, 0);}// Get the code page used to interpret the bytes of the document as characters.int wxScintilla::GetCodePage() { return SendMsg (SCI_GETCODEPAGE, 0, 0);}// Get the foreground colour of the caret.wxColour wxScintilla::GetCaretForeground() { long colour = SendMsg (SCI_GETCARETFORE, 0, 0); return wxColourFromLong(colour);}// Get use palette (SCI_GETUSEPALETTE) not supported// In read-only mode?bool wxScintilla::GetReadOnly() { return SendMsg (SCI_GETREADONLY, 0, 0) != 0;}// Sets the position of the caret.void wxScintilla::SetCurrentPos (int pos) { SendMsg (SCI_SETCURRENTPOS, pos, 0);}// Sets the position that starts the selection - this becomes the anchor.void wxScintilla::SetSelectionStart (int pos) { SendMsg (SCI_SETSELECTIONSTART, pos, 0);}// Returns the position at the start of the selection.int wxScintilla::GetSelectionStart() { return SendMsg (SCI_GETSELECTIONSTART, 0, 0);}// Sets the position that ends the selection - this becomes the currentPosition.void wxScintilla::SetSelectionEnd (int pos) { SendMsg (SCI_SETSELECTIONEND, pos, 0);}// Returns the position at the end of the selection.int wxScintilla::GetSelectionEnd() { return SendMsg (SCI_GETSELECTIONEND, 0, 0);}// Sets the print magnification added to the point size of each style for printing.void wxScintilla::SetPrintMagnification (int magnification) { SendMsg (SCI_SETPRINTMAGNIFICATION, magnification, 0);}// Returns the print magnification.int wxScintilla::GetPrintMagnification() { return SendMsg (SCI_GETPRINTMAGNIFICATION, 0, 0);}// Modify colours when printing for clearer printed text.void wxScintilla::SetPrintColourMode (int mode) { SendMsg (SCI_SETPRINTCOLOURMODE, mode, 0);}// Returns the print colour mode.int wxScintilla::GetPrintColourMode() { return SendMsg (SCI_GETPRINTCOLOURMODE, 0, 0);}// Find some text in the document.int wxScintilla::FindText (int minPos, int maxPos, const wxString& text, int flags, int* lengthFound) { TextToFind ft; ft.chrg.cpMin = minPos; ft.chrg.cpMax = maxPos; wxWX2MBbuf buf = (wxWX2MBbuf)wx2sci(text); ft.lpstrText = (char*)(const char*)buf; int ret = SendMsg (SCI_FINDTEXT, flags, (long)&ft); if (lengthFound) *lengthFound = ft.chrgText.cpMax - ft.chrgText.cpMin; return ret;}// On Windows, will draw the document into a display context such as a printer. int wxScintilla::FormatRange (bool doDraw, int startPos, int endPos, wxDC* draw, wxDC* target, wxRect renderRect, wxRect pageRect) { RangeToFormat fr; if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } fr.hdc = draw; fr.hdcTarget = target; fr.rc.top = renderRect.GetTop(); fr.rc.left = renderRect.GetLeft(); fr.rc.right = renderRect.GetRight(); fr.rc.bottom = renderRect.GetBottom(); fr.rcPage.top = pageRect.GetTop(); fr.rcPage.left = pageRect.GetLeft(); fr.rcPage.right = pageRect.GetRight(); fr.rcPage.bottom = pageRect.GetBottom(); fr.chrg.cpMin = startPos; fr.chrg.cpMax = endPos; return SendMsg (SCI_FORMATRANGE, doDraw, (long)&fr);}// Retrieve the display line at the top of the display.int wxScintilla::GetFirstVisibleLine() { return SendMsg (SCI_GETFIRSTVISIBLELINE, 0, 0);}// Retrieve the contents of a line.wxString wxScintilla::GetLine (int line) { int len = LineLength(line); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg (SCI_GETLINE, line, (long)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return sci2wx(buf);}// Returns the number of lines in the document. There is always at least one.int wxScintilla::GetLineCount() { return SendMsg (SCI_GETLINECOUNT, 0, 0);}// Sets the size in pixels of the left margin.void wxScintilla::SetMarginLeft (int pixels) { SendMsg (SCI_SETMARGINLEFT, 0, pixels);}// Returns the size in pixels of the left margin.int wxScintilla::GetMarginLeft() { return SendMsg (SCI_GETMARGINLEFT, 0, 0);}// Sets the size in pixels of the right margin.void wxScintilla::SetMarginRight (int pixels) { SendMsg (SCI_SETMARGINRIGHT, 0, pixels);}// Returns the size in pixels of the right margin.int wxScintilla::GetMarginRight() { return SendMsg (SCI_GETMARGINRIGHT, 0, 0);}// Is the document different from when it was last saved?bool wxScintilla::GetModify() { return SendMsg (SCI_GETMODIFY, 0, 0) != 0;}// Select a range of text.void wxScintilla::SetSelection (int startPos, int endPos) { SendMsg (SCI_SETSEL, startPos, endPos);}// Retrieve the selected text.wxString wxScintilla::GetSelectedText() { int start; int end; GetSelection(&start, &end); int len = end - start; if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+2); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg (SCI_GETSELTEXT, 0, (long)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return sci2wx(buf);}// Retrieve a range of text.wxString wxScintilla::GetTextRange (int startPos, int endPos) { if (endPos < startPos) { int temp = startPos; startPos = endPos; endPos = temp; } int len = endPos - startPos; if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len); TextRange tr; tr.lpstrText = buf; tr.chrg.cpMin = startPos; tr.chrg.cpMax = endPos; SendMsg (SCI_GETTEXTRANGE, 0, (long)&tr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -