Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Dec 12, 2023
1 parent fdfb97c commit 240dab3
Show file tree
Hide file tree
Showing 13 changed files with 320 additions and 217 deletions.
2 changes: 1 addition & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@
<IsPartOfProject Value="True"/>
</Unit115>
<Unit116>
<Filename Value="editor/simba.editor_popupmenu.pas"/>
<Filename Value="simba.tab_popupmenu.pas"/>
<IsPartOfProject Value="True"/>
</Unit116>
<Unit117>
Expand Down
31 changes: 18 additions & 13 deletions Source/components/simba.component_scrollbar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface

uses
Classes, SysUtils, Controls, ComCtrls, StdCtrls,
ATScrollBar, simba.settings;
ATScrollBar, simba.mufasatypes, simba.settings;

type
TSimbaScrollBar = class(TATScrollBar)
Expand All @@ -23,16 +23,15 @@ TSimbaScrollBar = class(TATScrollBar)
public
ForwardScrollControl: TControl;

procedure Assign(From: TScrollBar);
procedure Assign(Source: TPersistent); override;

constructor Create(AOwner: TComponent); override;
end;

implementation

uses
LMessages,
simba.mufasatypes;
LMessages;

function TSimbaScrollBar.DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean;
begin
Expand All @@ -55,16 +54,22 @@ procedure TSimbaScrollBar.DoSettingChange_ScrollBarArrowSize(Setting: TSimbaSett
Update();
end;

procedure TSimbaScrollBar.Assign(From: TScrollBar);
procedure TSimbaScrollBar.Assign(Source: TPersistent);
var
From: TScrollBar absolute Source;
begin
Min := From.Min;
Max := From.Max+1;
SmallChange := From.SmallChange;
LargeChange := From.LargeChange;
PageSize := From.PageSize;
Position := From.Position;

Update();
if (Source is TScrollBar) then
begin
Min := From.Min;
Max := From.Max + 1;
SmallChange := From.SmallChange;
LargeChange := From.LargeChange;
PageSize := From.PageSize;
Position := From.Position;

Update();
end else
inherited Assign(Source);
end;

constructor TSimbaScrollBar.Create(AOwner: TComponent);
Expand Down
69 changes: 41 additions & 28 deletions Source/editor/simba.editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ interface

uses
Classes, SysUtils, Graphics, Controls, ComCtrls, LCLType,
SynEdit, SynEditTypes, SynGutterLineOverview, SynEditMouseCmds, SynEditMiscClasses, SynEditKeyCmds, SynEditHighlighter,
SynEdit, SynEditTypes, SynGutterLineOverview, SynEditMouseCmds, SynEditMiscClasses, SynEditKeyCmds, SynEditHighlighter, SynEditMarkupCtrlMouseLink, SynEditMarkupHighAll,
simba.mufasatypes, simba.settings, simba.editor_autocomplete, simba.editor_paramhint, simba.editor_attributes, simba.editor_modifiedlinegutter, simba.component_synedit;

type
TSimbaEditor = class(TSimbaSynEdit)
protected
FMarkupHighlightAllCaret: TSynEditMarkupHighlightAllCaret;
FMarkupCtrlMouse: TSynEditMarkupCtrlMouseLink;

FUseSimbaColors: Boolean;
FAutoComplete: TSimbaAutoComplete;
FParamHint: TSimbaParamHint;
Expand Down Expand Up @@ -51,21 +54,16 @@ TSimbaEditor = class(TSimbaSynEdit)
procedure DoSettingChanged_FontSize(Setting: TSimbaSetting);
procedure DoSettingChanged_FontName(Setting: TSimbaSetting);

// Accept drop from TTreeView
procedure DoDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure DoDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);

// Temp line coloring
procedure DoSpecialLineColor(Sender: TObject; Line: Integer; var Special: Boolean; AMarkup: TSynSelectedColor);

procedure StatusChanged(AChanges: TSynStatusChanges); override;
procedure SetUpdateState(NewUpdating: Boolean; Sender: TObject); override;

procedure SetColorModified(Value: TColor);
procedure SetColorSaved(Value: TColor);
procedure SetUseSimbaColors(Value: Boolean);
public
FileName: String;

property TextView;
property AutoComplete: TSimbaAutoComplete read FAutoComplete;
property ParamHint: TSimbaParamHint read FParamHint;
Expand All @@ -78,6 +76,10 @@ TSimbaEditor = class(TSimbaSynEdit)
property ColorModified: TColor read FColorModified write SetColorModified;
property UseSimbaColors: Boolean read FUseSimbaColors write SetUseSimbaColors;

// Accept from TTreeView
procedure DragDrop(Source: TObject; X, Y: Integer); override;
procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); override;

function GetCaretPos(GoBackToWord: Boolean): Integer;

// Is highlighter attribute at caret
Expand Down Expand Up @@ -107,11 +109,11 @@ TSimbaEditor = class(TSimbaSynEdit)
implementation

uses
SynEditPointClasses, SynGutter, SynHighlighterPas_Simba, SynEditMarkupHighAll, LazSynEditMouseCmdsTypes, Forms,
SynEditPointClasses, SynGutter, SynHighlighterPas_Simba, LazSynEditMouseCmdsTypes, Forms,
simba.fonthelpers, simba.editor_blockcompletion,
simba.editor_docgenerator, simba.editor_commentblock,
simba.editor_mousewheelzoom, simba.editor_multicaret,
simba.editor_popupmenu, simba.theme;
simba.theme;

