Skip to content

Commit

Permalink
[NEW_FEATURE] Add find characters in range feature.
Browse files Browse the repository at this point in the history
[NEW_FEATURE] Add file switcher (list) dialog (in progress).

- Notepad-plus svn trunk @ 756
  • Loading branch information
donho committed May 19, 2011
1 parent 68c9f0b commit 21b72a7
Show file tree
Hide file tree
Showing 22 changed files with 763 additions and 31 deletions.
57 changes: 44 additions & 13 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "TaskListDlg.h"
#include "xmlMatchedTagsHighlighter.h"
#include "EncodingMapper.h"
#include "ansiCharPanel.h"
#include "clipboardHistoryPanel.h"
#include "VerticalFileSwitcher.h"

enum tb_stat {tb_saved, tb_unsaved, tb_ro};
#define DIR_LEFT true
Expand Down Expand Up @@ -104,7 +107,7 @@ ToolBarButtonUnit toolBarIcons[] = {

Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
_pMainSplitter(NULL),
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false),
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL),
_linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _sysMenuEntering(false),
_autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg),
_isFileOpening(false), _rememberThisSession(true), _pAnsiCharPanel(NULL), _pClipboardHistoryPanel(NULL)
Expand Down Expand Up @@ -150,6 +153,9 @@ Notepad_plus::~Notepad_plus()

if (_pClipboardHistoryPanel)
delete _pClipboardHistoryPanel;

if (_pFileSwitcherPanel)
delete _pFileSwitcherPanel;
}


Expand Down Expand Up @@ -533,6 +539,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_incrementFindDlg.init(_pPublicInterface->getHinst(), hwnd, &_findReplaceDlg, _nativeLangSpeaker.isRTL());
_incrementFindDlg.addToRebar(&_rebarBottom);
_goToLineDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_findCharsInRangeDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_colEditorDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
_aboutDlg.init(_pPublicInterface->getHinst(), hwnd);
_runDlg.init(_pPublicInterface->getHinst(), hwnd);
Expand Down Expand Up @@ -578,12 +585,12 @@ LRESULT Notepad_plus::init(HWND hwnd)

