From 44e28a94a80f4444b5b90eb7bb3da4fbd79a7d57 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 13 Mar 2016 18:40:15 +0100 Subject: [PATCH] editor, add more brace auto-closing modes --- src/ce_synmemo.pas | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index c403ca54..4b284dbc 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -25,7 +25,9 @@ type autoCloseNever, autoCloseAtEof, autoCloseAlways, - autoCloseLexically + autoCloseLexically, + autoCloseOnNewLine, + autoCloseLexicallyOnNewLine ); TIdentifierMatchOptions = set of TIdentifierMatchOption; @@ -1388,6 +1390,27 @@ end; {$REGION user input ------------------------------------------------------------} procedure TCESynMemo.KeyDown(var Key: Word; Shift: TShiftState); begin + if Key = VK_RETURN then + begin + if (fAutoCloseCurlyBrace in [autoCloseOnNewLine, autoCloseLexicallyOnNewLine]) + and (CaretX > 1) and (LineText[CaretX-1] = '{') then + begin + if fAutoCloseCurlyBrace = autoCloseOnNewLine then + begin + Key := 0; + curlyBraceCloseAndIndent(self); + end + else begin + fLexToks.Clear; + lex(lines.Text, fLexToks); + if lexCanCloseBrace then + begin + Key := 0; + curlyBraceCloseAndIndent(self); + end; + end; + end; + end; inherited; highlightCurrentIdentifier; if fCompletion.IsActive then @@ -1414,7 +1437,7 @@ end; procedure TCESynMemo.KeyUp(var Key: Word; Shift: TShiftState); begin case Key of - VK_PRIOR, VK_NEXT, Vk_UP: fPositions.store; + VK_PRIOR, VK_NEXT, VK_UP: fPositions.store; VK_OEM_PERIOD, VK_DECIMAL: fCanAutoDot := true; end; inherited;