From 473cb00c0e34d6e8db58cccab17ba5926448911f Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 19 Feb 2015 06:05:53 +0100 Subject: [PATCH 1/5] fix, element must be deleted in reverse order --- src/ce_main.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ce_main.pas b/src/ce_main.pas index 4d379f27..288a7e84 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -670,7 +670,7 @@ begin if ce_common.dlgOkCancel( 'last project modifications are not saved, quit anyway ?') <> mrOK then exit; - for i := 0 to fMultidoc.documentCount-1 do + for i := fMultidoc.documentCount-1 downto 0 do if not fMultidoc.closeDocument(i) then exit; canClose := true; From b360c4a814d20b8285d487c2995ec2f04f54ff01 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 19 Feb 2015 06:06:16 +0100 Subject: [PATCH 2/5] fix, memory leak --- src/ce_observer.pas | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ce_observer.pas b/src/ce_observer.pas index 36e20754..7b5e1623 100644 --- a/src/ce_observer.pas +++ b/src/ce_observer.pas @@ -111,6 +111,7 @@ destructor TCEEntitiesConnector.destroy; begin fObservers.Free; fSubjects.Free; + fServices.Free; inherited; end; From c99f30434f9ddbebd792dd26fa108cb1b16b6fc9 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 19 Feb 2015 06:06:49 +0100 Subject: [PATCH 3/5] make the global Highlighter streamable --- src/ce_d2syn.pas | 1 + src/ce_txtsyn.pas | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ce_d2syn.pas b/src/ce_d2syn.pas index d13913b2..60aba8df 100644 --- a/src/ce_d2syn.pas +++ b/src/ce_d2syn.pas @@ -265,6 +265,7 @@ end; constructor TSynD2Syn.create(aOwner: TComponent); begin inherited create(aOwner); + SetSubComponent(true); DefaultFilter:= 'D source|*.d|D interface|*.di'; diff --git a/src/ce_txtsyn.pas b/src/ce_txtsyn.pas index bf4c85e8..60d3b33d 100644 --- a/src/ce_txtsyn.pas +++ b/src/ce_txtsyn.pas @@ -59,6 +59,7 @@ uses constructor TSynTxtSyn.create(aOwner: TComponent); begin inherited; + SetSubComponent(true); // fSymAttribs := TSynHighlighterAttributes.Create('Symbols', 'Symbols'); fTxtAttribs := TSynHighlighterAttributes.Create('Text', 'Text'); From b562324894d86340b6ffbdee4bbb490059f18af7 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 19 Feb 2015 06:07:38 +0100 Subject: [PATCH 4/5] renamed field --- src/ce_synmemo.pas | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 50d7b3a2..78758977 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -83,7 +83,7 @@ type fIdentifier: string; fTempFileName: string; fMultiDocSubject: TCECustomSubject; - fStoredFontSize: Integer; + fDefaultFontSize: Integer; fPositions: TCESynMemoPositions; fMousePos: TPoint; function getMouseStart: Integer; @@ -91,6 +91,7 @@ type procedure identifierToD2Syn; procedure saveCache; procedure loadCache; + procedure setDefaultFontSize(aValue: Integer); protected procedure SetVisible(Value: Boolean); override; procedure SetHighlighter(const Value: TSynCustomHighlighter); override; @@ -99,6 +100,8 @@ type procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y:Integer); override; + published + property defaultFontSize: Integer read fDefaultFontSize write setDefaultFontSize; public constructor Create(aOwner: TComponent); override; destructor destroy; override; @@ -317,7 +320,7 @@ constructor TCESynMemo.Create(aOwner: TComponent); begin inherited; SetDefaultKeystrokes; // not called in inherited if owner = nil ! - fStoredFontSize := 10; + fDefaultFontSize := 10; Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5; Gutter.LineNumberPart.MarkupInfo.Foreground := clGray; Gutter.SeparatorPart.LineOffset := 1; @@ -360,6 +363,17 @@ begin inherited; end; +procedure TCESynMemo.setDefaultFontSize(aValue: Integer); +var + old: Integer; +begin + old := Font.Size; + if aValue < 5 then aValue := 5; + fDefaultFontSize:= aValue; + if Font.Size = old then + Font.Size := fDefaultFontSize; +end; + procedure TCESynMemo.setFocus; begin inherited; @@ -499,7 +513,7 @@ begin case Key of VK_ADD: if Font.Size < 50 then Font.Size := Font.Size + 1; VK_SUBTRACT: if Font.Size > 3 then Font.Size := Font.Size - 1; - VK_DECIMAL: Font.Size := fStoredFontSize; + VK_DECIMAL: Font.Size := fDefaultFontSize; end; TCEEditorHintWindow.FontSize := Font.Size; end; @@ -544,7 +558,7 @@ procedure TCESynMemo.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y:Inte begin inherited; if (Button = mbMiddle) and (Shift = [ssCtrl]) then - Font.Size := fStoredFontSize + Font.Size := fDefaultFontSize //TODO-cLCL&LAZ-specific: test this feature under gtk2/linux on next release, should work else if Button = mbExtra1 then fPositions.back From 94ec732c39d530e54d692a12fb64e815baa13d88 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 19 Feb 2015 06:08:06 +0100 Subject: [PATCH 5/5] dev option editor - 3 --- src/ce_editoroptions.pas | 104 +++++++++++++++++++++++++++++---------- src/ce_optionseditor.lfm | 13 +++-- 2 files changed, 87 insertions(+), 30 deletions(-) diff --git a/src/ce_editoroptions.pas b/src/ce_editoroptions.pas index 05b129b2..1583bb93 100644 --- a/src/ce_editoroptions.pas +++ b/src/ce_editoroptions.pas @@ -21,14 +21,13 @@ type (** * Container for the editor and highlither options. - * The base class is also used to backup settings - * to allow settings to be previewed in live and restored - * when not accepted. + * The base class is also used to backup the settings + * to allow a live preview and to restore them when not accepted. *) TCEEditorOptionsBase = class(TWritableLfmTextComponent) private - fDHlOptions: TPersistent; - fTxtHlOptions: TPersistent; + fD2Syn: TPersistent; + fTxtSyn: TPersistent; fFont: TFont; // fTabWidth: Integer; @@ -40,6 +39,8 @@ type fMouseOptions: TSynEditorMouseOptions; // procedure setFont(aFont: TFont); + procedure setD2Syn(aValue: TPersistent); + procedure setTxtSyn(aValue: TPersistent); published property tabulationWidth: Integer read fTabWidth write fTabWidth; property blockIdentation: Integer read fBlockIdent write fBlockIdent; @@ -49,11 +50,11 @@ type property options1: TSynEditorOptions read fOptions1 write fOptions1; property options2: TSynEditorOptions2 read fOptions2 write fOptions2; property mouseOptions: TSynEditorMouseOptions read fMouseOptions write fMouseOptions; - - property D_colorizer: TPersistent read fDHlOptions; - property TXT_colorizer: TPersistent read fTxtHlOptions; + property D2Highlighter: TPersistent read fD2Syn write setD2Syn; + property TxtHighlighter: TPersistent read fTxtSyn write setTxtSyn; public constructor Create(AOwner: TComponent); override; + destructor Destroy; override; // procedure assign(src: TPersistent); override; end; @@ -77,22 +78,25 @@ type // procedure applyChangesFromSelf; procedure applyChangeToEditor(anEditor: TCESynMemo); + protected + procedure afterLoad; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; +implementation + +const + edoptFname = 'editor.txt'; + var EditorOptions: TCEEditorOptions; -implementation - {$REGION Standard Comp/Obj -----------------------------------------------------} constructor TCEEditorOptionsBase.Create(AOwner: TComponent); begin inherited; - fDHlOptions := D2Syn; - fTxtHlOptions := TxtSyn; // fFont := TFont.Create; fFont.Size := 10; @@ -101,6 +105,11 @@ begin fFont.Pitch := fpFixed; fFont.Size:= 10; // + fD2Syn := TSynD2Syn.create(self); + fD2Syn.Assign(D2Syn); + fTxtSyn := TSynTxtSyn.create(self); + fTxtSyn.Assign(TxtSyn); + // tabulationWidth := 4; blockIdentation := 4; // @@ -114,16 +123,9 @@ begin [emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks]; end; -constructor TCEEditorOptions.Create(AOwner: TComponent); +destructor TCEEditorOptionsBase.Destroy; begin - inherited; - fBackup := TCEEditorOptionsBase.Create(self); - EntitiesConnector.addObserver(self); -end; - -destructor TCEEditorOptions.Destroy; -begin - EntitiesConnector.removeObserver(self); + fFont.Free; inherited; end; @@ -136,6 +138,8 @@ begin srcopt := TCEEditorOptionsBase(src); // font.Assign(srcopt.font); + fD2Syn.Assign(srcopt.fD2Syn); + fTxtSyn.Assign(srcopt.fTxtSyn); tabulationWidth := srcopt.tabulationWidth; blockIdentation := srcopt.blockIdentation; lineSpacing := srcopt.lineSpacing; @@ -151,6 +155,43 @@ procedure TCEEditorOptionsBase.setFont(aFont: TFont); begin fFont.Assign(aFont); end; + +procedure TCEEditorOptionsBase.setD2Syn(aValue: TPersistent); +begin + D2Syn.Assign(aValue); +end; + +procedure TCEEditorOptionsBase.setTxtSyn(aValue: TPersistent); +begin + TxtSyn.Assign(aValue); +end; + +constructor TCEEditorOptions.Create(AOwner: TComponent); +var + fname: string; +begin + inherited; + fBackup := TCEEditorOptionsBase.Create(self); + EntitiesConnector.addObserver(self); + // + fname := getCoeditDocPath + edoptFname; + if fileExists(fname) then loadFromFile(fname); +end; + +destructor TCEEditorOptions.Destroy; +begin + saveToFile(getCoeditDocPath + edoptFname); + // + EntitiesConnector.removeObserver(self); + inherited; +end; + +procedure TCEEditorOptions.afterLoad; +begin + inherited; + D2Syn.Assign(fD2Syn); + TxtSyn.Assign(fTxtSyn); +end; {$ENDREGION} {$REGION ICEMultiDocObserver ----------------------------------------------------} @@ -185,7 +226,11 @@ end; function TCEEditorOptions.optionedWantContainer: TPersistent; begin + fD2Syn := D2Syn; + fTxtSyn := TxtSyn; fBackup.Assign(self); + fBackup.fD2Syn.Assign(D2Syn); + fBackup.fTxtSyn.Assign(TxtSyn); exit(self); end; @@ -193,12 +238,21 @@ procedure TCEEditorOptions.optionedEvent(anEvent: TOptionEditorEvent); begin // restores if anEvent = oeeCancel then + begin self.assign(fBackup); - // apply + D2Syn.Assign(fBackup.fD2Syn); + TxtSyn.Assign(fBackup.fTxtSyn); + end; + // apply, if change/accept event + // to get a live preview applyChangesFromSelf; // new backup values based on accepted values. if anEvent = oeeAccept then + begin fBackup.assign(self); + fBackup.fD2Syn.Assign(D2Syn); + fBackup.fTxtSyn.Assign(TxtSyn); + end; end; {$ENDREGION} @@ -208,16 +262,16 @@ var multied: ICEMultiDocHandler; i: Integer; begin - // editors multied := getMultiDocHandler; for i := 0 to multied.documentCount-1 do applyChangeToEditor(multied.document[i]); - // highlighter(s) - // ... + end; procedure TCEEditorOptions.applyChangeToEditor(anEditor: TCESynMemo); begin + anEditor.defaultFontSize := font.Size; + // current editor zoom cant be mainainted. anEditor.Font.Assign(font); anEditor.TabWidth := tabulationWidth; anEditor.BlockIndent := blockIdentation; diff --git a/src/ce_optionseditor.lfm b/src/ce_optionseditor.lfm index a62d3f34..fd34b5a9 100644 --- a/src/ce_optionseditor.lfm +++ b/src/ce_optionseditor.lfm @@ -62,7 +62,8 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget Indent = 16 NameFont.Color = clWindowText OnModified = inspectorModified - SplitterX = 200 + PreferredSplitterX = 170 + SplitterX = 170 ValueFont.Color = clMaroon end end @@ -85,20 +86,22 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget ClientWidth = 540 TabOrder = 1 object btnCancel: TSpeedButton - Left = 333 + Left = 473 Height = 24 + Hint = 'cancel and revert modifications' Top = 3 - Width = 100 + Width = 30 Align = alRight BorderSpacing.Left = 2 BorderSpacing.Around = 2 OnClick = btnCancelClick end object btnAccept: TSpeedButton - Left = 437 + Left = 507 Height = 24 + Hint = 'accept modifications' Top = 3 - Width = 100 + Width = 30 Align = alRight BorderSpacing.Left = 2 BorderSpacing.Around = 2