function TSimbaEditor.IsHighlighterAttribute(Values: TStringArray): Boolean;
var
Expand Down Expand Up @@ -210,18 +212,6 @@ procedure TSimbaEditor.FocusLine(Line, Column: Integer; AColor: TColor);
end;
end;

procedure TSimbaEditor.DoDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
if (Source is TTreeView) and (TTreeView(Source).Selected <> nil) then
TextBetweenPoints[PixelsToRowColumn(TPoint.Create(X, Y)),
PixelsToRowColumn(TPoint.Create(X, Y))] := TTreeView(Source).Selected.Text;
end;

procedure TSimbaEditor.DoDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source is TTreeView;
end;

procedure TSimbaEditor.SetUpdateState(NewUpdating: Boolean; Sender: TObject);
begin
inherited SetUpdateState(NewUpdating, Sender);
Expand Down Expand Up @@ -280,7 +270,8 @@ procedure TSimbaEditor.SetUseSimbaColors(Value: Boolean);

procedure TSimbaEditor.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (ssCtrl in Shift) then // Mouse link fix
// Mouse link fix
if FMarkupCtrlMouse.IsMouseOverLink then
CaretXY := PixelsToRowColumn(Point(X, Y));

inherited MouseDown(Button, Shift, X, Y);
Expand Down Expand Up @@ -347,6 +338,22 @@ procedure TSimbaEditor.DoSettingChanged_FontName(Setting: TSimbaSetting);
Font.Name := Setting.Value;
end;

procedure TSimbaEditor.DragDrop(Source: TObject; X, Y: Integer);
begin
inherited DragDrop(Source, X, Y);

if (Source is TTreeView) and (TTreeView(Source).Selected <> nil) then
TextBetweenPoints[PixelsToRowColumn(TPoint.Create(X, Y)),
PixelsToRowColumn(TPoint.Create(X, Y))] := TTreeView(Source).Selected.Text;
end;

procedure TSimbaEditor.DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Source is TTreeView;
if not Accept then
inherited DragOver(Source, X, Y, State, Accept);
end;

procedure TSimbaEditor.DoSpecialLineColor(Sender: TObject; Line: Integer; var Special: Boolean; AMarkup: TSynSelectedColor);
var
I: Integer;
Expand All @@ -367,6 +374,14 @@ procedure TSimbaEditor.DoSpecialLineColor(Sender: TObject; Line: Integer; var Sp
end;
end;

procedure TSimbaEditor.StatusChanged(AChanges: TSynStatusChanges);
begin
inherited StatusChanged(AChanges);

if (scSelection in AChanges) then
FMarkupHighlightAllCaret.Enabled := SelAvail;
end;

function TSimbaEditor.GetExpression(X, Y: Integer): String;
var
Line: String;
Expand Down Expand Up @@ -429,10 +444,8 @@ constructor TSimbaEditor.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

OnDragDrop := @DoDragDrop;
OnDragOver := @DoDragOver;

PopupMenu := TSimbaEditorPopupMenu.Create(Self);
FMarkupHighlightAllCaret := MarkupByClass[TSynEditMarkupHighlightAllCaret] as TSynEditMarkupHighlightAllCaret;
FMarkupCtrlMouse := MarkupByClass[TSynEditMarkupCtrlMouseLink] as TSynEditMarkupCtrlMouseLink;

Options := Options + [eoTabIndent, eoKeepCaretX, eoDragDropEditing, eoScrollPastEof] - [eoSmartTabs];
Options2 := Options2 + [eoCaretSkipsSelection];
Expand Down Expand Up @@ -464,7 +477,7 @@ constructor TSimbaEditor.Create(AOwner: TComponent);

with TSynEditMarkupHighlightAllCaret(MarkupByClass[TSynEditMarkupHighlightAllCaret]) do
begin
Enabled := True;
Enabled := False;
WaitTime := 1;
IgnoreKeywords := True;
end;
Expand All @@ -477,7 +490,7 @@ constructor TSimbaEditor.Create(AOwner: TComponent);
FModifiedLinesGutter.ColorSaved := Gutter.ChangesPart.SavedColor;

AutoSize := False;
Width := Scale96ToScreen(4);
Width := Scale96ToScreen(6);
//TSynGutterLOvProviderCurrentPage.Create(Providers);
end;

Expand Down
142 changes: 0 additions & 142 deletions Source/editor/simba.editor_popupmenu.pas

This file was deleted.

2 changes: 1 addition & 1 deletion Source/forms/simba.functionlistform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ procedure TSimbaFunctionListForm.Fill;
if CanUpdate then
begin
Script := SimbaScriptTabsForm.CurrentEditor.Text;
ScriptFileName := SimbaScriptTabsForm.CurrentEditor.FileName;
ScriptFileName := SimbaScriptTabsForm.CurrentTab.ScriptFileName;
TabID := SimbaScriptTabsForm.CurrentTab.UID;
ExpandScriptNode := (FScriptNode.Count = 0) or FScriptNode.Expanded;

Expand Down
Loading

0 comments on commit 240dab3

Please sign in to comment.