From 851284d90e2f5ab870e76729c5202c288722bfa9 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 23 May 2011 00:51:13 +0000 Subject: [PATCH] [ENHANCE] enhance AnsiCharactersInsertion feature. [UPDATE] Implementation of document switcher is in progress. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@761 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nativeLang/french.xml | 4 +- PowerEditor/src/NppBigSwitch.cpp | 3 + PowerEditor/src/NppCommands.cpp | 4 +- .../WinControls/AnsiCharPanel/ListView.cpp | 2 +- .../AnsiCharPanel/ansiCharPanel.cpp | 84 ++++++++++++------- .../WinControls/AnsiCharPanel/ansiCharPanel.h | 1 + .../VerticalFileSwitcher.cpp | 35 ++++++-- .../VerticalFileSwitcher.h | 2 + .../VerticalFileSwitcher.rc | 2 +- .../VerticalFileSwitcherListView.cpp | 8 +- .../VerticalFileSwitcherListView.h | 3 + 11 files changed, 103 insertions(+), 45 deletions(-) diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index c15b7bc3..96d94c83 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -22,7 +22,7 @@ - + @@ -249,7 +249,7 @@ - + diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 773d206c..61092c26 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -706,6 +706,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa TaskListInfo * tli = (TaskListInfo *)wParam; getTaskListInfo(tli); + if (lParam != 0) + return TRUE; + if (NppParameters::getInstance()->getNppGUI()._styleMRU) { tli->_currentIndex = 0; diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d1b834cb..443c80e1 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -50,8 +50,8 @@ void Notepad_plus::command(int id) case IDM_FILE_OPEN: { - fileOpen(); - //launchFileSwitcherPanel(); + //fileOpen(); + launchFileSwitcherPanel(); } break; diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp index f58c82ed..406b46f1 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp @@ -32,7 +32,7 @@ void ListView::init(HINSTANCE hInst, HWND parent) // Create the list-view window in report view with label editing enabled. int listViewStyles = LVS_REPORT | LVS_NOSORTHEADER\ | LVS_SINGLESEL | LVS_AUTOARRANGE\ - | LVS_SHAREIMAGELISTS; + | LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS; _hSelf = ::CreateWindow(WC_LISTVIEW, TEXT(""), diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp index bc426961..f5994dc3 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp @@ -47,44 +47,36 @@ BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa { case NM_DBLCLK: { - //printStr(TEXT("OK")); LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int i = lpnmitem->iItem; if (i == -1) return TRUE; - char charStr[2]; - charStr[0] = (unsigned char)i; - charStr[1] = '\0'; - wchar_t wCharStr[10]; - char multiByteStr[10]; - int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); - if (codepage == -1) - { - bool isUnicode = ((*_ppEditView)->execute(SCI_GETCODEPAGE) == SC_CP_UTF8); - if (isUnicode) - { - MultiByteToWideChar(0, 0, charStr, -1, wCharStr, sizeof(wCharStr)); - WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); - } - else // ANSI - { - multiByteStr[0] = charStr[0]; - multiByteStr[1] = charStr[1]; - } - } - else - { - MultiByteToWideChar(codepage, 0, charStr, -1, wCharStr, sizeof(wCharStr)); - WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); - } - (*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)""); - int len = (i < 128)?1:strlen(multiByteStr); - (*_ppEditView)->execute(SCI_ADDTEXT, len, (LPARAM)multiByteStr); - + insertChar((unsigned char)i); return TRUE; } + + case LVN_KEYDOWN: + { + switch (((LPNMLVKEYDOWN)lParam)->wVKey) + { + case VK_RETURN: + { + int i = ListView_GetSelectionMark(_listView.getHSelf()); + + if (i == -1) + return TRUE; + + insertChar((unsigned char)i); + return TRUE; + } + default: + break; + } + } + break; + default: break; } @@ -104,3 +96,35 @@ BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa } return DockingDlgInterface::run_dlgProc(message, wParam, lParam); } + +void AnsiCharPanel::insertChar(unsigned char char2insert) const +{ + char charStr[2]; + charStr[0] = char2insert; + charStr[1] = '\0'; + wchar_t wCharStr[10]; + char multiByteStr[10]; + int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); + if (codepage == -1) + { + bool isUnicode = ((*_ppEditView)->execute(SCI_GETCODEPAGE) == SC_CP_UTF8); + if (isUnicode) + { + MultiByteToWideChar(0, 0, charStr, -1, wCharStr, sizeof(wCharStr)); + WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); + } + else // ANSI + { + multiByteStr[0] = charStr[0]; + multiByteStr[1] = charStr[1]; + } + } + else + { + MultiByteToWideChar(codepage, 0, charStr, -1, wCharStr, sizeof(wCharStr)); + WideCharToMultiByte(CP_UTF8, 0, wCharStr, -1, multiByteStr, sizeof(multiByteStr), NULL, NULL); + } + (*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)""); + int len = (char2insert < 128)?1:strlen(multiByteStr); + (*_ppEditView)->execute(SCI_ADDTEXT, len, (LPARAM)multiByteStr); +} \ No newline at end of file diff --git a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h index 490d12de..639788c8 100644 --- a/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h +++ b/PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.h @@ -48,6 +48,7 @@ public: }; void switchEncoding(); + void insertChar(unsigned char char2insert) const; protected: virtual BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 3799b9ca..38a00be5 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -45,15 +45,31 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA if (i == -1) return TRUE; -//printInt(i); -//printStr(TEXT("OK")); - - int view2set = _fileListView.getViewInfoFromIndex(i); - int index2Switch = _fileListView.getDocIndexInfoFromIndex(i); - ::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch); + activateDoc(i); return TRUE; } + + case LVN_KEYDOWN: + { + switch (((LPNMLVKEYDOWN)lParam)->wVKey) + { + case VK_RETURN: + { + int i = ListView_GetSelectionMark(_fileListView.getHSelf()); + + if (i == -1) + return TRUE; + + activateDoc(i); + return TRUE; + } + default: + break; + } + } + break; + default: break; } @@ -73,3 +89,10 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA } return DockingDlgInterface::run_dlgProc(message, wParam, lParam); } + +void VerticalFileSwitcher::activateDoc(int i) const +{ + int view2set = _fileListView.getViewInfoFromIndex(i); + int index2Switch = _fileListView.getDocIndexInfoFromIndex(i); + ::SendMessage(_hParent, NPPM_ACTIVATEDOC, view2set, index2Switch); +} \ No newline at end of file diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h index 2d3b0133..a5331b54 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.h @@ -45,6 +45,8 @@ public: _hParent = parent2set; }; + void activateDoc(int i) const; + protected: virtual BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.rc b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.rc index b160baf6..d237b001 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.rc +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.rc @@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. IDD_FILESWITCHER_PANEL DIALOGEX 26, 41, 142, 324 STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE -CAPTION "File Switcher" +CAPTION "Doc Switcher" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN //LISTBOX IDC_LIST_FILESWITCHER,50,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index 7c0c564d..36e55f44 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -32,7 +32,7 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST // Create the list-view window in report view with label editing enabled. int listViewStyles = LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER\ | LVS_SINGLESEL | LVS_AUTOARRANGE\ - | LVS_SHAREIMAGELISTS /*| WS_BORDER*/; + | LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS; _hSelf = ::CreateWindow(WC_LISTVIEW, TEXT(""), @@ -52,10 +52,12 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this); _defaultProc = reinterpret_cast(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc)); - +/* DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf); exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ; ListView_SetExtendedListViewStyle(_hSelf, exStyle); +*/ + ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT); LVCOLUMN lvColumn; lvColumn.mask = LVCF_WIDTH; @@ -84,7 +86,7 @@ LRESULT VerticalFileSwitcherListView::runProc(HWND hwnd, UINT Message, WPARAM wP void VerticalFileSwitcherListView::initList() { - ::SendMessage(::GetParent(_hParent), WM_GETTASKLISTINFO, (WPARAM)&_taskListInfo, 0); + ::SendMessage(::GetParent(_hParent), WM_GETTASKLISTINFO, (WPARAM)&_taskListInfo, TRUE); for (size_t i = 0 ; i < _taskListInfo._tlfsLst.size() ; i++) { TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[i]; diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h index 5651c7eb..a2bdfa3a 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.h @@ -32,6 +32,9 @@ public: void initList(); int getViewInfoFromIndex(int index) const; int getDocIndexInfoFromIndex(int index) const; + void setBgColour(int i) { + ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF); + } protected: TaskListInfo _taskListInfo;