Merge branch 'a12_2_a13'

This commit is contained in:
Basile Burg 2015-02-19 03:21:47 +01:00
commit 1610f07dbc
9 changed files with 292 additions and 43 deletions

View File

@ -140,7 +140,7 @@
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="34">
<Units Count="35">
<Unit0>
<Filename Value="coedit.lpr"/>
<IsPartOfProject Value="True"/>
@ -356,6 +356,11 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="ce_optionseditor"/>
</Unit33>
<Unit34>
<Filename Value="..\src\ce_editoroptions.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="ce_editoroptions"/>
</Unit34>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -8,7 +8,7 @@ uses
{$ENDIF}{$ENDIF}
Interfaces, Forms, lazcontrols, runtimetypeinfocontrols, ce_observer, ce_libman,
ce_tools, ce_dcd, ce_main, ce_writableComponent, ce_options, ce_symstring,
ce_staticmacro, ce_inspectors, LResources;
ce_staticmacro, ce_inspectors, LResources, ce_editoroptions;
{$R *.res}

238
src/ce_editoroptions.pas Normal file
View File

@ -0,0 +1,238 @@
unit ce_editoroptions;
{$I ce_defines.inc}
interface
uses
Classes, SysUtils, Graphics, SynEdit, SynEditMouseCmds,
ce_interfaces, ce_observer, ce_common, ce_writableComponent, ce_synmemo,
ce_d2syn, ce_txtsyn;
type
TDHighligthOptions = class(TPersistent)
end;
TTxtHighligthOptions = class(TPersistent)
end;
(**
* 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.
*)
TCEEditorOptionsBase = class(TWritableLfmTextComponent)
private
fDHlOptions: TPersistent;
fTxtHlOptions: TPersistent;
fFont: TFont;
//
fTabWidth: Integer;
fBlockIdent: Integer;
fLineSpacing: Integer;
fCharSpacing: Integer;
fOptions1: TSynEditorOptions;
fOptions2: TSynEditorOptions2;
fMouseOptions: TSynEditorMouseOptions;
//
procedure setFont(aFont: TFont);
published
property tabulationWidth: Integer read fTabWidth write fTabWidth;
property blockIdentation: Integer read fBlockIdent write fBlockIdent;
property lineSpacing: Integer read fLineSpacing write fLineSpacing;
property characterSpacing: Integer read fCharSpacing write fCharSpacing;
property font: TFont read fFont write setFont;
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;
public
constructor Create(AOwner: TComponent); override;
//
procedure assign(src: TPersistent); override;
end;
(**
* Manages and exposes all the editor and highligther options to an TCEOptionsEditor.
*)
TCEEditorOptions = class(TCEEditorOptionsBase, ICEEditableOptions, ICEMultiDocObserver)
private
fBackup: TCEEditorOptionsBase;
//
function optionedWantCategory(): string;
function optionedWantEditorKind: TOptionEditorKind;
function optionedWantContainer: TPersistent;
procedure optionedEvent(anEvent: TOptionEditorEvent);
//
procedure docNew(aDoc: TCESynMemo);
procedure docFocused(aDoc: TCESynMemo);
procedure docChanged(aDoc: TCESynMemo);
procedure docClosing(aDoc: TCESynMemo);
//
procedure applyChangesFromSelf;
procedure applyChangeToEditor(anEditor: TCESynMemo);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
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;
fFont.Name := 'Courier New';
fFont.Quality := fqProof;
fFont.Pitch := fpFixed;
fFont.Size:= 10;
//
tabulationWidth := 4;
blockIdentation := 4;
//
options1 :=
[eoAutoIndent, eoBracketHighlight, eoGroupUndo, eoTabsToSpaces,
eoDragDropEditing, eoShowCtrlMouseLinks, eoEnhanceHomeKey, eoTabIndent];
options2 :=
[eoEnhanceEndKey, eoFoldedCopyPaste, eoOverwriteBlock];
//
mouseOptions := MouseOptions +
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks];
end;
constructor TCEEditorOptions.Create(AOwner: TComponent);
begin
inherited;
fBackup := TCEEditorOptionsBase.Create(self);
EntitiesConnector.addObserver(self);
end;
destructor TCEEditorOptions.Destroy;
begin
EntitiesConnector.removeObserver(self);
inherited;
end;
procedure TCEEditorOptionsBase.assign(src: TPersistent);
var
srcopt: TCEEditorOptionsBase;
begin
if (src is TCEEditorOptionsBase) then
begin
srcopt := TCEEditorOptionsBase(src);
//
font.Assign(srcopt.font);
tabulationWidth := srcopt.tabulationWidth;
blockIdentation := srcopt.blockIdentation;
lineSpacing := srcopt.lineSpacing;
characterSpacing:= srcopt.characterSpacing;
options1 := srcopt.options1;
options2 := srcopt.options2;
mouseOptions := srcopt.mouseOptions;
end
else inherited;
end;
procedure TCEEditorOptionsBase.setFont(aFont: TFont);
begin
fFont.Assign(aFont);
end;
{$ENDREGION}
{$REGION ICEMultiDocObserver ----------------------------------------------------}
procedure TCEEditorOptions.docNew(aDoc: TCESynMemo);
begin
applyChangeToEditor(aDoc);
end;
procedure TCEEditorOptions.docFocused(aDoc: TCESynMemo);
begin
end;
procedure TCEEditorOptions.docChanged(aDoc: TCESynMemo);
begin
end;
procedure TCEEditorOptions.docClosing(aDoc: TCESynMemo);
begin
end;
{$ENDREGION}
{$REGION ICEEditableOptions ----------------------------------------------------}
function TCEEditorOptions.optionedWantCategory(): string;
begin
exit('Editor');
end;
function TCEEditorOptions.optionedWantEditorKind: TOptionEditorKind;
begin
exit(oekAbstract);
end;
function TCEEditorOptions.optionedWantContainer: TPersistent;
begin
fBackup.Assign(self);
exit(self);
end;
procedure TCEEditorOptions.optionedEvent(anEvent: TOptionEditorEvent);
begin
// restores
if anEvent = oeeCancel then
self.assign(fBackup);
// apply
applyChangesFromSelf;
// new backup values based on accepted values.
if anEvent = oeeAccept then
fBackup.assign(self);
end;
{$ENDREGION}
{$REGION ICEEditableOptions ----------------------------------------------------}
procedure TCEEditorOptions.applyChangesFromSelf;
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.Font.Assign(font);
anEditor.TabWidth := tabulationWidth;
anEditor.BlockIndent := blockIdentation;
anEditor.ExtraLineSpacing := lineSpacing;
anEditor.ExtraCharSpacing := characterSpacing;
anEditor.Options := options1;
anEditor.Options2 := options2;
anEditor.MouseOptions := mouseOptions;
end;
{$ENDREGION}
initialization
EditorOptions := TCEEditorOptions.Create(nil);
finalization
EditorOptions.Free;
end.

