editor, add the "undo all" action

This commit is contained in:
Basile Burg 2023-08-28 10:39:21 +02:00
parent 011907d934
commit 47e00a6a9b
6 changed files with 90 additions and 32 deletions

View File

@ -1,8 +1,12 @@
# v3.9.26-devel # v3.9.26-devel
## Enhancements
- Editor, added the _Undo All_ action.
## Bugx fixed ## Bugx fixed
- Fixed windows release (#116). ldc2 >= 1.31.0 is a minimal requirement now. - Fixed windows release (#116). From now ldc2 >= 1.31.0 is a minimal requirement.
- The context lines of the diff viewer were not legible whith dark themes. - The context lines of the diff viewer were not legible whith dark themes.
# v3.9.25 # v3.9.25

View File

@ -10,13 +10,14 @@ inherited EditorWidget: TEditorWidget
OnShow = FormShow OnShow = FormShow
inherited Content: TPanel inherited Content: TPanel
Height = 398 Height = 398
Top = 36
Width = 465 Width = 465
ClientHeight = 398 ClientHeight = 398
ClientWidth = 465 ClientWidth = 465
object editorStatus: TStatusBar[0] object editorStatus: TStatusBar[0]
Left = 0 Left = 0
Height = 19 Height = 20
Top = 377 Top = 376
Width = 465 Width = 465
BorderSpacing.Bottom = 2 BorderSpacing.Bottom = 2
Panels = < Panels = <
@ -45,20 +46,19 @@ inherited EditorWidget: TEditorWidget
end end
end end
inherited toolbar: TDexedToolBar inherited toolbar: TDexedToolBar
Height = 30
Width = 457 Width = 457
end end
inherited contextMenu: TPopupMenu inherited contextMenu: TPopupMenu
Left = 24 Left = 24
Top = 16 Top = 16
end end
object macRecorder: TSynMacroRecorder[2] object macRecorder: TSynMacroRecorder[3]
RecordShortCut = 0 RecordShortCut = 0
PlaybackShortCut = 0 PlaybackShortCut = 0
Left = 80 Left = 80
Top = 16 Top = 16
end end
object mnuEditor: TPopupMenu[3] object mnuEditor: TPopupMenu[4]
OnPopup = mnuEditorPopup OnPopup = mnuEditorPopup
Left = 152 Left = 152
Top = 16 Top = 16
@ -81,13 +81,17 @@ inherited EditorWidget: TEditorWidget
Caption = 'Undo' Caption = 'Undo'
OnClick = mnuedUndoClick OnClick = mnuedUndoClick
end end
object mnuedUndoAll: TMenuItem
Caption = 'Undo all'
OnClick = mnuedUndoAllClick
end
object mnuedRedo: TMenuItem object mnuedRedo: TMenuItem
Caption = 'Redo' Caption = 'Redo'
OnClick = mnuedRedoClick OnClick = mnuedRedoClick
end end
object enuItemRedoAll: TMenuItem object mnuedRedoAll: TMenuItem
Caption = 'Redo all' Caption = 'Redo all'
OnClick = enuItemRedoAllClick OnClick = mnuedRedoAllClick
end end
object MenuItem11: TMenuItem object MenuItem11: TMenuItem
Caption = '-' Caption = '-'
@ -280,7 +284,7 @@ inherited EditorWidget: TEditorWidget
OnClick = MenuItem8Click OnClick = MenuItem8Click
end end
end end
object mnuCurFile: TPopupMenu[4] object mnuCurFile: TPopupMenu[5]
Left = 216 Left = 216
Top = 16 Top = 16
object mnuCurFileShowInMiniExpl: TMenuItem object mnuCurFileShowInMiniExpl: TMenuItem

View File

@ -62,7 +62,8 @@ type
MenuItem14: TMenuItem; MenuItem14: TMenuItem;
MenuItem15: TMenuItem; MenuItem15: TMenuItem;
MenuItem16: TMenuItem; MenuItem16: TMenuItem;
enuItemRedoAll: TMenuItem; mnuedRedoAll: TMenuItem;
mnuedUndoAll: TMenuItem;
mnuCurFileCopyName: TMenuItem; mnuCurFileCopyName: TMenuItem;
mnuCurFileShowInMiniExpl: TMenuItem; mnuCurFileShowInMiniExpl: TMenuItem;
mnuCurFileShellOpen: TMenuItem; mnuCurFileShellOpen: TMenuItem;
@ -113,7 +114,7 @@ type
editorStatus: TStatusBar; editorStatus: TStatusBar;
mnuEditor: TPopupMenu; mnuEditor: TPopupMenu;
mnuCurFile: TPopupMenu; mnuCurFile: TPopupMenu;
procedure enuItemRedoAllClick(Sender: TObject); procedure mnuedRedoAllClick(Sender: TObject);
procedure FormShortCut(var Msg: TLMKey; var Handled: Boolean); procedure FormShortCut(var Msg: TLMKey; var Handled: Boolean);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure mnuCurFileCopyNameClick(Sender: TObject); procedure mnuCurFileCopyNameClick(Sender: TObject);
@ -134,6 +135,7 @@ type
procedure mnuEdShowSpecClick(Sender: TObject); procedure mnuEdShowSpecClick(Sender: TObject);
procedure mnuedSortLinesClick(Sender: TObject); procedure mnuedSortLinesClick(Sender: TObject);
procedure mnuEdTabWidth2Click(Sender: TObject); procedure mnuEdTabWidth2Click(Sender: TObject);
procedure mnuedUndoAllClick(Sender: TObject);
procedure mnuedUpcaseClick(Sender: TObject); procedure mnuedUpcaseClick(Sender: TObject);
procedure MenuItem5Click(Sender: TObject); procedure MenuItem5Click(Sender: TObject);
procedure MenuItem6Click(Sender: TObject); procedure MenuItem6Click(Sender: TObject);
@ -360,7 +362,9 @@ begin
AssignPng(mnuedCut.Bitmap, 'CUT'); AssignPng(mnuedCut.Bitmap, 'CUT');
AssignPng(mnuedPaste.Bitmap, 'PASTE'); AssignPng(mnuedPaste.Bitmap, 'PASTE');
AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO'); AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO');
AssignPng(mnuedUndoAll.Bitmap, 'ARROW_UNDO');
AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO'); AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO');
AssignPng(mnuedRedoAll.Bitmap, 'ARROW_REDO');
AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE'); AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE');
AssignPng(mnuedCopy.Bitmap, 'COPY'); AssignPng(mnuedCopy.Bitmap, 'COPY');
AssignPng(mnuedNext.Bitmap, 'GO_NEXT'); AssignPng(mnuedNext.Bitmap, 'GO_NEXT');
@ -388,7 +392,9 @@ begin
AssignPng(mnuedCut.Bitmap, 'CUT24'); AssignPng(mnuedCut.Bitmap, 'CUT24');
AssignPng(mnuedPaste.Bitmap, 'PASTE24'); AssignPng(mnuedPaste.Bitmap, 'PASTE24');
AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO24'); AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO24');
AssignPng(mnuedUndoAll.Bitmap, 'ARROW_UNDO24');
AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO24'); AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO24');
AssignPng(mnuedRedoAll.Bitmap, 'ARROW_REDO24');
//AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE24'); //AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE24');
AssignPng(mnuedCopy.Bitmap, 'COPY24'); AssignPng(mnuedCopy.Bitmap, 'COPY24');
AssignPng(mnuedNext.Bitmap, 'GO_NEXT24'); AssignPng(mnuedNext.Bitmap, 'GO_NEXT24');
@ -416,7 +422,9 @@ begin
AssignPng(mnuedCut.Bitmap, 'CUT32'); AssignPng(mnuedCut.Bitmap, 'CUT32');
AssignPng(mnuedPaste.Bitmap, 'PASTE32'); AssignPng(mnuedPaste.Bitmap, 'PASTE32');
AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO32'); AssignPng(mnuedUndo.Bitmap, 'ARROW_UNDO32');
AssignPng(mnuedUndoAll.Bitmap, 'ARROW_UNDO32');
AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO32'); AssignPng(mnuedRedo.Bitmap, 'ARROW_REDO32');
AssignPng(mnuedRedoAll.Bitmap, 'ARROW_REDO32');
//AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE32'); //AssignPng(mnuedJum2Decl.Bitmap, 'ARROW_SHOE32');
AssignPng(mnuedCopy.Bitmap, 'COPY32'); AssignPng(mnuedCopy.Bitmap, 'COPY32');
AssignPng(mnuedNext.Bitmap, 'GO_NEXT32'); AssignPng(mnuedNext.Bitmap, 'GO_NEXT32');
@ -1043,6 +1051,12 @@ begin
end; end;
end; end;
procedure TEditorWidget.mnuedUndoAllClick(Sender: TObject);
begin
if fDoc.isAssigned then
fDoc.undoAll();
end;
procedure TEditorWidget.mnuedNextCareaClick(Sender: TObject); procedure TEditorWidget.mnuedNextCareaClick(Sender: TObject);
begin begin
if fDoc.isAssigned then if fDoc.isAssigned then
@ -1092,7 +1106,7 @@ begin
end; end;
end; end;
procedure TEditorWidget.enuItemRedoAllClick(Sender: TObject); procedure TEditorWidget.mnuedRedoAllClick(Sender: TObject);
begin begin
if fDoc.isAssigned then if fDoc.isAssigned then
fDoc.redoAll(); fDoc.redoAll();
@ -1259,7 +1273,9 @@ begin
mnuedPaste.Enabled:=fDoc.CanPaste; mnuedPaste.Enabled:=fDoc.CanPaste;
mnuedCopy.Enabled:=fDoc.SelAvail; mnuedCopy.Enabled:=fDoc.SelAvail;
mnuedUndo.Enabled:=fDoc.CanUndo; mnuedUndo.Enabled:=fDoc.CanUndo;
mnuedUndoAll.Enabled:=fDoc.CanUndo;
mnuedRedo.Enabled:=fDoc.CanRedo; mnuedRedo.Enabled:=fDoc.CanRedo;
mnuedRedoAll.Enabled:=fDoc.CanRedo;
mnuedJum2Decl.Enabled:=fDoc.isDSource; mnuedJum2Decl.Enabled:=fDoc.isDSource;
mnuEdSetSpaces.Checked:= eoTabsToSpaces in fDoc.Options; mnuEdSetSpaces.Checked:= eoTabsToSpaces in fDoc.Options;

