[CLEAN] Clean up.

Refine the smart hiliting feature.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@182 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-04-23 17:23:24 +00:00
parent a54e45dd48
commit 84fa914ea1
10 changed files with 79 additions and 1416 deletions

View File

@ -6018,7 +6018,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
{
case WM_NCACTIVATE:
{
/* Note: lParam is -1 to prevent endless loops of calls */
// Note: lParam is -1 to prevent endless loops of calls
::SendMessage(_dockingManager.getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1);
return ::DefWindowProc(hwnd, Message, wParam, lParam);
}
@ -6661,15 +6661,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
_dockingManager.reSizeTo(rc);
//_pMainWindow->reSizeTo(rc);
//mkPosIncFindDlg();
result = TRUE;
}
break;
case WM_MOVE:
{
//redraw();
//mkPosIncFindDlg();
result = TRUE;
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -111,13 +111,6 @@ bool Searching::readBase(const char * string, int * value, int base, int size) {
return true;
}
int Searching::buildSearchFlags(FindOption * option) {
int flags = (option->_isWholeWord ? SCFIND_WHOLEWORD : 0) |
(option->_isMatchCase ? SCFIND_MATCHCASE : 0) |
(option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0);
return flags;
}
void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF8)
{
if (!hCombo) return;
@ -485,6 +478,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
case IDCANCEL : // Close
display(false);
return TRUE;
//Single actions
case IDOK : // Find Next
{
@ -1023,7 +1017,8 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
}
bool isRegExp = pOptions->_searchType == FindRegex;
int flags = Searching::buildSearchFlags(pOptions);
int flags = (op == ProcessMarkAll_2)?SCFIND_WHOLEWORD:Searching::buildSearchFlags(pOptions);
CharacterRange cr = (*_ppEditView)->getSelection();
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
@ -1117,7 +1112,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
bool isRealloc = false;
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
{
{
isRealloc = true;
_maxNbCharAllocated = nbChar;
delete [] _line;
@ -1149,52 +1144,57 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const
startPosition = posFind + foundTextLen;
break; }
case ProcessReplaceAll: {
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
(*_ppEditView)->execute(SCI_SETTARGETSTART, start);
(*_ppEditView)->execute(SCI_SETTARGETEND, end);
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
if ((_isInSelection) && (!isEntire))
{
endPosition = endPosition - foundTextLen + replacedLength;
}
else
{
if (direction == DIR_DOWN)
endPosition = docLength = docLength - foundTextLen + replacedLength;
}
startPosition = (direction == DIR_UP)?posFind - replacedLength:posFind + replacedLength;
if ((_isInSelection) && (!isEntire))
{
endPosition = endPosition - foundTextLen + replacedLength;
}
else
{
if (direction == DIR_DOWN)
endPosition = docLength = docLength - foundTextLen + replacedLength;
}
break; }
case ProcessMarkAll: {
if (_doStyleFoundToken)
{
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
}
if (_doStyleFoundToken)
{
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
}
if (_doMarkLine)
{
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
if (_doMarkLine)
{
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posFind);
int state = (*_ppEditView)->execute(SCI_MARKERGET, lineNumber);
if (!(state & (1 << MARK_BOOKMARK)))
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
}
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
if (!(state & (1 << MARK_BOOKMARK)))
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
}
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
break; }
case ProcessMarkAll_2: {
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, start, end - start);
startPosition = (direction == DIR_UP)?posFind - foundTextLen:posFind + foundTextLen;
break; }
case ProcessCountAll: {
startPosition = posFind + foundTextLen;
startPosition = posFind + foundTextLen;
break; }
default: {
delete [] pTextFind;
delete [] pTextReplace;
return nbReplaced;
return nbReplaced;
break; }
}
@ -1377,13 +1377,6 @@ BOOL CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
/*
case WM_INITDIALOG :
{
goToCenter();
return TRUE;
}
*/
case WM_COMMAND :
{
switch (wParam)
@ -1460,6 +1453,7 @@ void FindIncrementDlg::display(bool toShow) const {
::SetFocus(::GetDlgItem(_hSelf, IDC_INCFINDTEXT));
_pRebar->setIDVisible(_rbBand.wID, toShow);
}
BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)

