View Issue Details

IDProjectCategoryView StatusLast Update
0032581LazarusIDEpublic2018-01-26 14:45
ReportersilvioprogAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.9 (SVN)Product Build 
Target Version1.8.2Fixed in Version1.8.2 
Summary0032581: SynEdit: allow to paste filename copied from system files
DescriptionHello,

The attached path allows the user to copy a filename from the system and paste it to the Lazarus Source Editor.
Steps To Reproduce1. on your Linux (GTK), just select any file and perform Ctrl+C to copy its filename;
2. now, try to paste it to the Lazarus source editor;
3. bug: the source editor can't paste it.

note: feel free to edit the patch.
Additional InformationFilename copying works works fine in any editor installed on your system (eg: Mousepad, GEdit, Geany etc.).
TagsNo tags attached.
Fixed in Revision56989
LazTarget1.8.2
WidgetsetGTK 2
Attached Files
  • 0001-SynEdit-Paste-allows-to-paste-text-when-it-is-possib.patch (1,305 bytes)
    From 33cd66a40d87b386ad33751e881a134112fa0162 Mon Sep 17 00:00:00 2001
    From: silvioprog <silvioprog@gmail.com>
    Date: Mon, 16 Oct 2017 14:19:08 -0300
    Subject: [PATCH 1/1] SynEdit: Paste: allows to paste text when it is possible.
    
    ---
     components/synedit/syneditmiscclasses.pp | 14 ++++++++------
     1 file changed, 8 insertions(+), 6 deletions(-)
    
    diff --git a/components/synedit/syneditmiscclasses.pp b/components/synedit/syneditmiscclasses.pp
    index c51614e..51e6088 100644
    --- a/components/synedit/syneditmiscclasses.pp
    +++ b/components/synedit/syneditmiscclasses.pp
    @@ -1689,14 +1689,16 @@ begin
         end;
       end;
       // Normal text
    -  if (FTextP = nil) and AClipboard.HasFormat(CF_TEXT) then begin
    -    Result := true;
    +  if (FTextP = nil) then begin
         FText := AClipboard.AsText;
    -    if FText <> '' then begin
    +    Result := FText<>'';
    +    if Result then begin
           FTextP := @FText[1];
    -      ip := GetTagPointer(synClipTagExtText);
    -      if (length(FText) = 0) or (ip = nil) or (length(FText) <> ip^) then
    -        FIsPlainText := True;
    +      if AClipboard.HasFormat(CF_TEXT) then begin
    +        ip := GetTagPointer(synClipTagExtText);
    +        if (length(FText) = 0) or (ip = nil) or (length(FText) <> ip^) then
    +          FIsPlainText := True;
    +      end;
         end;
       end;
     end;
    -- 
    2.7.4
    
    
  • ctrlv_ctrlc_filename.png (65,693 bytes)
    ctrlv_ctrlc_filename.png (65,693 bytes)

Activities

silvioprog

2017-10-20 02:00

reporter  

0001-SynEdit-Paste-allows-to-paste-text-when-it-is-possib.patch (1,305 bytes)
From 33cd66a40d87b386ad33751e881a134112fa0162 Mon Sep 17 00:00:00 2001
From: silvioprog <silvioprog@gmail.com>
Date: Mon, 16 Oct 2017 14:19:08 -0300
Subject: [PATCH 1/1] SynEdit: Paste: allows to paste text when it is possible.

---
 components/synedit/syneditmiscclasses.pp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/components/synedit/syneditmiscclasses.pp b/components/synedit/syneditmiscclasses.pp
index c51614e..51e6088 100644
--- a/components/synedit/syneditmiscclasses.pp
+++ b/components/synedit/syneditmiscclasses.pp
@@ -1689,14 +1689,16 @@ begin
     end;
   end;
   // Normal text
-  if (FTextP = nil) and AClipboard.HasFormat(CF_TEXT) then begin
-    Result := true;
+  if (FTextP = nil) then begin
     FText := AClipboard.AsText;