View File

@ -1,17 +1,17 @@
object MainForm: TMainForm object MainForm: TMainForm
Left = 383 Left = 383
Height = 35 Height = 34
Top = 610 Top = 610
Width = 687 Width = 673
AllowDropFiles = True AllowDropFiles = True
Caption = 'Dexed' Caption = 'Dexed'
DesignTimePPI = 94
Menu = mainMenu Menu = mainMenu
OnClose = FormClose OnClose = FormClose
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnDropFiles = FormDropFiles OnDropFiles = FormDropFiles
OnResize = FormResize OnResize = FormResize
ShowHint = True ShowHint = True
LCLVersion = '2.2.4.0'
object mainMenu: TMainMenu object mainMenu: TMainMenu
Top = 1 Top = 1
object MenuItem1: TMenuItem object MenuItem1: TMenuItem
@ -134,6 +134,9 @@ object MainForm: TMainForm
object MenuItem19: TMenuItem object MenuItem19: TMenuItem
Action = actEdUndo Action = actEdUndo
end end
object MenuItem120: TMenuItem
Action = actEdUndoAll
end
object MenuItem20: TMenuItem object MenuItem20: TMenuItem
Action = actEdRedo Action = actEdRedo
end end
@ -420,7 +423,7 @@ object MainForm: TMainForm
end end
end end
object Actions: TActionList object Actions: TActionList
Left = 33 Left = 32
object actEdCopy: TAction object actEdCopy: TAction
Category = 'Edit' Category = 'Edit'
Caption = 'Copy' Caption = 'Copy'
@ -450,13 +453,6 @@ object MainForm: TMainForm
OnUpdate = updateDocEditBasedAction OnUpdate = updateDocEditBasedAction
ShortCut = 16474 ShortCut = 16474
end end
object actEdRedo: TAction
Category = 'Edit'
Caption = 'Redo'
OnExecute = actEdRedoExecute
OnUpdate = updateDocEditBasedAction
ShortCut = 24666
end
object actFileSave: TAction object actFileSave: TAction
Category = 'File' Category = 'File'
Caption = 'Save file' Caption = 'Save file'
@ -816,6 +812,19 @@ object MainForm: TMainForm
Caption = 'Check semantics' Caption = 'Check semantics'
OnExecute = actProjCheckSemaExecute OnExecute = actProjCheckSemaExecute
end end
object actEdUndoAll: TAction
Category = 'Edit'
Caption = 'Undo all'
OnExecute = actEdUndoAllExecute
OnUpdate = updateDocEditBasedAction
end
object actEdRedo: TAction
Category = 'Edit'
Caption = 'Redo'
OnExecute = actEdRedoExecute
OnUpdate = updateDocEditBasedAction
ShortCut = 24666
end
object actEdRedoAll: TAction object actEdRedoAll: TAction
Category = 'Edit' Category = 'Edit'
Caption = 'Redo all' Caption = 'Redo all'
@ -875,7 +884,7 @@ object MainForm: TMainForm
object ApplicationProperties1: TApplicationProperties object ApplicationProperties1: TApplicationProperties
OnActivate = ApplicationProperties1Activate OnActivate = ApplicationProperties1Activate
OnException = ApplicationProperties1Exception OnException = ApplicationProperties1Exception
Left = 64 Left = 63
Top = 1 Top = 1
end end
end end

