Jump to content

pyscripter

Members
  • Content Count

    780
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by pyscripter

  1. pyscripter

    Ssh library for Delphi

    Help wanted: libssh2 can be compiled so that it uses Windows CNG instead of OpenSSL, thus avoiding any dependence on other dynamic libraries. I wonder whether it would be possible to compile it into C obj files that can be linked into the Delphi executable. This would simplify the deployment greatly. Any help on this would be greatly appreciated.
  2. pyscripter

    Whats the idea behind Dev-Cpp support ?

    No it is written in Delphi pascal.
  3. pyscripter

    Whats the idea behind Dev-Cpp support ?

    No. It is (was) a stand-alone free and open source C/C++ IDE, working with the GNU compiler toolset built with Delphi and quite popular at its prime. There is a fork that includes a form designer for WxWidgets GUI applications. Does anyone recall the short-lived commercial C++ wxWidgets (then called WxWindows) Borland IDE (unrelated to Dev-C++)? I can't even remember what it was called.
  4. pyscripter

    tContainedObject, tAggregatedObject

    Yes
  5. pyscripter

    tContainedObject, tAggregatedObject

    Exactly. If you are familiar with Excel automation think about the Applications and the Workbooks collection. The second exists only as part of the first. The second could be implemented as a TContainedObject. What TAggregatedObject and TContainedObject have in common: They have no separate reference counting They should be created and destroyed by the Controller. How do they differ? (from the source code) TAggregatedObject simply reflects QueryInterface calls to its controller. From such an aggregated object, one can obtain any interface that the controller supports, and only interfaces that the controller supports. This is useful for implementing a controller class that uses one or more internal objects to implement the interfaces declared on the controller class. Aggregation promotes implementation sharing across the object hierarchy. TContainedObject is an aggregated object that isolates QueryInterface on the aggregate from the controller. TContainedObject will return only interfaces that the contained object itself implements, not interfaces that the controller implements.
  6. pyscripter

    SynEdit preferred version?

    If you are switching from another version of Synedit to Synedit-2 you need to uninstall the current version, remove all compiled packages and install from scratch. As mentioned above I am not sure which is the earliest version supported (same about the Turbo Synedit), however I am quite sure Delphi 10.2 should be good.
  7. Does anyone know in which Delphi version TStrings got following properties: Encoding/DefaultEncoding TrailingLineBreak WriteBOM LineBreak Thanks...
  8. pyscripter

    SynEdit preferred version?

    A more advanced wrapper for Scintilla was in http://myarmor.users.sourceforge.net/. I had some involvement in the initial development. But it died many years ago. A more up to date wrapper exists in the Inno Setup source code https://github.com/jrsoftware/issrc/tree/main/Components. However it is based on Scintilla 2.22, when the current version is 4.4...
  9. pyscripter

    SynEdit preferred version?

    That would be good, but the author says it is not going to be easy.
  10. pyscripter

    SynEdit preferred version?

    It does, but the spacing is not very good.
  11. pyscripter

    SynEdit preferred version?

    To be frank I am not sure. Like the Turbo branch it is aimed at the most recent versions of Delphi. The code uses generics and unicode, so that I suppose determines the minimum version.
  12. pyscripter

    SynEdit preferred version?

    Unfortunately SynEdit's ShowModification is half-baked and does not work well when you undo. This is why it has not been ported to SynEdit-2. Proper support requires some work in the undo/redo system.
  13. pyscripter

    SynEdit preferred version?

    I will start with a bit of history. The Original Code is based on mwCustomEdit.pas by Martin Waldenburg, a great programmer. The key feature of the editor was fast syntax highlighting. This was more than 20 years ago. After a split of the community the SynEdit project was formed maintaining some of the key features of mwEdit. Over the years some of the best Delphi programmers contributed to the project. The list includes for example Gerald Nunn, Eric Grange, Jordan Russell and many many others. Flavio Etrusco added word wrap and Maël Hörz added unicode support (but in a rather idiosyncratic way). However the project management was very weak and the code gradually became very hard to maintain and improve. It aimed to support very old Delphi versions including Kylix and the code became full of IFDEFs and patches without an overall coherence. An early fork of Synedit is part of Lazarus but the two development efforts have diverged a great deal. When Embarcadero introduced the GetIt package manager they asked Roman Kassebaum to produce a version of SynEdit for GetIt. Roman did a general code cleanup removing support for early Delphi versions and Kylix (Turbo fork(s)). I have added support for code folding (the first major new feature for years) to both the Turbo fork and the main Synedit repository. However the Turbo fork(s) were not actively supported or developed beyond recompiling for new Delphi versions and the main Synedit branch was too hard to work with, hence the creation of SynEdit-2 as a fork of Turbo SynEdit. Main new features in SynEdit-2: Replaced SynRegExpr with the built-in RegularExpressions Move/Copy Line(s) Up/Down commands as in VS Code Delete Line command should work with multi-line selection Handle triple and quadruple clicks for selection Triple click and drag should select lines Double click and drag should select whole words Support OLE Drag & Drop What are the key features missing in Synedit: Better Unicode handling: Better support for wide characters e.g. Chinese ideograms (爾雅爾雅爾雅爾雅) Support for surrogate pairs (two widechars correspond to one glyph) Combining characters (e.g. Åström ḱṷṓn) Multi-cursor and multi-selection editing as in VS Code. When these features get implemented I think SynEdit will become comparable to some of the best editors around. But both of them require major rewriting of the code. Work on the second is well advanced and the unicode work is in the planning stage. Of course it is your choice as to which version of SynEdit to use, but if anyone wants to contribute to the development you are very welcome.
  14. pyscripter

    JEDI Installation Annoyances 10.4

    @PeterPanettone Did you follow the instructions on the Github page? (Git clone etc.) It should work out of the box.
  15. pyscripter

    Revisiting TThreadedQueue and TMonitor

    And @Dmitry Arefiev while you are at it please deal with RSP-28200. Just as important if not more.
  16. pyscripter

    Revisiting TThreadedQueue and TMonitor

    This is worth a certain degree of celebration. I cannot remember Embarcadero/Inprice/Borland etc. being so responsive ever. It also demonstrates the power of the collective efforts of the community to make Delphi better.
  17. pyscripter

    JEDI Installation Annoyances 10.4

    It was here.
  18. Marco Cantu presented in CodeRage 2018 an implementation of Smart Pointers based on generics, similar to the one found in Spring4D. It can be used as follows: var smartP: TSmartPointer<TStringList>; begin smartP := TStringList.Create; smartP.Value.Add('foo'); TStringList(smartP).Add('foo2'); I am using in my code a non-generics implementation from JclSysUtils var sl: TStringList; slSafeGuard: ISafeGuard; begin sl := TStringList(Guard(TStringList.Create, slSafeGuard)); sl.Add('foo'): The second has the advantage that you do not have to use the Value property to get the object at the cost of having an extra declaration and being less elegant (?). Are there any performance or other advantages to the Generics implementation? Isn't the non-generics implementation faster and doesn't it generate less code?
  19. pyscripter

    Revisiting TThreadedQueue and TMonitor

    I have improved the fix to deal with TMonitor.Wait being called during unit finalization. Corner case but it did come up in a real application. See attached: MonitorWaitStackFix.pas
  20. I remember @David Heffernan saying that the first thing he does when installing a new Delphi version is to remove the Embarcadero entries in the Windows path. Do I remember well? Are there any downsides to doing that?
  21. pyscripter

    Embarcadero entries in the path

    Thank you all for your answers. What is wrong with removing all these entries. Does this cause Rad Studio to malfunction?
  22. That is so nice... Thanks for spotting the typo anyway. With the typo fixed the following test code: procedure Test(); begin try var Bob := TSmartPointer.Wrap(TTalking.Create('Bob')); Bob.Talk; var John := TSmartPointer.Wrap(TTalking.Create('John')); John.Talk; John := Bob; John.Talk; finally WriteLn('Do more stuff'); end; end; produces Bob is talking John is talking Release 0 John is gone Bob is talking Release 1 Release 0 Bob is gone Do more stuff with no AV or memory leak.
  23. True. Spring4D is the best! And for what it is (not) worth, I have voted for RSP-27375. Here is another one (more complex but still compact) which I think is comparable and similar in approach to Spring4D, based on a Stackoverflow question. I am adding it here for the completeness of the discussion. type TInjectType<T> = record public VMT: pointer; unknown: IInterface; RefCount: integer; AValue: T; end; TInject<T> = class public type TInjectType = TInjectType<T>; PInjectType = ^TInjectType; end; PInjectObjectType = TInject<TObject>.PInjectType; TSmartPointer = class class function Wrap<T: class>(const AValue: T): TFunc<T>; static; end; function Trick_Release(const obj: PInjectObjectType): Integer; stdcall; forward; function Trick_AddRef(const obj: PInjectObjectType): Integer; stdcall; forward; function Invoke(const obj: PInjectObjectType): TObject; forward; const PSEUDO_VMT: array [0 .. 3] of pointer = (nil, @Trick_AddRef, @Trick_Release, @Invoke); function Trick_AddRef(const obj: PInjectObjectType): Integer; stdcall; begin Result:= AtomicIncrement(Obj^.RefCount); end; function Trick_Release(const obj: PInjectObjectType): Integer; stdcall; begin Result:= AtomicDecrement(Obj^.RefCount); WriteLn('Release '+IntToStr(Obj.RefCount)); if Result = 0 then begin obj^.AValue.Free; FreeMem(obj); end; end; function Invoke(const obj: PInjectObjectType): TObject; begin Result:= obj^.AValue; end; class function TSmartPointer.Wrap<T>(const AValue: T): TFunc<T>; var p: PInjectObjectType; begin P:= GetMemory(SizeOf(TInjectType<T>)); p.RefCount:= 1; pointer(p.unknown):= p; p.VMT:= @PSEUDO_VMT; p.AValue:= AValue; pointer(Result):= pointer(TFunc<T>(p)); end; Note: typo corrected (see below).
  24. Minimalist implementation of SmartPointers based on a old post by Barry Kelly comparable to the Spring4D one in performance. type TObjectHandle<T: class> = class(TInterfacedObject, TFunc<T>) private FValue: T; public constructor Create(AValue: T); destructor Destroy; override; function Invoke: T; end; TSmartPointer = record class function Make<T: class>(AValue: T): TFunc<T>; static; end; constructor TObjectHandle<T>.Create(AValue: T); begin FValue := AValue; end; destructor TObjectHandle<T>.Destroy; begin FValue.Free; end; function TObjectHandle<T>.Invoke: T; begin Result := FValue; end; { TSmartPointer } class function TSmartPointer.Make<T>(AValue: T): TFunc<T>; begin Result := TObjectHandle<T>.Create(AValue); end; Used as in: var Bob := TSmartPointer.Make(TTalking.Create('Bob'))(); or var Bob := TSmartPointer.Make(TTalking.Create('Bob'));
×