-    if FText <> '' then begin
+    Result := FText<>'';
+    if Result then begin
       FTextP := @FText[1];
-      ip := GetTagPointer(synClipTagExtText);
-      if (length(FText) = 0) or (ip = nil) or (length(FText) <> ip^) then
-        FIsPlainText := True;
+      if AClipboard.HasFormat(CF_TEXT) then begin
+        ip := GetTagPointer(synClipTagExtText);
+        if (length(FText) = 0) or (ip = nil) or (length(FText) <> ip^) then
+          FIsPlainText := True;
+      end;
     end;
   end;
 end;
-- 
2.7.4

silvioprog

2017-10-20 02:02

reporter   ~0103592

Last edited: 2017-10-20 02:03

View 2 revisions

Edit:

*Additional Information*: Filename copying will work fine in any editor installed on your system (eg: Mousepad, GEdit, Geany etc.).

Juha Manninen

2017-10-20 12:39

developer   ~0103603

> on your Linux (GTK), just select any file and perform Ctrl+C to copy its filename;

From where exactly should I copy? Linux is a kernel, GTK is a GUI lib.

I don't think this depends on widgetset. Maybe the Widgetset="GTK 2" should be removed.

silvioprog

2017-10-20 16:08

reporter   ~0103608

> From where exactly should I copy? Linux is a kernel, GTK is a GUI lib.

oops, edit:

"1. on your Ubuntu (I'm using Xubuntu), just select any file anywhere (desktop, home etc.) and perform Ctrl+C to copy its filename;" (attached picture illustrates it)

> I don't think this depends on widgetset. Maybe the Widgetset="GTK 2" should be removed.

I've tested only on GTK 2 but feel free to test it in other widgets and edit issue. :-)

silvioprog

2017-10-20 16:09

reporter  

ctrlv_ctrlc_filename.png (65,693 bytes)
ctrlv_ctrlc_filename.png (65,693 bytes)

Juha Manninen

2017-10-20 23:28

developer   ~0103626

Last edited: 2017-10-21 00:04

View 2 revisions

