mirror of https://gitlab.com/basile.b/dexed.git
added additional brace closing option, lexically
This commit is contained in:
parent
d265769009
commit
7b423b5b34
|
@ -10,7 +10,7 @@ uses
|
|||
SynHighlighterLFM, SynEditHighlighter, SynEditMouseCmds, SynEditFoldedView,
|
||||
SynEditMarks, SynEditTypes, SynHighlighterJScript,
|
||||
ce_common, ce_observer, ce_writableComponent, ce_d2syn, ce_txtsyn, ce_dialogs,
|
||||
ce_sharedres;
|
||||
ce_sharedres, ce_dlang;
|
||||
|
||||
type
|
||||
|
||||
|
@ -24,7 +24,8 @@ type
|
|||
TBraceAutoCloseStyle = (
|
||||
autoCloseNever,
|
||||
autoCloseAtEof,
|
||||
autoCloseAlways
|
||||
autoCloseAlways,
|
||||
autoCloseLexically
|
||||
);
|
||||
|
||||
TIdentifierMatchOptions = set of TIdentifierMatchOption;
|
||||
|
@ -138,6 +139,7 @@ type
|
|||
fCallTipStrings: TStringList;
|
||||
fOverrideColMode: boolean;
|
||||
fAutoCloseCurlyBrace: TBraceAutoCloseStyle;
|
||||
fLexToks: TLexTokenList;
|
||||
procedure setMatchOpts(value: TIdentifierMatchOptions);
|
||||
function getMouseFileBytePos: Integer;
|
||||
procedure changeNotify(Sender: TObject);
|
||||
|
@ -164,6 +166,7 @@ type
|
|||
procedure removeBreakPoint(line: integer);
|
||||
function findBreakPoint(line: integer): boolean;
|
||||
procedure showCallTips(const tips: string);
|
||||
function lexCanCloseBrace: boolean;
|
||||
protected
|
||||
procedure DoEnter; override;
|
||||
procedure DoExit; override;
|
||||
|
@ -468,6 +471,7 @@ begin
|
|||
fDefaultFontSize := 10;
|
||||
Font.Size:=10;
|
||||
SetDefaultCoeditKeystrokes(Self); // not called in inherited if owner = nil !
|
||||
fLexToks:= TLexTokenList.Create;
|
||||
//
|
||||
OnDragDrop:= @ddHandler.DragDrop;
|
||||
OnDragOver:= @ddHandler.DragOver;
|
||||
|
@ -557,6 +561,8 @@ begin
|
|||
fCompletion.Free;
|
||||
fBreakPoints.Free;
|
||||
fCallTipStrings.Free;
|
||||
fLexToks.Clear;
|
||||
fLexToks.Free;
|
||||
//
|
||||
if fTempFileName.fileExists then
|
||||
sysutils.DeleteFile(fTempFileName);
|
||||
|
@ -1072,6 +1078,21 @@ end;
|
|||
{$ENDREGION --------------------------------------------------------------------}
|
||||
|
||||
{$REGION Coedit memo things ----------------------------------------------------}
|
||||
function TCESynMemo.lexCanCloseBrace: boolean;
|
||||
var
|
||||
i: integer;
|
||||
c: integer = 0;
|
||||
tok: PLexToken;
|
||||
begin
|
||||
for i := 0 to fLexToks.Count-1 do
|
||||
begin
|
||||
tok := PLexToken(fLexToks[i]);
|
||||
c += byte((tok^.kind = TLexTokenKind.ltkSymbol) and (tok^.Data = '{'));
|
||||
c -= byte((tok^.kind = TLexTokenKind.ltkSymbol) and (tok^.Data = '}'));
|
||||
end;
|
||||
exit(c > 0);
|
||||
end;
|
||||
|
||||
procedure TCESynMemo.SetHighlighter(const Value: TSynCustomHighlighter);
|
||||
begin
|
||||
inherited;
|
||||
|
@ -1341,13 +1362,20 @@ begin
|
|||
else
|
||||
showCallTips(fCallTipStrings.Text);
|
||||
end;
|
||||
'{': if fAutoCloseCurlyBrace <> autoCloseNever then
|
||||
begin
|
||||
if fAutoCloseCurlyBrace = autoCloseAlways then
|
||||
curlyBraceCloseAndIndent(self)
|
||||
else if (CaretY = Lines.Count) and (CaretX = LineText.length+1) then
|
||||
curlyBraceCloseAndIndent(self);
|
||||
end;
|
||||
'{': case fAutoCloseCurlyBrace of
|
||||
autoCloseAlways:
|
||||
curlyBraceCloseAndIndent(self);
|
||||
autoCloseAtEof:
|
||||
if (CaretY = Lines.Count) and (CaretX = LineText.length+1) then
|
||||
curlyBraceCloseAndIndent(self);
|
||||
autoCloseLexically:
|
||||
begin
|
||||
fLexToks.Clear;
|
||||
lex(lines.Text, fLexToks);
|
||||
if lexCanCloseBrace then
|
||||
curlyBraceCloseAndIndent(self);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if fCompletion.IsActive then
|
||||
fCompletion.CurrentString:=GetWordAtRowCol(LogicalCaretXY);
|
||||
|
|
|
@ -470,7 +470,7 @@ Custom macros can be edited in the [options editor][lnk_widg_opts]:
|
|||
|
||||

