mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #4574 from RaiKoHoff/Dev_Master
Enhancement for auto-close char-pairs
This commit is contained in:
commit
adac8a1e3e
@ -8358,23 +8358,39 @@ static void _HandleInsertCheck(const SCNotification* const scn)
|
||||
}
|
||||
if (Settings.AutoCloseQuotes) {
|
||||
if (scn->length == 1) {
|
||||
bool bInserted = true;
|
||||
DocPos len = 0;
|
||||
switch (scn->text[0]) {
|
||||
case '"':
|
||||
len = _EncloseSelectionBuffer('"', '"');
|
||||
if (Sci_GetCurrChar() == '"') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
else {
|
||||
len = _EncloseSelectionBuffer('"', '"');
|
||||
}
|
||||
break;
|
||||
case '\'':
|
||||
len = _EncloseSelectionBuffer('\'', '\'');
|
||||
if (Sci_GetCurrChar() == '\'') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
else {
|
||||
len = _EncloseSelectionBuffer('\'', '\'');
|
||||
}
|
||||
break;
|
||||
case '`':
|
||||
len = _EncloseSelectionBuffer('`', '`');
|
||||
if (Sci_GetCurrChar() == '`') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
else {
|
||||
len = _EncloseSelectionBuffer('`', '`');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bInserted = false;
|
||||
break;
|
||||
}
|
||||
if (bInserted) {
|
||||
if (len) {
|
||||
SciCall_ChangeInsertion(len, s_SelectionBuffer);
|
||||
if (len == 2) {
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARLEFT, 0, 0);
|
||||
@ -8384,7 +8400,6 @@ static void _HandleInsertCheck(const SCNotification* const scn)
|
||||
}
|
||||
if (Settings.AutoCloseBrackets) {
|
||||
if (scn->length == 1) {
|
||||
bool bInserted = true;
|
||||
DocPos len = 0;
|
||||
switch (scn->text[0]) {
|
||||
case '[':
|
||||
@ -8396,11 +8411,28 @@ static void _HandleInsertCheck(const SCNotification* const scn)
|
||||
case '(':
|
||||
len = _EncloseSelectionBuffer('(', ')');
|
||||
break;
|
||||
case ')':
|
||||
if (Sci_GetCurrChar() == ')') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
if (Sci_GetCurrChar() == '}') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
break;
|
||||
case ']':
|
||||
if (Sci_GetCurrChar() == ']') {
|
||||
SciCall_ChangeInsertion(0, ""); // clear
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARRIGHT, 0, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bInserted = false;
|
||||
break;
|
||||
}
|
||||
if (bInserted) {
|
||||
if (len) {
|
||||
SciCall_ChangeInsertion(len, s_SelectionBuffer);
|
||||
if (len == 2) {
|
||||
PostMessage(Globals.hwndEdit, SCI_CHARLEFT, 0, 0);
|
||||
|
||||
@ -772,6 +772,9 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool);
|
||||
#define Sci_GetLineStartPosition(position) SciCall_PositionFromLine(SciCall_LineFromPosition(position))
|
||||
#define Sci_GetLineEndPosition(position) SciCall_GetLineEndPosition(SciCall_LineFromPosition(position))
|
||||
|
||||
#define Sci_GetCurrChar() SciCall_GetCharAt(SciCall_GetCurrentPos())
|
||||
#define Sci_GetNextChar() SciCall_GetCharAt(SciCall_PositionAfter(SciCall_GetCurrentPos()))
|
||||
|
||||
// length of line w/o line-end chars (full use SciCall_LineLength()
|
||||
#define Sci_GetNetLineLength(line) (SciCall_GetLineEndPosition(line) - SciCall_PositionFromLine(line))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user