Skip to content

Commit

Permalink
Change NotifyParent() to pass value by reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Dec 11, 2024
1 parent 7bdf7e6 commit f827c5b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
43 changes: 20 additions & 23 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5801,8 +5801,10 @@ Sci::Position Editor::GetTag(char *tagValue, int tagNumber) {
const char *text = nullptr;
Sci::Position length = 0;
if ((tagNumber >= 1) && (tagNumber <= 9)) {
char name[3] = "\\?";
char name[3];
name[0] = '\\';
name[1] = static_cast<char>(tagNumber + '0');
name[2] = '\0';
length = 2;
text = pdoc->SubstituteByPosition(name, &length);
}
Expand Down Expand Up @@ -6110,6 +6112,10 @@ constexpr Selection::SelTypes SelTypeFromMode(SelectionMode mode) noexcept {
return static_cast<Selection::SelTypes>(static_cast<int>(mode) + 1);
}

constexpr int SelectionModeFromSelType(Selection::SelTypes selType) noexcept {
return std::max(0, static_cast<int>(selType) - 1);
}

}

void Editor::SetSelectionMode(uptr_t wParam, bool setMoveExtends) {
Expand Down Expand Up @@ -6993,15 +6999,17 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {

case Message::ClearTabStops:
if (view.ClearTabstops(LineFromUPtr(wParam))) {
const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
NotifyModified(pdoc, mh, nullptr);
// const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
// NotifyModified(pdoc, mh, nullptr);
Redraw();
}
break;

case Message::AddTabStop:
if (view.AddTabstop(LineFromUPtr(wParam), static_cast<int>(lParam))) {
const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
NotifyModified(pdoc, mh, nullptr);
// const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
// NotifyModified(pdoc, mh, nullptr);
Redraw();
}
break;

Expand Down Expand Up @@ -7309,9 +7317,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (wParam <= MarkerMax) {
vs.markers[wParam].markType = static_cast<MarkerSymbol>(lParam);
vs.CalcLargestMarkerHeight();
InvalidateStyleData();
RedrawSelMargin();
}
InvalidateStyleData();
RedrawSelMargin();
break;

case Message::MarkerSymbolDefined:
Expand Down Expand Up @@ -7393,9 +7401,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (wParam <= MarkerMax) {
vs.markers[wParam].SetXPM(ConstCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
InvalidateStyleData();
RedrawSelMargin();
}
InvalidateStyleData();
RedrawSelMargin();
break;

case Message::RGBAImageSetWidth:
Expand All @@ -7414,9 +7422,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (wParam <= MarkerMax) {
vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, ConstUCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
InvalidateStyleData();
RedrawSelMargin();
}
InvalidateStyleData();
RedrawSelMargin();
break;

case Message::SetMarginTypeN:
Expand Down Expand Up @@ -8256,18 +8264,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
SetSelectionMode(wParam, false);
break;
case Message::GetSelectionMode:
switch (sel.selType) {
case Selection::SelTypes::stream:
return static_cast<sptr_t>(SelectionMode::Stream);
case Selection::SelTypes::rectangle:
return static_cast<sptr_t>(SelectionMode::Rectangle);
case Selection::SelTypes::lines:
return static_cast<sptr_t>(SelectionMode::Lines);
case Selection::SelTypes::thin:
return static_cast<sptr_t>(SelectionMode::Thin);
default: // ?!
return static_cast<sptr_t>(SelectionMode::Stream);
}
return SelectionModeFromSelType(sel.selType);
case Message::SetMoveExtendsSelection:
sel.SetMoveExtends(wParam != 0);
break;
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class Editor : public EditModel, public DocWatcher {
virtual int GetCtrlID() const noexcept {
return ctrlID;
}
virtual void NotifyParent(Scintilla::NotificationData scn) noexcept = 0;
virtual void NotifyParent(Scintilla::NotificationData &scn) const noexcept = 0;
virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
void NotifyChar(int ch, Scintilla::CharacterSource charSource, bool handled = false) noexcept;
void NotifySavePoint(bool isSavePoint) noexcept;
Expand Down
6 changes: 3 additions & 3 deletions scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ class ScintillaWin final :
void NotifyFocus(bool focus) override;
void SetCtrlID(int identifier) noexcept override;
int GetCtrlID() const noexcept override;
void NotifyParent(NotificationData scn) noexcept override;
void NotifyParent(NotificationData &scn) const noexcept override;
void NotifyDoubleClick(Point pt, KeyMod modifiers) override;
std::unique_ptr<CaseFolder> CaseFolderForEncoding() override;
std::string CaseMapString(const std::string &s, CaseMapping caseMapping) const override;
Expand Down Expand Up @@ -2762,11 +2762,11 @@ int ScintillaWin::GetCtrlID() const noexcept {
return ::GetDlgCtrlID(MainHWND());
}

void ScintillaWin::NotifyParent(NotificationData scn) noexcept {
void ScintillaWin::NotifyParent(NotificationData &scn) const noexcept {
scn.nmhdr.hwndFrom = MainHWND();
scn.nmhdr.idFrom = GetCtrlID();
::SendMessage(::GetParent(MainHWND()), WM_NOTIFY,
GetCtrlID(), AsInteger<LPARAM>(&scn));
scn.nmhdr.idFrom, AsInteger<LPARAM>(&scn));
}

void ScintillaWin::NotifyDoubleClick(Point pt, KeyMod modifiers) {
Expand Down

0 comments on commit f827c5b

Please sign in to comment.