[Lazarus] Patch for MK_ALT
revised patch (ignore prev message about "Forms.pp function error"). Needs some testing on Carbon/Cocoa, because MK_ALT const is defined in Mac WS'es. -- Regards, Alexey Index: lcl/interfaces/carbon/carbonproc.pp === --- lcl/interfaces/carbon/carbonproc.pp (revision 59355) +++ lcl/interfaces/carbon/carbonproc.pp (working copy) @@ -329,7 +329,7 @@ VK_SCROLL: Result := MK_SCRLOCK; VK_SHIFT : Result := MK_SHIFTKEY; VK_CONTROL : Result := MK_COMMAND; - VK_MENU : Result := MK_ALT; + VK_MENU : Result := CarbonProc.MK_ALT; // see LCLType.MK_ALT VK_OEM_3 : Result := MK_TILDE; //VK_OEM_MINUS : Result := MK_MINUS; VK_OEM_PLUS : Result := MK_EQUAL; @@ -482,7 +482,7 @@ if (ButtonState and 4) > 0 then Inc(Result, MK_MButton); if (shiftKeyand Modifiers) > 0 then Inc(Result, MK_Shift); if (controlKey and Modifiers) > 0 then Inc(Result, MK_Control); - if (optionKey and Modifiers) > 0 then Inc(Result, $2000); + if (optionKey and Modifiers) > 0 then Inc(Result, LCLType.MK_ALT); // see CarbonProc.MK_ALT //DebugLn('GetCarbonMsgKeyState Result=',dbgs(KeysToShiftState(Result)),' Modifiers=',hexstr(Modifiers,8),' ButtonState=',hexstr(ButtonState,8)); end; Index: lcl/interfaces/cocoa/cocoautils.pas === --- lcl/interfaces/cocoa/cocoautils.pas (revision 59355) +++ lcl/interfaces/cocoa/cocoautils.pas (working copy) @@ -815,7 +815,7 @@ VK_SCROLL: Result := MK_SCRLOCK; VK_SHIFT : Result := MK_SHIFTKEY; VK_CONTROL : Result := MK_COMMAND; - VK_MENU : Result := MK_ALT; + VK_MENU : Result := CocoaUtils.MK_ALT; // LCLType.MK_ALT exists VK_OEM_3 : Result := MK_TILDE; VK_OEM_MINUS : Result := MK_MINUS; VK_OEM_PLUS : Result := MK_EQUAL; Index: lcl/interfaces/cocoa/cocoawscommon.pas === --- lcl/interfaces/cocoa/cocoawscommon.pas (revision 59355) +++ lcl/interfaces/cocoa/cocoawscommon.pas (working copy) @@ -253,7 +253,7 @@ if AModifiers and NSControlKeyMask <> 0 then Result := Result or MK_CONTROL; if AModifiers and NSAlternateKeyMask <> 0 then -Result := Result or $2000; +Result := Result or LCLType.MK_ALT; // see CocoaUtils.MK_ALT end; class function TLCLCommonCallback.CocoaPressedMouseButtonsToKeyState(AMouseButtons: NSUInteger): PtrInt; @@ -474,7 +474,8 @@ IsSysKey := (Event.modifierFlags and NSCommandKeyMask) <> 0; KeyData := (Ord(Event.isARepeat) + 1) or Event.keyCode shl 16; if (Event.modifierFlags and NSAlternateKeyMask) <> 0 then - KeyData := KeyData or $2000; // So that MsgKeyDataToShiftState recognizes Alt key, see bug 30129 + KeyData := KeyData or LCLType.MK_ALT; // So that MsgKeyDataToShiftState recognizes Alt key, see bug 30129 + // see CocoaUtils.MK_ALT KeyCode := Event.keyCode; //non-printable keys (see mackeycodes.inc) @@ -844,7 +845,8 @@ IsSysKey := (Event.modifierFlags and NSCommandKeyMask) <> 0; KeyData := (Ord(Event.isARepeat) + 1) or Event.keyCode shl 16; if (Event.modifierFlags and NSAlternateKeyMask) <> 0 then -KeyData := KeyData or $2000; // So that MsgKeyDataToShiftState recognizes Alt key, see bug 30129 +KeyData := KeyData or LCLType.MK_ALT; // So that MsgKeyDataToShiftState recognizes Alt key, see bug 30129 +// see CocoaUtils.MK_ALT KeyCode := Event.keyCode; VKKeyCode := MacCodeToVK(KeyCode); Index: lcl/interfaces/gtk3/gtk3widgets.pas === --- lcl/interfaces/gtk3/gtk3widgets.pas (revision 59355) +++ lcl/interfaces/gtk3/gtk3widgets.pas (working copy) @@ -1494,7 +1494,7 @@ if AIsKeyEvent then Result := Result or KF_ALTDOWN else - Result := Result or $2000; + Result := Result or MK_ALT; end; end; @@ -1581,7 +1581,7 @@ ShiftState := ShiftState + [ssShift]; if AState and MK_CONTROL <> 0 then ShiftState := ShiftState + [ssCtrl]; - if AState and $2000 <> 0 then + if AState and MK_ALT <> 0 then ShiftState := ShiftState + [ssAlt]; // MappedXY := TranslateGdkPointToClientArea(AEvent^.scroll.window, EventXY, //{%H-}TGtk3Widget(AWinControl.Handle).GetContainerWidget); Index: lcl/interfaces/mui/muibaseunit.pas === --- lcl/interfaces/mui/muibaseunit.pas (revision 59355) +++ lcl/interfaces/mui/muibaseunit.pas (working copy) @@ -1574,9 +1574,9 @@ begin Result := 0; if State and IEQUALIFIER_LALT <> 0 then -Result := Result or $2000; +Result := Result or MK_ALT; //if State and IEQUALIFIER_RALT <> 0 then - // Result := Result or $2000; + // Result := Result or MK_ALT;
[Lazarus] Forms.pp function error?
As pointed by Dmitry B, and checked by myself in LCL, MK_ALT must be defined in LCLType.pp as $2000. For ex, this is sample from qtwidgets.pas: if (ModifierState and MK_SHIFT) <> 0 then Msg.State := [ssShift]; if (ModifierState and MK_CONTROL) <> 0 then Msg.State := [ssCtrl] + Msg.State; if (ModifierState and $2000) <> 0 then Msg.State := [ssAlt] + Msg.State; patch added. -- Regards, Alexey Index: lcl/lcltype.pp === --- lcl/lcltype.pp (revision 59355) +++ lcl/lcltype.pp (working copy) @@ -2836,6 +2836,7 @@ MK_DOUBLECLICK = $80; MK_TRIPLECLICK = $100; MK_QUADCLICK = $200; + MK_ALT = $2000; // used (as number) by several widgetsets //== // Constants from commctrl -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Micro optimization for LazUtils
On Fri, 26 Oct 2018 21:21:16 +0300 AlexeyT via Lazarus wrote: > added 2 inline's + fixed for loop. Thanks. Applied. Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] Micro optimization for LazUtils
added 2 inline's + fixed for loop. -- Regards, Alexey Index: components/lazutils/fpcadds.pas === --- components/lazutils/fpcadds.pas (revision 59355) +++ components/lazutils/fpcadds.pas (working copy) @@ -25,24 +25,21 @@ function StrToWord(const s: string): word; -function AlignToPtr(const p: Pointer): Pointer; -function AlignToInt(const p: Pointer): Pointer; +function AlignToPtr(const p: Pointer): Pointer; inline; +function AlignToInt(const p: Pointer): Pointer; inline; implementation function StrToWord(const s: string): word; var - p: Integer; + i: Integer; begin Result:=0; - p:=1; - while (p<=length(s)) do begin -Result:=Result*10+ord(s[p])-ord('0'); -inc(p); - end; + for i:=1 to Length(s) do +Result:=Result*10+ord(s[i])-ord('0'); end; -function AlignToPtr(const p: Pointer): Pointer; +function AlignToPtr(const p: Pointer): Pointer; inline; begin {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT} Result := Align(p, SizeOf(Pointer)); @@ -51,7 +48,7 @@ {$ENDIF} end; -function AlignToInt(const p: Pointer): Pointer; +function AlignToInt(const p: Pointer): Pointer; inline; begin {$IFDEF FPC_REQUIRES_PROPER_ALIGNMENT} Result := Align(p, SizeOf(integer)); -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Exception handling in Linux?
El 25/10/18 a las 18:46, Bo Berglund via Lazarus escribió: I am working on a port of a Windows Win32 command line program (Delphi 2007) to Linux Ubuntu 18.04 64bit. I am almost done now and my tests show that the basic functionality works as intended. But I am not sure about the exception handling at all... In my code I have many instances of: try some code block except on E: Exception do begin LogDebug('Exception in module : ' + E.Message; end end; Now when testing I have experienced that Lazarus trows up an exception dialog when code inside such a construct is running (it typically comes from some Indy10 operation). When I hit Continue I expect the code to run the except block but it does not. There are no log messages concerning the exception So I wonder if this is a difference between Windows and Linux or some missing configuration setting on my part? Do you get that exception dialog when you run the executable out of the IDE environment? I mean, maybe the exception is handled inside indy10, so it is not propagated to the level of your except block. My theory is that the exception dialog is raised by Lazarus environment whenever an exception is raised, handled or not, and if you click "continue", then Indy10 handles it. -- Saludos Santiago A. -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Lazarus tooltips do not work properly in Indy10 on Unix
BTW, what you call a tooltip is actually an identifier completion window. A tooltip is just a hint window for a ToolButton or similar. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Lazarus tooltips do not work properly in Indy10 on Unix
If a syntax is accepted by FPC then it should be accepted also by CodeTools. Please open a bug report with a minimal example code. Do not include units from Indy. Just reduce the problematic line into its simplest form that triggers the bug. Juha -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus
[Lazarus] Lazarus tooltips do not work properly in Indy10 on Unix
I discovered a strange IDE issue concerning the tooltips in Lazarus when using TIdFTP objects from Indy10. I have made two installations of Lazarus 1.8.4 + FPC 3.0.4, one on Windows7 and one in IUbuntu 18.04. I am working on a project ported from Delphi 2007 which uses Indy10. So in both IDE:s I have used the IndyLaz package (installed it via OnLine PackageManager). In both environments the project builds OK, no errors or warnings, but in the Lazarus IDE there are differences: Windows version: If I type the name of a TIdFTP variable and wait a few seconds to get it highlighted, then type the period, the tooltips pop up with the possible methods I can use. This is expected and useful. Ubuntu Linux x64 version: - If I do the same in this environment nothing pops up, instead there is an error message in the messages panel: Codetools, Errors: 1 IdGlobal.pas(1889,105) Error: expected ;, but deprecated found So I opened the iundicated line by clicking on the error message and got to this: {$IFDEF UNIX} GOffsetFromUTC: TDateTime = 0{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; {$ENDIF} Apparently this line, which does not even exist on Windows breaks the tooltips in Lazarus without breaking the compiler 3.0.4. I have now tested a number of variations of this line without success: GOffsetFromUTC: TDateTime = 0 deprecated; ==> IdGlobal.pas(1890,33) Error: expected ;, but deprecated found GOffsetFromUTC: TDateTime = 0; deprecated; ==> IdGlobal.pas(1896,3) Error: expected end., but IndyPos found except: GOffsetFromUTC: TDateTime = 0; ==> This actually works in the IDE to bring up the IdFTP methods tooltips! And the project builds without any errors or warnings related to this, just warns about variables that are not used in my own code. They should be ifdef:ed for DELPHI... I asked Remy Lebeau about this and he suggested I report this on the Lazarus list since he has had debates before on this very issue... Why is there a construct like that in the IdGlobals file in the first place??? Lazarus without tool-tips for complex classes like this is no good. -- Bo Berglund Developer in Sweden -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus