Skip to content

Commit

Permalink
Merge BME_EDIT_BOOKMARKNEXT and BME_EDIT_BOOKMARKPREV cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Oct 13, 2024
1 parent 8d1ce64 commit 81b5c06
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions src/Notepad4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3725,34 +3725,23 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) {
break;

// Main Bookmark Functions
case BME_EDIT_BOOKMARKNEXT: {
const Sci_Position iPos = SciCall_GetCurrentPos();
const Sci_Line iLine = SciCall_LineFromPosition(iPos);

Sci_Line iNextLine = SciCall_MarkerNext(iLine + 1, MarkerBitmask_Bookmark);
if (iNextLine < 0) {
iNextLine = SciCall_MarkerNext(0, MarkerBitmask_Bookmark);
}

if (iNextLine >= 0) {
editMarkAll.ignoreSelectionUpdate = true;
SciCall_EnsureVisible(iNextLine);
SciCall_GotoLine(iNextLine);
SciCall_SetYCaretPolicy(CARET_SLOP | CARET_STRICT | CARET_EVEN, 10);
SciCall_ScrollCaret();
SciCall_SetYCaretPolicy(CARET_EVEN, 0);
}
}
break;

case BME_EDIT_BOOKMARKNEXT:
case BME_EDIT_BOOKMARKPREV: {
const Sci_Position iPos = SciCall_GetCurrentPos();
const Sci_Line iLine = SciCall_LineFromPosition(iPos);

Sci_Line iNextLine = SciCall_MarkerPrevious(iLine - 1, MarkerBitmask_Bookmark);
if (iNextLine < 0) {
const Sci_Line nLines = SciCall_GetLineCount();
iNextLine = SciCall_MarkerPrevious(nLines, MarkerBitmask_Bookmark);
Sci_Line iNextLine;
if (LOWORD(wParam) == BME_EDIT_BOOKMARKNEXT) {
iNextLine = SciCall_MarkerNext(iLine + 1, MarkerBitmask_Bookmark);
if (iNextLine < 0) {
iNextLine = SciCall_MarkerNext(0, MarkerBitmask_Bookmark);
}
} else {
iNextLine = SciCall_MarkerPrevious(iLine - 1, MarkerBitmask_Bookmark);
if (iNextLine < 0) {
const Sci_Line iLines = SciCall_GetLineCount();
iNextLine = SciCall_MarkerPrevious(iLines, MarkerBitmask_Bookmark);
}
}

if (iNextLine >= 0) {
Expand Down

0 comments on commit 81b5c06

Please sign in to comment.