mirror of https://gitlab.com/basile.b/dexed.git
add shortcuts for the pagecontrol, close #61
This commit is contained in:
parent
e15c44577c
commit
573b14854b
|
@ -9,25 +9,39 @@ uses
|
||||||
ComCtrls, SynEditHighlighter, ExtCtrls, Menus, SynMacroRecorder, dialogs,
|
ComCtrls, SynEditHighlighter, ExtCtrls, Menus, SynMacroRecorder, dialogs,
|
||||||
SynPluginSyncroEdit, SynEdit, SynHighlighterMulti, ce_dialogs,
|
SynPluginSyncroEdit, SynEdit, SynHighlighterMulti, ce_dialogs,
|
||||||
ce_widget, 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,
|
||||||
ce_sharedres, ce_controls, ce_writableComponent;
|
ce_sharedres, ce_controls, ce_writableComponent, LMessages;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
TCEEditorWidget = class;
|
TCEEditorWidget = class;
|
||||||
|
|
||||||
TCEPagesOptions = class(TWritableLfmTextComponent, ICEEditableOptions)
|
TCEPagesOptions = class(TWritableLfmTextComponent, ICEEditableOptions, ICEEditableShortCut)
|
||||||
private
|
private
|
||||||
fEditorWidget: TCEEditorWidget;
|
fEditorWidget: TCEEditorWidget;
|
||||||
fPageButtons: TCEPageControlButtons;
|
fPageButtons: TCEPageControlButtons;
|
||||||
fPageOptions: TCEPageControlOptions;
|
fPageOptions: TCEPageControlOptions;
|
||||||
|
fMoveLeft: TShortCut;
|
||||||
|
fMoveRight: TShortCut;
|
||||||
|
fNextPage: TShortCut;
|
||||||
|
fPrevPage: TShortCut;
|
||||||
|
fShCount: integer;
|
||||||
function optionedWantCategory(): string;
|
function optionedWantCategory(): string;
|
||||||
function optionedWantEditorKind: TOptionEditorKind;
|
function optionedWantEditorKind: TOptionEditorKind;
|
||||||
function optionedWantContainer: TPersistent;
|
function optionedWantContainer: TPersistent;
|
||||||
procedure optionedEvent(anEvent: TOptionEditorEvent);
|
procedure optionedEvent(anEvent: TOptionEditorEvent);
|
||||||
function optionedOptionsModified: boolean;
|
function optionedOptionsModified: boolean;
|
||||||
|
//
|
||||||
|
function scedWantFirst: boolean;
|
||||||
|
function scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean;
|
||||||
|
procedure scedSendItem(const category, identifier: string; aShortcut: TShortcut);
|
||||||
|
procedure scedSendDone;
|
||||||
published
|
published
|
||||||
property pageButtons: TCEPageControlButtons read fPageButtons write fPageButtons;
|
property pageButtons: TCEPageControlButtons read fPageButtons write fPageButtons;
|
||||||
property pageOptions: TCEPageControlOptions read fPageOptions write fPageOptions;
|
property pageOptions: TCEPageControlOptions read fPageOptions write fPageOptions;
|
||||||
|
property nextPage: TShortCut read fNextPage write fNextPage;
|
||||||
|
property previousPage: TShortCut read fPrevPage write fPrevPage;
|
||||||
|
property moveLeft: TShortCut read fMoveLeft write fMoveLeft;
|
||||||
|
property moveRight: TShortCut read fMoveRight write fMoveRight;
|
||||||
public
|
public
|
||||||
procedure Assign(Source: TPersistent); override;
|
procedure Assign(Source: TPersistent); override;
|
||||||
procedure AssignTo(Target: TPersistent); override;
|
procedure AssignTo(Target: TPersistent); override;
|
||||||
|
@ -77,8 +91,6 @@ type
|
||||||
procedure mnuedUndoClick(Sender: TObject);
|
procedure mnuedUndoClick(Sender: TObject);
|
||||||
procedure mnuedRedoClick(Sender: TObject);
|
procedure mnuedRedoClick(Sender: TObject);
|
||||||
procedure mnuedJum2DeclClick(Sender: TObject);
|
procedure mnuedJum2DeclClick(Sender: TObject);
|
||||||
procedure PageControlChanged(Sender: TObject);
|
|
||||||
procedure PageControlChanging(Sender: TObject; var AllowChange: Boolean);
|
|
||||||
protected
|
protected
|
||||||
procedure updateDelayed; override;
|
procedure updateDelayed; override;
|
||||||
procedure updateImperative; override;
|
procedure updateImperative; override;
|
||||||
|
@ -91,6 +103,8 @@ type
|
||||||
fTokList: TLexTokenList;
|
fTokList: TLexTokenList;
|
||||||
fModStart: boolean;
|
fModStart: boolean;
|
||||||
fLastCommand: TSynEditorCommand;
|
fLastCommand: TSynEditorCommand;
|
||||||
|
procedure PageControlChanged(Sender: TObject);
|
||||||
|
procedure PageControlChanging(Sender: TObject; var AllowChange: Boolean);
|
||||||
procedure updateStatusBar;
|
procedure updateStatusBar;
|
||||||
procedure updatePageCaption;
|
procedure updatePageCaption;
|
||||||
procedure pageBtnAddCLick(Sender: TObject);
|
procedure pageBtnAddCLick(Sender: TObject);
|
||||||
|
@ -211,6 +225,42 @@ function TCEPagesOptions.optionedOptionsModified: boolean;
|
||||||
begin
|
begin
|
||||||
exit(false);
|
exit(false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCEPagesOptions.scedWantFirst: boolean;
|
||||||
|
begin
|
||||||
|
fShCount := 0;
|
||||||
|
exit(true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCEPagesOptions.scedWantNext(out category, identifier: string; out aShortcut: TShortcut): boolean;
|
||||||
|
begin
|
||||||
|
category := 'Editor pages';
|
||||||
|
case fShCount of
|
||||||
|
0: begin identifier := 'Select next page'; aShortcut:= fNextPage; end;
|
||||||
|
1: begin identifier := 'Select previous page'; aShortcut:= fPrevPage; end;
|
||||||
|
2: begin identifier := 'Move page left'; aShortcut:= fMoveLeft; end;
|
||||||
|
3: begin identifier := 'Move page right'; aShortcut:= fMoveRight; end;
|
||||||
|
end;
|
||||||
|
fShCount += 1;
|
||||||
|
result := fShCount <> 4;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEPagesOptions.scedSendItem(const category, identifier: string; aShortcut: TShortcut);
|
||||||
|
begin
|
||||||
|
if fShCount = 4 then
|
||||||
|
fShCount := 0;
|
||||||
|
case fShCount of
|
||||||
|
0: fNextPage := aShortcut;
|
||||||
|
1: fPrevPage := aShortcut;
|
||||||
|
2: fMoveLeft := aShortcut;
|
||||||
|
3: fMoveRight:= aShortcut;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCEPagesOptions.scedSendDone;
|
||||||
|
begin
|
||||||
|
fShCount := 0;
|
||||||
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION Standard Comp/Obj------------------------------------------------------}
|
{$REGION Standard Comp/Obj------------------------------------------------------}
|
||||||
|
@ -270,6 +320,7 @@ function TCEEditorWidget.closeQuery: boolean;
|
||||||
begin
|
begin
|
||||||
result := inherited and Parent.isNil;
|
result := inherited and Parent.isNil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
{$REGION ICEMultiDocObserver ---------------------------------------------------}
|
{$REGION ICEMultiDocObserver ---------------------------------------------------}
|
||||||
|
@ -315,6 +366,7 @@ begin
|
||||||
fDoc := aDoc;
|
fDoc := aDoc;
|
||||||
focusedEditorChanged;
|
focusedEditorChanged;
|
||||||
updateImperative;
|
updateImperative;
|
||||||
|
fDoc.enterEdit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.docChanged(aDoc: TCESynMemo);
|
procedure TCEEditorWidget.docChanged(aDoc: TCESynMemo);
|
||||||
|
@ -472,17 +524,28 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEEditorWidget.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TCEEditorWidget.memoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
var
|
||||||
|
sh: TShortCut;
|
||||||
begin
|
begin
|
||||||
case Key of
|
case Key of
|
||||||
VK_CLEAR,VK_RETURN,VK_BACK : fKeyChanged := true;
|
VK_CLEAR,VK_RETURN,VK_BACK :
|
||||||
|
fKeyChanged := true;
|
||||||
VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT:
|
VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT:
|
||||||
begin
|
if Shift = [] then
|
||||||
if Shift <> [ssCtrl, ssAlt, ssShift] then
|
updateImperative;
|
||||||
updateImperative
|
else begin
|
||||||
else begin
|
sh := KeyToShortCut(Key, shift);
|
||||||
if Key = VK_LEFT then pageControl.pageIndex := pageControl.pageIndex -1
|
if sh = fOptions.fNextPage then
|
||||||
else if Key = VK_RIGHT then pageControl.pageIndex := pageControl.pageIndex +1;
|
begin
|
||||||
end;
|
pageControl.pageIndex:= (pageControl.pageIndex + 1) mod pageControl.pageCount;
|
||||||
|
end
|
||||||
|
else if sh = fOptions.fPrevPage then
|
||||||
|
pageControl.pageIndex:= (pageControl.pageIndex - 1) mod pageControl.pageCount
|
||||||
|
else if sh = fOptions.fMoveLeft then
|
||||||
|
pageControl.movePageLeft
|
||||||
|
else if sh = fOptions.fMoveRight then
|
||||||
|
pageControl.movePageRight
|
||||||
|
else sh := 0;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if fKeyChanged then
|
if fKeyChanged then
|
||||||
|
|
|
@ -192,6 +192,7 @@ type
|
||||||
constructor Create(aOwner: TComponent); override;
|
constructor Create(aOwner: TComponent); override;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
procedure setFocus; override;
|
procedure setFocus; override;
|
||||||
|
procedure enterEdit;
|
||||||
//
|
//
|
||||||
procedure checkFileDate;
|
procedure checkFileDate;
|
||||||
procedure loadFromFile(const aFilename: string);
|
procedure loadFromFile(const aFilename: string);
|
||||||
|
@ -600,11 +601,19 @@ begin
|
||||||
Font.Size := fDefaultFontSize;
|
Font.Size := fDefaultFontSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCESynMemo.enterEdit;
|
||||||
|
var
|
||||||
|
key: word = 0;
|
||||||
|
begin
|
||||||
|
//MouseDown(mbLeft, [], CaretXPix, CaretYPix);
|
||||||
|
//MouseUp(mbLeft, [], CaretXPix, CaretYPix);
|
||||||
|
//TODO-cbugfix: editor has not the input focus after Ctrl+Tab (after pagecontrol.nextPage via shortcut)
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCESynMemo.setFocus;
|
procedure TCESynMemo.setFocus;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
checkFileDate;
|
checkFileDate;
|
||||||
//
|
|
||||||
highlightCurrentIdentifier;
|
highlightCurrentIdentifier;
|
||||||
subjDocFocused(TCEMultiDocSubject(fMultiDocSubject), self);
|
subjDocFocused(TCEMultiDocSubject(fMultiDocSubject), self);
|
||||||
end;
|
end;
|
||||||
|
|
Loading…
Reference in New Issue