for (size_t i = 0 ; i < dmd._pluginDockInfo.size() ; i++)
{
PlugingDlgDockingInfo & pdi = dmd._pluginDockInfo[i];
PluginDlgDockingInfo & pdi = dmd._pluginDockInfo[i];
if (pdi._isVisible)
{
if (pdi._name == NPP_INTERNAL_FUCTION_STR)
{
::SendMessage(hwnd, WM_COMMAND, pdi._internalID, 0);
_internalFuncIDs.push_back(pdi._internalID);
}
else
{
Expand Down Expand Up @@ -688,7 +695,7 @@ void Notepad_plus::saveDockingParams()
nppGUI._dockingData._containerTabInfo.clear();

// create a vector to save the current information
vector<PlugingDlgDockingInfo> vPluginDockInfo;
vector<PluginDlgDockingInfo> vPluginDockInfo;
vector<FloatingWindowInfo> vFloatingWindowInfo;

// save every container
Expand All @@ -703,7 +710,7 @@ void Notepad_plus::saveDockingParams()
{
if (vDataVis[j]->pszName && vDataVis[j]->pszName[0])
{
PlugingDlgDockingInfo pddi(vDataVis[j]->pszModuleName, vDataVis[j]->dlgID, i, vDataVis[j]->iPrevCont, true);
PluginDlgDockingInfo pddi(vDataVis[j]->pszModuleName, vDataVis[j]->dlgID, i, vDataVis[j]->iPrevCont, true);
vPluginDockInfo.push_back(pddi);
}
}
Expand All @@ -715,7 +722,7 @@ void Notepad_plus::saveDockingParams()
{
if ((vDataAll[j]->pszName && vDataAll[j]->pszName[0]) && (!vCont[i]->isTbVis(vDataAll[j])))
{
PlugingDlgDockingInfo pddi(vDataAll[j]->pszModuleName, vDataAll[j]->dlgID, i, vDataAll[j]->iPrevCont, false);
PluginDlgDockingInfo pddi(vDataAll[j]->pszModuleName, vDataAll[j]->dlgID, i, vDataAll[j]->iPrevCont, false);
vPluginDockInfo.push_back(pddi);
}
}
Expand Down Expand Up @@ -2467,7 +2474,6 @@ int Notepad_plus::wordCount()
{
FindOption env;
env._str2Search = TEXT("[^ \\\\.,;:!?()+\\-\\*/=\\]\\[{}&~\"'`|@$%§<>\\^]+");
//printStr(env._str2Search.c_str());
env._searchType = FindRegex;
return _findReplaceDlg.processAll(ProcessCountAll, &env, true);
}
Expand Down Expand Up @@ -3829,7 +3835,7 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool

for (size_t i = 0 ; i < dockingData._pluginDockInfo.size() ; i++)
{
const PlugingDlgDockingInfo & pddi = dockingData._pluginDockInfo[i];
const PluginDlgDockingInfo & pddi = dockingData._pluginDockInfo[i];

if (!generic_stricmp(pddi._name.c_str(), dockData.pszModuleName) && (pddi._internalID == dockData.dlgID))
{
Expand All @@ -3842,7 +3848,7 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool
int cont = (pddi._currContainer < DOCKCONT_MAX ? pddi._prevContainer : pddi._currContainer);
RECT *pRc = dockingData.getFloatingRCFrom(cont);
if (pRc)
dockData.rcFloat = *pRc;
dockData.rcFloat = *pRc;
}
return true;
}
Expand Down Expand Up @@ -4555,9 +4561,9 @@ bool Notepad_plus::reloadLang()
_nativeLangSpeaker.changeDlgLang(_runMacroDlg.getHSelf(), "MultiMacro");
}

if (_goToLineDlg.isCreated())
if (_findCharsInRangeDlg.isCreated())
{
_nativeLangSpeaker.changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine");
_nativeLangSpeaker.changeDlgLang(_findCharsInRangeDlg.getHSelf(), "FindCharsInRange");
}

if (_colEditorDlg.isCreated())
Expand Down Expand Up @@ -4601,6 +4607,32 @@ void Notepad_plus::launchClipboardHistoryPanel()
_pClipboardHistoryPanel->display();
}

void Notepad_plus::launchFileSwitcherPanel()
{
if (!_pFileSwitcherPanel)
{
_pFileSwitcherPanel = new VerticalFileSwitcher;
HIMAGELIST hImgLst = _docTabIconList.getHandle();
_pFileSwitcherPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), hImgLst);

tTbData data = {0};
_pFileSwitcherPanel->create(&data);

::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pFileSwitcherPanel->getHSelf());
// define the default docking behaviour
data.uMask = DWS_DF_CONT_LEFT | DWS_ICONTAB;
//data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
data.pszModuleName = NPP_INTERNAL_FUCTION_STR;

// the dlgDlg should be the index of funcItem where the current function pointer is
// in this case is DOCKABLE_DEMO_INDEX
// In the case of Notepad++ internal function, it'll be the command ID which triggers this dialog
data.dlgID = IDM_VIEW_FILESWITCHER_PANEL;
::SendMessage(_pPublicInterface->getHSelf(), NPPM_DMMREGASDCKDLG, 0, (LPARAM)&data);
}
_pFileSwitcherPanel->display();
}

void Notepad_plus::launchAnsiCharPanel()
{
if (!_pAnsiCharPanel)
Expand All @@ -4614,7 +4646,7 @@ void Notepad_plus::launchAnsiCharPanel()

::SendMessage(_pPublicInterface->getHSelf(), NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_pAnsiCharPanel->getHSelf());
// define the default docking behaviour
data.uMask = DWS_DF_CONT_RIGHT | DWS_ICONTAB/* | DWS_ADDINFO*/;
data.uMask = DWS_DF_CONT_RIGHT | DWS_ICONTAB;
//data.hIconTab = (HICON)::LoadImage(_pPublicInterface->getHinst(), MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT);
data.pszModuleName = NPP_INTERNAL_FUCTION_STR;

Expand All @@ -4626,4 +4658,3 @@ void Notepad_plus::launchAnsiCharPanel()
}
_pAnsiCharPanel->display();
}