View File

@ -75,7 +75,11 @@ class Searching {
public:
static int convertExtendedToString(const char * query, char * result, int length);
static TargetRange t;
static int buildSearchFlags(FindOption * option);
static int buildSearchFlags(FindOption * option) {
return (option->_isWholeWord ? SCFIND_WHOLEWORD : 0) |
(option->_isMatchCase ? SCFIND_MATCHCASE : 0) |
(option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0);
};
private:
static bool readBase(const char * string, int * value, int base, int size);

View File

@ -159,15 +159,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
case WM_MOUSEHWHEEL :
{
if ((short)HIWORD(wParam) > 0)
{
//if (execute(SCI_GETXOFFSET) < 10)
::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, SB_LINERIGHT, NULL);
}
else
{
::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, SB_LINELEFT, NULL);
}
::CallWindowProc(_scintillaDefaultProc, hwnd, WM_HSCROLL, ((short)HIWORD(wParam) > 0)?SB_LINERIGHT:SB_LINELEFT, NULL);
break;
}
@ -181,15 +173,12 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
//Have to perform the scroll first, because the first/last line do not get updated untill after the scroll has been parsed
LRESULT scrollResult = ::CallWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam);
//recalcHorizontalScrollbar();
return scrollResult;
break;
}
case WM_VSCROLL :
{
//if (LOWORD(wParam) == SB_ENDSCROLL)
//recalcHorizontalScrollbar();
break;
}
}
@ -198,7 +187,6 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
void ScintillaEditView::setSpecialIndicator(Style & styleToSet)
{
//execute(SCI_INDICSETSTYLE, styleToSet._styleID, INDIC_ROUNDBOX);
execute(SCI_INDICSETFORE, styleToSet._styleID, styleToSet._bgColor);
}

View File

@ -96,7 +96,7 @@ void DockingCont::doDialog(bool willBeShown, bool isFloating)
_isFloating = isFloating;
if (_isFloating == true)
if (_isFloating)
{
::SetWindowLong(_hSelf, GWL_STYLE, POPUP_STYLES);
::SetWindowLong(_hSelf, GWL_EXSTYLE, POPUP_EXSTYLES);
@ -109,24 +109,8 @@ void DockingCont::doDialog(bool willBeShown, bool isFloating)
::ShowWindow(_hCaption, SW_SHOW);
}
//If you want to use titlebar metrics
//NONCLIENTMETRICS ncm;
//ncm.cbSize = sizeof(ncm);
//if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0)) {
// ncm.lfCaptionFont.lfWeight = FW_NORMAL;
// _hFont = ::CreateFontIndirect(&ncm.lfCaptionFont);
//}
//If you want defualt GUI font
_hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
//If you want MS Shell Dlg
//_hFont = ::CreateFont(14, 0, 0, 0,
// FW_NORMAL, FALSE, FALSE, FALSE,
// ANSI_CHARSET, OUT_DEFAULT_PRECIS,
// CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
// DEFAULT_PITCH | FF_ROMAN,
// "MS Shell Dlg");
}
display(willBeShown);
@ -144,7 +128,7 @@ tTbData* DockingCont::createToolbar(tTbData data, Window **ppWin)
::SetWindowLong(pTbData->hClient, GWL_EXSTYLE, CHILD_EXSTYLES);
/* restore position if plugin is in floating state */
if ((_isFloating == true) && (::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0) == 0))
if ((_isFloating) && (::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0) == 0))
{
reSizeToWH(pTbData->rcFloat);
}
@ -1206,7 +1190,7 @@ INT DockingCont::hideToolbar(tTbData *pTbData, BOOL hideClient)
this->doDialog(false);
/* send message to docking manager for resize */
if (_isFloating == false)
if (!_isFloating)
{
::SendMessage(_hParent, WM_SIZE, 0, 0);
}

