From 8d6b6f8b99cfdb184782fbbbced2ec8f476144cc Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 13 Mar 2016 22:09:07 +0100 Subject: [PATCH] editor, auto close on new line, change so that each mode has the 3 same sub modes --- src/ce_synmemo.pas | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 4b284dbc..f324ee5a 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -26,8 +26,9 @@ type autoCloseAtEof, autoCloseAlways, autoCloseLexically, - autoCloseOnNewLine, - autoCloseLexicallyOnNewLine + autoCloseOnNewLineEof, + autoCloseOnNewLineAlways, + autoCloseOnNewLineLexically ); TIdentifierMatchOptions = set of TIdentifierMatchOption; @@ -1392,15 +1393,22 @@ procedure TCESynMemo.KeyDown(var Key: Word; Shift: TShiftState); begin if Key = VK_RETURN then begin - if (fAutoCloseCurlyBrace in [autoCloseOnNewLine, autoCloseLexicallyOnNewLine]) + if (fAutoCloseCurlyBrace in [autoCloseOnNewLineEof .. autoCloseOnNewLineLexically]) and (CaretX > 1) and (LineText[CaretX-1] = '{') then - begin - if fAutoCloseCurlyBrace = autoCloseOnNewLine then + case fAutoCloseCurlyBrace of + autoCloseOnNewLineAlways: begin Key := 0; curlyBraceCloseAndIndent(self); - end - else begin + end; + autoCloseOnNewLineEof: + if (CaretY = Lines.Count) and (CaretX = LineText.length+1) then + begin + Key := 0; + curlyBraceCloseAndIndent(self); + end; + autoCloseOnNewLineLexically: + begin fLexToks.Clear; lex(lines.Text, fLexToks); if lexCanCloseBrace then