From 318f2419e73d25f7d1165309a40e0c0c7181a931 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 25 Apr 2020 01:59:48 +0200 Subject: [PATCH] diff dialog, add button to reload with history destruction --- CHANGELOG.md | 4 ++- src/u_diff.lfm | 58 +++++++++++++++++++++++-------------- src/u_diff.pas | 4 +++ src/u_synmemo.pas | 74 +++++++++++++++++++++++++++-------------------- 4 files changed, 86 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b51b28f..57d32d02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## Enhancements -- Dlang highlighter: added suport for HEREDOC strings literal of type `q"()"` `q"[]"`, `q"<>"` and `q"{}"`. "Custom" HEREDOC strings literal wont be handled as they might be removed as per DIP 1026. +- D highlighter: added suport for HEREDOC strings literal of type `q"()"` `q"[]"`, `q"<>"` and `q"{}"`. Support for HEREDOC strings literal based on a custom identifier wont be added as they might be removed as per DIP 1026. - Docking: added a dialog to remind that docking is locked in certain scenarios. (#30) +- Editor: set the option to detect the indentation mode on by default, to prevent mixed indentation style. +- Editor: a fourth button in the diff dialog allows to reload but without preserving the undo history, which is better to navigate using _go to next changed area_ and _go to prev changed area_. - Search Replace: the result of _FindAll_ when the string to seach is a regular expression are highlighted. (#14) - TODO list: a new option, _disableIfMoreFilesThan_, allows to disable auto refreshing of the list could be slow when the current project is huge. diff --git a/src/u_diff.lfm b/src/u_diff.lfm index af85be91..a50a51b0 100644 --- a/src/u_diff.lfm +++ b/src/u_diff.lfm @@ -1,16 +1,16 @@ object DiffViewer: TDiffViewer Left = 1004 - Height = 441 + Height = 468 Top = 279 - Width = 516 + Width = 578 Caption = 'External file modification' - ClientHeight = 441 - ClientWidth = 516 + ClientHeight = 468 + ClientWidth = 578 inline editor: TSynEdit Left = 4 - Height = 387 + Height = 414 Top = 15 - Width = 508 + Width = 570 Align = alClient BorderSpacing.Around = 4 Font.Height = -13 @@ -112,17 +112,17 @@ object DiffViewer: TDiffViewer object Panel1: TPanel Left = 4 Height = 31 - Top = 406 - Width = 508 + Top = 433 + Width = 570 Align = alBottom AutoSize = True BorderSpacing.Around = 4 BevelOuter = bvLowered ClientHeight = 31 - ClientWidth = 508 + ClientWidth = 570 TabOrder = 1 object btnIgnore: TBitBtn - Left = 106 + Left = 68 Height = 27 Hint = 'Don''t show this dialog until more modifications are detected' Top = 2 @@ -138,55 +138,71 @@ object DiffViewer: TDiffViewer TabOrder = 0 end object btnAccept: TBitBtn - Left = 382 + Left = 347 Height = 27 - Hint = 'Load the new version' + Hint = 'Load the external version but still allow to undo' Top = 2 - Width = 124 + Width = 55 Align = alRight AutoSize = True BorderSpacing.Left = 2 BorderSpacing.Around = 1 - Caption = 'Load new version' + Caption = 'Reload' ModalResult = 1 ParentShowHint = False ShowHint = True TabOrder = 2 end object btnCancel: TBitBtn - Left = 287 + Left = 249 Height = 27 - Hint = 'Don''t reload the modifications for now' + Hint = 'Don''t reload the external version this time' Top = 2 - Width = 92 + Width = 95 Align = alRight AutoSize = True BorderSpacing.Left = 2 BorderSpacing.Around = 1 - Caption = 'Keep current' + Caption = 'Keep for now' ModalResult = 2 ParentShowHint = False ShowHint = True TabOrder = 1 end + object btnAccept1: TBitBtn + Left = 405 + Height = 27 + Hint = 'Load the external version and reset the history of changes' + Top = 2 + Width = 163 + Align = alRight + AutoSize = True + BorderSpacing.Left = 2 + BorderSpacing.Around = 1 + Caption = 'Reload and reset undos' + ModalResult = 8 + ParentShowHint = False + ShowHint = True + TabOrder = 3 + end end object Panel2: TPanel Left = 4 Height = 7 Top = 4 - Width = 508 + Width = 570 Align = alTop AutoSize = True BorderSpacing.Around = 4 BevelOuter = bvLowered ClientHeight = 7 - ClientWidth = 508 + ClientWidth = 570 TabOrder = 2 object lbl: TLabel Left = 3 Height = 1 Top = 3 - Width = 502 + Width = 564 Align = alClient Alignment = taCenter BorderSpacing.Around = 2 diff --git a/src/u_diff.pas b/src/u_diff.pas index 9a2365b5..d0afebf8 100644 --- a/src/u_diff.pas +++ b/src/u_diff.pas @@ -10,7 +10,11 @@ uses u_common, StdCtrls, ExtCtrls, Buttons; type + + { TDiffViewer } + TDiffViewer = class(TForm) + btnAccept1: TBitBtn; btnIgnore: TBitBtn; btnAccept: TBitBtn; btnCancel: TBitBtn; diff --git a/src/u_synmemo.pas b/src/u_synmemo.pas index d9f108af..3abb9e28 100644 --- a/src/u_synmemo.pas +++ b/src/u_synmemo.pas @@ -3427,12 +3427,12 @@ end; procedure TDexedMemo.checkFileDate; var - mr: TModalResult; - newDate: double; - newMd5: TMDDigest; - curMd5: TMDDigest; - str: TStringList; - txt: string; + mr : TModalResult; + newDate : double; + newMd5 : TMDDigest; + curMd5 : TMDDigest; + str : TStringList; + newTxt : string; begin if fDiffDialogWillClose or fDisableFileDateCheck then exit; @@ -3450,35 +3450,45 @@ begin str := TStringList.Create; try str.LoadFromFile(fFilename); - txt := str.strictText; - newMd5 := MD5String(txt); - txt := lines.strictText; - curMd5 := MD5String(txt); - if not MDMatch(curMd5, newMd5) then - begin - lines.SaveToFile(tempFilename); - fDiffDialogWillClose := true; - With TDiffViewer.construct(self, fTempFileName, fFilename) do - try - mr := ShowModal; - case mr of - mrOK: - begin - replaceUndoableContent(str.strictText); - fModified := false; - fFileDate := newDate; - end; - mrIgnore: fFileDate := newDate; - mrCancel:; - end; - finally - free; - fDiffDialogWillClose := false; - end; - end; + newTxt := str.strictText; finally str.Free; end; + newMd5 := MD5String(newTxt); + curMd5 := MD5String(lines.strictText); + if not MDMatch(curMd5, newMd5) then + begin + lines.SaveToFile(tempFilename); + fDiffDialogWillClose := true; + with TDiffViewer.construct(self, fTempFileName, fFilename) do + try + mr := ShowModal; + case mr of + mrOK: + begin + replaceUndoableContent(newTxt); + fModified := false; + fFileDate := newDate; + end; + mrAll: + begin + fModified := false; + text := newTxt; + fFileDate := newDate; + end; + mrIgnore: + begin + fFileDate := newDate; + end; + mrCancel: + begin + end; + end; + finally + free; + fDiffDialogWillClose := false; + end; + end; end else fFileDate := newDate; end;