Recent

Author Topic: [SOLVED] Synedit copy /past not working on first try  (Read 732 times)

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #15 on: July 02, 2026, 11:46:15 pm »
Thanks.
Which Uses unit do I need for AllocatePluginKeyRange(1, False) to compile. Getting an error currently.

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #16 on: July 03, 2026, 12:25:05 am »
Found the Unit (SynEditKeyCmds) for AllocatePluginKeyRange(1, False).

Thanks again.

I think there is still some funny business with the cut/paste behavior between the design-time versus runtime creation of the TSynCompletion contro

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #17 on: July 03, 2026, 01:12:23 am »
I think there is still some funny business with the cut/paste behavior between the design-time versus runtime creation of the TSynCompletion contro

I still plan to look at your example, but I need to finish some other stuff first. (and I may be away for a few days, if the other stuff takes me to long before I could have a look)

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #18 on: July 03, 2026, 11:18:27 am »
There is no rush, and we found a work-around with runtime creation.

Happy travels.

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #19 on: July 03, 2026, 01:48:19 pm »
One more observation; If I create the Completion widget in the FormCreate() event, then the cut/paste problem occurs.
However, if I create it later, like in the FormShow() or a buttonClick event, I do not get the cut/paste problem.

Demo app attached.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #20 on: July 03, 2026, 05:05:03 pm »
Did I miss it somewhere, did you specify if you use gtk2, gtk3, Qt-5 or 6, ....?

I just run your app (qt-6) and had no issues. I did change it to make the call in FormCreate

That is, I tested with your 2nd example.

------------
Also, do I need any steps like triggering the completions?

I just:
- copied something into the clipboard (so it has old content, and I would note if I pasted the old content)
- run the app
- the empty synedit on the form showed up
- typed in a few chars
- selected them and ctrl-c copied them
- clicked on geany (editor) and pasted.
It worked.
« Last Edit: July 03, 2026, 05:08:07 pm by Martin_fr »

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #21 on: July 03, 2026, 07:46:15 pm »
I'm using the default Linux Mint 22.3 cinnamon desktop.
The steps you listed are also what I am doing.

Below is a dump of my System Info:

Code: [Select]
System:
  Kernel: 6.8.0-134-generic arch: x86_64 bits: 64 compiler: gcc v: 13.3.0 clocksource: tsc
  Desktop: Cinnamon v: 6.6.7 tk: GTK v: 3.24.41 wm: Muffin v: 6.6.3 vt: 7 dm: LightDM v: 1.30.0
    Distro: Linux Mint 22.3 Zena base: Ubuntu 24.04 noble
Machine:
  Type: Laptop System: Notebook product: NJx0AU v: N/A serial: <superuser required>
    Chassis: No Enclosure type: 10 serial: <superuser required>
  Mobo: Notebook model: NJx0AU serial: <superuser required> uuid: <superuser required>
    UEFI: INSYDE v: 1.07.08TP date: 08/07/2024
Battery:
  ID-1: BAT0 charge: 44.3 Wh (100.0%) condition: 44.3/45.9 Wh (96.6%) volts: 16.3 min: 14.8
    model: Notebook BAT type: Li-ion serial: <filter> status: full
