From d2539f25a961e163385b39d4825126e9bd342474 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Thu, 23 Sep 2010 10:24:31 +0200 Subject: memo: minor optimization - SomethingSelected is only called once now. --- src/gui/fpg_memo.pas | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gui/fpg_memo.pas b/src/gui/fpg_memo.pas index 994959e7..7818ff41 100644 --- a/src/gui/fpg_memo.pas +++ b/src/gui/fpg_memo.pas @@ -352,22 +352,15 @@ procedure TfpgMemo.SetDefaultPopupMenuItemsState; var i: integer; itm: TfpgMenuItem; + b: boolean; function SomethingSelected: boolean; - var - selsl: integer; - selsp: integer; - selel: integer; - selep: integer; begin - Result := FSelecting; - //Result := (FSelStartPos <> FCursorPos) - // and (FSelEndPos <> 0) - // and (FSelStartLine <> -1) - // and (FSelEndLine <> -1); + Result := SelectionText <> ''; end; begin + b := SomethingSelected; for i := 0 to FDefaultPopupMenu.ComponentCount-1 do begin if FDefaultPopupMenu.Components[i] is TfpgMenuItem then @@ -375,9 +368,9 @@ begin itm := TfpgMenuItem(FDefaultPopupMenu.Components[i]); // enabled/disable menu items if itm.Name = ipmCut then - itm.Enabled := (not ReadOnly) and SomethingSelected + itm.Enabled := (not ReadOnly) and b else if itm.Name = ipmCopy then - itm.Enabled := SomethingSelected + itm.Enabled := b else if itm.Name = ipmPaste then itm.Enabled := (not ReadOnly) and (fpgClipboard.Text <> '') else if itm.Name = ipmClearAll then -- cgit v1.2.3-70-g09d2