[NEW_FEATURE] (Author: Andreas Jonsson) Delimiter select by ctrl + Double click.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1055 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
3b9f24ba51
commit
7e66078bed
@ -433,7 +433,84 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
|
||||
case SCN_DOUBLECLICK :
|
||||
{
|
||||
if (_isHotspotDblClicked)
|
||||
if(notification->modifiers == SCMOD_CTRL)
|
||||
{
|
||||
const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI();
|
||||
|
||||
char *buf;
|
||||
int length;
|
||||
int position_of_click;
|
||||
if(nppGUI._delimiterSelectionOnEntireDocument)
|
||||
{
|
||||
// Get entire document.
|
||||
length = notifyView->execute(SCI_GETLENGTH);
|
||||
buf = new char[length + 1];
|
||||
notifyView->execute(SCI_GETTEXT, (LPARAM)(length + 1), (WPARAM)buf);
|
||||
|
||||
position_of_click = notification->position;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get single line.
|
||||
length = notifyView->execute(SCI_GETCURLINE);
|
||||
buf = new char[length + 1];
|
||||
notifyView->execute(SCI_GETCURLINE, (WPARAM)length, (LPARAM)buf);
|
||||
|
||||
// Compute the position of the click (relative to the beginning of the line).
|
||||
const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber());
|
||||
position_of_click = notification->position - line_position;
|
||||
}
|
||||
|
||||
// Scan for the left delimiter.
|
||||
int leftmost_position = -1;
|
||||
for(int i = position_of_click; i >= 0; --i)
|
||||
{
|
||||
if(buf[i] == nppGUI._leftmostDelimiter)
|
||||
{
|
||||
leftmost_position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(leftmost_position == -1)
|
||||
{
|
||||
delete [] buf;
|
||||
break;
|
||||
}
|
||||
|
||||
// Scan for right delimiter.
|
||||
int rightmost_position = -1;
|
||||
for(int i = position_of_click; i <= length; ++i)
|
||||
{
|
||||
if(buf[i] == nppGUI._rightmostDelimiter)
|
||||
{
|
||||
rightmost_position = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(rightmost_position == -1)
|
||||
{
|
||||
delete [] buf;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set selection to the position we found.
|
||||
if(nppGUI._delimiterSelectionOnEntireDocument)
|
||||
{
|
||||
notifyView->execute(SCI_SETCURRENTPOS, rightmost_position);
|
||||
notifyView->execute(SCI_SETANCHOR, leftmost_position + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int line_position = notifyView->execute(SCI_POSITIONFROMLINE, notifyView->getCurrentLineNumber());
|
||||
notifyView->execute(SCI_SETCURRENTPOS, line_position + rightmost_position);
|
||||
notifyView->execute(SCI_SETANCHOR, line_position + leftmost_position + 1);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
else if (_isHotspotDblClicked)
|
||||
{
|
||||
int pos = notifyView->execute(SCI_GETCURRENTPOS);
|
||||
notifyView->execute(SCI_SETCURRENTPOS, pos);
|
||||
|
@ -3882,6 +3882,24 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
|
||||
if (themePath != NULL && themePath[0])
|
||||
_nppGUI._themeName.assign(themePath);
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("delimiterSelection")))
|
||||
{
|
||||
int leftmost = 0;
|
||||
element->Attribute(TEXT("leftmostDelimiter"), &leftmost);
|
||||
if(leftmost > 0 && leftmost < 256)
|
||||
_nppGUI._leftmostDelimiter = (char)leftmost;
|
||||
|
||||
int rightmost = 0;
|
||||
element->Attribute(TEXT("rightmostDelimiter"), &rightmost);
|
||||
if(rightmost > 0 && rightmost < 256)
|
||||
_nppGUI._rightmostDelimiter = (char)rightmost;
|
||||
|
||||
const TCHAR *delimiterSelectionOnEntireDocument = element->Attribute(TEXT("delimiterSelectionOnEntireDocument"));
|
||||
if(delimiterSelectionOnEntireDocument != NULL && !lstrcmp(delimiterSelectionOnEntireDocument, TEXT("yes")))
|
||||
_nppGUI._delimiterSelectionOnEntireDocument = true;
|
||||
else
|
||||
_nppGUI._delimiterSelectionOnEntireDocument = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4216,6 +4234,7 @@ bool NppParameters::writeGUIParams()
|
||||
bool openSaveDirExist = false;
|
||||
bool titleBarExist = false;
|
||||
bool stylerThemeExist = false;
|
||||
bool delimiterSelectionExist = false;
|
||||
|
||||
TiXmlNode *dockingParamNode = NULL;
|
||||
|
||||
@ -4580,6 +4599,16 @@ bool NppParameters::writeGUIParams()
|
||||
stylerThemeExist = true;
|
||||
element->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str());
|
||||
}
|
||||
else if (!lstrcmp(nm, TEXT("delimiterSelection")))
|
||||
{
|
||||
element->SetAttribute(TEXT("leftmostDelimiter"), (int)_nppGUI._leftmostDelimiter);
|
||||
element->SetAttribute(TEXT("rightmostDelimiter"), (int)_nppGUI._rightmostDelimiter);
|
||||
if(_nppGUI._delimiterSelectionOnEntireDocument)
|
||||
element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("yes"));
|
||||
else
|
||||
element->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), TEXT("no"));
|
||||
delimiterSelectionExist = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!noUpdateExist)
|
||||
@ -4779,6 +4808,14 @@ bool NppParameters::writeGUIParams()
|
||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("stylerTheme"));
|
||||
GUIConfigElement->SetAttribute(TEXT("path"), _nppGUI._themeName.c_str());
|
||||
}
|
||||
if (!delimiterSelectionExist)
|
||||
{
|
||||
TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
|
||||
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("delimiterSelection"));
|
||||
GUIConfigElement->SetAttribute(TEXT("leftmostDelimiter"), _nppGUI._leftmostDelimiter);
|
||||
GUIConfigElement->SetAttribute(TEXT("rightmostDelimiter"), _nppGUI._rightmostDelimiter);
|
||||
GUIConfigElement->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), _nppGUI._delimiterSelectionOnEntireDocument);
|
||||
}
|
||||
|
||||
insertDockingParamNode(GUIRoot);
|
||||
return true;
|
||||
|
@ -682,7 +682,7 @@ struct NppGUI
|
||||
_doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\
|
||||
_autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")),\
|
||||
_doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false),
|
||||
_smartHiliteCaseSensitive(false) {
|
||||
_smartHiliteCaseSensitive(false), _leftmostDelimiter('('), _rightmostDelimiter(')'), _delimiterSelectionOnEntireDocument(false) {
|
||||
_appPos.left = 0;
|
||||
_appPos.top = 0;
|
||||
_appPos.right = 700;
|
||||
@ -730,6 +730,9 @@ struct NppGUI
|
||||
bool _enableTagAttrsHilite;
|
||||
bool _enableHiliteNonHTMLZone;
|
||||
bool _styleMRU;
|
||||
char _leftmostDelimiter, _rightmostDelimiter;
|
||||
bool _delimiterSelectionOnEntireDocument;
|
||||
|
||||
|
||||
// 0 : do nothing
|
||||
// 1 : don't draw underline
|
||||
|
Loading…
Reference in New Issue
Block a user