From 874d5605c43f8a9010985da8bd157d8f8db4d3c9 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 9 Jun 2013 08:52:15 +0000 Subject: [PATCH] [NEW_FEATURE] (Author: Andreas Jonsson) Add Begin/End Select feature. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1057 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.rc | 15 ++++++++------- PowerEditor/src/NppCommands.cpp | 6 ++++++ PowerEditor/src/Parameters.cpp | 1 + .../src/ScitillaComponent/ScintillaEditView.cpp | 15 ++++++++++++++- .../src/ScitillaComponent/ScintillaEditView.h | 6 +++++- PowerEditor/src/contextMenu.xml | 1 + PowerEditor/src/menuCmdID.h | 1 + PowerEditor/src/resource.h | 6 +++--- 8 files changed, 39 insertions(+), 12 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 4cf4c4b4..78a96ad4 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -223,14 +223,15 @@ BEGIN POPUP "&Edit" BEGIN - MENUITEM "&Undo", IDM_EDIT_UNDO - MENUITEM "&Redo", IDM_EDIT_REDO + MENUITEM "&Undo", IDM_EDIT_UNDO + MENUITEM "&Redo", IDM_EDIT_REDO MENUITEM SEPARATOR - MENUITEM "Cu&t", IDM_EDIT_CUT - MENUITEM "&Copy", IDM_EDIT_COPY - MENUITEM "&Paste", IDM_EDIT_PASTE - MENUITEM "&Delete", IDM_EDIT_DELETE - MENUITEM "Select A&ll", IDM_EDIT_SELECTALL + MENUITEM "Cu&t", IDM_EDIT_CUT + MENUITEM "&Copy", IDM_EDIT_COPY + MENUITEM "&Paste", IDM_EDIT_PASTE + MENUITEM "&Delete", IDM_EDIT_DELETE + MENUITEM "Select A&ll", IDM_EDIT_SELECTALL + MENUITEM "Begin/End Select", IDM_EDIT_BEGINENDSELECT MENUITEM SEPARATOR POPUP "Copy to Clipboard" BEGIN diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index b8386977..ccc57118 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -309,6 +309,12 @@ void Notepad_plus::command(int id) } break; + case IDM_EDIT_BEGINENDSELECT: + { + _pEditView->beginOrEndSelect(); + } + break; + case IDM_EDIT_CHAR_PANEL: { launchAnsiCharPanel(); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index de818d1a..5b709332 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -106,6 +106,7 @@ WinMenuKeyDefinition winKeyDefs[] = { {VK_NULL, IDM_EDIT_TAB2SW, false, false, false, NULL}, {VK_NULL, IDM_EDIT_SW2TAB_ALL, false, false, false, NULL}, {VK_NULL, IDM_EDIT_SW2TAB_LEADING, false, false, false, NULL}, + {VK_NULL, IDM_EDIT_BEGINENDSELECT, false, false, false, NULL}, {VK_C, IDM_EDIT_COLUMNMODE, false, true, false, NULL}, {VK_U, IDM_EDIT_UPPERCASE, true, false, true, NULL}, diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index df50d83e..e99d9d2d 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2043,7 +2043,20 @@ void ScintillaEditView::addText(int length, const char *buf) { execute(SCI_ADDTEXT, length, (LPARAM)buf); } - + +void ScintillaEditView::beginOrEndSelect() +{ + if(_beginSelectPosition == -1) + { + _beginSelectPosition = execute(SCI_GETCURRENTPOS); + } + else + { + execute(SCI_SETANCHOR, (WPARAM)_beginSelectPosition); + _beginSelectPosition = -1; + } +} + void ScintillaEditView::marginClick(int position, int modifiers) { int lineClick = int(execute(SCI_LINEFROMPOSITION, position, 0)); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index ed51e7a9..556ebf23 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -203,7 +203,7 @@ friend class Finder; public: ScintillaEditView() : Window(), _pScintillaFunc(NULL),_pScintillaPtr(NULL), - _lineNumbersShown(false), _wrapRestoreNeeded(false) + _lineNumbersShown(false), _wrapRestoreNeeded(false), _beginSelectPosition(-1) { ++_refCount; }; @@ -277,6 +277,8 @@ public: void saveCurrentFold(); void restoreCurrentFold(); + void beginOrEndSelect(); + int getCurrentDocLen() const { return int(execute(SCI_GETLENGTH)); }; @@ -676,6 +678,8 @@ protected: typedef std::map BufferStyleMap; BufferStyleMap _hotspotStyles; + int _beginSelectPosition; + //Lexers and Styling void restyleBuffer(); const char * getCompleteKeywordList(std::basic_string & kwl, LangType langType, int keywordIndex); diff --git a/PowerEditor/src/contextMenu.xml b/PowerEditor/src/contextMenu.xml index f42c1806..58f8341a 100644 --- a/PowerEditor/src/contextMenu.xml +++ b/PowerEditor/src/contextMenu.xml @@ -18,6 +18,7 @@ http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Context_Menu + diff --git a/PowerEditor/src/menuCmdID.h b/PowerEditor/src/menuCmdID.h index fa5fecc1..30d44bc9 100644 --- a/PowerEditor/src/menuCmdID.h +++ b/PowerEditor/src/menuCmdID.h @@ -62,6 +62,7 @@ #define IDM_EDIT_PASTE (IDM_EDIT + 5) #define IDM_EDIT_DELETE (IDM_EDIT + 6) #define IDM_EDIT_SELECTALL (IDM_EDIT + 7) + #define IDM_EDIT_BEGINENDSELECT (IDM_EDIT + 20) #define IDM_EDIT_INS_TAB (IDM_EDIT + 8) #define IDM_EDIT_RMV_TAB (IDM_EDIT + 9) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 17f60807..b0eb61be 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -29,12 +29,12 @@ #ifndef RESOURCE_H #define RESOURCE_H -#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v6.3.3") +#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v6.4") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 // ex : #define VERSION_VALUE TEXT("5.63\0") -#define VERSION_VALUE TEXT("6.33\0") -#define VERSION_DIGITALVALUE 6, 3, 3, 0 +#define VERSION_VALUE TEXT("6.4\0") +#define VERSION_DIGITALVALUE 6, 4, 0, 0 #ifdef UNICODE #define UNICODE_ANSI_MODE TEXT("(UNICODE)")