13 changes: 11 additions & 2 deletions PowerEditor/src/Notepad_plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
#include "GoToLineDlg.h"
#endif //GOTILINE_DLG_H

#ifndef FINDCHARSINRANGE_DLG_H
#include "FindCharsInRange.h"
#endif //FINDCHARSINRANGE_DLG_H

#ifndef COLUMNEDITOR_H
#include "columnEditor.h"
#endif //COLUMNEDITOR_H
Expand Down Expand Up @@ -111,8 +115,7 @@
#endif //SIZE_DLG_H

#include "localization.h"
#include "ansiCharPanel.h"
#include "clipboardHistoryPanel.h"


#define MENU 0x01
#define TOOLBAR 0x02
Expand Down Expand Up @@ -168,6 +171,8 @@ struct VisibleGUIConf {
class FileDialog;
class Notepad_plus_Window;
class AnsiCharPanel;
class ClipboardHistoryPanel;
class VerticalFileSwitcher;

class Notepad_plus {

Expand Down Expand Up @@ -278,6 +283,7 @@ friend class Notepad_plus_Window;
Notepad_plus_Window *_pPublicInterface;
Window *_pMainWindow;
DockingManager _dockingManager;
vector<int> _internalFuncIDs;

AutoCompletion _autoCompleteMain;
AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete
Expand Down Expand Up @@ -319,6 +325,7 @@ friend class Notepad_plus_Window;
ColumnEditorDlg _colEditorDlg;
WordStyleDlg _configStyleDlg;
PreferenceDlg _preference;
FindCharsInRangeDlg _findCharsInRangeDlg;

// a handle list of all the Notepad++ dialogs
vector<HWND> _hModelessDlgs;
Expand Down Expand Up @@ -391,6 +398,7 @@ friend class Notepad_plus_Window;

AnsiCharPanel *_pAnsiCharPanel;
ClipboardHistoryPanel *_pClipboardHistoryPanel;
VerticalFileSwitcher *_pFileSwitcherPanel;

BOOL notify(SCNotification *notification);
void specialCmd(int id);
Expand Down Expand Up @@ -576,6 +584,7 @@ friend class Notepad_plus_Window;
void doTrim(trimOp whichPart);
void launchAnsiCharPanel();
void launchClipboardHistoryPanel();
void launchFileSwitcherPanel();
};


Expand Down
2 changes: 2 additions & 0 deletions PowerEditor/src/Notepad_plus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ BEGIN
MENUITEM "Remove Unmarked Lines", IDM_SEARCH_DELETEUNMARKEDLINES
MENUITEM "Inverse Bookmark", IDM_SEARCH_INVERSEMARKS
END
MENUITEM SEPARATOR
MENUITEM "Find characters in range...", IDM_SEARCH_FINDCHARINRANGE
END

POPUP "&View"
Expand Down
3 changes: 3 additions & 0 deletions PowerEditor/src/Notepad_plus_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
}
}

for (size_t i = 0 ; i < _notepad_plus_plus_core._internalFuncIDs.size() ; i++)
::SendMessage(_hSelf, WM_COMMAND, _notepad_plus_plus_core._internalFuncIDs[i], 0);

// Notify plugins that Notepad++ is ready
SCNotification scnN;
scnN.nmhdr.code = NPPN_READY;
Expand Down
24 changes: 22 additions & 2 deletions PowerEditor/src/NppCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ void Notepad_plus::command(int id)
switch (id)
{
case IDM_FILE_NEW:
{
fileNew();
break;
//launchFileSwitcherPanel();
}
break;

case IDM_FILE_OPEN:
{
fileOpen();
break;
}
break;

case IDM_FILE_RELOAD:
fileReload();
Expand Down Expand Up @@ -287,6 +292,12 @@ void Notepad_plus::command(int id)
}
break;

case IDM_VIEW_FILESWITCHER_PANEL:
{
launchFileSwitcherPanel();
}
break;

case IDM_EDIT_DELETE:
_pEditView->execute(WM_CLEAR);
break;
Expand Down Expand Up @@ -602,6 +613,15 @@ void Notepad_plus::command(int id)
break;
}