View File

@ -118,6 +118,7 @@ type
actFileNewClip: TAction; actFileNewClip: TAction;
actEdFormat: TAction; actEdFormat: TAction;
actEdRedoAll: TAction; actEdRedoAll: TAction;
actEdUndoAll: TAction;
actProjCheckSema: TAction; actProjCheckSema: TAction;
actProjSetEnv: TAction; actProjSetEnv: TAction;
actProjGitPull: TAction; actProjGitPull: TAction;
@ -188,6 +189,7 @@ type
MenuItem117: TMenuItem; MenuItem117: TMenuItem;
MenuItem118: TMenuItem; MenuItem118: TMenuItem;
MenuItem119: TMenuItem; MenuItem119: TMenuItem;
MenuItem120: TMenuItem;
mnuGitBranch: TMenuItem; mnuGitBranch: TMenuItem;
mnuItemDubDialog: TMenuItem; mnuItemDubDialog: TMenuItem;
mnuItemHelp: TMenuItem; mnuItemHelp: TMenuItem;
@ -299,6 +301,7 @@ type
MenuItem8: TMenuItem; MenuItem8: TMenuItem;
MenuItem9: TMenuItem; MenuItem9: TMenuItem;
procedure actEdFormatExecute(Sender: TObject); procedure actEdFormatExecute(Sender: TObject);
procedure actEdUndoAllExecute(Sender: TObject);
procedure actFileCloseAllExecute(Sender: TObject); procedure actFileCloseAllExecute(Sender: TObject);
procedure actFileCloseAllOthersExecute(Sender: TObject); procedure actFileCloseAllOthersExecute(Sender: TObject);
procedure actFileCompileExecute(Sender: TObject); procedure actFileCompileExecute(Sender: TObject);
@ -1565,6 +1568,7 @@ begin
actFileNewClip.ImageIndex:= i; actFileNewClip.ImageIndex:= i;
i := loadIcon('ARROW_UNDO'); i := loadIcon('ARROW_UNDO');
actEdUndo.ImageIndex:= i; actEdUndo.ImageIndex:= i;
actEdUndoAll.ImageIndex:= i;
i := loadIcon('ARROW_REDO'); i := loadIcon('ARROW_REDO');
actEdRedo.ImageIndex:= i; actEdRedo.ImageIndex:= i;
actEdRedoAll.ImageIndex:= i; actEdRedoAll.ImageIndex:= i;
@ -2916,6 +2920,12 @@ begin
fDoc.redoAll(); fDoc.redoAll();
end; end;
procedure TMainForm.actEdUndoAllExecute(Sender: TObject);
begin
if fDoc.isAssigned then
fDoc.undoAll();
end;
procedure TMainForm.actEdMacPlayExecute(Sender: TObject); procedure TMainForm.actEdMacPlayExecute(Sender: TObject);
begin begin
if fDoc.isAssigned then if fDoc.isAssigned then