View File

@ -60,29 +60,15 @@ class DockingCont : public StaticDialog
public:
DockingCont();
~DockingCont();
void init(HINSTANCE hInst, HWND hWnd) {
Window::init(hInst, hWnd);
};
HWND getTabWnd(void) {
HWND hRet = NULL;
if (isCreated())
hRet = _hContTab;
return hRet;
HWND getTabWnd(void) {
return _hContTab;
};
HWND getCaptionWnd(void) {
HWND hRet = NULL;
if (isCreated())
{
if (_isFloating == false)
hRet = _hCaption;
else
hRet = _hSelf;
}
return hRet;
if (_isFloating == false)
return _hCaption;
else
return _hSelf;
};
tTbData* createToolbar(tTbData data, Window **ppWin);

View File

@ -2,7 +2,7 @@
#include <windows.h>
#include "dockingResource.h"
IDD_CONTAINER_DLG DIALOGEX 0, 0, 186, 103
IDD_CONTAINER_DLG DIALOGEX 0, 0, 0, 0//186, 103
STYLE DS_SETFONT | DS_SETFOREGROUND | WS_MAXIMIZEBOX | WS_POPUP |
WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_TOOLWINDOW

View File

@ -351,26 +351,28 @@ void DockingManager::onSize()
void DockingManager::reSizeTo(RECT & rc)
{
/* store current size of client area */
// store current size of client area
_rect = rc;
/* prepare size of work area */
// prepare size of work area
_rcWork = rc;
if (_isInitialized == FALSE)
return;
/* set top container */
// set top container
_dockData.rcRegion[CONT_TOP].left = rc.left;
_dockData.rcRegion[CONT_TOP].top = rc.top;
_dockData.rcRegion[CONT_TOP].right = rc.right-rc.left;
_vSplitter[CONT_TOP]->display(false);
if (_vContainer[CONT_TOP]->isVisible())
{
_rcWork.top += _dockData.rcRegion[CONT_TOP].bottom + SPLITTER_WIDTH;
_rcWork.bottom -= _dockData.rcRegion[CONT_TOP].bottom + SPLITTER_WIDTH;
/* set size of splitter */
// set size of splitter
RECT rc = {_dockData.rcRegion[CONT_TOP].left ,
_dockData.rcRegion[CONT_TOP].top + _dockData.rcRegion[CONT_TOP].bottom,
_dockData.rcRegion[CONT_TOP].right ,
@ -378,20 +380,21 @@ void DockingManager::reSizeTo(RECT & rc)
_vSplitter[CONT_TOP]->reSizeTo(rc);
}
/* set bottom container */
// set bottom container
_dockData.rcRegion[CONT_BOTTOM].left = rc.left;
_dockData.rcRegion[CONT_BOTTOM].top = rc.top + rc.bottom - _dockData.rcRegion[CONT_BOTTOM].bottom;
_dockData.rcRegion[CONT_BOTTOM].right = rc.right-rc.left;
/* create temporary rect for bottom container */
// create temporary rect for bottom container
RECT rcBottom = _dockData.rcRegion[CONT_BOTTOM];
_vSplitter[CONT_BOTTOM]->display(false);
if (_vContainer[CONT_BOTTOM]->isVisible())
{
_rcWork.bottom -= _dockData.rcRegion[CONT_BOTTOM].bottom + SPLITTER_WIDTH;
/* correct the visibility of bottom container when height is NULL */
// correct the visibility of bottom container when height is NULL
if (_rcWork.bottom < rc.top)
{
rcBottom.top = _rcWork.top + rc.top + SPLITTER_WIDTH;
@ -403,7 +406,7 @@ void DockingManager::reSizeTo(RECT & rc)
_rcWork.bottom = rc.bottom - _dockData.rcRegion[CONT_TOP].bottom;
}
/* set size of splitter */
// set size of splitter
RECT rc = {rcBottom.left,
rcBottom.top - SPLITTER_WIDTH,
rcBottom.right,
@ -411,17 +414,19 @@ void DockingManager::reSizeTo(RECT & rc)
_vSplitter[CONT_BOTTOM]->reSizeTo(rc);
}
/* set left container */
// set left container
_dockData.rcRegion[CONT_LEFT].left = rc.left;
_dockData.rcRegion[CONT_LEFT].top = _rcWork.top;
_dockData.rcRegion[CONT_LEFT].bottom = _rcWork.bottom;
_vSplitter[CONT_LEFT]->display(false);
if (_vContainer[CONT_LEFT]->isVisible())
{
_rcWork.left += _dockData.rcRegion[CONT_LEFT].right + SPLITTER_WIDTH;
_rcWork.right -= _dockData.rcRegion[CONT_LEFT].right + SPLITTER_WIDTH;
/* set size of splitter */
// set size of splitter
RECT rc = {_dockData.rcRegion[CONT_LEFT].right,
_dockData.rcRegion[CONT_LEFT].top,
SPLITTER_WIDTH,
@ -429,12 +434,12 @@ void DockingManager::reSizeTo(RECT & rc)
_vSplitter[CONT_LEFT]->reSizeTo(rc);
}
/* set right container */
// set right container
_dockData.rcRegion[CONT_RIGHT].left = rc.right - _dockData.rcRegion[CONT_RIGHT].right;
_dockData.rcRegion[CONT_RIGHT].top = _rcWork.top;
_dockData.rcRegion[CONT_RIGHT].bottom = _rcWork.bottom;
/* create temporary rect for right container */
// create temporary rect for right container
RECT rcRight = _dockData.rcRegion[CONT_RIGHT];
_vSplitter[CONT_RIGHT]->display(false);
@ -442,7 +447,7 @@ void DockingManager::reSizeTo(RECT & rc)
{
_rcWork.right -= _dockData.rcRegion[CONT_RIGHT].right + SPLITTER_WIDTH;
/* correct the visibility of right container when width is NULL */
// correct the visibility of right container when width is NULL
if (_rcWork.right < 15)
{
rcRight.left = _rcWork.left + 15 + SPLITTER_WIDTH;
@ -450,7 +455,7 @@ void DockingManager::reSizeTo(RECT & rc)
_rcWork.right = 15;
}
/* set size of splitter */
// set size of splitter
RECT rc = {rcRight.left - SPLITTER_WIDTH,
rcRight.top,
SPLITTER_WIDTH,
@ -458,8 +463,7 @@ void DockingManager::reSizeTo(RECT & rc)
_vSplitter[CONT_RIGHT]->reSizeTo(rc);
}
/* set window positions of container*/
// set window positions of container
if (_vContainer[CONT_BOTTOM]->isVisible())
{
::SetWindowPos(_vContainer[CONT_BOTTOM]->getHSelf(), NULL,
@ -503,7 +507,6 @@ void DockingManager::reSizeTo(RECT & rc)
SWP_NOZORDER);
_vSplitter[CONT_LEFT]->display();
}
(*_ppMainWindow)->reSizeTo(_rcWork);
}

View File

@ -548,8 +548,6 @@ void Gripper::drawRectangle(POINT pt)
{
HANDLE hbrushOrig = NULL;
RECT rc = {0};
//BOOL isRcTab = FALSE;
//RECT rcTab = {0};
if (!_hdc)
_hdc = ::GetDC(NULL);
@ -677,13 +675,13 @@ DockingCont* Gripper::contHitTest(POINT pt)
}
/* test only tabs that are visible */
if (::IsWindowVisible(vCont[iCont]->getTabWnd()) == TRUE)
if (::IsWindowVisible(vCont[iCont]->getTabWnd()))
{
/* test if within tab (rect test is used, because of drag and drop behaviour) */
RECT rc = {0};
::GetWindowRect(vCont[iCont]->getTabWnd(), &rc);
if (::PtInRect(&rc, pt) == TRUE)
if (::PtInRect(&rc, pt))
{
return vCont[iCont];
}