View File

@ -469,6 +469,7 @@ begin
for i := 0 to fWidgList.Count-1 do
begin
if not fWidgList.widget[i].isDockable then continue;
DockMaster.MakeDockable(fWidgList.widget[i], not fileExists(getCoeditDocPath + 'docking.xml'));
DockMaster.GetAnchorSite(fWidgList.widget[i]).Header.HeaderPosition := adlhpTop;
end;
@ -544,6 +545,7 @@ begin
// does not save minimized/undocked windows to prevent bugs
for i:= 0 to fWidgList.Count-1 do
begin
if not fWidgList.widget[i].isDockable then continue;
if DockMaster.GetAnchorSite(fWidgList.widget[i]).WindowState = wsMinimized then
DockMaster.GetAnchorSite(fWidgList.widget[i]).Close
else if DockMaster.GetAnchorSite(fWidgList.widget[i]).SiteType = adhstNone then
@ -1366,7 +1368,12 @@ var
begin
widg := TCEWidget( TComponent(sender).tag );
if widg = nil then exit;
win := DockMaster.GetAnchorSite(widg);
//
if widg.isDockable then
win := DockMaster.GetAnchorSite(widg)
else
win := widg;
//
if win = nil then exit;
win.Show;
win.BringToFront;
@ -1395,6 +1402,7 @@ begin
// TODO-cLCL&LAZ-specific: possible loading AV, xml saved after undocking some widgets, xml file abnormal size.
for i:= 0 to fWidgList.Count-1 do
begin
if not fWidgList.widget[i].isDockable then continue;
if DockMaster.GetAnchorSite(fWidgList.widget[i]).WindowState = wsMinimized then
DockMaster.GetAnchorSite(fWidgList.widget[i]).Close
else if DockMaster.GetAnchorSite(fWidgList.widget[i]).SiteType = adhstNone then

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, ComCtrls,
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, Buttons,
lcltype, ce_widget, ActnList, Menus, clipbrd, AnchorDocking, Buttons, ce_writableComponent,
ce_common, ce_project, ce_synmemo, ce_dlangutils, ce_interfaces, ce_observer;
type
@ -20,7 +20,7 @@ type
data: Pointer;
end;
TCEMessagesOptions = class(TPersistent)
TCEMessagesOptions = class(TWritableLfmTextComponent)
private
fMaxCount: Integer;
fAutoSelect: boolean;
@ -74,9 +74,9 @@ type
function iconIndex(aKind: TCEAppMessageKind): Integer;
//
procedure optset_MaxMessageCount(aReader: TReader);
procedure optget_MaxMessageCount(awriter: TWriter);
procedure optget_MaxMessageCount(aWriter: TWriter);
procedure optset_AutoSelect(aReader: TReader);
procedure optget_AutoSelect(awriter: TWriter);
procedure optget_AutoSelect(aWriter: TWriter);
//
procedure projNew(aProject: TCEProject);
procedure projClosing(aProject: TCEProject);
@ -124,7 +124,7 @@ implementation
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEMessagesWidget.create(aOwner: TComponent);
begin
fMaxMessCnt := 125;
fMaxMessCnt := 500;
fCtxt := amcAll;
//
fActAutoSel := TAction.Create(self);
@ -149,7 +149,9 @@ begin
//
inherited;
//
fEditableOptions := TCEMessagesOptions.Create;
fEditableOptions := TCEMessagesOptions.Create(Self);
fEditableOptions.Name:= 'messageOptions';
//
List.PopupMenu := contextMenu;
List.OnDeletion := @ListDeletion;
//
@ -173,7 +175,6 @@ end;
destructor TCEMessagesWidget.destroy;
begin
EntitiesConnector.removeObserver(self);
fEditableOptions.Free;
Inherited;
end;
@ -250,6 +251,7 @@ begin
begin
fMaxMessCnt := fEditableOptions.maxMessageCount;
fActAutoSel.Checked := fEditableOptions.autoSelect;
clearOutOfRangeMessg;
end;
end;
{$ENDREGION}
@ -257,10 +259,8 @@ end;
{$REGION ICESessionOptionsObserver ---------------------------------------------}
procedure TCEMessagesWidget.setMaxMessageCount(aValue: Integer);
begin
if aValue < 10 then
aValue := 10;
if aValue > 1023 then
aValue := 1023;
if aValue < 5 then
aValue := 5;
if fMaxMessCnt = aValue then
exit;
fMaxMessCnt := aValue;
@ -283,9 +283,9 @@ begin
fActAutoSel.Checked := fAutoSelect;
end;
procedure TCEMessagesWidget.optget_AutoSelect(awriter: TWriter);
procedure TCEMessagesWidget.optget_AutoSelect(aWriter: TWriter);
begin
awriter.WriteBoolean(fAutoSelect);
aWriter.WriteBoolean(fAutoSelect);
end;
procedure TCEMessagesWidget.sesoptDeclareProperties(aFiler: TFiler);