Here it works when I copy a file from Dolphin (KDE's file manager).
The pasted string is eg. "file:///home/juha/patch/patch.diff".
Lazarus widgetset does not matter.

Martin Friebe

2017-10-20 23:57

manager   ~0103629

The current implementation indeed does not deal with any "text" on the clipboard, if it is no CF_TEXT.

But I am not sure about the patch.

If "AClipboard.HasFormat(ClipboardFormatId)" is true (first if block), then only CF_TEXT should be expected.

However, if "AClipboard.HasFormat(ClipboardFormatId)" is false, then normal Clipboard.AsText (and FIsPlaintext = True) should be used.

This however relies on that if any other app (e.g. the file explorer) adds data to the clipboard, it removes all other data-formats from the clipboard before.

----------

Please test the following replacement function


function TSynClipboardStream.ReadFromClipboard(AClipboard: TClipboard): Boolean;
var
  ip: PInteger;
  len: LongInt;
begin
  Result := false;
  Clear;
  FTextP := nil;
  // Check for embedded text
  if AClipboard.HasFormat(ClipboardFormatId) then begin
    Result := AClipboard.GetFormat(ClipboardFormatId, FMemStream);
    FTextP := GetTagPointer(synClipTagText);
    if FTextP <> nil then begin
      len := GetTagLen(synClipTagText);
      if len > 0 then
        (FTextP + len - 1)^ := #0
      else
        FTextP := nil;
    end;
    // Normal text
    if (FTextP = nil) and AClipboard.HasFormat(CF_TEXT) then begin
      Result := true;
      FText := AClipboard.AsText;
      if FText <> '' then begin
        FTextP := @FText[1];
        ip := GetTagPointer(synClipTagExtText);
        if (length(FText) = 0) or (ip = nil) or (length(FText) <> ip^) then
          FIsPlainText := True;
      end;
    end;
  end
  else begin
    FText := AClipboard.AsText;
    Result := FText<>'';
    FIsPlainText := Result;
  end;
end;

Martin Friebe

2017-10-21 00:12

manager   ~0103630

For explanation / From memory

SynEdit can either:
1 - Put only its own format on the clipboard,
2 - Only CF_TEXT
3 - Put a combination of its own format and CF_TEXT on the clipboard

Case 1 or 2 happens, if AquireClipboard [*] is used, and data is only written, if an other app requests it. In this case SynEdit detects if the requestor is a SynEdit.
If the requestor is a SynEdit, then case 1, else case 2

If SynEdit writes to clipboard immediately (ctrl-c) then case 3 is used. So a none SynEdit will get CF_TEXT, a SynEdit can get the combination.


In case 1 SynEdits internal format contains the text, in case 3 it omits the text.

[*] If a selection is made, that can be pasted by middle mouse.

silvioprog

2017-11-03 16:02

reporter   ~0103853

> Please test the following replacement function

I've tested it, but unfortunately it doesn't work. The IDE's "Paste" menu is enabled, but any path is paste in source editor. :-(

Martin Friebe

2018-01-06 17:21

manager   ~0105408

I can not reproduce this. On Fedora it works.
But I think the
  and AClipboard.HasFormat(CF_TEXT)
is wrong.

So I dropped this in rev 56989.

Martin Friebe

2018-01-06 17:22

manager   ~0105409

please test.

silvioprog

2018-01-26 14:45

reporter   ~0106050

Fixed. Thank you!

Issue History

Date Modified Username Field Change
2017-10-20 02:00 silvioprog New Issue
2017-10-20 02:00 silvioprog File Added: 0001-SynEdit-Paste-allows-to-paste-text-when-it-is-possib.patch
2017-10-20 02:02 silvioprog Note Added: 0103592
2017-10-20 02:03 silvioprog Note Edited: 0103592 View Revisions
2017-10-20 10:41 Mattias Gaertner LazTarget => -
2017-10-20 10:41 Mattias Gaertner Summary [IDE/source-editor] allows to paste filename copied from system files => SynEdit: allow to paste filename copied from system files
2017-10-20 12:39 Juha Manninen Note Added: 0103603
2017-10-20 16:08 silvioprog Note Added: 0103608
2017-10-20 16:09 silvioprog File Added: ctrlv_ctrlc_filename.png
2017-10-20 22:43 Juha Manninen Relationship added related to 0024371
2017-10-20 22:44 Juha Manninen Relationship deleted related to 0024371
2017-10-20 23:28 Juha Manninen Note Added: 0103626
2017-10-20 23:57 Martin Friebe Note Added: 0103629
2017-10-20 23:58 Martin Friebe Assigned To => Martin Friebe
2017-10-20 23:58 Martin Friebe Status new => feedback
2017-10-21 00:04 Juha Manninen Note Edited: 0103626 View Revisions
2017-10-21 00:12 Martin Friebe Note Added: 0103630
2017-11-03 16:02 silvioprog Note Added: 0103853
2017-11-03 16:02 silvioprog Status feedback => assigned
2018-01-06 17:21 Martin Friebe Note Added: 0105408
2018-01-06 17:22 Martin Friebe Fixed in Revision => 56989
2018-01-06 17:22 Martin Friebe LazTarget - => 1.8.2
2018-01-06 17:22 Martin Friebe Note Added: 0105409
2018-01-06 17:22 Martin Friebe Status assigned => resolved
2018-01-06 17:23 Martin Friebe Fixed in Version => 1.8.2
2018-01-06 17:23 Martin Friebe Resolution open => fixed
2018-01-06 17:23 Martin Friebe Target Version => 1.8.2
2018-01-26 14:45 silvioprog Note Added: 0106050
2018-01-26 14:45 silvioprog Status resolved => closed