editor, display macro recorded state in status bar

This commit is contained in:
Basile Burg 2015-12-17 02:56:51 +01:00
parent ed11f2db5d
commit 6657eb52ff
4 changed files with 81 additions and 49 deletions

View File

@ -21,7 +21,6 @@ inherited CEEditorWidget: TCEEditorWidget
Height = 18
Top = 386
Width = 465
AutoSize = False
BorderSpacing.Bottom = 2
Panels = <
item
@ -32,6 +31,9 @@ inherited CEEditorWidget: TCEEditorWidget
end
item
Width = 200
end
item
Width = 50
end>
SimplePanel = False
end
@ -42,8 +44,8 @@ inherited CEEditorWidget: TCEEditorWidget
top = 16
end
object macRecorder: TSynMacroRecorder[2]
RecordShortCut = 24658
PlaybackShortCut = 24656
RecordShortCut = 0
PlaybackShortCut = 0
left = 80
top = 16
end

View File

@ -13,8 +13,6 @@ uses
type
//TODO-crefact: moves the macro recorded to TCESynMemo, + add visual feedback + declare shortcuts ecXXXX
{ TCEEditorWidget }
TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler)
@ -199,8 +197,6 @@ begin
exit('ICEMultiDocHandler');
end;
//TODO-cfeature: jump to definition, don't open/select tab if origin is in right split view
function TCEEditorWidget.documentCount: Integer;
begin
exit(PageControl.PageCount);
@ -275,7 +271,6 @@ end;
procedure TCEEditorWidget.focusedEditorChanged;
begin
macRecorder.Clear;
if fDoc = nil then exit;
//
macRecorder.Editor:= fDoc;
@ -320,8 +315,24 @@ procedure TCEEditorWidget.memoCmdProcessed(Sender: TObject; var Command: TSynEdi
begin
fLastCommand := Command;
//
if Command = ecJumpToDeclaration then
case Command of
ecJumpToDeclaration:
getSymbolLoc;
ecRecordMacro:
begin
if macRecorder.State = msStopped then
macRecorder.RecordMacro(fDoc)
else
macRecorder.Stop;
updateImperative;
end;
ecPlayMacro:
begin
macRecorder.Stop;
macRecorder.PlaybackMacro(fDoc);
updateImperative;
end;
end;
end;
procedure TCEEditorWidget.memoKeyPress(Sender: TObject; var Key: char);
@ -399,10 +410,17 @@ begin
editorStatus.Panels[0].Text := '';
editorStatus.Panels[1].Text := '';
editorStatus.Panels[2].Text := '';
editorStatus.Panels[3].Text := '';
end else begin
editorStatus.Panels[0].Text := format('%d : %d | %d', [fDoc.CaretY, fDoc.CaretX, fDoc.SelEnd - fDoc.SelStart]);
editorStatus.Panels[1].Text := modstr[fDoc.modified];
editorStatus.Panels[2].Text := fDoc.fileName;
if macRecorder.State = msRecording then
editorStatus.Panels[3].Text := 'recording macro'
else if macRecorder.IsEmpty then
editorStatus.Panels[3].Text := 'no macro'
else
editorStatus.Panels[3].Text := 'macro ready';
if Visible and (pageControl.currentPage <> nil) and ((pageControl.currentPage.Caption = '') or
(pageControl.currentPage.Caption = '<new document>')) then
begin

View File

@ -220,6 +220,8 @@ const
ecJumpToDeclaration = ecUserFirst + 2;
ecPreviousLocation = ecUserFirst + 3;
ecNextLocation = ecUserFirst + 4;
ecRecordMacro = ecUserFirst + 5;
ecPlayMacro = ecUserFirst + 6;
var
D2Syn: TSynD2Syn; // used as model to set the options when no editor exists.
@ -687,6 +689,8 @@ begin
AddKey(ecJumpToDeclaration, VK_UP, [ssCtrl,ssShift], 0, []);
AddKey(ecPreviousLocation, 0, [], 0, []);
AddKey(ecNextLocation, 0, [], 0, []);
AddKey(ecRecordMacro, ord('R'), [ssCtrl,ssShift], 0, []);
AddKey(ecPlayMacro, ord('P'), [ssCtrl,ssShift], 0, []);
end;
end;
@ -697,6 +701,8 @@ begin
'ecJumpToDeclaration': begin Int := ecJumpToDeclaration; exit(true); end;
'ecPreviousLocation': begin Int := ecPreviousLocation; exit(true); end;
'ecNextLocation': begin Int := ecNextLocation; exit(true); end;
'ecRecordMacro': begin Int := ecRecordMacro; exit(true); end;
'ecPlayMacro': begin Int := ecPlayMacro; exit(true); end;
else exit(false);
end;
end;
@ -708,6 +714,8 @@ begin
ecJumpToDeclaration: begin Ident := 'ecJumpToDeclaration'; exit(true); end;
ecPreviousLocation: begin Ident := 'ecPreviousLocation'; exit(true); end;
ecNextLocation: begin Ident := 'ecNextLocation'; exit(true); end;
ecRecordMacro: begin Ident := 'ecRecordMacro'; exit(true); end;
ecPlayMacro: begin Ident := 'ecPlayMacro'; exit(true); end;
else exit(false);
end;
end;
@ -800,24 +808,6 @@ begin
getCompletionList;
end;
procedure TCESynMemo.DoOnProcessCommand(var Command: TSynEditorCommand;
var AChar: TUTF8Char; Data: pointer);
begin
inherited;
case Command of
ecCompletionMenu:
begin
fCanAutoDot:=false;
fCompletion.Execute(GetWordAtRowCol(LogicalCaretXY),
ClientToScreen(point(CaretXPix, CaretYPix + LineHeight)));
end;
ecPreviousLocation:
fPositions.back;
ecNextLocation:
fPositions.next;
end;
end;
procedure TCESynMemo.getCompletionList;
begin
if not DcdWrapper.available then exit;
@ -871,6 +861,24 @@ end;
{$ENDREGION --------------------------------------------------------------------}
{$REGION Coedit memo things ----------------------------------------------------}
procedure TCESynMemo.DoOnProcessCommand(var Command: TSynEditorCommand;
var AChar: TUTF8Char; Data: pointer);
begin
inherited;
case Command of
ecCompletionMenu:
begin
fCanAutoDot:=false;
fCompletion.Execute(GetWordAtRowCol(LogicalCaretXY),
ClientToScreen(point(CaretXPix, CaretYPix + LineHeight)));
end;
ecPreviousLocation:
fPositions.back;
ecNextLocation:
fPositions.next;
end;
end;
procedure TCESynMemo.SetHighlighter(const Value: TSynCustomHighlighter);
begin
inherited;

View File

@ -418,17 +418,16 @@ The _source editor widget_ is a standard code editor, specialized for highlighti
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/sourceditor1.png)
It's based on the [**Synedit**](http://wiki.freepascal.org/SynEdit) suite, a powerful set of Pascal components and classes,
which can be described as a _"Scintilla for Pascal"_. It features:
#### Overview
- folding (curly brackets blocks, multi-line strings, block comments, nested block comments, DDoc comments blocks).
- colorization of the following categories: keywords, numbers, symbols, comments, assembler instructions and identifiers, DDoc comments.
- folding: curly brackets blocks, multi-line strings, block comments, nested block comments, DDoc comments blocks.
- colorization of the following categories: keywords, special keywords, numbers, symbols, comments, assembler instructions and identifiers, DDoc comments.
- current identifier markup, selection markup.
- standard keyboard navigation shortcuts <kbd>CTRL</kbd> + (<kbd>SHIFT</kbd> +) <kbd>LEFT</kbd>/<kbd>RIGHT</kbd>, <kbd>CTRL</kbd> + <kbd>HOME</kbd>, <kbd>CTRL</kbd> + <kbd>END</kbd> etc.
- macro recording and playback using <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>R</kbd> (start/stop recording) or <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>P</kbd> (play).
- synchro-edit (activated when clicking the pen icon located in the gutter, or with the shortcut <kbd>CTRL</kbd>+<kbd>E</kbd> and <kbd>CTRL</kbd>+<kbd>SHIFT</kbd>+<kbd>E</kbd>).
- zoom: (<kbd>CTRL</kbd>+<kbd>WHEEL</kbd>, <kbd>CTRL</kbd>+<kbd>MIDDLE MB</kbd>, <kbd>CTRL</kbd>+<kbd>+</kbd>, <kbd>CTRL</kbd>+<kbd>-</kbd>, <kbd>CTRL</kbd>+<kbd>.</kbd>).
- display cache: for each document, the zoom ratio, the folds and the caret position are saved between two sessions. A cache file has a fixed life-time of three months from its last modification.
- display cache: for each document, the zoom ratio, the folding state and the caret position are saved between two sessions. A cache file has a fixed life-time of three months from its last modification.
- drag & drop editing.
- external modification tracking. Each time the focus is put on a document (switch document, show & hide application), Coedit verifies if its time stamp has changed.
- static macros.
@ -437,13 +436,13 @@ which can be described as a _"Scintilla for Pascal"_. It features:
- split view: an editor can be pined to the right.
- most recent location buffer: instead of bookmarks, the most recent caret positions are stored in a buffer. Positions can be recovered with the lateral mouse buttons (_X1_ & _X2_) or with the multimedia keyboard keys _next web page_ & _previous web page_.
### Custom regions
#### Custom regions
The custom regions are defined in single line comments.
A region starts with a comment that ends with at least three hyphens and a add symbol.
A region starts with a comment that ends with at least three hyphens and a plus symbol.
A region stops with a comment ending with at least four hyphens.
For example:
Two valid examples:
```D
// ctor/dtor -------------+
@ -458,7 +457,11 @@ T opIndex(size_t i){}
// ----
```
### Static macros
Regions are saved and reloaded with the editor cache. They give a clear and compact view of a module:
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/editor.regions.png)
#### Static macros
The static macros can be described as *parameter-less code snippets*.
A static macro starts with the dollar symbol and ends with an alphabetic character.
@ -468,9 +471,9 @@ Custom macros can be edited in the [options editor][lnk_widg_opts]:
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/optmacros.png)
Note that the pre-defined macros are not hardcoded anymore and they can be completly deleted.
Note that since version 2, the pre-defined macros are not hardcoded anymore and they can be completly deleted.
### Editor options
#### Editor options
Editor options are displayed in the [option editor][lnk_widg_opts].
They cover many aspects of the editor:
@ -486,7 +489,7 @@ The editor shortcuts are listed here:
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/editor.shortcuts.png)
### Split view
#### Split view
The split view allows to pin one of the document to the right of the other documents.
To pin a document, open it in an editor and click the right-most toolbar button.
@ -496,7 +499,8 @@ The document to pin can be replaced on the fly, still using the same button, and
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/editor.splitview.png)
It's useful to display a module that contains the types, the enums or the prototypes of a library binding since it's not anymore necessary to change the editor page to verify the members of an enum or the parameters of a function.
It's useful to display a module that contains the declarations of a library binding since it's not anymore necessary to change the editor page to verify the members of an enum or the parameters of a function.
Note that the action _jump to declaration_ (see [DCD][lnk_dcd]) is adapted so that the page index is not modified if the declaration definition is in the document that's pined to the right.
## Find & replace widget
@ -546,17 +550,17 @@ This can be skipped if the library is only a small orphan _d_ source that's not
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/other/script_bricks.png): set the project file that matches the selected item.
If they're not automatically detected, it's recommended to add the _runtime library_ and _phobos_.
A bunch of third party libraries are provided by the [_metad_][lnk_metad] repository.
A collection of third party libraries are provided by the [_metad_][lnk_metad] repository.
All of them can be easily build in Coedit and setup in the _libman_.
The library entries are saved in the user folder[ (see options)][lnk_widg_opts] as _libraryManager.txt_.
The library entries are saved in the user folder [(see options)][lnk_widg_opts] as _libraryManager.txt_.
## Symbol list widget
The symbol list enumerates the declarations found in a D module (imports, classes, variables, and so on).
The widget is a GUI front end for the [_cesyms_][lnk_cesyms] tool.
It can be used to quickly find and go to the declaration of a symbol but also as a basic linter since the
syntactic errors are displayed (in real time if the option _refresh on change_ is checked).
syntactic errors are displayed (almost immediately if the option _refresh on change_ is checked).
![](https://raw.githubusercontent.com/BBasile/CoeditWikiData/master/symlist1.png)
@ -579,7 +583,7 @@ Notice that instead of using the dialogs to add some files, it's also possible t
## Project configuration widget
The project configuration widget is a powerful editor for the compiler options. By design it uses an "_Object Inspector_" GUI element (_TIPropertyGrid_).
The project configuration widget is a powerful editor for the compiler options. By design it uses an "_Object Inspector_" GUI element.
If this choice has avoided a painful GUI designing work, it also perfectly represents the way the classes that encapsulates the compiler options have been programmed. (see _ce_dmdwrap.pas_).
- ![](https://raw.githubusercontent.com/BBasile/Coedit/master/icons/cog/cog_add.png): adds a new compiler configuration. An input-query dialog allows to directly set its name (see the above note about the configuration name).