From fa82ca0224144fde50890f22e5a5f1e6424ce529 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 15 Dec 2023 19:44:15 +0100 Subject: [PATCH] Add document tab "Move to Start" & "Move to End" commands Fix #13982, fix #9525 --- PowerEditor/src/Notepad_plus.rc | 3 +++ PowerEditor/src/NppCommands.cpp | 13 +++++++++++ PowerEditor/src/NppNotification.cpp | 3 +++ PowerEditor/src/Parameters.cpp | 2 ++ PowerEditor/src/WinControls/TabBar/TabBar.cpp | 23 +++++++++++++++++++ PowerEditor/src/WinControls/TabBar/TabBar.h | 12 +++------- .../src/WinControls/shortcut/shortcut.cpp | 2 +- PowerEditor/src/menuCmdID.h | 3 ++- 8 files changed, 50 insertions(+), 11 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index e7fc93a4f..72a1a17d8 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -708,6 +708,9 @@ BEGIN END POPUP "Move/Clone Current Document" BEGIN + MENUITEM "Move to Start", IDM_VIEW_GOTO_START + MENUITEM "Move to End", IDM_VIEW_GOTO_END + MENUITEM SEPARATOR MENUITEM "Move to Other View", IDM_VIEW_GOTO_ANOTHER_VIEW MENUITEM "Clone to Other View", IDM_VIEW_CLONE_TO_ANOTHER_VIEW MENUITEM "Move to New Instance", IDM_VIEW_GOTO_NEW_INSTANCE diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d3b0ebdca..0c6098d25 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3239,6 +3239,14 @@ void Notepad_plus::command(int id) break; } + case IDM_VIEW_GOTO_START: + _pDocTab->currentTabToStart(); + break; + + case IDM_VIEW_GOTO_END: + _pDocTab->currentTabToEnd(); + break; + case IDM_VIEW_GOTO_ANOTHER_VIEW: docGotoAnotherEditView(TransferMove); checkSyncState(); @@ -4258,7 +4266,12 @@ void Notepad_plus::command(int id) case IDM_VIEW_UNFOLD_6: case IDM_VIEW_UNFOLD_7: case IDM_VIEW_UNFOLD_8: + case IDM_VIEW_GOTO_START: + case IDM_VIEW_GOTO_END: case IDM_VIEW_GOTO_ANOTHER_VIEW: + case IDM_VIEW_CLONE_TO_ANOTHER_VIEW: + case IDM_VIEW_GOTO_NEW_INSTANCE: + case IDM_VIEW_LOAD_IN_NEW_INSTANCE: case IDM_VIEW_SYNSCROLLV: case IDM_VIEW_SYNSCROLLH: case IDM_VIEW_TAB1: diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 41bccc5ff..6e9e314c2 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -552,6 +552,9 @@ BOOL Notepad_plus::notify(SCNotification *notification) itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FULLPATHTOCLIP, TEXT("Copy Full File Path"), TEXT("Copy to Clipboard"))); itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_FILENAMETOCLIP, TEXT("Copy Filename"), TEXT("Copy to Clipboard"))); itemUnitArray.push_back(MenuItemUnit(IDM_EDIT_CURRENTDIRTOCLIP, TEXT("Copy Current Dir. Path"), TEXT("Copy to Clipboard"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_START, TEXT("Move to Start"), TEXT("Move Document"))); + itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_END, TEXT("Move to End"), TEXT("Move Document"))); + itemUnitArray.push_back(MenuItemUnit(0, NULL, TEXT("Move Document"))); itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, TEXT("Move to Other View"), TEXT("Move Document"))); itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, TEXT("Clone to Other View"), TEXT("Move Document"))); itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_NEW_INSTANCE, TEXT("Move to New Instance"), TEXT("Move Document"))); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 7fb5eb390..3b7212ab3 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -280,6 +280,8 @@ static const WinMenuKeyDefinition winKeyDefs[] = // { VK_NULL, IDM_VIEW_ZOOMIN, false, false, false, nullptr }, // { VK_NULL, IDM_VIEW_ZOOMOUT, false, false, false, nullptr }, // { VK_NULL, IDM_VIEW_ZOOMRESTORE, false, false, false, nullptr }, + { VK_NULL, IDM_VIEW_GOTO_START, false, false, false, nullptr }, + { VK_NULL, IDM_VIEW_GOTO_END, false, false, false, nullptr }, { VK_NULL, IDM_VIEW_GOTO_ANOTHER_VIEW, false, false, false, nullptr }, { VK_NULL, IDM_VIEW_CLONE_TO_ANOTHER_VIEW, false, false, false, nullptr }, { VK_NULL, IDM_VIEW_GOTO_NEW_INSTANCE, false, false, false, nullptr }, diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 156f78478..3dbafb12d 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -404,6 +404,29 @@ void TabBarPlus::setColour(COLORREF colour2Set, tabColourIndex i) doOwnerDrawTab(); } +void TabBarPlus::currentTabToStart() +{ + int currentTabIndex = getCurrentTabIndex(); + if (currentTabIndex <= 0) + return; + + for (int i = currentTabIndex, j = currentTabIndex - 1; j >= 0; --i, --j) + { + exchangeTabItemData(i, j); + } +} + +void TabBarPlus::currentTabToEnd() +{ + int currentTabIndex = getCurrentTabIndex(); + if (currentTabIndex >= _nbItem) + return; + + for (int i = currentTabIndex, j = currentTabIndex + 1; j < _nbItem; ++i, ++j) + { + exchangeTabItemData(i, j); + } +} void TabBarPlus::doVertical() { diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index cc1a29b6a..841798e63 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -159,14 +159,6 @@ public : return _doDragNDrop; }; - int getSrcTabIndex() const { - return _nSrcTab; - }; - - int getTabDraggedIndex() const { - return _nTabDragged; - }; - POINT getDraggingPoint() const { return _draggingPoint; }; @@ -217,9 +209,11 @@ public : } static void setColour(COLORREF colour2Set, tabColourIndex i); - virtual int getIndividualTabColour(int tabIndex) = 0; + void currentTabToStart(); + void currentTabToEnd(); + protected: // it's the boss to decide if we do the drag N drop static bool _doDragNDrop; diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 2402d6d15..b57456153 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -1230,7 +1230,7 @@ void CommandShortcut::setCategoryFromMenu(HMENU hMenu) if (_id >= IDM_WINDOW_WINDOWS && _id <= IDM_WINDOW_SORT_FS_DSC) pNativeSpeaker->getMainMenuEntryName(_category, hMenu, "Window", L"Window"); - else if ( _id >= IDM_VIEW_GOTO_ANOTHER_VIEW && _id <= IDM_VIEW_LOAD_IN_NEW_INSTANCE) + else if ( _id >= IDM_VIEW_GOTO_ANOTHER_VIEW && _id <= IDM_VIEW_GOTO_END) pNativeSpeaker->getMainMenuEntryName(_category, hMenu, "view", L"View"); else if (_id == IDM_EDIT_LTR || _id == IDM_EDIT_RTL) pNativeSpeaker->getMainMenuEntryName(_category, hMenu, "view", L"View"); diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index 3af033f29..c6361252c 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -396,7 +396,8 @@ #define IDM_VIEW_CLONE_TO_ANOTHER_VIEW 10002 #define IDM_VIEW_GOTO_NEW_INSTANCE 10003 #define IDM_VIEW_LOAD_IN_NEW_INSTANCE 10004 - + #define IDM_VIEW_GOTO_START 10005 + #define IDM_VIEW_GOTO_END 10006 #define IDM_FORMAT (IDM + 5000) #define IDM_FORMAT_TODOS (IDM_FORMAT + 1)