From d8d5ce965fcb6c7b4ec62a1ff8651fbb21f4299a Mon Sep 17 00:00:00 2001 From: donho Date: Fri, 2 May 2008 14:35:10 +0000 Subject: [PATCH] [] Add "CURRENT_LINE" and "CURRENT_COLUMN" environment variables for run dialog. Add NPPM_GETCURRENTLINE and NPPM_GETCURRENTCOLUMN plugin messages. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@195 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../src/MISC/PluginsManager/Notepad_plus_msgs.h | 10 ++++++++++ PowerEditor/src/Notepad_plus.cpp | 13 ++++++++++--- .../src/WinControls/StaticDialog/RunDlg/RunDlg.cpp | 14 +++++++++++++- .../src/WinControls/StaticDialog/RunDlg/RunDlg.h | 2 ++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index c0a0f680..eea13512 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -233,6 +233,14 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV // The return value is TRUE when get string operation success // Otherwise (allocated array size is too small) FALSE + #define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE) + // INT NPPM_GETCURRENTLINE(0, 0) + // return the caret current position line + #define NPPM_GETCURRENTCOLUMN (RUNCOMMAND_USER + CURRENT_COLUMN) + // INT NPPM_GETCURRENTCOLUMN(0, 0) + // return the caret current position column + + #define VAR_NOT_RECOGNIZED 0 #define FULL_CURRENT_PATH 1 #define CURRENT_DIRECTORY 2 @@ -241,6 +249,8 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV #define EXT_PART 5 #define CURRENT_WORD 6 #define NPP_DIRECTORY 7 + #define CURRENT_LINE 8 + #define CURRENT_COLUMN 9 // Notification code diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index f758baa3..14020121 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2408,9 +2408,6 @@ void Notepad_plus::addHotSpot(bool docIsModifing) vector > hotspotStylers; - //char *regExprStr0 = "http://[a-z0-9_-+.:?=/%]*";//"http://[^ \\t\\\"]*"; - //char *regExprStr1 = "[a-zA-Z0-9._]+@[a-zA-Z0-9_]+.[a-zA-Z0-9_]+"; - int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); while (posFound != -1) @@ -6843,6 +6840,16 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_GETCURRENTLINE : + { + return _pEditView->getCurrentLineNumber(); + } + + case NPPM_GETCURRENTCOLUMN : + { + return _pEditView->getCurrentColumnNumber(); + } + case NPPM_GETCURRENTSCINTILLA : { *((int *)lParam) = (_pEditView == &_mainEditView)?0:1; diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index a26ab882..7a52bdba 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -79,6 +79,11 @@ int whichVar(char *str) return CURRENT_WORD; else if (!strcmp(nppDir, str)) return NPP_DIRECTORY; + else if (!strcmp(currentLine, str)) + return CURRENT_LINE; + else if (!strcmp(currentColumn, str)) + return CURRENT_COLUMN; + return VAR_NOT_RECOGNIZED; } @@ -121,7 +126,14 @@ void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDe else { char expandedStr[256]; - ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, MAX_PATH, (LPARAM)expandedStr); + if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN) + { + int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0); + sprintf(expandedStr, "%d", lineNumber); + } + else + ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, MAX_PATH, (LPARAM)expandedStr); + for (size_t p = 0 ; p < strlen(expandedStr) ; p++) stringDest[j++] = expandedStr[p]; } diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index 8d511b79..c0b2f890 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -33,6 +33,8 @@ const char fileNamePart[] = "NAME_PART"; const char fileExtPart[] = "EXT_PART"; const char currentWord[] = "CURRENT_WORD"; const char nppDir[] = "NPP_DIRECTORY"; +const char currentLine[] = "CURRENT_LINE"; +const char currentColumn[] = "CURRENT_COLUMN"; int whichVar(char *str); void expandNppEnvironmentStrs(const char *strSrc, char *stringDest, size_t strDestLen, HWND hWnd);