[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
This commit is contained in:
Don Ho 2011-05-23 00:51:13 +00:00
parent 1309f8fa8e
commit 851284d90e
11 changed files with 103 additions and 45 deletions

View File

@ -22,7 +22,7 @@
<SubEntries> <SubEntries>
<Item posX="1" posY="9" name="Copier dans le presse-papiers"/> <Item posX="1" posY="9" name="Copier dans le presse-papiers"/>
<Item posX="1" posY="10" name="Indentation"/> <Item posX="1" posY="10" name="Indentation"/>
<Item posX="1" posY="11" name="MAJUSCULE/minuscule"/> <Item posX="1" posY="11" name="MAJUSCULE/miniscule"/>
<Item posX="1" posY="12" name="Ligne"/> <Item posX="1" posY="12" name="Ligne"/>
<Item posX="1" posY="13" name="Commentaire"/> <Item posX="1" posY="13" name="Commentaire"/>
<Item posX="1" posY="14" name="Autocomplétion"/> <Item posX="1" posY="14" name="Autocomplétion"/>
@ -249,7 +249,7 @@
</Menu> </Menu>
<Dialog> <Dialog>
<Find title="" titleFind="Rechercher" titleReplace="Remplacer" titleFindInFiles="Rechercher dans les fichiers d'un dossier"> <Find title="" titleFind="Rechercher" titleReplace="Remplacer" titleFindInFiles="Rechercher dans les fichiers d'un dossier" titleMark="Marquer">
<Item id="1" name="Suivant"/> <Item id="1" name="Suivant"/>
<Item id="2" name="Annuler"/> <Item id="2" name="Annuler"/>
<Item id="1620" name="Recherche :"/> <Item id="1620" name="Recherche :"/>

View File

@ -706,6 +706,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
TaskListInfo * tli = (TaskListInfo *)wParam; TaskListInfo * tli = (TaskListInfo *)wParam;
getTaskListInfo(tli); getTaskListInfo(tli);
if (lParam != 0)
return TRUE;
if (NppParameters::getInstance()->getNppGUI()._styleMRU) if (NppParameters::getInstance()->getNppGUI()._styleMRU)
{ {
tli->_currentIndex = 0; tli->_currentIndex = 0;

View File

@ -50,8 +50,8 @@ void Notepad_plus::command(int id)
case IDM_FILE_OPEN: case IDM_FILE_OPEN:
{ {
fileOpen(); //fileOpen();
//launchFileSwitcherPanel(); launchFileSwitcherPanel();
} }
break; break;

View File

@ -32,7 +32,7 @@ void ListView::init(HINSTANCE hInst, HWND parent)
// Create the list-view window in report view with label editing enabled. // Create the list-view window in report view with label editing enabled.
int listViewStyles = LVS_REPORT | LVS_NOSORTHEADER\ int listViewStyles = LVS_REPORT | LVS_NOSORTHEADER\
| LVS_SINGLESEL | LVS_AUTOARRANGE\ | LVS_SINGLESEL | LVS_AUTOARRANGE\
| LVS_SHAREIMAGELISTS; | LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS;
_hSelf = ::CreateWindow(WC_LISTVIEW, _hSelf = ::CreateWindow(WC_LISTVIEW,
TEXT(""), TEXT(""),

View File

@ -47,44 +47,36 @@ BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
{ {
case NM_DBLCLK: case NM_DBLCLK:
{ {
//printStr(TEXT("OK"));
LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
int i = lpnmitem->iItem; int i = lpnmitem->iItem;
if (i == -1) if (i == -1)
return TRUE; return TRUE;
char charStr[2]; insertChar((unsigned char)i);
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);
return TRUE; 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: default:
break; break;
} }
@ -104,3 +96,35 @@ BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
} }
return DockingDlgInterface::run_dlgProc(message, wParam, lParam); 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);
}

View File

@ -48,6 +48,7 @@ public:
}; };
void switchEncoding(); void switchEncoding();
void insertChar(unsigned char char2insert) const;
protected: protected:
virtual BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);

View File

@ -45,15 +45,31 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
if (i == -1) if (i == -1)
return TRUE; 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; 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: default:
break; break;
} }
@ -73,3 +89,10 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA
} }
return DockingDlgInterface::run_dlgProc(message, wParam, lParam); 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);
}

View File

@ -45,6 +45,8 @@ public:
_hParent = parent2set; _hParent = parent2set;
}; };
void activateDoc(int i) const;
protected: protected:
virtual BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);

View File

@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
IDD_FILESWITCHER_PANEL DIALOGEX 26, 41, 142, 324 IDD_FILESWITCHER_PANEL DIALOGEX 26, 41, 142, 324
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "File Switcher" CAPTION "Doc Switcher"
FONT 8, "MS Sans Serif", 0, 0, 0x0 FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN BEGIN
//LISTBOX IDC_LIST_FILESWITCHER,50,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP //LISTBOX IDC_LIST_FILESWITCHER,50,44,78,120,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP

View File

@ -32,7 +32,7 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST
// Create the list-view window in report view with label editing enabled. // Create the list-view window in report view with label editing enabled.
int listViewStyles = LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER\ int listViewStyles = LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER\
| LVS_SINGLESEL | LVS_AUTOARRANGE\ | LVS_SINGLESEL | LVS_AUTOARRANGE\
| LVS_SHAREIMAGELISTS /*| WS_BORDER*/; | LVS_SHAREIMAGELISTS | LVS_SHOWSELALWAYS;
_hSelf = ::CreateWindow(WC_LISTVIEW, _hSelf = ::CreateWindow(WC_LISTVIEW,
TEXT(""), TEXT(""),
@ -52,10 +52,12 @@ void VerticalFileSwitcherListView::init(HINSTANCE hInst, HWND parent, HIMAGELIST
::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this); ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR)this);
_defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc)); _defaultProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSelf, GWLP_WNDPROC, (LONG_PTR)staticProc));
/*
DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf); DWORD exStyle = ListView_GetExtendedListViewStyle(_hSelf);
exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ; exStyle |= LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT ;
ListView_SetExtendedListViewStyle(_hSelf, exStyle); ListView_SetExtendedListViewStyle(_hSelf, exStyle);
*/
ListView_SetExtendedListViewStyle(_hSelf, LVS_EX_FULLROWSELECT | LVS_EX_BORDERSELECT);
LVCOLUMN lvColumn; LVCOLUMN lvColumn;
lvColumn.mask = LVCF_WIDTH; lvColumn.mask = LVCF_WIDTH;
@ -84,7 +86,7 @@ LRESULT VerticalFileSwitcherListView::runProc(HWND hwnd, UINT Message, WPARAM wP
void VerticalFileSwitcherListView::initList() 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++) for (size_t i = 0 ; i < _taskListInfo._tlfsLst.size() ; i++)
{ {
TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[i]; TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[i];

View File

@ -32,6 +32,9 @@ public:
void initList(); void initList();
int getViewInfoFromIndex(int index) const; int getViewInfoFromIndex(int index) const;
int getDocIndexInfoFromIndex(int index) const; int getDocIndexInfoFromIndex(int index) const;
void setBgColour(int i) {
ListView_SetItemState(_hSelf, i, LVIS_SELECTED|LVIS_FOCUSED, 0xFF);
}
protected: protected:
TaskListInfo _taskListInfo; TaskListInfo _taskListInfo;