CPU:
  Info: 10-core (2-mt/8-st) model: 13th Gen Intel Core i5-1335U bits: 64 type: MST AMCP
    smt: enabled arch: Raptor Lake rev: 3 cache: L1: 928 KiB L2: 6.5 MiB L3: 12 MiB
  Speed (MHz): avg: 1329 high: 3800 min/max: 400/4600:3400 cores: 1: 400 2: 400 3: 3700 4: 3800
    5: 1705 6: 2222 7: 400 8: 1725 9: 400 10: 400 11: 400 12: 400 bogomips: 59904
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
Graphics:
  Device-1: Intel Raptor Lake-P [UHD Graphics] vendor: CLEVO/KAPOK driver: i915 v: kernel
    arch: Gen-13 ports: active: HDMI-A-1,eDP-1 empty: DP-1,DP-2,HDMI-A-2 bus-ID: 0000:00:02.0
    chip-ID: 8086:a721 class-ID: 0300
  Device-2: Bison BisonCam NB Pro driver: uvcvideo type: USB rev: 2.0 speed: 480 Mb/s lanes: 1
    bus-ID: 1-7:4 chip-ID: 5986:9102 class-ID: 0e02
  Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.6 driver: X: loaded: modesetting
    unloaded: fbdev,vesa dri: iris gpu: i915 display-ID: :0 screens: 1
  Screen-1: 0 s-res: 3840x1080 s-dpi: 96 s-size: 1016x285mm (40.00x11.22")
    s-diag: 1055mm (41.54")
  Monitor-1: HDMI-A-1 mapped: HDMI-1 pos: right model: Dell S2425H serial: <filter>
    res: 1920x1080 hz: 60 dpi: 93 size: 527x296mm (20.75x11.65") diag: 604mm (23.8") modes:
    max: 1920x1080 min: 720x400
  Monitor-2: eDP-1 pos: primary,left model: BOE Display 0x0700 res: 1920x1080 hz: 60 dpi: 142
    size: 344x194mm (13.54x7.64") diag: 395mm (15.5") modes: 1920x1080
  API: EGL v: 1.5 hw: drv: intel iris platforms: device: 0 drv: iris device: 1 drv: swrast gbm:
    drv: iris surfaceless: drv: iris x11: drv: iris inactive: wayland
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 25.2.8-0ubuntu0.24.04.2 glx-v: 1.4
    direct-render: yes renderer: Mesa Intel Graphics (RPL-U) device-ID: 8086:a721
  API: Vulkan v: 1.3.275 layers: 3 surfaces: xcb,xlib device: 0 type: integrated-gpu driver: N/A
    device-ID: 8086:a721 device: 1 type: cpu driver: N/A device-ID: 10005:0000
Audio:
  Device-1: Intel Raptor Lake-P/U/H cAVS vendor: CLEVO/KAPOK driver: snd_hda_intel v: kernel
    bus-ID: 0000:00:1f.3 chip-ID: 8086:51ca class-ID: 0403
  Device-2: C-Media USB Advanced Audio Device driver: hid-generic,snd-usb-audio,usbhid type: USB
    rev: 2.0 speed: 12 Mb/s lanes: 1 bus-ID: 1-6:3 chip-ID: 0d8c:0299 class-ID: 0300
  API: ALSA v: k6.8.0-134-generic status: kernel-api with: osspd status: active
  Server-1: PipeWire v: 1.0.5 status: active with: 1: pipewire-pulse status: active
    2: wireplumber status: active 3: pipewire-alsa type: plugin
Network:
  Device-1: Intel Ethernet I219-V vendor: CLEVO/KAPOK driver: e1000e v: kernel port: N/A
    bus-ID: 0000:00:1f.6 chip-ID: 8086:1a1f class-ID: 0200
  IF: enp0s31f6 state: down mac: <filter>
  Device-2: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter vendor: Dell Vostro 3470
    driver: ath9k v: kernel bus-ID: 0000:01:00.0 chip-ID: 168c:0036 class-ID: 0280
  IF: wlp1s0 state: up mac: <filter>
Bluetooth:
  Device-1: Qualcomm Atheros driver: btusb v: 0.8 type: USB rev: 1.1 speed: 12 Mb/s lanes: 1
    bus-ID: 1-10:6 chip-ID: 0cf3:e005 class-ID: e001
  Report: hciconfig ID: hci0 rfk-id: 1 state: up address: <filter> bt-v: 4.1 lmp-v: 7 sub-v: 1
    hci-v: 7 rev: 3101 class-ID: 7c010c
RAID:
  Hardware-1: Intel Volume Management Device NVMe RAID Controller Intel driver: vmd v: 0.6
    port: N/A bus-ID: 0000:00:0e.0 chip-ID: 8086:a77f rev: class-ID: 0104
Drives:
  Local Storage: total: 931.51 GiB used: 111.34 GiB (12.0%)
  ID-1: /dev/nvme0n1 vendor: Western Digital model: WD Blue SN580 1TB size: 931.51 GiB
    speed: 63.2 Gb/s lanes: 4 tech: SSD serial: <filter> fw-rev: 281010WD temp: 32.9 C scheme: GPT
Partition:
  ID-1: / size: 915.32 GiB used: 111.34 GiB (12.2%) fs: ext4 dev: /dev/nvme0n1p2
  ID-2: /boot/efi size: 511 MiB used: 6.1 MiB (1.2%) fs: vfat dev: /dev/nvme0n1p1
Swap:
  ID-1: swap-1 type: file size: 2 GiB used: 512 KiB (0.0%) priority: -2 file: /swapfile
USB:
  Hub-1: 1-0:1 info: hi-speed hub with single TT ports: 12 rev: 2.0 speed: 480 Mb/s lanes: 1
    chip-ID: 1d6b:0002 class-ID: 0900
  Device-1: 1-2:2 info: Logitech Logi Bolt Receiver type: keyboard,mouse,HID
    driver: hid-generic,hid-multitouch,usbhid interfaces: 4 rev: 2.0 speed: 12 Mb/s lanes: 1
    power: 98mA chip-ID: 046d:c548 class-ID: 0300
  Device-2: 1-6:3 info: C-Media USB Advanced Audio Device type: audio,HID
    driver: hid-generic,snd-usb-audio,usbhid interfaces: 4 rev: 2.0 speed: 12 Mb/s lanes: 1
    power: 100mA chip-ID: 0d8c:0299 class-ID: 0300
  Device-3: 1-7:4 info: Bison BisonCam NB Pro type: video driver: uvcvideo interfaces: 2 rev: 2.0
    speed: 480 Mb/s lanes: 1 power: 500mA chip-ID: 5986:9102 class-ID: 0e02
  Device-4: 1-10:6 info: Qualcomm Atheros type: bluetooth driver: btusb interfaces: 2 rev: 1.1
    speed: 12 Mb/s lanes: 1 power: 100mA chip-ID: 0cf3:e005 class-ID: e001
  Hub-2: 2-0:1 info: super-speed hub ports: 4 rev: 3.1 speed: 10 Gb/s lanes: 1 chip-ID: 1d6b:0003
    class-ID: 0900
Sensors:
  System Temperatures: cpu: 53.0 C mobo: N/A
  Fan Speeds (rpm): N/A
Repos:
  Packages: 3081 pm: dpkg pkgs: 3060 pm: flatpak pkgs: 21
  No active apt repos in: /etc/apt/sources.list
  Active apt repos in: /etc/apt/sources.list.d/google-earth-pro.list
    1: deb [arch=amd64] http: //dl.google.com/linux/earth/deb/ stable main
  Active apt repos in: /etc/apt/sources.list.d/official-package-repositories.list
    1: deb http: //packages.linuxmint.com zena main upstream import backport
    2: deb http: //archive.linux.duke.edu/ubuntu noble main restricted universe multiverse
    3: deb http: //archive.linux.duke.edu/ubuntu noble-updates main restricted universe multiverse
    4: deb http: //archive.linux.duke.edu/ubuntu noble-backports main restricted universe multiverse
    5: deb http: //security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse
  Active apt repos in: /etc/apt/sources.list.d/google-chrome.sources
    1: deb [arch=amd64] https: //dl.google.com/linux/chrome-stable/deb/ stable main
Info:
  Memory: total: 16 GiB note: est. available: 15.33 GiB used: 3.49 GiB (22.8%)
  Processes: 331 Power: uptime: 2d 3h 30m states: freeze,mem,disk suspend: deep wakeups: 0
    hibernate: platform Init: systemd v: 255 target: graphical (5) default: graphical
  Compilers: clang: 16 gcc: 13.3.0 Client: Unknown python3.12 client inxi: 3.3.34


 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #22 on: July 03, 2026, 08:53:35 pm »
Ok, that is the trouble with tracing stuff on Linux. There can be subtle differences between distros.

None of mine currently get the issue. I tried the 2 systems I currently have on Gtk3 (opensuse / manjaro), but both a bit older.

---------------

The only significance bit I can see in your example is that FormCreate (as well as lfm loading) is before the main form is created (before a handle for it is created). And that would be the handle for the main form of the app.

That would mean that creating the completion would have to be creating a handle before that (or accessing the clipboard before that), and that would for reasons I wouldn't know have to upset the clipboard.

So after some stepping, I found the creation of such a handle (the stackframe at the bottom is for myself)




Question, if you:
- comment out the problem call to setup the completion
- Add a 2nd form to your testapp
- in project options set the 2nd form to be NOT auto created.
- in the TForm1.FormCreated add

Code: Pascal  [Select][+][-]
  1. var f2: TForm2; // must be in uses
  2. begin
  3.   f2 := TForm2.create(nil);
  4.   f2.canvas.handle;

Does that also cause the issue?




This may need 2 fixes.

One in the WS (gtk3) code.

And one in SynEdit. Which even if that did not cause the issue you have, shouldn't be doing what it does.
For the SynEdit part I have probably enough info. But that does only fix the trigger, not the problem.

Code: Text  [Select][+][-]
  1. #0 TControlCanvas.CreateHandle(TControlCanvas($00007F79B1F3A300)) at controlcanvas.inc:92
  2. #1 TCanvas.RequiredState(TCanvas($00007F79B1F3A300), [csHandleValid, csFontValid, csPenvalid, csBrushValid]) at canvas.inc:1701
  3. #2 TCanvas.GetHandle(TCanvas($00007F79B1F3A300)) at canvas.inc:1600
  4. #3 TSynBaseCompletionForm.FontChanged(TSynBaseCompletionForm($00007F79B2054D30), TObject($00007F79B02C1AC0)) at syncompletion.pas:1214
  5. #4 TSynBaseCompletionForm.Create(TSynBaseCompletionForm($00007F79B2054D30), ^$__vtbl_ptr_type($0000000000000001), nil) at syncompletion.pas:691
  6. #5 TSynBaseCompletion.Create(TSynBaseCompletion($00007F79B1FC6040), ^$__vtbl_ptr_type(nil), TComponent($00007F79B2052970)) at syncompletion.pas:1405
  7. #6 TSynCompletion.Create(TSynCompletion($00007F79B1FC6040), ^$__vtbl_ptr_type($0000000000000001), TComponent($00007F79B2052970)) at syncompletion.pas:1915
  8. #7 TForm1.SetUpWidgets(TForm1($00007F79B2052970)) at unit1.pas:71
  9. #8 TForm1.FormCreate(TForm1($00007F79B2052970), TObject($00007F79B2052970)) at unit1.pas:58
  10. #9 TCustomForm.DoCreate(TCustomForm($00007F79B2052970)) at customform.inc:931
  11.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #23 on: July 03, 2026, 09:02:01 pm »
Could you also in the IDE go to menu: Help > About Lazarus

And check if it says "gtk 3" ?
Or right click, and "copy version info", and paste that here?

Thanks.

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #24 on: July 03, 2026, 09:31:47 pm »
I tried to follow you direction:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var f2: TForm2; // must be in uses
  3. begin
  4.   f2 := TForm2.create(nil);
  5.   f2.canvas.handle;
  6.  
  7.   // Calling it here gets cut/paste problem
  8.  //  SetUpWidgets;
  9. end;
  10.  

Nothing happens...
But also the cut/paste issue will not come up as no TSynCompletion is being added.
Did I misunderstand what you want me to do?

Below is a copy from the Lazarus Help/about:
Lazarus 4.2 (rev Unknown) FPC 3.2.2 x86_64-linux-gtk2

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #25 on: July 03, 2026, 10:03:35 pm »
Ok so your desktop is Gtk3. But your IDE is gtk-2

I now tested on Gtk-2 and I can reproduce it (and on an old system, so likely a persistent issues if it happens with old and new...)

-----------------

The test I wanted you do to was because I couldn't get it, so I was looking at "possible causes" and if they could be caused in other ways... And yes, you tested exactly what I wanted you to test.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #26 on: July 03, 2026, 10:17:23 pm »
I was close. The below does it for me. Forcing the handle of the borderless form => and copy to clipboard fails.

Code: Pascal  [Select][+][-]
  1. var
  2.   f2: TForm2;
  3. begin
  4. f2 :=tform2.Create(nil);
  5. f2.BorderStyle:=bsNone;
  6. f2.Canvas.Handle;
  7.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #27 on: July 03, 2026, 10:25:34 pm »
Anyway, for now just create the completion later.

I will look at fixing the behaviour of the creation.

I also created a report for the underlying gtk2 problem https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42403

Tomu

  • New Member
  • *
  • Posts: 44
Re: Synedit copy /past not working on first try
« Reply #28 on: July 03, 2026, 10:39:11 pm »
Thanks Martin,

Let me know if there is anything else I can do.

Not sure what you meant by "just create the completion later."

Alles glutes,
Tom

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12537
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit copy /past not working on first try
« Reply #29 on: July 04, 2026, 12:49:21 am »

Not sure what you meant by "just create the completion later."

Well, create the TSynCompletion in the from show, or any time after that.

Once fixed (and released) you can revert to loading from lfm

 

TinyPortal © 2005-2018