Skip to content

Commit

Permalink
Cleanup (prexisting) can paste check.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Oct 11, 2024
1 parent d7ae087 commit c9a9dc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Components/ScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ TScintEdit = class(TWinControl)
procedure CancelAutoComplete;
procedure CancelAutoCompleteAndCallTip;
procedure CancelCallTip;
function CanPaste: Boolean;
function CanRedo: Boolean;
function CanUndo: Boolean;
procedure ChooseCaretX;
Expand Down Expand Up @@ -712,6 +713,11 @@ procedure TScintEdit.CancelCallTip;
Call(SCI_CALLTIPCANCEL, 0, 0);
end;

function TScintEdit.CanPaste: Boolean;
begin
Result := Call(SCI_CANPASTE, 0, 0) <> 0;
end;

function TScintEdit.CanRedo: Boolean;
begin
Result := Call(SCI_CANREDO, 0, 0) <> 0;
Expand Down
4 changes: 2 additions & 2 deletions Projects/Src/IDE.MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ procedure TMainForm.MemoKeyDown(Sender: TObject; var Key: Word;
end;
end;
end else if ((Key = Ord('V')) or (Key = VK_INSERT)) and (Shift * [ssShift, ssAlt, ssCtrl] = [ssCtrl]) then begin
if not FActiveMemo.ReadOnly and Clipboard.HasFormat(CF_TEXT) then { Also see EMenuClick }
if FActiveMemo.CanPaste then
if MultipleSelectionPasteFromClipboard(FActiveMemo) then
Key := 0;
end else if (Key = VK_SPACE) and (Shift * [ssShift, ssAlt, ssCtrl] = [ssShift, ssCtrl]) then begin
Expand Down Expand Up @@ -2864,7 +2864,7 @@ procedure TMainForm.EMenuClick(Sender: TObject);
ERedo.Enabled := MemoHasFocus and FActiveMemo.CanRedo;
ECut.Enabled := MemoHasFocus and not MemoIsReadOnly and not FActiveMemo.SelEmpty;
ECopy.Enabled := MemoHasFocus and not FActiveMemo.SelEmpty;
EPaste.Enabled := MemoHasFocus and not MemoIsReadOnly and Clipboard.HasFormat(CF_TEXT); { Also see MemoKeyDown }
EPaste.Enabled := MemoHasFocus and FActiveMemo.CanPaste;
EDelete.Enabled := MemoHasFocus and not FActiveMemo.SelEmpty;
ESelectAll.Enabled := MemoHasFocus;
ESelectNextOccurrence.Enabled := MemoHasFocus;
Expand Down

0 comments on commit c9a9dc5

Please sign in to comment.