diff --git a/README.md b/README.md index 04b1cd3..fa73ae7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SurroundSelection -Notepad++ plugin to automatically surround the selection in quotes/brackets/parenthesis/etc. +Notepad++ plugin to automatically surround the selection in quotes/brackets/parenthesis/etc. This can also be used on multiple or rectangluar selections. **Note:** This is still in early development. It has not been tested with non-US keyboard layouts. @@ -12,10 +12,10 @@ Select some text and type one of the following characters: - `[` ## Installation -No public release is currently available. +Install the plugin by downloading it from the [Release](https://github.com/dail8859/SurroundSelection/releases) page and copy `SurroundSelection.dll` to your `plugins` folder. ## Development -The code has been developed using MSVC 2013. Building the code will generate the DLL which can be used by Notepad++. For convenience, MSVC copies the DLL into the Notepad++ plugin directory. +The code has been developed using MSVC 2015. Building the code will generate the DLL which can be used by Notepad++. For convenience, MSVC copies the DLL into the Notepad++ plugin directory. ## License This code is released under the [GNU General Public License version 2](http://www.gnu.org/licenses/gpl-2.0.txt). diff --git a/SurroundSelection.sln b/SurroundSelection.sln index eaf606c..0056513 100644 --- a/SurroundSelection.sln +++ b/SurroundSelection.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SurroundSelection", "src\SurroundSelection.vcxproj", "{1590D7CD-7D3A-4AB7-A355-EE02F7FB987D}" EndProject diff --git a/src/Main.cpp b/src/Main.cpp index d07cc36..441ea56 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -61,26 +61,29 @@ static void SurroundSelectionsWith(char ch1, char ch2) { // Sort so they are replaced top to bottom std::sort(selections.begin(), selections.end()); - int offset = 0; - int i = 0; + editor.BeginUndoAction(); - for (const auto &selection : selections) { + editor.ClearSelections(); + + int offset = 0; + for (size_t i = 0; i < selections.size(); ++i) { + const auto &selection = selections[i]; editor.SetTargetRange(selection.first + offset, selection.second + offset); - std::string target(editor.GetTargetText(NULL), '\0'); - editor.GetTargetText(&target[0]); + auto target = editor.GetTargetText(); // Add in the characters target.insert(target.begin(), 1, ch1); target.insert(target.end(), 1, ch2); - editor.ReplaceTarget(-1, target.c_str()); + editor.ReplaceTarget(target); - editor.SetSelectionNStart(i, selection.first + offset + 1); - editor.SetSelectionNEnd(i, selection.second + offset + 2 - 1); + if (i == 0) + editor.SetSelection(selection.first + offset + 1, selection.second + offset + 1); + else + editor.AddSelection(selection.first + offset + 1, selection.second + offset + 1); - offset += 2; - ++i; + offset += 2; // Add 2 since the replaced string is 2 chars longer } editor.EndUndoAction(); @@ -136,15 +139,15 @@ LRESULT CALLBACK KeyboardProc(int ncode, WPARAM wparam, LPARAM lparam) { BOOL APIENTRY DllMain(HANDLE hModule, DWORD reasonForCall, LPVOID lpReserved) { switch (reasonForCall) { - case DLL_PROCESS_ATTACH: - _hModule = hModule; - break; - case DLL_PROCESS_DETACH: - break; - case DLL_THREAD_ATTACH: - break; - case DLL_THREAD_DETACH: - break; + case DLL_PROCESS_ATTACH: + _hModule = hModule; + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; } return TRUE; } @@ -194,4 +197,4 @@ extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam extern "C" __declspec(dllexport) BOOL isUnicode() { return TRUE; } -#endif //UNICODE +#endif diff --git a/src/ScintillaGateway.h b/src/ScintillaGateway.h index 887b239..90621bc 100644 --- a/src/ScintillaGateway.h +++ b/src/ScintillaGateway.h @@ -1,8 +1,8 @@ -// This file is part of ElasticTabstops. +// This file is part of SurroundSelection. // // Copyright (C)2017 Justin Dailey // -// ElasticTabstops is free software; you can redistribute it and/or +// SurroundSelection is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. @@ -18,6 +18,8 @@ #pragma once +#include + #include "Scintilla.h" #define SCI_UNUSED 0 @@ -36,6 +38,16 @@ class ScintillaGateway final { SciFnDirect directFunction = nullptr; sptr_t directPointer = 0; + static inline void trim(std::string &s) { + while (s.length() > 0 && s.back() == '\0') s.pop_back(); + } + + template + inline sptr_t Call(unsigned int message, T wParam = 0, U lParam = 0) const { + sptr_t retVal = directFunction(directPointer, message, (uptr_t)wParam, (sptr_t)lParam); + return retVal; + } + public: ScintillaGateway() {} @@ -53,18 +65,16 @@ class ScintillaGateway final { return scintilla; } - template - inline sptr_t Call(unsigned int message, T wParam = 0, U lParam = 0) const { - sptr_t retVal = directFunction(directPointer, message, (uptr_t)wParam, (sptr_t)lParam); - return retVal; - } - /* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ void AddText(int length, const char* text) const { Call(SCI_ADDTEXT, length, text); } + void AddText(const std::string& text) const { + Call(SCI_ADDTEXT, text.length(), text.c_str()); + } + void AddStyledText(int length, const Cell* c) const { Call(SCI_ADDSTYLEDTEXT, length, c); } @@ -73,10 +83,18 @@ class ScintillaGateway final { Call(SCI_INSERTTEXT, pos, text); } + void InsertText(int pos, const std::string& text) const { + Call(SCI_INSERTTEXT, pos, text.c_str()); + } + void ChangeInsertion(int length, const char* text) const { Call(SCI_CHANGEINSERTION, length, text); } + void ChangeInsertion(const std::string& text) const { + Call(SCI_CHANGEINSERTION, text.length(), text.c_str()); + } + void ClearAll() const { Call(SCI_CLEARALL, SCI_UNUSED, SCI_UNUSED); } @@ -190,6 +208,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetCurLine() const { + auto size = Call(SCI_GETCURLINE, SCI_UNUSED, NULL); + std::string text(size + 1, '\0'); + Call(SCI_GETCURLINE, text.length(), &text[0]); + trim(text); + return text; + } + int GetEndStyled() const { sptr_t res = Call(SCI_GETENDSTYLED, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -312,6 +338,10 @@ class ScintillaGateway final { Call(SCI_MARKERDEFINEPIXMAP, markerNumber, pixmap); } + void MarkerDefinePixmap(int markerNumber, const std::string& pixmap) const { + Call(SCI_MARKERDEFINEPIXMAP, markerNumber, pixmap.c_str()); + } + void MarkerAddSet(int line, int set) const { Call(SCI_MARKERADDSET, line, set); } @@ -393,6 +423,10 @@ class ScintillaGateway final { Call(SCI_STYLESETFONT, style, fontName); } + void StyleSetFont(int style, const std::string& fontName) const { + Call(SCI_STYLESETFONT, style, fontName.c_str()); + } + void StyleSetEOLFilled(int style, bool filled) const { Call(SCI_STYLESETEOLFILLED, style, filled); } @@ -435,6 +469,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string StyleGetFont(int style) const { + auto size = Call(SCI_STYLEGETFONT, style, NULL); + std::string fontName(size + 1, '\0'); + Call(SCI_STYLEGETFONT, style, &fontName[0]); + trim(fontName); + return fontName; + } + bool StyleGetEOLFilled(int style) const { sptr_t res = Call(SCI_STYLEGETEOLFILLED, style, SCI_UNUSED); return res != 0; @@ -546,6 +588,10 @@ class ScintillaGateway final { Call(SCI_SETSTYLINGEX, length, styles); } + void SetStylingEx(const std::string& styles) const { + Call(SCI_SETSTYLINGEX, styles.length(), styles.c_str()); + } + void StyleSetVisible(int style, bool visible) const { Call(SCI_STYLESETVISIBLE, style, visible); } @@ -563,11 +609,23 @@ class ScintillaGateway final { Call(SCI_SETWORDCHARS, SCI_UNUSED, characters); } + void SetWordChars(const std::string& characters) const { + Call(SCI_SETWORDCHARS, SCI_UNUSED, characters.c_str()); + } + int GetWordChars(char* characters) const { sptr_t res = Call(SCI_GETWORDCHARS, SCI_UNUSED, characters); return static_cast(res); } + std::string GetWordChars() const { + auto size = Call(SCI_GETWORDCHARS, SCI_UNUSED, NULL); + std::string characters(size + 1, '\0'); + Call(SCI_GETWORDCHARS, SCI_UNUSED, &characters[0]); + trim(characters); + return characters; + } + void BeginUndoAction() const { Call(SCI_BEGINUNDOACTION, SCI_UNUSED, SCI_UNUSED); } @@ -696,6 +754,10 @@ class ScintillaGateway final { Call(SCI_AUTOCSHOW, lenEntered, itemList); } + void AutoCShow(int lenEntered, const std::string& itemList) const { + Call(SCI_AUTOCSHOW, lenEntered, itemList.c_str()); + } + void AutoCCancel() const { Call(SCI_AUTOCCANCEL, SCI_UNUSED, SCI_UNUSED); } @@ -718,6 +780,10 @@ class ScintillaGateway final { Call(SCI_AUTOCSTOPS, SCI_UNUSED, characterSet); } + void AutoCStops(const std::string& characterSet) const { + Call(SCI_AUTOCSTOPS, SCI_UNUSED, characterSet.c_str()); + } + void AutoCSetSeparator(int separatorCharacter) const { Call(SCI_AUTOCSETSEPARATOR, separatorCharacter, SCI_UNUSED); } @@ -731,6 +797,10 @@ class ScintillaGateway final { Call(SCI_AUTOCSELECT, SCI_UNUSED, text); } + void AutoCSelect(const std::string& text) const { + Call(SCI_AUTOCSELECT, SCI_UNUSED, text.c_str()); + } + void AutoCSetCancelAtStart(bool cancel) const { Call(SCI_AUTOCSETCANCELATSTART, cancel, SCI_UNUSED); } @@ -744,6 +814,10 @@ class ScintillaGateway final { Call(SCI_AUTOCSETFILLUPS, SCI_UNUSED, characterSet); } + void AutoCSetFillUps(const std::string& characterSet) const { + Call(SCI_AUTOCSETFILLUPS, SCI_UNUSED, characterSet.c_str()); + } + void AutoCSetChooseSingle(bool chooseSingle) const { Call(SCI_AUTOCSETCHOOSESINGLE, chooseSingle, SCI_UNUSED); } @@ -766,6 +840,10 @@ class ScintillaGateway final { Call(SCI_USERLISTSHOW, listType, itemList); } + void UserListShow(int listType, const std::string& itemList) const { + Call(SCI_USERLISTSHOW, listType, itemList.c_str()); + } + void AutoCSetAutoHide(bool autoHide) const { Call(SCI_AUTOCSETAUTOHIDE, autoHide, SCI_UNUSED); } @@ -788,6 +866,10 @@ class ScintillaGateway final { Call(SCI_REGISTERIMAGE, type, xpmData); } + void RegisterImage(int type, const std::string& xpmData) const { + Call(SCI_REGISTERIMAGE, type, xpmData.c_str()); + } + void ClearRegisteredImages() const { Call(SCI_CLEARREGISTEREDIMAGES, SCI_UNUSED, SCI_UNUSED); } @@ -972,6 +1054,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetLine(int line) const { + auto size = Call(SCI_GETLINE, line, NULL); + std::string text(size + 1, '\0'); + Call(SCI_GETLINE, line, &text[0]); + trim(text); + return text; + } + int GetLineCount() const { sptr_t res = Call(SCI_GETLINECOUNT, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -1009,6 +1099,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetSelText() const { + auto size = Call(SCI_GETSELTEXT, SCI_UNUSED, NULL); + std::string text(size + 1, '\0'); + Call(SCI_GETSELTEXT, SCI_UNUSED, &text[0]); + trim(text); + return text; + } + int GetTextRange(Sci_TextRange* tr) const { sptr_t res = Call(SCI_GETTEXTRANGE, SCI_UNUSED, tr); return static_cast(res); @@ -1054,6 +1152,10 @@ class ScintillaGateway final { Call(SCI_REPLACESEL, SCI_UNUSED, text); } + void ReplaceSel(const std::string& text) const { + Call(SCI_REPLACESEL, SCI_UNUSED, text.c_str()); + } + void SetReadOnly(bool readOnly) const { Call(SCI_SETREADONLY, readOnly, SCI_UNUSED); } @@ -1100,11 +1202,23 @@ class ScintillaGateway final { Call(SCI_SETTEXT, SCI_UNUSED, text); } + void SetText(const std::string& text) const { + Call(SCI_SETTEXT, SCI_UNUSED, text.c_str()); + } + int GetText(int length, char* text) const { sptr_t res = Call(SCI_GETTEXT, length, text); return static_cast(res); } + std::string GetText() const { + auto size = Call(SCI_GETTEXT, SCI_UNUSED, NULL); + std::string text(size + 1, '\0'); + Call(SCI_GETTEXT, text.length(), &text[0]); + trim(text); + return text; + } + int GetTextLength() const { sptr_t res = Call(SCI_GETTEXTLENGTH, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -1165,21 +1279,44 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetTargetText() const { + auto size = Call(SCI_GETTARGETTEXT, SCI_UNUSED, NULL); + std::string characters(size + 1, '\0'); + Call(SCI_GETTARGETTEXT, SCI_UNUSED, &characters[0]); + trim(characters); + return characters; + } + int ReplaceTarget(int length, const char* text) const { sptr_t res = Call(SCI_REPLACETARGET, length, text); return static_cast(res); } + int ReplaceTarget(const std::string& text) const { + sptr_t res = Call(SCI_REPLACETARGET, text.length(), text.c_str()); + return static_cast(res); + } + int ReplaceTargetRE(int length, const char* text) const { sptr_t res = Call(SCI_REPLACETARGETRE, length, text); return static_cast(res); } + int ReplaceTargetRE(const std::string& text) const { + sptr_t res = Call(SCI_REPLACETARGETRE, text.length(), text.c_str()); + return static_cast(res); + } + int SearchInTarget(int length, const char* text) const { sptr_t res = Call(SCI_SEARCHINTARGET, length, text); return static_cast(res); } + int SearchInTarget(const std::string& text) const { + sptr_t res = Call(SCI_SEARCHINTARGET, text.length(), text.c_str()); + return static_cast(res); + } + void SetSearchFlags(int flags) const { Call(SCI_SETSEARCHFLAGS, flags, SCI_UNUSED); } @@ -1193,6 +1330,10 @@ class ScintillaGateway final { Call(SCI_CALLTIPSHOW, pos, definition); } + void CallTipShow(int pos, const std::string& definition) const { + Call(SCI_CALLTIPSHOW, pos, definition.c_str()); + } + void CallTipCancel() const { Call(SCI_CALLTIPCANCEL, SCI_UNUSED, SCI_UNUSED); } @@ -1451,6 +1592,11 @@ class ScintillaGateway final { return static_cast(res); } + int TextWidth(int style, const std::string& text) const { + sptr_t res = Call(SCI_TEXTWIDTH, style, text.c_str()); + return static_cast(res); + } + void SetEndAtLastLine(bool endAtLastLine) const { Call(SCI_SETENDATLASTLINE, endAtLastLine, SCI_UNUSED); } @@ -1478,6 +1624,10 @@ class ScintillaGateway final { Call(SCI_APPENDTEXT, length, text); } + void AppendText(const std::string& text) const { + Call(SCI_APPENDTEXT, text.length(), text.c_str()); + } + bool GetTwoPhaseDraw() const { sptr_t res = Call(SCI_GETTWOPHASEDRAW, SCI_UNUSED, SCI_UNUSED); return res != 0; @@ -1523,6 +1673,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetTag(int tagNumber) const { + auto size = Call(SCI_GETTAG, tagNumber, NULL); + std::string tagValue(size + 1, '\0'); + Call(SCI_GETTAG, tagNumber, &tagValue[0]); + trim(tagValue); + return tagValue; + } + void TargetFromSelection() const { Call(SCI_TARGETFROMSELECTION, SCI_UNUSED, SCI_UNUSED); } @@ -1863,11 +2021,21 @@ class ScintillaGateway final { return static_cast(res); } + int SearchNext(int flags, const std::string& text) const { + sptr_t res = Call(SCI_SEARCHNEXT, flags, text.c_str()); + return static_cast(res); + } + int SearchPrev(int flags, const char* text) const { sptr_t res = Call(SCI_SEARCHPREV, flags, text); return static_cast(res); } + int SearchPrev(int flags, const std::string& text) const { + sptr_t res = Call(SCI_SEARCHPREV, flags, text.c_str()); + return static_cast(res); + } + int LinesOnScreen() const { sptr_t res = Call(SCI_LINESONSCREEN, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -2091,6 +2259,10 @@ class ScintillaGateway final { Call(SCI_COPYTEXT, length, text); } + void CopyText(const std::string& text) const { + Call(SCI_COPYTEXT, text.length(), text.c_str()); + } + void SetSelectionMode(int mode) const { Call(SCI_SETSELECTIONMODE, mode, SCI_UNUSED); } @@ -2182,20 +2354,44 @@ class ScintillaGateway final { Call(SCI_SETWHITESPACECHARS, SCI_UNUSED, characters); } + void SetWhitespaceChars(const std::string& characters) const { + Call(SCI_SETWHITESPACECHARS, SCI_UNUSED, characters.c_str()); + } + int GetWhitespaceChars(char* characters) const { sptr_t res = Call(SCI_GETWHITESPACECHARS, SCI_UNUSED, characters); return static_cast(res); } + std::string GetWhitespaceChars() const { + auto size = Call(SCI_GETWHITESPACECHARS, SCI_UNUSED, NULL); + std::string characters(size + 1, '\0'); + Call(SCI_GETWHITESPACECHARS, SCI_UNUSED, &characters[0]); + trim(characters); + return characters; + } + void SetPunctuationChars(const char* characters) const { Call(SCI_SETPUNCTUATIONCHARS, SCI_UNUSED, characters); } + void SetPunctuationChars(const std::string& characters) const { + Call(SCI_SETPUNCTUATIONCHARS, SCI_UNUSED, characters.c_str()); + } + int GetPunctuationChars(char* characters) const { sptr_t res = Call(SCI_GETPUNCTUATIONCHARS, SCI_UNUSED, characters); return static_cast(res); } + std::string GetPunctuationChars() const { + auto size = Call(SCI_GETPUNCTUATIONCHARS, SCI_UNUSED, NULL); + std::string characters(size + 1, '\0'); + Call(SCI_GETPUNCTUATIONCHARS, SCI_UNUSED, &characters[0]); + trim(characters); + return characters; + } + void SetCharsDefault() const { Call(SCI_SETCHARSDEFAULT, SCI_UNUSED, SCI_UNUSED); } @@ -2210,6 +2406,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string AutoCGetCurrentText() const { + auto size = Call(SCI_AUTOCGETCURRENTTEXT, SCI_UNUSED, NULL); + std::string s(size + 1, '\0'); + Call(SCI_AUTOCGETCURRENTTEXT, SCI_UNUSED, &s[0]); + trim(s); + return s; + } + void AutoCSetCaseInsensitiveBehaviour(int behaviour) const { Call(SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR, behaviour, SCI_UNUSED); } @@ -2246,6 +2450,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string TargetAsUTF8() const { + auto size = Call(SCI_TARGETASUTF8, SCI_UNUSED, NULL); + std::string s(size + 1, '\0'); + Call(SCI_TARGETASUTF8, SCI_UNUSED, &s[0]); + trim(s); + return s; + } + void SetLengthForEncode(int bytes) const { Call(SCI_SETLENGTHFORENCODE, bytes, SCI_UNUSED); } @@ -2255,6 +2467,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string EncodedFromUTF8(const std::string& utf8) const { + auto size = Call(SCI_ENCODEDFROMUTF8, utf8.c_str(), NULL); + std::string encoded(size + 1, '\0'); + Call(SCI_ENCODEDFROMUTF8, utf8.c_str(), &encoded[0]); + trim(encoded); + return encoded; + } + int FindColumn(int line, int column) const { sptr_t res = Call(SCI_FINDCOLUMN, line, column); return static_cast(res); @@ -2423,11 +2643,23 @@ class ScintillaGateway final { Call(SCI_MARGINSETTEXT, line, text); } + void MarginSetText(int line, const std::string& text) const { + Call(SCI_MARGINSETTEXT, line, text.c_str()); + } + int MarginGetText(int line, char* text) const { sptr_t res = Call(SCI_MARGINGETTEXT, line, text); return static_cast(res); } + std::string MarginGetText(int line) const { + auto size = Call(SCI_MARGINGETTEXT, line, NULL); + std::string text(size + 1, '\0'); + Call(SCI_MARGINGETTEXT, line, &text[0]); + trim(text); + return text; + } + void MarginSetStyle(int line, int style) const { Call(SCI_MARGINSETSTYLE, line, style); } @@ -2441,11 +2673,23 @@ class ScintillaGateway final { Call(SCI_MARGINSETSTYLES, line, styles); } + void MarginSetStyles(int line, const std::string& styles) const { + Call(SCI_MARGINSETSTYLES, line, styles.c_str()); + } + int MarginGetStyles(int line, char* styles) const { sptr_t res = Call(SCI_MARGINGETSTYLES, line, styles); return static_cast(res); } + std::string MarginGetStyles(int line) const { + auto size = Call(SCI_MARGINGETSTYLES, line, NULL); + std::string styles(size + 1, '\0'); + Call(SCI_MARGINGETSTYLES, line, &styles[0]); + trim(styles); + return styles; + } + void MarginTextClearAll() const { Call(SCI_MARGINTEXTCLEARALL, SCI_UNUSED, SCI_UNUSED); } @@ -2472,11 +2716,23 @@ class ScintillaGateway final { Call(SCI_ANNOTATIONSETTEXT, line, text); } + void AnnotationSetText(int line, const std::string& text) const { + Call(SCI_ANNOTATIONSETTEXT, line, text.c_str()); + } + int AnnotationGetText(int line, char* text) const { sptr_t res = Call(SCI_ANNOTATIONGETTEXT, line, text); return static_cast(res); } + std::string AnnotationGetText(int line) const { + auto size = Call(SCI_ANNOTATIONGETTEXT, line, NULL); + std::string text(size + 1, '\0'); + Call(SCI_ANNOTATIONGETTEXT, line, &text[0]); + trim(text); + return text; + } + void AnnotationSetStyle(int line, int style) const { Call(SCI_ANNOTATIONSETSTYLE, line, style); } @@ -2490,11 +2746,23 @@ class ScintillaGateway final { Call(SCI_ANNOTATIONSETSTYLES, line, styles); } + void AnnotationSetStyles(int line, const std::string& styles) const { + Call(SCI_ANNOTATIONSETSTYLES, line, styles.c_str()); + } + int AnnotationGetStyles(int line, char* styles) const { sptr_t res = Call(SCI_ANNOTATIONGETSTYLES, line, styles); return static_cast(res); } + std::string AnnotationGetStyles(int line) const { + auto size = Call(SCI_ANNOTATIONGETSTYLES, line, NULL); + std::string styles(size + 1, '\0'); + Call(SCI_ANNOTATIONGETSTYLES, line, &styles[0]); + trim(styles); + return styles; + } + int AnnotationGetLines(int line) const { sptr_t res = Call(SCI_ANNOTATIONGETLINES, line, SCI_UNUSED); return static_cast(res); @@ -2816,10 +3084,18 @@ class ScintillaGateway final { Call(SCI_MARKERDEFINERGBAIMAGE, markerNumber, pixels); } + void MarkerDefineRGBAImage(int markerNumber, const std::string& pixels) const { + Call(SCI_MARKERDEFINERGBAIMAGE, markerNumber, pixels.c_str()); + } + void RegisterRGBAImage(int type, const char* pixels) const { Call(SCI_REGISTERRGBAIMAGE, type, pixels); } + void RegisterRGBAImage(int type, const std::string& pixels) const { + Call(SCI_REGISTERRGBAIMAGE, type, pixels.c_str()); + } + void ScrollToStart() const { Call(SCI_SCROLLTOSTART, SCI_UNUSED, SCI_UNUSED); } @@ -2889,15 +3165,31 @@ class ScintillaGateway final { Call(SCI_SETREPRESENTATION, encodedCharacter, representation); } + void SetRepresentation(const std::string& encodedCharacter, const std::string& representation) const { + Call(SCI_SETREPRESENTATION, encodedCharacter.c_str(), representation.c_str()); + } + int GetRepresentation(const char* encodedCharacter, char* representation) const { sptr_t res = Call(SCI_GETREPRESENTATION, encodedCharacter, representation); return static_cast(res); } + std::string GetRepresentation(const std::string& encodedCharacter) const { + auto size = Call(SCI_GETREPRESENTATION, encodedCharacter.c_str(), NULL); + std::string representation(size + 1, '\0'); + Call(SCI_GETREPRESENTATION, encodedCharacter.c_str(), &representation[0]); + trim(representation); + return representation; + } + void ClearRepresentation(const char* encodedCharacter) const { Call(SCI_CLEARREPRESENTATION, encodedCharacter, SCI_UNUSED); } + void ClearRepresentation(const std::string& encodedCharacter) const { + Call(SCI_CLEARREPRESENTATION, encodedCharacter.c_str(), SCI_UNUSED); + } + void StartRecord() const { Call(SCI_STARTRECORD, SCI_UNUSED, SCI_UNUSED); } @@ -2923,33 +3215,70 @@ class ScintillaGateway final { Call(SCI_SETPROPERTY, key, value); } + void SetProperty(const std::string& key, const std::string& value) const { + Call(SCI_SETPROPERTY, key.c_str(), value.c_str()); + } + void SetKeyWords(int keywordSet, const char* keyWords) const { Call(SCI_SETKEYWORDS, keywordSet, keyWords); } + void SetKeyWords(int keywordSet, const std::string& keyWords) const { + Call(SCI_SETKEYWORDS, keywordSet, keyWords.c_str()); + } + void SetLexerLanguage(const char* language) const { Call(SCI_SETLEXERLANGUAGE, SCI_UNUSED, language); } + void SetLexerLanguage(const std::string& language) const { + Call(SCI_SETLEXERLANGUAGE, SCI_UNUSED, language.c_str()); + } + void LoadLexerLibrary(const char* path) const { Call(SCI_LOADLEXERLIBRARY, SCI_UNUSED, path); } + void LoadLexerLibrary(const std::string& path) const { + Call(SCI_LOADLEXERLIBRARY, SCI_UNUSED, path.c_str()); + } + int GetProperty(const char* key, char* buf) const { sptr_t res = Call(SCI_GETPROPERTY, key, buf); return static_cast(res); } + std::string GetProperty(const std::string& key) const { + auto size = Call(SCI_GETPROPERTY, key.c_str(), NULL); + std::string buf(size + 1, '\0'); + Call(SCI_GETPROPERTY, key.c_str(), &buf[0]); + trim(buf); + return buf; + } + int GetPropertyExpanded(const char* key, char* buf) const { sptr_t res = Call(SCI_GETPROPERTYEXPANDED, key, buf); return static_cast(res); } + std::string GetPropertyExpanded(const std::string& key) const { + auto size = Call(SCI_GETPROPERTYEXPANDED, key.c_str(), NULL); + std::string buf(size + 1, '\0'); + Call(SCI_GETPROPERTYEXPANDED, key.c_str(), &buf[0]); + trim(buf); + return buf; + } + int GetPropertyInt(const char* key) const { sptr_t res = Call(SCI_GETPROPERTYINT, key, SCI_UNUSED); return static_cast(res); } + int GetPropertyInt(const std::string& key) const { + sptr_t res = Call(SCI_GETPROPERTYINT, key.c_str(), SCI_UNUSED); + return static_cast(res); + } + int GetStyleBitsNeeded() const { sptr_t res = Call(SCI_GETSTYLEBITSNEEDED, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -2960,6 +3289,14 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetLexerLanguage() const { + auto size = Call(SCI_GETLEXERLANGUAGE, SCI_UNUSED, NULL); + std::string text(size + 1, '\0'); + Call(SCI_GETLEXERLANGUAGE, SCI_UNUSED, &text[0]); + trim(text); + return text; + } + int PrivateLexerCall(int operation, sptr_t pointer) const { sptr_t res = Call(SCI_PRIVATELEXERCALL, operation, pointer); return static_cast(res); @@ -2970,21 +3307,50 @@ class ScintillaGateway final { return static_cast(res); } + std::string PropertyNames() const { + auto size = Call(SCI_PROPERTYNAMES, SCI_UNUSED, NULL); + std::string names(size + 1, '\0'); + Call(SCI_PROPERTYNAMES, SCI_UNUSED, &names[0]); + trim(names); + return names; + } + int PropertyType(const char* name) const { sptr_t res = Call(SCI_PROPERTYTYPE, name, SCI_UNUSED); return static_cast(res); } + int PropertyType(const std::string& name) const { + sptr_t res = Call(SCI_PROPERTYTYPE, name.c_str(), SCI_UNUSED); + return static_cast(res); + } + int DescribeProperty(const char* name, char* description) const { sptr_t res = Call(SCI_DESCRIBEPROPERTY, name, description); return static_cast(res); } + std::string DescribeProperty(const std::string& name) const { + auto size = Call(SCI_DESCRIBEPROPERTY, name.c_str(), NULL); + std::string description(size + 1, '\0'); + Call(SCI_DESCRIBEPROPERTY, name.c_str(), &description[0]); + trim(description); + return description; + } + int DescribeKeyWordSets(char* descriptions) const { sptr_t res = Call(SCI_DESCRIBEKEYWORDSETS, SCI_UNUSED, descriptions); return static_cast(res); } + std::string DescribeKeyWordSets() const { + auto size = Call(SCI_DESCRIBEKEYWORDSETS, SCI_UNUSED, NULL); + std::string descriptions(size + 1, '\0'); + Call(SCI_DESCRIBEKEYWORDSETS, SCI_UNUSED, &descriptions[0]); + trim(descriptions); + return descriptions; + } + int GetLineEndTypesSupported() const { sptr_t res = Call(SCI_GETLINEENDTYPESSUPPORTED, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -3023,6 +3389,10 @@ class ScintillaGateway final { Call(SCI_SETIDENTIFIERS, style, identifiers); } + void SetIdentifiers(int style, const std::string& identifiers) const { + Call(SCI_SETIDENTIFIERS, style, identifiers.c_str()); + } + int DistanceToSecondaryStyles() const { sptr_t res = Call(SCI_DISTANCETOSECONDARYSTYLES, SCI_UNUSED, SCI_UNUSED); return static_cast(res); @@ -3033,5 +3403,13 @@ class ScintillaGateway final { return static_cast(res); } + std::string GetSubStyleBases() const { + auto size = Call(SCI_GETSUBSTYLEBASES, SCI_UNUSED, NULL); + std::string styles(size + 1, '\0'); + Call(SCI_GETSUBSTYLEBASES, SCI_UNUSED, &styles[0]); + trim(styles); + return styles; + } + /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ }; diff --git a/src/SurroundSelection.vcxproj b/src/SurroundSelection.vcxproj index e1d0d5d..8f94231 100644 --- a/src/SurroundSelection.vcxproj +++ b/src/SurroundSelection.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,23 +27,23 @@ DynamicLibrary Unicode - v120_xp + v140_xp DynamicLibrary Unicode - v120_xp + v140_xp DynamicLibrary Unicode - v120_xp + v140_xp true DynamicLibrary Unicode - v120_xp + v140_xp true