diff --git a/Source/Simba.lpi b/Source/Simba.lpi index d661c42f5..70d4bcdb4 100644 --- a/Source/Simba.lpi +++ b/Source/Simba.lpi @@ -380,7 +380,7 @@ - + @@ -968,6 +968,13 @@ + + + + + + + diff --git a/Source/forms/simba.settingsform.lfm b/Source/forms/simba.settingsform.lfm index 51e659dcf..9fab2a582 100644 --- a/Source/forms/simba.settingsform.lfm +++ b/Source/forms/simba.settingsform.lfm @@ -1,11 +1,11 @@ object SimbaSettingsForm: TSimbaSettingsForm - Left = 3352 + Left = -1107 Height = 625 - Top = 69 + Top = 465 Width = 750 Caption = 'Settings' - ClientHeight = 625 - ClientWidth = 750 + ClientHeight = 0 + ClientWidth = 0 DesignTimePPI = 120 OnShow = FormShow Position = poMainFormCenter diff --git a/Source/forms/simba.settingsform.pas b/Source/forms/simba.settingsform.pas index 6d574e38d..b8b49abaf 100644 --- a/Source/forms/simba.settingsform.pas +++ b/Source/forms/simba.settingsform.pas @@ -12,6 +12,7 @@ interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls, ButtonPanel, Spin, simba.settingsform_editor_font, simba.settingsform_editor_colors, simba.settingsform_editor_general, + simba.settingsform_editor_default, simba.settingsform_simba_general, simba.settingsform_outputbox, simba.settingsform_backup, simba.settingsform_codetools; @@ -34,6 +35,7 @@ TSimbaSettingsForm = class(TForm) EditorGeneralFrame: TEditorGeneralFrame; EditorFontFrame: TEditorFontFrame; EditorColorsFrame: TEditorColorsFrame; + EditorDefaultFrame: TEditorDefaultFrame; procedure ShowPage(Title: String); @@ -91,8 +93,11 @@ procedure TSimbaSettingsForm.FormShow(Sender: TObject); SimbaCodetoolsFrame.Load(); EditorGeneralFrame.Load(); EditorColorsFrame.Load(); + EditorDefaultFrame.Load(); SimbaOutputBoxFrame.Load(); SimbaBackupFrame.Load(); + + TreeView.Selected := TreeView.Items.GetFirstNode(); end; procedure TSimbaSettingsForm.OKButtonClick(Sender: TObject); @@ -113,6 +118,7 @@ procedure TSimbaSettingsForm.OKButtonClick(Sender: TObject); SimbaCodetoolsFrame.Save(); EditorGeneralFrame.Save(); EditorColorsFrame.Save(); + EditorDefaultFrame.Save(); SimbaOutputBoxFrame.Save(); SimbaBackupFrame.Save(); end; @@ -183,7 +189,10 @@ constructor TSimbaSettingsForm.Create(AOwner: TComponent); EditorColorsFrame.Align := alClient; EditorColorsFrame.ParentFont := True; - TreeView.Selected := TreeView.Items.GetFirstNode(); + EditorDefaultFrame := TEditorDefaultFrame.Create(Self); + EditorDefaultFrame.Parent := AddPage('Default Script', Node); + EditorDefaultFrame.Align := alClient; + EditorDefaultFrame.ParentFont := True; end; end. diff --git a/Source/forms/simba.settingsform_editor_default.lfm b/Source/forms/simba.settingsform_editor_default.lfm new file mode 100644 index 000000000..ab032059c --- /dev/null +++ b/Source/forms/simba.settingsform_editor_default.lfm @@ -0,0 +1,120 @@ +object EditorDefaultFrame: TEditorDefaultFrame + Left = 0 + Height = 388 + Top = 0 + Width = 552 + ClientHeight = 388 + ClientWidth = 552 + DesignTimePPI = 120 + ParentFont = False + TabOrder = 0 + DesignLeft = -631 + DesignTop = 843 + object RadioGroup1: TRadioGroup + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 88 + Top = 0 + Width = 552 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + AutoSize = True + Caption = 'On New Tab' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 58 + ClientWidth = 548 + Items.Strings = ( + 'Load File' + 'Set Script' + ) + OnSelectionChanged = RadioGroup1SelectionChanged + TabOrder = 0 + end + object Notebook1: TNotebook + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = RadioGroup1 + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = Owner + AnchorSideBottom.Side = asrBottom + Left = 0 + Height = 290 + Top = 98 + Width = 552 + PageIndex = 1 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 10 + TabOrder = 1 + object PageLoadFile: TPage + object FileNameEdit1: TFileNameEdit + AnchorSideLeft.Control = LabelFileName + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = PageLoadFile + AnchorSideRight.Control = PageLoadFile + AnchorSideRight.Side = asrBottom + Left = 103 + Height = 33 + Top = 0 + Width = 444 + FileName = 'FileNameEdit1' + FilterIndex = 0 + HideDirectories = False + ButtonWidth = 29 + NumGlyphs = 1 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 5 + BorderSpacing.Right = 5 + MaxLength = 0 + TabOrder = 0 + Text = 'FileNameEdit1' + end + object LabelFileName: TLabel + AnchorSideLeft.Control = PageLoadFile + AnchorSideTop.Control = FileNameEdit1 + AnchorSideBottom.Control = FileNameEdit1 + AnchorSideBottom.Side = asrBottom + Left = 5 + Height = 33 + Top = 0 + Width = 93 + Anchors = [akTop, akLeft, akBottom] + BorderSpacing.Left = 5 + Caption = 'File To Load' + Layout = tlCenter + end + end + object PageSetScript: TPage + object Label1: TLabel + Left = 5 + Height = 25 + Top = 0 + Width = 547 + Align = alTop + BorderSpacing.Left = 5 + Caption = 'Script' + end + object Memo1: TMemo + Left = 5 + Height = 255 + Top = 30 + Width = 542 + Align = alClient + BorderSpacing.Around = 5 + Lines.Strings = ( + 'Memo1' + ) + TabOrder = 0 + end + end + end +end diff --git a/Source/forms/simba.settingsform_editor_default.pas b/Source/forms/simba.settingsform_editor_default.pas new file mode 100644 index 000000000..6a2fb3a2c --- /dev/null +++ b/Source/forms/simba.settingsform_editor_default.pas @@ -0,0 +1,62 @@ +{ + Author: Raymond van Venetiƫ and Merlijn Wajer + Project: Simba (https://github.com/MerlijnWajer/Simba) + License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0) +} +unit simba.settingsform_editor_default; + +{$i simba.inc} + +interface + +uses + Classes, SysUtils, Forms, Controls, StdCtrls, ExtCtrls, EditBtn; + +type + TEditorDefaultFrame = class(TFrame) + FileNameEdit1: TFileNameEdit; + Label1: TLabel; + LabelFileName: TLabel; + Memo1: TMemo; + Notebook1: TNotebook; + PageLoadFile: TPage; + PageSetScript: TPage; + RadioGroup1: TRadioGroup; + + procedure RadioGroup1SelectionChanged(Sender: TObject); + public + procedure Load; + procedure Save; + end; + +implementation + +uses + simba.settings; + +procedure TEditorDefaultFrame.RadioGroup1SelectionChanged(Sender: TObject); +begin + case RadioGroup1.ItemIndex of + 0: PageLoadFile.Show(); + 1: PageSetScript.Show(); + end; +end; + +procedure TEditorDefaultFrame.Load; +begin + Memo1.Lines.Text := SimbaSettings.Editor.DefaultScript.Value; + FileNameEdit1.FileName := SimbaSettings.Editor.DefaultScriptFile.Value; + RadioGroup1.ItemIndex := SimbaSettings.Editor.DefaultScriptType.Value; +end; + +procedure TEditorDefaultFrame.Save; +begin + SimbaSettings.Editor.DefaultScript.Value := Memo1.Lines.Text; + SimbaSettings.Editor.DefaultScriptFile.Value := FileNameEdit1.FileName; + SimbaSettings.Editor.DefaultScriptType.Value := RadioGroup1.ItemIndex; +end; + +{$R *.lfm} + +end. + diff --git a/Source/forms/simba.settingsform_editor_general.lfm b/Source/forms/simba.settingsform_editor_general.lfm index 6aa8ea85d..5a9e17765 100644 --- a/Source/forms/simba.settingsform_editor_general.lfm +++ b/Source/forms/simba.settingsform_editor_general.lfm @@ -1,22 +1,22 @@ object EditorGeneralFrame: TEditorGeneralFrame Left = 0 - Height = 672 + Height = 500 Top = 0 - Width = 946 - ClientHeight = 672 - ClientWidth = 946 + Width = 500 + ClientHeight = 500 + ClientWidth = 500 DesignTimePPI = 120 ParentFont = False TabOrder = 0 - DesignLeft = 3792 - DesignTop = 388 + DesignLeft = 36 + DesignTop = 722 object CaretPastEOLCheckBox: TCheckBox AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner Left = 0 - Height = 24 + Height = 29 Top = 0 - Width = 159 + Width = 185 Caption = 'Allow Caret Past EOL' TabOrder = 0 end @@ -25,9 +25,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideTop.Control = DividerBevel4 AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 64 - Width = 65 + Height = 29 + Top = 74 + Width = 72 BorderSpacing.Top = 10 Caption = 'Visible' TabOrder = 1 @@ -37,9 +37,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = VisibleRightMarginCheckbox AnchorSideTop.Side = asrBottom - Left = 46 - Height = 28 - Top = 98 + Left = 52 + Height = 33 + Top = 113 Width = 125 BorderSpacing.Left = 10 BorderSpacing.Top = 10 @@ -52,9 +52,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideBottom.Control = RightMarginEdit AnchorSideBottom.Side = asrBottom Left = 0 - Height = 28 - Top = 98 - Width = 36 + Height = 33 + Top = 113 + Width = 42 Anchors = [akTop, akLeft, akBottom] Caption = 'Value' Layout = tlCenter @@ -67,9 +67,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 20 - Top = 34 - Width = 946 + Height = 25 + Top = 39 + Width = 500 Caption = 'Right Margin' Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 10 @@ -82,9 +82,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 20 - Top = 136 - Width = 946 + Height = 25 + Top = 156 + Width = 500 Caption = 'Block Completion' Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 10 @@ -95,9 +95,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideTop.Control = CompleteLabel AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 196 - Width = 142 + Height = 29 + Top = 226 + Width = 165 BorderSpacing.Top = 10 Caption = '"begin" add "end"' TabOrder = 3 @@ -107,9 +107,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideTop.Control = CompleteBeginCheckbox AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 230 - Width = 89 + Height = 29 + Top = 265 + Width = 100 BorderSpacing.Top = 10 Caption = '"(" add ")"' TabOrder = 4 @@ -119,9 +119,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideTop.Control = CompleteParenthesesCheckbox AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 264 - Width = 89 + Height = 29 + Top = 304 + Width = 100 BorderSpacing.Top = 10 Caption = '"[" add "]"' TabOrder = 5 @@ -131,9 +131,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideTop.Control = CompleteDivider AnchorSideTop.Side = asrBottom Left = 0 - Height = 20 - Top = 166 - Width = 248 + Height = 25 + Top = 191 + Width = 295 BorderSpacing.Top = 10 Caption = 'Automatically complete the block on:' ParentColor = False @@ -145,9 +145,9 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 20 - Top = 298 - Width = 946 + Height = 25 + Top = 343 + Width = 500 Caption = 'Documentation Comment' Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 10 @@ -160,8 +160,8 @@ object EditorGeneralFrame: TEditorGeneralFrame AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom Left = 0 - Height = 334 - Top = 328 + Height = 112 + Top = 378 Width = 408 Anchors = [akTop, akLeft, akBottom] BorderSpacing.Top = 10 diff --git a/Source/simba.scripttab.pas b/Source/simba.scripttab.pas index 28c5787a5..db8938992 100644 --- a/Source/simba.scripttab.pas +++ b/Source/simba.scripttab.pas @@ -89,6 +89,8 @@ TSimbaScriptTab = class(TSimbaTab) FOutputBox: TSimbaOutputBox; + procedure LoadDefaultScript; + // Keep output tab in sync procedure TextChanged; override; @@ -336,6 +338,16 @@ function TSimbaScriptTab.GetScriptChanged: Boolean; Result := FEditor.Text <> FSavedText; end; +procedure TSimbaScriptTab.LoadDefaultScript; +begin + case SimbaSettings.Editor.DefaultScriptType.Value of + 0: FEditor.Text := TSimbaFile.FileRead(SimbaSettings.Editor.DefaultScriptFile.Value); + 1: FEditor.Text := SimbaSettings.Editor.DefaultScript.Value; + end; + + FEditor.MarkTextAsSaved(); +end; + procedure TSimbaScriptTab.TextChanged; begin inherited TextChanged(); @@ -604,8 +616,6 @@ constructor TSimbaScriptTab.Create(AOwner: TComponent); FEditor := TSimbaEditor.Create(Self); FEditor.Parent := Self; FEditor.Align := alClient; - FEditor.Text := SimbaSettings.Editor.DefaultScript.Value; - FEditor.MarkTextAsSaved(); FEditor.RegisterStatusChangedHandler(@DoEditorStatusChanges, [scCaretX, scCaretY, scModified]); FEditor.OnClickLink := @DoEditorLinkClick; FEditor.OnModified := @DoEditorModified; @@ -616,6 +626,8 @@ constructor TSimbaScriptTab.Create(AOwner: TComponent); FOutputBox := SimbaOutputForm.AddScriptOutput('Untitled'); FOutputBox.TabImageIndex := IMG_STOP; + LoadDefaultScript(); + FSavedText := FEditor.Text; end; diff --git a/Source/simba.settings.pas b/Source/simba.settings.pas index 48ebbda83..e09d82fea 100644 --- a/Source/simba.settings.pas +++ b/Source/simba.settings.pas @@ -114,7 +114,9 @@ TSimbaSettings = class end; Editor: record + DefaultScriptType: TSimbaSetting; DefaultScript: TSimbaSetting; + DefaultScriptFile: TSimbaSetting; CustomColors: TSimbaSetting; FontSize: TSimbaSetting; FontName: TSimbaSetting; @@ -503,7 +505,9 @@ constructor TSimbaSettings.Create; General.FindInFilesCaseSens := TSimbaSetting_Boolean.Create(Self, 'General', 'FindInFilesCaseSens', False); // Editor + Editor.DefaultScriptType := TSimbaSetting_Integer.Create(Self, 'Editor', 'DefaultScriptType', 1); Editor.DefaultScript := TSimbaSetting_BinaryString.Create(Self, 'Editor', 'DefaultScript', 'program new;' + LineEnding + 'begin' + LineEnding + 'end.'); + Editor.DefaultScriptFile := TSimbaSetting_String.Create(Self, 'Editor', 'DefaultScriptFile', ''); Editor.CustomColors := TSimbaSetting_String.Create(Self, 'Editor', 'CustomColors', ''); Editor.FontSize := TSimbaSetting_Integer.Create(Self, 'Editor', 'FontSize', SynDefaultFontSize); Editor.FontName := TSimbaSetting_String.Create(Self, 'Editor', 'FontName', SynDefaultFontName); @@ -524,7 +528,7 @@ constructor TSimbaSettings.Create; CodeTools.IgnoreIDEDirective := TSimbaSetting_Boolean.Create(Self, 'CodeTools', 'IgnoreIDEDirective', False); - Codetools.CompletionAddKeywords := TSimbaSetting_Boolean.Create(Self, 'CodeTools', 'CompletionAddKeywords', True); + CodeTools.CompletionAddKeywords := TSimbaSetting_Boolean.Create(Self, 'CodeTools', 'CompletionAddKeywords', True); CodeTools.CompletionOpenAutomatically := TSimbaSetting_Boolean.Create(Self, 'CodeTools', 'CompletionOpenAutomatically', True); CodeTools.CompletionKey := TSimbaSetting_Integer.Create(Self, 'CodeTools', 'CompletionKey', VK_SPACE); CodeTools.CompletionKeyModifiers := TSimbaSetting_Integer.Create(Self, 'CodeTools', 'CompletionKeyModifiers', Integer(TShiftState([ssCtrl])));