[BUG_FIXED] Fix tooltip crash issue.

[NEW_FEATURE] Add selected lines moving up/down capacity.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@533 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2009-09-11 00:22:40 +00:00
parent 0800917f32
commit 3c7977ecba
3 changed files with 100 additions and 79 deletions

View File

@ -2648,9 +2648,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt;
lpttt = (LPTOOLTIPTEXT)notification;
try {
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification;
//Joce's fix
lpttt->hinst = NULL;
@ -2660,34 +2659,54 @@ BOOL Notepad_plus::notify(SCNotification *notification)
::ScreenToClient(_hSelf, &p);
HWND hWin = ::RealChildWindowFromPoint(_hSelf, p);
const int tipMaxLen = 1024;
/*static */TCHAR tip[tipMaxLen];
tip[0] = '\0';
static TCHAR toolTip[tipMaxLen];
static TCHAR mainDocTip[tipMaxLen];
static TCHAR subDocTip[tipMaxLen];
toolTip[0] = mainDocTip[0] = subDocTip[0] = '\0';
generic_string tipTmp(TEXT(""));
int id = int(lpttt->hdr.idFrom);
if (hWin == _rebarTop.getHSelf())
{
getNameStrFromCmd(id, tipTmp);
if (tipTmp.length() >= tipMaxLen)
return FALSE;
lstrcpy(toolTip, tipTmp.c_str());
lpttt->lpszText = toolTip;
return TRUE;
}
else if (hWin == _mainDocTab.getHSelf())
{
BufferID idd = _mainDocTab.getBufferByIndex(id);
Buffer * buf = MainFileManager->getBufferByID(idd);
tipTmp = buf->getFullPathName();
if (tipTmp.length() >= tipMaxLen)
return FALSE;
lstrcpy(mainDocTip, tipTmp.c_str());
lpttt->lpszText = mainDocTip;
return TRUE;
}
else if (hWin == _subDocTab.getHSelf())
{
BufferID idd = _subDocTab.getBufferByIndex(id);
Buffer * buf = MainFileManager->getBufferByID(idd);
tipTmp = buf->getFullPathName();
if (tipTmp.length() >= tipMaxLen)
return FALSE;
lstrcpy(subDocTip, tipTmp.c_str());
lpttt->lpszText = subDocTip;
return TRUE;
}
else
break;
if (tipTmp.length() < tipMaxLen)
lstrcpy(tip, tipTmp.c_str());
lpttt->lpszText = tip;
{
return FALSE;
}
} catch (...) {
//printStr(TEXT("ToolTip crash is catched!"));
}
}
break;
@ -3805,11 +3824,11 @@ void Notepad_plus::command(int id)
break;
case IDM_EDIT_LINE_UP:
_pEditView->currentLineUp();
_pEditView->currentLinesUp();
break;
case IDM_EDIT_LINE_DOWN:
_pEditView->currentLineDown();
_pEditView->currentLinesDown();
break;
case IDM_EDIT_UPPERCASE:

View File

@ -2065,6 +2065,33 @@ void ScintillaEditView::setMultiSelections(const ColumnModeInfos & cmi)
}
}
void ScintillaEditView::currentLineUp() const
{
int currentLine = getCurrentLineNumber();
if (currentLine != 0)
{
execute(SCI_BEGINUNDOACTION);
currentLine--;
execute(SCI_LINETRANSPOSE);
execute(SCI_GOTOLINE, currentLine);
execute(SCI_ENDUNDOACTION);
}
}
void ScintillaEditView::currentLineDown() const
{
int currentLine = getCurrentLineNumber();
if (currentLine != (execute(SCI_GETLINECOUNT) - 1))
{
execute(SCI_BEGINUNDOACTION);
currentLine++;
execute(SCI_GOTOLINE, currentLine);
execute(SCI_LINETRANSPOSE);
execute(SCI_ENDUNDOACTION);
}
}
pair<int, int> ScintillaEditView::getSelectionLinesRange() const
{
pair<int, int> range(-1, -1);
@ -2086,6 +2113,7 @@ void ScintillaEditView::currentLinesUp() const
if ((lineRange.first == -1 || lineRange.first == 0))
return;
bool noSel = lineRange.first == lineRange.second;
int nbSelLines = lineRange.second - lineRange.first + 1;
int line2swap = lineRange.first - 1;
@ -2099,48 +2127,42 @@ void ScintillaEditView::currentLinesUp() const
for (int i = 0 ; i < nbSelLines ; i++)
{
/*
execute(SCI_GOTOLINE, line2swap);
execute(SCI_LINETRANSPOSE);
line2swap++;
*/
currentLineDown();
}
execute(SCI_ENDUNDOACTION);
execute(SCI_SETSELECTIONSTART, posStart - nbChar);
execute(SCI_SETSELECTIONEND, posEnd - nbChar);
execute(SCI_SETSELECTIONEND, noSel?posStart - nbChar:posEnd - nbChar);
}
void ScintillaEditView::currentLinesDown() const
{
pair<int, int> lineRange = getSelectionLinesRange();
if ((lineRange.first == -1 || lineRange.first == 0))
if ((lineRange.first == -1 || lineRange.second >= execute(SCI_LINEFROMPOSITION, getCurrentDocLen())))
return;
bool noSel = lineRange.first == lineRange.second;
int nbSelLines = lineRange.second - lineRange.first + 1;
int line2swap = lineRange.first - 1;
int line2swap = lineRange.second + 1;
int nbChar = execute(SCI_LINELENGTH, line2swap);
int posStart = execute(SCI_POSITIONFROMLINE, lineRange.first);
int posEnd = execute(SCI_GETLINEENDPOSITION, lineRange.second);
execute(SCI_BEGINUNDOACTION);
execute(SCI_GOTOLINE, line2swap);
for (int i = 0 ; i < nbSelLines ; i++)
{
/*
execute(SCI_GOTOLINE, line2swap);
execute(SCI_LINETRANSPOSE);
line2swap++;
*/
currentLineDown();
currentLineUp();
}
execute(SCI_ENDUNDOACTION);
execute(SCI_SETSELECTIONSTART, lineRange.first - nbChar);
execute(SCI_SETSELECTIONEND, lineRange.second - nbChar);
execute(SCI_SETSELECTIONSTART, posStart + nbChar);
execute(SCI_SETSELECTIONEND, noSel?posStart + nbChar:posEnd + nbChar);
}
void ScintillaEditView::convertSelectedTextTo(bool Case)

View File

@ -468,33 +468,13 @@ public:
void expand(int &line, bool doExpand, bool force = false, int visLevels = 0, int level = -1);
void currentLineUp() const {
int currentLine = getCurrentLineNumber();
if (currentLine != 0)
{
execute(SCI_BEGINUNDOACTION);
currentLine--;
execute(SCI_LINETRANSPOSE);
execute(SCI_GOTOLINE, currentLine);
execute(SCI_ENDUNDOACTION);
}
};
void currentLineUp() const;
void currentLineDown() const;
pair<int, int> getSelectionLinesRange() const;
void currentLinesUp() const;
void currentLinesDown() const;
void currentLineDown() const {
int currentLine = getCurrentLineNumber();
if (currentLine != (execute(SCI_GETLINECOUNT) - 1))
{
execute(SCI_BEGINUNDOACTION);
currentLine++;
execute(SCI_GOTOLINE, currentLine);
execute(SCI_LINETRANSPOSE);
execute(SCI_ENDUNDOACTION);
}
};
void convertSelectedTextTo(bool Case);
void setMultiSelections(const ColumnModeInfos & cmi);