Merge branch 'a12_2_a13'

This commit is contained in:
Basile Burg 2015-02-19 06:08:26 +01:00
commit 20bb18b227
7 changed files with 109 additions and 35 deletions

View File

@ -265,6 +265,7 @@ end;
constructor TSynD2Syn.create(aOwner: TComponent);
begin
inherited create(aOwner);
SetSubComponent(true);
DefaultFilter:= 'D source|*.d|D interface|*.di';

View File

@ -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;

View File

@ -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;

View File

@ -111,6 +111,7 @@ destructor TCEEntitiesConnector.destroy;
begin
fObservers.Free;
fSubjects.Free;
fServices.Free;
inherited;
end;

View File

@ -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

View File

@ -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

View File

@ -59,6 +59,7 @@ uses
constructor TSynTxtSyn.create(aOwner: TComponent);
begin
inherited;
SetSubComponent(true);
//
fSymAttribs := TSynHighlighterAttributes.Create('Symbols', 'Symbols');
fTxtAttribs := TSynHighlighterAttributes.Create('Text', 'Text');