Skip to content

Commit

Permalink
Weekly Scintilla sync up.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 1, 2024
1 parent 2f469c8 commit aa16556
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 58 deletions.
14 changes: 4 additions & 10 deletions scintilla/src/RESearch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ int RESearch::GetBackslashExpression(const char *pattern, int &incr) noexcept {
result = escapeValue(bsc);
break;
case 'x': {
const unsigned char hd1 = *(pattern + 1);
const unsigned char hd2 = *(pattern + 2);
const unsigned char hd1 = pattern[1];
const unsigned char hd2 = pattern[2];
const int hexValue = GetHexValue(hd1, hd2);
if (hexValue >= 0) {
result = hexValue;
Expand Down Expand Up @@ -521,15 +521,12 @@ const char *RESearch::DoCompile(const char *pattern, size_t length, FindOption f
p++;
int incr;
c2 = GetBackslashExpression(p, incr);
prevChar = c2;
i += incr;
p += incr;
if (c2 >= 0) {
// Convention: \c (c is any char) is case sensitive, whatever the option
ChSet(static_cast<unsigned char>(c2));
prevChar = c2;
} else {
// bittab is already changed
prevChar = -1;
}
}
}
Expand All @@ -556,15 +553,12 @@ const char *RESearch::DoCompile(const char *pattern, size_t length, FindOption f
p++;
int incr;
const int c = GetBackslashExpression(p, incr);
prevChar = c;
i += incr;
p += incr;
if (c >= 0) {
// Convention: \c (c is any char) is case sensitive, whatever the option
ChSet(static_cast<unsigned char>(c));
prevChar = c;
} else {
// bittab is already changed
prevChar = -1;
}
} else {
prevChar = static_cast<unsigned char>(*p);
Expand Down
39 changes: 19 additions & 20 deletions scintilla/src/Selection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void SelectionRange::MinimizeVirtualSpace() noexcept {
}
}

Selection::Selection() noexcept : mainRange(0), moveExtends(false), tentativeMain(false), selType(SelTypes::stream) {
Selection::Selection() : mainRange(0), moveExtends(false), tentativeMain(false), selType(SelTypes::stream) {
AddSelection(SelectionRange(SelectionPosition(0)));
}

Expand All @@ -219,16 +219,13 @@ SelectionRange& Selection::Rectangular() noexcept {
}

SelectionSegment Selection::Limits() const noexcept {
if (ranges.empty()) {
return SelectionSegment();
} else {
SelectionSegment sr(ranges[0].anchor, ranges[0].caret);
for (size_t i = 1; i < ranges.size(); i++) {
sr.Extend(ranges[i].anchor);
sr.Extend(ranges[i].caret);
}
return sr;
PLATFORM_ASSERT(!ranges.empty());
SelectionSegment sr(ranges[0].anchor, ranges[0].caret);
for (size_t i = 1; i < ranges.size(); i++) {
sr.Extend(ranges[i].anchor);
sr.Extend(ranges[i].caret);
}
return sr;
}

SelectionSegment Selection::LimitsForRectangularElseMain() const noexcept {
Expand Down Expand Up @@ -344,10 +341,12 @@ void Selection::TrimOtherSelections(size_t r, SelectionRange range) noexcept {
}
}

void Selection::SetSelection(SelectionRange range) {
ranges.clear();
ranges.push_back(range);
mainRange = ranges.size() - 1;
void Selection::SetSelection(SelectionRange range) noexcept {
if (ranges.size() > 1) {
ranges.erase(ranges.begin() + 1, ranges.end());
}
ranges[0] = range;
mainRange = 0;
}

void Selection::AddSelection(SelectionRange range) {
Expand Down Expand Up @@ -376,7 +375,7 @@ void Selection::DropSelection(size_t r) noexcept {
}
}

void Selection::DropAdditionalRanges() {
void Selection::DropAdditionalRanges() noexcept {
SetSelection(RangeMain());
}

Expand Down Expand Up @@ -426,10 +425,11 @@ Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const noexcept {
return virtualSpace;
}

void Selection::Clear() {
ranges.clear();
ranges.emplace_back();
mainRange = ranges.size() - 1;
void Selection::Clear() noexcept {
if (ranges.size() > 1) {
ranges.erase(ranges.begin() + 1, ranges.end());
}
mainRange = 0;
selType = SelTypes::stream;
moveExtends = false;
ranges[mainRange].Reset();
Expand Down Expand Up @@ -464,4 +464,3 @@ void Selection::RemoveDuplicates() noexcept {
void Selection::RotateMain() noexcept {
mainRange = (mainRange + 1) % ranges.size();
}

8 changes: 4 additions & 4 deletions scintilla/src/Selection.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Selection {
};
SelTypes selType;

Selection() noexcept;
Selection();
bool IsRectangular() const noexcept;
Sci::Position MainCaret() const noexcept;
Sci::Position MainAnchor() const noexcept;
Expand All @@ -177,18 +177,18 @@ class Selection {
void MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) noexcept;
void TrimSelection(SelectionRange range) noexcept;
void TrimOtherSelections(size_t r, SelectionRange range) noexcept;
void SetSelection(SelectionRange range);
void SetSelection(SelectionRange range) noexcept;
void AddSelection(SelectionRange range);
void AddSelectionWithoutTrim(SelectionRange range);
void DropSelection(size_t r) noexcept;
void DropAdditionalRanges();
void DropAdditionalRanges() noexcept;
void TentativeSelection(SelectionRange range);
void CommitTentative() noexcept;
InSelection RangeType(size_t r) const noexcept;
InSelection CharacterInSelection(Sci::Position posCharacter) const noexcept;
InSelection InSelectionForEOL(Sci::Position pos) const noexcept;
Sci::Position VirtualSpaceFor(Sci::Position pos) const noexcept;
void Clear();
void Clear() noexcept;
void Reset() noexcept;
void RemoveDuplicates() noexcept;
void RotateMain() noexcept;
Expand Down
39 changes: 17 additions & 22 deletions scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,13 @@ constexpr bool KeyboardIsNumericKeypadFunction(Scintilla::uptr_t wParam, Scintil
}
}

inline CLIPFORMAT GetClipboardFormat(LPCWSTR name) noexcept {
return static_cast<CLIPFORMAT>(::RegisterClipboardFormat(name));
inline CLIPFORMAT RegisterClipboardType(LPCWSTR lpszFormat) noexcept {
// Registered clipboard format values are 0xC000 through 0xFFFF.
// RegisterClipboardFormat() returns 32-bit unsigned and CLIPFORMAT is 16-bit
// unsigned so choose the low 16-bits with &.
return static_cast<CLIPFORMAT>(::RegisterClipboardFormat(lpszFormat));
}

#if 0
inline void LazyGetClipboardFormat(UINT &fmt, LPCWSTR name) noexcept {
if (fmt == 0) {
fmt = ::RegisterClipboardFormat(name);
}
}
#endif

}

namespace Scintilla::Internal {
Expand Down Expand Up @@ -420,9 +415,9 @@ class ScintillaWin final :
HRGN hRgnUpdate {};

CLIPFORMAT cfColumnSelect;
UINT cfBorlandIDEBlockType;
UINT cfLineSelect;
UINT cfVSLineTag;
CLIPFORMAT cfBorlandIDEBlockType;
CLIPFORMAT cfLineSelect;
CLIPFORMAT cfVSLineTag;

#if EnableDrop_VisualStudioProjectItem
CLIPFORMAT cfVSStgProjectItem;
Expand Down Expand Up @@ -665,22 +660,22 @@ ScintillaWin::ScintillaWin(HWND hwnd) noexcept {

// There does not seem to be a real standard for indicating that the clipboard
// contains a rectangular selection, so copy Developer Studio and Borland Delphi.
cfColumnSelect = GetClipboardFormat(L"MSDEVColumnSelect");
cfBorlandIDEBlockType = ::RegisterClipboardFormat(L"Borland IDE Block Type");
cfColumnSelect = RegisterClipboardType(L"MSDEVColumnSelect");
cfBorlandIDEBlockType = RegisterClipboardType(L"Borland IDE Block Type");

// Likewise for line-copy (copies a full line when no text is selected)
cfLineSelect = ::RegisterClipboardFormat(L"MSDEVLineSelect");
cfVSLineTag = ::RegisterClipboardFormat(L"VisualStudioEditorOperationsLineCutCopyClipboardTag");
cfLineSelect = RegisterClipboardType(L"MSDEVLineSelect");
cfVSLineTag = RegisterClipboardType(L"VisualStudioEditorOperationsLineCutCopyClipboardTag");

#if EnableDrop_VisualStudioProjectItem
cfVSStgProjectItem = GetClipboardFormat(L"CF_VSSTGPROJECTITEMS");
cfVSRefProjectItem = GetClipboardFormat(L"CF_VSREFPROJECTITEMS");
cfVSStgProjectItem = RegisterClipboardType(L"CF_VSSTGPROJECTITEMS");
cfVSRefProjectItem = RegisterClipboardType(L"CF_VSREFPROJECTITEMS");
#endif
#if Enable_ChromiumWebCustomMIMEDataFormat
cfChromiumCustomMIME = GetClipboardFormat(L"Chromium Web Custom MIME Data Format");
cfChromiumCustomMIME = RegisterClipboardType(L"Chromium Web Custom MIME Data Format");
#endif
#if DebugCopyAsRichTextFormat
cfRTF = GetClipboardFormat(L"Rich Text Format");
cfRTF = RegisterClipboardType(L"Rich Text Format");
#endif

UINT index = 0;
Expand Down Expand Up @@ -3736,7 +3731,7 @@ const char* GetStorageMediumType(DWORD tymed) noexcept {
}

const char* GetSourceFormatName(UINT fmt, char name[], int cchName) noexcept {
const int len = GetClipboardFormatNameA(fmt, name, cchName);
const int len = RegisterClipboardTypeNameA(fmt, name, cchName);
if (len <= 0) {
switch (fmt) {
case CF_TEXT:
Expand Down
4 changes: 2 additions & 2 deletions version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git clone https://github.com/XhmikosR/notepad2-mod.git
Scintilla (upstream)
hg clone http://hg.code.sf.net/p/scintilla/code scintilla
5.4.1
2023-12-26 9467:9104a12e97a9
2023-12-30 9474:8149e116262d

Lexilla (upstream)
git clone https://github.com/ScintillaOrg/lexilla.git
Expand All @@ -15,7 +15,7 @@ git clone https://github.com/ScintillaOrg/lexilla.git
SciTE (upstream)
hg clone http://hg.code.sf.net/p/scintilla/scite
5.4.1
2023-12-26 6240:f81defa8898a
2023-12-27 6241:d6037a19b287

init submodule:
git submodule init
Expand Down

0 comments on commit aa16556

Please sign in to comment.