View File

@ -1,11 +1,13 @@
inherited CEOptionEditorWidget: TCEOptionEditorWidget
Left = 626
Left = 594
Height = 377
Top = 270
Top = 257
Width = 548
BorderIcons = [biSystemMenu, biMinimize, biMaximize]
Caption = 'Options editor'
ClientHeight = 377
ClientWidth = 548
FormStyle = fsSystemStayOnTop
inherited Back: TPanel
Height = 377
Width = 548
@ -31,7 +33,7 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
Left = 0
Height = 335
Top = 0
Width = 193
Width = 140
Align = alLeft
DefaultItemHeight = 18
ScrollBars = ssAutoBoth
@ -40,31 +42,32 @@ inherited CEOptionEditorWidget: TCEOptionEditorWidget
OnSelectionChanged = selCatSelectionChanged
end
object pnlEd: TPanel
Left = 199
Left = 146
Height = 335
Top = 0
Width = 341
Width = 394
Align = alClient
BevelOuter = bvNone
ClientHeight = 335
ClientWidth = 341
ClientWidth = 394
TabOrder = 1
object inspector: TTIPropertyGrid
Left = 0
Height = 335
Top = 0
Width = 341
Width = 394
Align = alClient
DefaultValueFont.Color = clWindowText
Filter = [tkInteger, tkChar, tkEnumeration, tkFloat, tkSet, tkMethod, tkSString, tkLString, tkAString, tkWString, tkVariant, tkArray, tkRecord, tkInterface, tkClass, tkObject, tkWChar, tkBool, tkInt64, tkQWord, tkDynArray, tkInterfaceRaw, tkProcVar, tkUString, tkUChar, tkHelper]
Indent = 16
NameFont.Color = clWindowText
OnModified = inspectorModified
SplitterX = 200
ValueFont.Color = clMaroon
end
end
object Splitter1: TSplitter
Left = 193
Left = 140
Height = 335
Top = 0
Width = 6

