add options overrides to the editor ctxt mnu, close #334

This commit is contained in:
Basile Burg 2018-06-30 13:08:23 +02:00
parent 6da39d518d
commit 388fc722c3
2 changed files with 157 additions and 5 deletions

View File

@ -21,8 +21,8 @@ inherited CEEditorWidget: TCEEditorWidget
ClientWidth = 465
object editorStatus: TStatusBar[0]
Left = 0
Height = 21
Top = 375
Height = 19
Top = 377
Width = 465
BorderSpacing.Bottom = 2
Panels = <
@ -41,6 +41,9 @@ inherited CEEditorWidget: TCEEditorWidget
end
item
Width = 2000
end
item
Width = 50
end>
SimplePanel = False
SizeGrip = False
@ -169,6 +172,84 @@ inherited CEEditorWidget: TCEEditorWidget
object MenuItem12: TMenuItem
Caption = '-'
end
object MenuItem13: TMenuItem
Caption = 'Options overrides'
object MenuItem15: TMenuItem
Caption = 'Indentation mode'
object mnuEdSetSpaces: TMenuItem
Caption = 'spaces'
GroupIndex = 1
RadioItem = True
OnClick = mnuEdSetSpacesClick
end
object mnuEdSetTabs: TMenuItem
Caption = 'tabs'
GroupIndex = 1
RadioItem = True
OnClick = mnuEdSetTabsClick
end
end
object MenuItem16: TMenuItem
Caption = 'Spaces per tab'
object mnuEdTabWidth2: TMenuItem
Tag = 2
Caption = '2'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth3: TMenuItem
Tag = 3
Caption = '3'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth4: TMenuItem
Tag = 4
Caption = '4'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth5: TMenuItem
Tag = 5
Caption = '5'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth6: TMenuItem
Tag = 6
Caption = '6'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth7: TMenuItem
Tag = 7
Caption = '7'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
object mnuEdTabWidth8: TMenuItem
Tag = 8
Caption = '8'
GroupIndex = 2
RadioItem = True
OnClick = mnuEdTabWidth2Click
end
end
object mnuEdShowSpec: TMenuItem
AutoCheck = True
Caption = 'Show special chars'
OnClick = mnuEdShowSpecClick
end
end
object MenuItem14: TMenuItem
Caption = '-'
end
object mnuedDdocTmp: TMenuItem
Caption = 'Insert DDOC template'
OnClick = mnuedDdocTmpClick

View File

@ -52,12 +52,25 @@ type
end;
{ TCEEditorWidget }
TCEEditorWidget = class(TCEWidget, ICEDocumentObserver, ICEMultiDocHandler, ICEProjectObserver)
MenuItem1: TMenuItem;
MenuItem10: TMenuItem;
MenuItem11: TMenuItem;
MenuItem12: TMenuItem;
MenuItem13: TMenuItem;
MenuItem14: TMenuItem;
MenuItem15: TMenuItem;
MenuItem16: TMenuItem;
mnuEdTabWidth2: TMenuItem;
mnuEdTabWidth3: TMenuItem;
mnuEdTabWidth4: TMenuItem;
mnuEdTabWidth5: TMenuItem;
mnuEdTabWidth6: TMenuItem;
mnuEdTabWidth7: TMenuItem;
mnuEdTabWidth8: TMenuItem;
mnuEdShowSpec: TMenuItem;
mnuEdSetSpaces: TMenuItem;
mnuEdSetTabs: TMenuItem;
mnuedGotoline: TMenuItem;
mnuedPrevWarn: TMenuItem;
mnuedNextWarn: TMenuItem;
@ -104,7 +117,11 @@ type
procedure mnuedPrevCareaClick(Sender: TObject);
procedure mnuedLowcaseClick(Sender: TObject);
procedure mnuedPrevWarnClick(Sender: TObject);
procedure mnuEdSetSpacesClick(Sender: TObject);
procedure mnuEdSetTabsClick(Sender: TObject);
procedure mnuEdShowSpecClick(Sender: TObject);
procedure mnuedSortLinesClick(Sender: TObject);
procedure mnuEdTabWidth2Click(Sender: TObject);
procedure mnuedUpcaseClick(Sender: TObject);
procedure MenuItem5Click(Sender: TObject);
procedure MenuItem6Click(Sender: TObject);
@ -950,12 +967,52 @@ begin
fDoc.previousWarning;
end;
procedure TCEEditorWidget.mnuEdSetSpacesClick(Sender: TObject);
begin
if fDoc.isNotNil then
fDoc.Options := fDoc.Options + [eoTabsToSpaces];
end;
procedure TCEEditorWidget.mnuEdSetTabsClick(Sender: TObject);
begin
if fDoc.isNotNil then
fDoc.Options := fDoc.Options - [eoTabsToSpaces];
end;
procedure TCEEditorWidget.mnuEdShowSpecClick(Sender: TObject);
begin
if fDoc.isNil then
exit;
if mnuEdShowSpec.Checked then
fDoc.Options := fDoc.Options + [eoShowSpecialChars]
else
fDoc.Options := fDoc.Options - [eoShowSpecialChars];
end;
procedure TCEEditorWidget.mnuedSortLinesClick(Sender: TObject);
begin
if fDoc.isNotNil then
fDoc.CommandProcessor(ecSortLines, #0, nil);
end;
procedure TCEEditorWidget.mnuEdTabWidth2Click(Sender: TObject);
begin
if fDoc.isNil then
exit;
fDoc.TabWidth:= TMenuItem(sender).Tag;
if not (eoTabsToSpaces in fDoc.options) then
begin
fDoc.BlockIndent := 0;
fDoc.BlockTabIndent := 1;
end
else
begin
fDoc.BlockIndent := fDoc.TabWidth;
fDoc.BlockTabIndent := 0;
end;
end;
procedure TCEEditorWidget.mnuedNextCareaClick(Sender: TObject);
begin
if fDoc.isNotNil then
@ -1114,14 +1171,28 @@ end;
procedure TCEEditorWidget.mnuEditorPopup(Sender: TObject);
begin
if fDoc.isNil then exit;
//
if fDoc.isNil then
exit;
mnuedCut.Enabled:=fDoc.SelAvail;
mnuedPaste.Enabled:=fDoc.CanPaste;
mnuedCopy.Enabled:=fDoc.SelAvail;
mnuedUndo.Enabled:=fDoc.CanUndo;
mnuedRedo.Enabled:=fDoc.CanRedo;
mnuedJum2Decl.Enabled:=fDoc.isDSource;
mnuEdSetSpaces.Checked:= eoTabsToSpaces in fDoc.Options;
mnuEdSetTabs.Checked:= not (eoTabsToSpaces in fDoc.Options);
mnuEdShowSpec.Checked:=eoShowSpecialChars in fDoc.Options;
case fDoc.TabWidth of
2: mnuEdTabWidth2.Checked:=true;
3: mnuEdTabWidth3.Checked:=true;
4: mnuEdTabWidth4.Checked:=true;
5: mnuEdTabWidth5.Checked:=true;
6: mnuEdTabWidth6.Checked:=true;
7: mnuEdTabWidth7.Checked:=true;
8: mnuEdTabWidth8.Checked:=true;
end;
end;
{$ENDREGION}
end.