case IDM_SEARCH_FINDCHARINRANGE :
{
bool isFirstTime = !_findCharsInRangeDlg.isCreated();
_findCharsInRangeDlg.doDialog(_nativeLangSpeaker.isRTL());
if (isFirstTime)
_nativeLangSpeaker.changeDlgLang(_findCharsInRangeDlg.getHSelf(), "FindCharsInRange");
break;
}

case IDM_EDIT_COLUMNMODETIP :
{
_nativeLangSpeaker.messageBox("ColumnModeTip",
Expand Down
4 changes: 2 additions & 2 deletions PowerEditor/src/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3854,7 +3854,7 @@ void NppParameters::feedDockingManager(TiXmlNode *node)
isVisible = (lstrcmp(val, TEXT("yes")) == 0);
}

_nppGUI._dockingData._pluginDockInfo.push_back(PlugingDlgDockingInfo(name, id, curr, prev, isVisible));
_nppGUI._dockingData._pluginDockInfo.push_back(PluginDlgDockingInfo(name, id, curr, prev, isVisible));
}
}

Expand Down Expand Up @@ -4602,7 +4602,7 @@ void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot)

for (size_t i = 0 ; i < _nppGUI._dockingData._pluginDockInfo.size() ; i++)
{
PlugingDlgDockingInfo & pdi = _nppGUI._dockingData._pluginDockInfo[i];
PluginDlgDockingInfo & pdi = _nppGUI._dockingData._pluginDockInfo[i];
TiXmlElement PDNode(TEXT("PluginDlg"));
PDNode.SetAttribute(TEXT("pluginName"), pdi._name);
PDNode.SetAttribute(TEXT("id"), pdi._internalID);
Expand Down
8 changes: 4 additions & 4 deletions PowerEditor/src/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ struct FloatingWindowInfo {
};
};

struct PlugingDlgDockingInfo {
struct PluginDlgDockingInfo {
generic_string _name;
int _internalID;

int _currContainer;
int _prevContainer;
bool _isVisible;

PlugingDlgDockingInfo(const TCHAR *pluginName, int id, int curr, int prev, bool isVis) : _internalID(id), _currContainer(curr), _prevContainer(prev), _isVisible(isVis), _name(pluginName){};
PluginDlgDockingInfo(const TCHAR *pluginName, int id, int curr, int prev, bool isVis) : _internalID(id), _currContainer(curr), _prevContainer(prev), _isVisible(isVis), _name(pluginName){};

friend inline const bool operator==(const PlugingDlgDockingInfo & a, const PlugingDlgDockingInfo & b) {
friend inline const bool operator==(const PluginDlgDockingInfo & a, const PluginDlgDockingInfo & b) {
if ((a._name == b._name) && (a._internalID == b._internalID))
return true;
else
Expand All @@ -219,7 +219,7 @@ struct DockingManagerData {
DockingManagerData() : _leftWidth(200), _rightWidth(200), _topHeight(200), _bottomHight(200) {};

vector<FloatingWindowInfo> _flaotingWindowInfo;
vector<PlugingDlgDockingInfo> _pluginDockInfo;
vector<PluginDlgDockingInfo> _pluginDockInfo;
vector<ContainerTabInfo> _containerTabInfo;

RECT * getFloatingRCFrom(int floatCont) {
Expand Down
2 changes: 1 addition & 1 deletion PowerEditor/src/WinControls/AnsiCharPanel/ListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ generic_string ListView::getAscii(unsigned char value)
ascii[1] = '\0';
MultiByteToWideChar(_codepage, 0, ascii, -1, charStr, sizeof(charStr));
#else
charStr[0] = (unsigned char)i;
charStr[0] = (unsigned char)value;
charStr[1] = '\0';
#endif
return charStr;
Expand Down
3 changes: 0 additions & 3 deletions PowerEditor/src/WinControls/AnsiCharPanel/ansiCharPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ BOOL CALLBACK AnsiCharPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPa
{
case WM_INITDIALOG :
{
TCHAR asciiStr[2];
asciiStr[1] = '\0';

_listView.init(_hInst, _hSelf);
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding();
_listView.setValues(codepage==-1?0:codepage);
Expand Down

0 comments on commit 21b72a7

Please sign in to comment.