View File

@ -51,6 +51,7 @@ var
png: TPortableNetworkGraphic;
begin
inherited;
fDockable := false;
fEdOptsSubj := TCEEditableOptionsSubject.create;
//
png := TPortableNetworkGraphic.Create;
@ -149,6 +150,9 @@ begin
PCategoryData(selCat.Selected.Data)^
.observer
.optionedEvent(oeeCancel);
//
// if generic editor then
// refresh displayed value since the provider may have updated the options container
end;
procedure TCEOptionEditorWidget.btnAcceptClick(Sender: TObject);

View File

@ -7,7 +7,8 @@ interface
uses
Classes, SysUtils, SynEdit, ce_d2syn, ce_txtsyn ,SynEditHighlighter, controls,
lcltype, LazSynEditText, SynEditKeyCmds, SynHighlighterLFM, SynEditMouseCmds,
SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent, Forms;
SynEditFoldedView, crc, ce_common, ce_observer, ce_writableComponent, Forms,
graphics;
type
@ -129,9 +130,7 @@ var
implementation
uses
graphics, ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase;
ce_interfaces, ce_staticmacro, ce_dcd, SynEditHighlighterFoldBase;
constructor TCEEditorHintWindow.Create(AOwner: TComponent);
begin
@ -318,20 +317,7 @@ constructor TCESynMemo.Create(aOwner: TComponent);
begin
inherited;
SetDefaultKeystrokes; // not called in inherited if owner = nil !
Font.Quality := fqProof;
Font.Pitch := fpFixed;
Font.Size:= 10;
TabWidth := 4;
BlockIndent := 4;
Options :=
[eoAutoIndent, eoBracketHighlight, eoGroupUndo, eoTabsToSpaces,
eoDragDropEditing, eoShowCtrlMouseLinks, eoEnhanceHomeKey, eoTabIndent];
Options2 :=
[eoEnhanceEndKey, eoFoldedCopyPaste, eoOverwriteBlock];
fStoredFontSize := Font.Size;
MouseOptions := MouseOptions +
[emAltSetsColumnMode, emDragDropEditing, emCtrlWheelZoom, emShowCtrlMouseLinks];
fStoredFontSize := 10;
Gutter.LineNumberPart.ShowOnlyLineNumbersMultiplesOf := 5;
Gutter.LineNumberPart.MarkupInfo.Foreground := clGray;
Gutter.SeparatorPart.LineOffset := 1;
@ -541,10 +527,11 @@ end;
procedure TCESynMemo.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
fMousePos := PixelsToRowColumn(Point(X,Y));
Application.HideHint;
inherited;
if ssLeft in Shift then
identifierToD2Syn;
fMousePos := PixelsToRowColumn(Point(X,Y));
end;
procedure TCESynMemo.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y:Integer);

View File

@ -35,6 +35,7 @@ type
procedure optget_UpdaterDelay(aWriter: TWriter);
procedure optset_UpdaterDelay(aReader: TReader);
protected
fDockable: boolean;
fID: string;
// a descendant overrides to implementi a periodic update.
procedure UpdateByLoop; virtual;
@ -74,6 +75,8 @@ type
//
// returns true if one of the three updater is processing.
property updating: boolean read fUpdating;
// true by default, allow a widget to be docked.
property isDockable: boolean read fDockable;
end;
(**
@ -110,6 +113,7 @@ var
itm: TmenuItem;
begin
inherited;
fDockable := true;
fUpdaterAuto := TTimer.Create(self);
fUpdaterAuto.Interval := 70;
fUpdaterAuto.OnTimer := @updaterAutoProc;