View File

@ -382,6 +382,7 @@ type
procedure setDscannerOptions(dsEnabled: boolean; dsDelay: integer); procedure setDscannerOptions(dsEnabled: boolean; dsDelay: integer);
procedure centerCursor(); procedure centerCursor();
procedure redoAll(); procedure redoAll();
procedure undoAll();
procedure scrollCentered(down: boolean); procedure scrollCentered(down: boolean);
// //
property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts; property IdentifierMatchOptions: TIdentifierMatchOptions read fMatchOpts write setMatchOpts;
@ -484,8 +485,9 @@ const
ecSelLeftWordEdge = ecUserFirst + 32; ecSelLeftWordEdge = ecUserFirst + 32;
ecSelRightWordEdge = ecUserFirst + 33; ecSelRightWordEdge = ecUserFirst + 33;
ecRedoAll = ecUserFirst + 34; ecRedoAll = ecUserFirst + 34;
ecScrollCenteredUp = ecUserFirst + 35; ecUndoAll = ecUserFirst + 35;
ecScrollCenteredDown = ecUserFirst + 36; ecScrollCenteredUp = ecUserFirst + 36;
ecScrollCenteredDown = ecUserFirst + 37;
var var
D2Syn: TSynD2Syn; // used as model to set the options when no editor exists. D2Syn: TSynD2Syn; // used as model to set the options when no editor exists.
TxtSyn: TSynTxtSyn; // used as model to set the options when no editor exists. TxtSyn: TSynTxtSyn; // used as model to set the options when no editor exists.
@ -1487,6 +1489,7 @@ begin
AddKey(ecSmartWordLeft, 0, [], 0, []); AddKey(ecSmartWordLeft, 0, [], 0, []);
AddKey(ecSmartWordRight, 0, [], 0, []); AddKey(ecSmartWordRight, 0, [], 0, []);
AddKey(ecRedoAll, 0, [], 0, []); AddKey(ecRedoAll, 0, [], 0, []);
AddKey(ecUndoAll, 0, [], 0, []);
AddKey(ecScrollCenteredDown, VK_DOWN, [ssCtrl, ssAlt], 0, []); AddKey(ecScrollCenteredDown, VK_DOWN, [ssCtrl, ssAlt], 0, []);
AddKey(ecScrollCenteredUp, VK_UP, [ssCtrl, ssAlt], 0, []); AddKey(ecScrollCenteredUp, VK_UP, [ssCtrl, ssAlt], 0, []);
end; end;
@ -1529,6 +1532,7 @@ begin
'ecSelLeftWordEdge': begin Int := ecSelLeftWordEdge; exit(true); end; 'ecSelLeftWordEdge': begin Int := ecSelLeftWordEdge; exit(true); end;
'ecSelRightWordEdge': begin Int := ecSelRightWordEdge; exit(true); end; 'ecSelRightWordEdge': begin Int := ecSelRightWordEdge; exit(true); end;
'ecRedoAll': begin Int := ecRedoAll; exit(true); end; 'ecRedoAll': begin Int := ecRedoAll; exit(true); end;
'ecUndoAll': begin Int := ecUndoAll; exit(true); end;
'ecScrollCenteredUp': begin Int := ecScrollCenteredUp; exit(true); end; 'ecScrollCenteredUp': begin Int := ecScrollCenteredUp; exit(true); end;
'ecScrollCenteredDown': begin Int := ecScrollCenteredDown; exit(true); end; 'ecScrollCenteredDown': begin Int := ecScrollCenteredDown; exit(true); end;
else exit(false); else exit(false);
@ -1572,6 +1576,7 @@ begin
ecSelLeftWordEdge: begin Ident := 'ecSelLeftWordEdge'; exit(true); end; ecSelLeftWordEdge: begin Ident := 'ecSelLeftWordEdge'; exit(true); end;
ecSelRightWordEdge: begin Ident := 'ecSelRightWordEdge'; exit(true); end; ecSelRightWordEdge: begin Ident := 'ecSelRightWordEdge'; exit(true); end;
ecRedoAll: begin Ident := 'ecRedoAll'; exit(true); end; ecRedoAll: begin Ident := 'ecRedoAll'; exit(true); end;
ecUndoAll: begin Ident := 'ecUndoAll'; exit(true); end;
ecScrollCenteredUp: begin Ident := 'ecScrollCenteredUp'; exit(true); end; ecScrollCenteredUp: begin Ident := 'ecScrollCenteredUp'; exit(true); end;
ecScrollCenteredDown: begin Ident := 'ecScrollCenteredDown'; exit(true); end; ecScrollCenteredDown: begin Ident := 'ecScrollCenteredDown'; exit(true); end;
else exit(false); else exit(false);
@ -1708,6 +1713,8 @@ begin
gotoWordEdge(true); gotoWordEdge(true);
ecRedoAll: ecRedoAll:
redoAll(); redoAll();
ecUndoAll:
undoAll();
ecScrollCenteredUp: ecScrollCenteredUp:
scrollCentered(false); scrollCentered(false);
ecScrollCenteredDown: ecScrollCenteredDown:
@ -2715,6 +2722,14 @@ begin
EndUpdate(); EndUpdate();
end; end;
procedure TDexedMemo.undoAll();
begin
BeginUpdate(false);
while CanUndo do
Undo;
EndUpdate();
end;
procedure TDexedMemo.gotoWordEdge(right: boolean); procedure TDexedMemo.gotoWordEdge(right: boolean);
var var
s: string; s: string;