test editable editor shortcut

This commit is contained in:
Basile Burg 2015-02-21 13:58:34 +01:00
parent 9e5278f221
commit 3ff19f5160
1 changed files with 46 additions and 13 deletions

View File

@ -7,8 +7,8 @@ interface
uses uses
Classes, SysUtils, FileUtil, ExtendedNotebook, Forms, Controls, lcltype, Classes, SysUtils, FileUtil, ExtendedNotebook, Forms, Controls, lcltype,
Graphics, SynEditKeyCmds, ComCtrls, SynEditHighlighter, ExtCtrls, Menus, Graphics, SynEditKeyCmds, ComCtrls, SynEditHighlighter, ExtCtrls, Menus,
SynMacroRecorder, SynPluginSyncroEdit, SynEdit, SynCompletion, ce_widget, SynMacroRecorder, SynPluginSyncroEdit, SynEdit, SynCompletion,
ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer; ce_widget, ce_interfaces, ce_synmemo, ce_dlang, ce_common, ce_dcd, ce_observer;
type type
@ -19,7 +19,7 @@ type
procedure SetVisible(Value: Boolean); override; procedure SetVisible(Value: Boolean); override;
end; end;
TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler) TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler, ICEEditableShortCut)
PageControl: TExtendedNotebook; PageControl: TExtendedNotebook;
macRecorder: TSynMacroRecorder; macRecorder: TSynMacroRecorder;
editorStatus: TStatusBar; editorStatus: TStatusBar;
@ -36,9 +36,10 @@ type
fDoc: TCESynMemo; fDoc: TCESynMemo;
// TODO-cbugfix: syncro-edit partially broken, undetermined condition // TODO-cbugfix: syncro-edit partially broken, undetermined condition
fSyncEdit: TSynPluginSyncroEdit; fSyncEdit: TSynPluginSyncroEdit;
tokLst: TLexTokenList; fTokList: TLexTokenList;
errLst: TLexErrorList; fErrList: TLexErrorList;
fModStart: boolean; fModStart: boolean;
fShortcutCount: Integer;
{$IFDEF LINUX} {$IFDEF LINUX}
procedure pageCloseBtnClick(Sender: TObject); procedure pageCloseBtnClick(Sender: TObject);
{$ENDIF} {$ENDIF}
@ -64,6 +65,10 @@ type
function findDocument(aFilename: string): TCESynMemo; function findDocument(aFilename: string): TCESynMemo;
procedure openDocument(aFilename: string); procedure openDocument(aFilename: string);
function closeDocument(index: Integer): boolean; function closeDocument(index: Integer): boolean;
//
function scedWantFirst: boolean;
function scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean;
procedure scedSendItem(const category, identifier: string; aShortcut: TShortcut);
public public
constructor create(aOwner: TComponent); override; constructor create(aOwner: TComponent); override;
destructor destroy; override; destructor destroy; override;
@ -88,8 +93,8 @@ var
begin begin
inherited; inherited;
// //
tokLst := TLexTokenList.Create; fTokList := TLexTokenList.Create;
errLst := TLexErrorList.Create; fErrList := TLexErrorList.Create;
// //
completion.OnPaintItem := @completionItemPaint; completion.OnPaintItem := @completionItemPaint;
fSyncEdit := TSynPluginSyncroEdit.Create(self); fSyncEdit := TSynPluginSyncroEdit.Create(self);
@ -120,8 +125,8 @@ begin
if PageControl.Page[i].ControlCount > 0 then if PageControl.Page[i].ControlCount > 0 then
if (PageControl.Page[i].Controls[0] is TCESynMemo) then if (PageControl.Page[i].Controls[0] is TCESynMemo) then
PageControl.Page[i].Controls[0].Free; PageControl.Page[i].Controls[0].Free;
tokLst.Free; fTokList.Free;
errLst.Free; fErrList.Free;
inherited; inherited;
end; end;
@ -252,6 +257,34 @@ begin
end; end;
{$ENDREGION} {$ENDREGION}
{$REGION ICEEDitableSHortcut ---------------------------------------------------}
function TCEEditorWidget.scedWantFirst: boolean;
begin
result := fDoc <> nil;
fShortcutCount := 0;
end;
function TCEEditorWidget.scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean;
var
shrct: TSynEditKeyStroke;
begin
result := false;
if fShortcutCount > fDoc.Keystrokes.Count-1 then exit;
//
shrct := fDoc.Keystrokes.Items[fShortcutCount];
category := 'Editor';
identifier:= shrct.DisplayName;
aShortcut := Shortcut(shrct.Key, shrct.Shift);
//
fShortcutCount += 1;
result := true;
end;
procedure TCEEditorWidget.scedSendItem(const category, identifier: string; aShortcut: TShortcut);
begin
end;
{$ENDREGION}
{$REGION PageControl/Editor things ---------------------------------------------} {$REGION PageControl/Editor things ---------------------------------------------}
{$IFDEF LINUX} {$IFDEF LINUX}
@ -411,15 +444,15 @@ begin
fKeyChanged := false; fKeyChanged := false;
if fDoc.Lines.Count = 0 then exit; if fDoc.Lines.Count = 0 then exit;
// //
lex(fDoc.Lines.Text, tokLst, @lexFindToken); lex(fDoc.Lines.Text, fTokList, @lexFindToken);
md := ''; md := '';
if fDoc.isDSource then if fDoc.isDSource then
md := getModuleName(tokLst); md := getModuleName(fTokList);
if md = '' then md := extractFileName(fDoc.fileName); if md = '' then md := extractFileName(fDoc.fileName);
pageControl.ActivePage.Caption := md; pageControl.ActivePage.Caption := md;
// //
tokLst.Clear; fTokList.Clear;
errLst.Clear; fErrList.Clear;
// when a widget saves a temp file & syncro mode is on: // when a widget saves a temp file & syncro mode is on:
// - editor is saved // - editor is saved
// - gutter is updated (green bar indicating a saved block) // - gutter is updated (green bar indicating a saved block)