mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-30 09:14:39 +02:00
[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:
parent
0800917f32
commit
3c7977ecba
@ -2648,9 +2648,8 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
|
|
||||||
case TTN_GETDISPINFO:
|
case TTN_GETDISPINFO:
|
||||||
{
|
{
|
||||||
LPTOOLTIPTEXT lpttt;
|
try {
|
||||||
|
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)notification;
|
||||||
lpttt = (LPTOOLTIPTEXT)notification;
|
|
||||||
|
|
||||||
//Joce's fix
|
//Joce's fix
|
||||||
lpttt->hinst = NULL;
|
lpttt->hinst = NULL;
|
||||||
@ -2660,34 +2659,54 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
::ScreenToClient(_hSelf, &p);
|
::ScreenToClient(_hSelf, &p);
|
||||||
HWND hWin = ::RealChildWindowFromPoint(_hSelf, p);
|
HWND hWin = ::RealChildWindowFromPoint(_hSelf, p);
|
||||||
const int tipMaxLen = 1024;
|
const int tipMaxLen = 1024;
|
||||||
/*static */TCHAR tip[tipMaxLen];
|
static TCHAR toolTip[tipMaxLen];
|
||||||
tip[0] = '\0';
|
static TCHAR mainDocTip[tipMaxLen];
|
||||||
|
static TCHAR subDocTip[tipMaxLen];
|
||||||
|
toolTip[0] = mainDocTip[0] = subDocTip[0] = '\0';
|
||||||
|
|
||||||
generic_string tipTmp(TEXT(""));
|
generic_string tipTmp(TEXT(""));
|
||||||
int id = int(lpttt->hdr.idFrom);
|
int id = int(lpttt->hdr.idFrom);
|
||||||
|
|
||||||
if (hWin == _rebarTop.getHSelf())
|
if (hWin == _rebarTop.getHSelf())
|
||||||
{
|
{
|
||||||
getNameStrFromCmd(id, tipTmp);
|
getNameStrFromCmd(id, tipTmp);
|
||||||
|
if (tipTmp.length() >= tipMaxLen)
|
||||||
|
return FALSE;
|
||||||
|
lstrcpy(toolTip, tipTmp.c_str());
|
||||||
|
lpttt->lpszText = toolTip;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (hWin == _mainDocTab.getHSelf())
|
else if (hWin == _mainDocTab.getHSelf())
|
||||||
{
|
{
|
||||||
BufferID idd = _mainDocTab.getBufferByIndex(id);
|
BufferID idd = _mainDocTab.getBufferByIndex(id);
|
||||||
Buffer * buf = MainFileManager->getBufferByID(idd);
|
Buffer * buf = MainFileManager->getBufferByID(idd);
|
||||||
tipTmp = buf->getFullPathName();
|
tipTmp = buf->getFullPathName();
|
||||||
|
|
||||||
|
if (tipTmp.length() >= tipMaxLen)
|
||||||
|
return FALSE;
|
||||||
|
lstrcpy(mainDocTip, tipTmp.c_str());
|
||||||
|
lpttt->lpszText = mainDocTip;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (hWin == _subDocTab.getHSelf())
|
else if (hWin == _subDocTab.getHSelf())
|
||||||
{
|
{
|
||||||
BufferID idd = _subDocTab.getBufferByIndex(id);
|
BufferID idd = _subDocTab.getBufferByIndex(id);
|
||||||
Buffer * buf = MainFileManager->getBufferByID(idd);
|
Buffer * buf = MainFileManager->getBufferByID(idd);
|
||||||
tipTmp = buf->getFullPathName();
|
tipTmp = buf->getFullPathName();
|
||||||
|
|
||||||
|
if (tipTmp.length() >= tipMaxLen)
|
||||||
|
return FALSE;
|
||||||
|
lstrcpy(subDocTip, tipTmp.c_str());
|
||||||
|
lpttt->lpszText = subDocTip;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
{
|
||||||
|
return FALSE;
|
||||||
if (tipTmp.length() < tipMaxLen)
|
}
|
||||||
lstrcpy(tip, tipTmp.c_str());
|
} catch (...) {
|
||||||
|
//printStr(TEXT("ToolTip crash is catched!"));
|
||||||
lpttt->lpszText = tip;
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3805,11 +3824,11 @@ void Notepad_plus::command(int id)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_EDIT_LINE_UP:
|
case IDM_EDIT_LINE_UP:
|
||||||
_pEditView->currentLineUp();
|
_pEditView->currentLinesUp();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_EDIT_LINE_DOWN:
|
case IDM_EDIT_LINE_DOWN:
|
||||||
_pEditView->currentLineDown();
|
_pEditView->currentLinesDown();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDM_EDIT_UPPERCASE:
|
case IDM_EDIT_UPPERCASE:
|
||||||
|
@ -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> ScintillaEditView::getSelectionLinesRange() const
|
||||||
{
|
{
|
||||||
pair<int, int> range(-1, -1);
|
pair<int, int> range(-1, -1);
|
||||||
@ -2086,6 +2113,7 @@ void ScintillaEditView::currentLinesUp() const
|
|||||||
if ((lineRange.first == -1 || lineRange.first == 0))
|
if ((lineRange.first == -1 || lineRange.first == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool noSel = lineRange.first == lineRange.second;
|
||||||
int nbSelLines = lineRange.second - lineRange.first + 1;
|
int nbSelLines = lineRange.second - lineRange.first + 1;
|
||||||
|
|
||||||
int line2swap = lineRange.first - 1;
|
int line2swap = lineRange.first - 1;
|
||||||
@ -2099,48 +2127,42 @@ void ScintillaEditView::currentLinesUp() const
|
|||||||
|
|
||||||
for (int i = 0 ; i < nbSelLines ; i++)
|
for (int i = 0 ; i < nbSelLines ; i++)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
execute(SCI_GOTOLINE, line2swap);
|
|
||||||
execute(SCI_LINETRANSPOSE);
|
|
||||||
|
|
||||||
line2swap++;
|
|
||||||
*/
|
|
||||||
currentLineDown();
|
currentLineDown();
|
||||||
}
|
}
|
||||||
execute(SCI_ENDUNDOACTION);
|
execute(SCI_ENDUNDOACTION);
|
||||||
|
|
||||||
execute(SCI_SETSELECTIONSTART, posStart - nbChar);
|
execute(SCI_SETSELECTIONSTART, posStart - nbChar);
|
||||||
execute(SCI_SETSELECTIONEND, posEnd - nbChar);
|
execute(SCI_SETSELECTIONEND, noSel?posStart - nbChar:posEnd - nbChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScintillaEditView::currentLinesDown() const
|
void ScintillaEditView::currentLinesDown() const
|
||||||
{
|
{
|
||||||
pair<int, int> lineRange = getSelectionLinesRange();
|
pair<int, int> lineRange = getSelectionLinesRange();
|
||||||
if ((lineRange.first == -1 || lineRange.first == 0))
|
|
||||||
|
if ((lineRange.first == -1 || lineRange.second >= execute(SCI_LINEFROMPOSITION, getCurrentDocLen())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool noSel = lineRange.first == lineRange.second;
|
||||||
int nbSelLines = lineRange.second - lineRange.first + 1;
|
int nbSelLines = lineRange.second - lineRange.first + 1;
|
||||||
|
|
||||||
int line2swap = lineRange.first - 1;
|
int line2swap = lineRange.second + 1;
|
||||||
int nbChar = execute(SCI_LINELENGTH, line2swap);
|
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_BEGINUNDOACTION);
|
||||||
execute(SCI_GOTOLINE, line2swap);
|
execute(SCI_GOTOLINE, line2swap);
|
||||||
|
|
||||||
for (int i = 0 ; i < nbSelLines ; i++)
|
for (int i = 0 ; i < nbSelLines ; i++)
|
||||||
{
|
{
|
||||||
/*
|
currentLineUp();
|
||||||
execute(SCI_GOTOLINE, line2swap);
|
|
||||||
execute(SCI_LINETRANSPOSE);
|
|
||||||
|
|
||||||
line2swap++;
|
|
||||||
*/
|
|
||||||
currentLineDown();
|
|
||||||
}
|
}
|
||||||
execute(SCI_ENDUNDOACTION);
|
execute(SCI_ENDUNDOACTION);
|
||||||
|
|
||||||
execute(SCI_SETSELECTIONSTART, lineRange.first - nbChar);
|
execute(SCI_SETSELECTIONSTART, posStart + nbChar);
|
||||||
execute(SCI_SETSELECTIONEND, lineRange.second - nbChar);
|
execute(SCI_SETSELECTIONEND, noSel?posStart + nbChar:posEnd + nbChar);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScintillaEditView::convertSelectedTextTo(bool Case)
|
void ScintillaEditView::convertSelectedTextTo(bool Case)
|
||||||
|
@ -468,33 +468,13 @@ public:
|
|||||||
|
|
||||||
void expand(int &line, bool doExpand, bool force = false, int visLevels = 0, int level = -1);
|
void expand(int &line, bool doExpand, bool force = false, int visLevels = 0, int level = -1);
|
||||||
|
|
||||||
void currentLineUp() const {
|
void currentLineUp() const;
|
||||||
int currentLine = getCurrentLineNumber();
|
void currentLineDown() const;
|
||||||
if (currentLine != 0)
|
|
||||||
{
|
|
||||||
execute(SCI_BEGINUNDOACTION);
|
|
||||||
currentLine--;
|
|
||||||
execute(SCI_LINETRANSPOSE);
|
|
||||||
execute(SCI_GOTOLINE, currentLine);
|
|
||||||
execute(SCI_ENDUNDOACTION);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
pair<int, int> getSelectionLinesRange() const;
|
pair<int, int> getSelectionLinesRange() const;
|
||||||
void currentLinesUp() const;
|
void currentLinesUp() const;
|
||||||
void currentLinesDown() 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 convertSelectedTextTo(bool Case);
|
||||||
void setMultiSelections(const ColumnModeInfos & cmi);
|
void setMultiSelections(const ColumnModeInfos & cmi);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user