|
||||
|
||||
Note that since version 2, the pre-defined macros are not hardcoded anymore and they can be completly deleted.
|
||||
Note that since version 2, the predefined macros are not hardcoded anymore and they can be completely deleted.
|
||||
|
||||
#### Editor options
|
||||
|
||||
|
@ -484,7 +484,7 @@ They cover many aspects of the editor:
|
|||
|
||||

|
||||
|
||||
The editor shortcuts are listed here:
|
||||
The shortcuts are editable from the [option editor][lnk_widg_opts], category _Shortcuts, Code editor_:
|
||||
|
||||

|
||||
|
||||
|
@ -517,13 +517,13 @@ The _find and replace_ widget allows to find and replace text patterns in the fo
|
|||
- allow regex: when checked, the search is performed by a regex engine (which doesn't mean that the pattern to find has to be a regex).
|
||||
|
||||
By default <kbd>CTRL</kbd> + <kbd>F</kbd> is used to pass the current identifier to the first field and <kbd>F3</kbd> to execute a search.
|
||||
Unless _Find all_ is used, the results are directly visible in the editor.
|
||||
_Find all_ results are displayed in the [messages widget][lnk_widg_msg] and are clickable.
|
||||
_Find all_ results are displayed in the [messages widget][lnk_widg_msg], with a context and they are clickable.
|
||||
|
||||

|
||||
|
||||
The scope of _Find all_ can be set, either to the current editor or to the whole project, by clicking the icon at the right.
|
||||
|
||||
The most recent searches and replacements are saved between each session.
|
||||
|
||||
Note that to find a symbol, <kbd>Ctrl</kbd> + <kbd>MB Left</kbd> or the [symbol list][lnk_widg_symlist] are faster.
|
||||
Note that to find the declaration of a symbol, <kbd>Ctrl</kbd> + <kbd>MB Left</kbd> or the [symbol list][lnk_widg_symlist] are faster.
|
||||
|
||||
## Library manager widget
|
||||
|
||||
|
@ -803,7 +803,7 @@ When double-clicked, a message is parsed in order to extract a *position* and a
|
|||
If the operation is successful then the *file* will be opened at a *position*.
|
||||
So far, *DMD* and *[_Dscanner_](https://www.github.com/Hackerpilot/Dscanner)* or DUB messages are well parsed.
|
||||
The messages emitted by custom tools can be clickable if they follow a similar format.
|
||||
(**`<relative | absolute filename> <(line [:column])><message body>`**).
|
||||
(**`<relative|absolute filename><(line[:column])><message body>`**).
|
||||
|
||||
The context menu contains a few useful actions, such as *copy messages*, *save message(s) to file*.
|
||||
By default only the last 500 messages are displayed, regardless of the categories.
|
||||
|
@ -958,7 +958,7 @@ This tutorial will cover, from A to Z the integration of this tool to the Coedit
|
|||
|
||||
####Prepare the Coedit Project to build harbored
|
||||
|
||||
- [Clone][harbGit] harbored-mod repository and its submodules.
|
||||
- [Clone][harbGit] harbored-mod repository and its sub modules.
|
||||
- Open Coedit and initialize a new project. Start by adding the **src/** folder to the project files.
|
||||
|
||||

|
||||
|
@ -1155,7 +1155,7 @@ In the menu **Project** click **Compile project**.
|
|||
The static library is build. We'll add it to the [_libman_][lnk_widg_lib].
|
||||
Start by adding a new item (icon add).
|
||||
Click on to select the library file produced previously (icon brick).
|
||||
The alias will be set automatically to the library filename, without its extension.
|
||||
The alias will be set automatically to the library file name, without its extension.
|
||||
|
||||
Click to select the path to the sources.
|
||||
Select **`<path to libdparse>\src`**,
|
||||
|
|
Loading…
Reference in New Issue