Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-10 Thread zeljko
On Saturday 10 of March 2012 14:56:52 cobines wrote:
 2012/3/9 zeljko zel...@holobit.net:
  Good, then prepare patch and that's it :) My observation about openoffice
  IS about OpenOffice (not LibreOffice) maybe 2yrs ago, and probably gtk2
   2.20 or something like that.Also when i said copy from OO, I didn't
  mean copy via Ctrl + C , but via mouse selection and then middle click
  into eg TEdit or TMemo - that problem existed definitelly.
 
 Indeed, the problem still exists with OpenOffice and LibreOffice, but
 this must is a bug in OpenOffice because the selection received from X
 doesn't match what was selected by mouse. This only happens with
 PRIMARY clipboard (mouse selection), copying via CLIPBOARD selection
 (Ctrl+C) doesn't have this problem. The problem also exists when
 pasting to other non-Lazarus applications; copying from Lazarus app
 into OpenOffice doesn't show any problems.
 
 I have opened an issue:
 http://bugs.freepascal.org/view.php?id=21453
 
 I basically did the same as in LCLQT - make LCLGTK2 remove the
 trailing zero. Also, conversion to COMPOUND_TEXT already indirectly
 removed trailing zero.

ok, let's back at beginning ... what problem is caused by trailing null 
terminator under gtk2 ?

zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-10 Thread cobines
2012/3/10 zeljko zel...@holobit.net:
 ok, let's back at beginning ... what problem is caused by trailing null
 terminator under gtk2 ?

When assigning
  Clipboard.AsText := '1234';

and pasting to some programs (I only experience it with jEdit though),
'1234'#0 is pasted, i.e., string of length 5 instead of length 4.

It can be treated as:
a) a bug in LCL; why add #0 when '1234' was assigned, not '1234'#0. If
it is required by some widgetset then add trailing zero in the
widgetset;
b) a bug in LCLGTK2; regardless of what LCL does, programs in GTK2 (or
rather Linux programs, since LCLQT also strips the #0) should not put
trailing #0 to the clipboard;
c) a bug in the program that doesn't strip the trailing zero when
pasting from clipboard (in this case jEdit).

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-10 Thread zeljko
On Saturday 10 of March 2012 16:17:35 cobines wrote:
 2012/3/10 zeljko zel...@holobit.net:
  ok, let's back at beginning ... what problem is caused by trailing null
  terminator under gtk2 ?
 
 When assigning
   Clipboard.AsText := '1234';
 
 and pasting to some programs (I only experience it with jEdit though),
 '1234'#0 is pasted, i.e., string of length 5 instead of length 4.
 
 It can be treated as:
 a) a bug in LCL; why add #0 when '1234' was assigned, not '1234'#0. If
 it is required by some widgetset then add trailing zero in the
 widgetset;
 b) a bug in LCLGTK2; regardless of what LCL does, programs in GTK2 (or
 rather Linux programs, since LCLQT also strips the #0) should not put
 trailing #0 to the clipboard;
 c) a bug in the program that doesn't strip the trailing zero when
 pasting from clipboard (in this case jEdit).

If there's no problem when you paste it to gedit or to kwrite or to firefox 
then I'll vote for C). So then new question raises: Shell we fix Jedit bugs by 
fixing lcl ?

zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-10 Thread cobines
I see it as: there's no problems when zero is not added, while there
is problem when it is added.

Why LCLQT cuts the zero then if adding it causes no problems? Why
can't LCLGTK2 cut it as well?

Incidentally I found that I don't need to use Clipboard.AsText,
instead I can use this:

Clipboard.Clear;
Clipboard.AddFormat(PredefinedClipboardFormat(pcfText),s[1],length(s));

So, if actually no changes are done, I think that it wouldn't be a problem.

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread cobines
2012/3/8 zeljko zel...@holobit.net:
 We cannot remove it just because you think so. If it's removed we need to
 test consequences on gtk, gtk2 and qt.
I know, I was counting on someone saying that it is needed and why.


With copying to clipboard, I found this in LCLQT in TQtClipboard.GetOwnerShip:

  if (QByteArray_length(Data)  1) and QByteArray_endsWith(Data, #0) then
QByteArray_chop(Data, 1);


With pasting from clipboard, there is this in LCL:

TClipboard.GetAsText:

  if (ASize0) and (pchar(MemStream.Memory)[ASize-1]=#0) then
Dec(ASize);

If the #0 is specifically removed then maybe it doesn't need to be
added as well. As I see it, the stream (or array) size determines the
length, not the #0.

I can only test by installing lots of applications and testing if
copying/pasting still works after removing the #0.

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread zeljko
On Friday 09 of March 2012 15:36:09 cobines wrote:
 2012/3/8 zeljko zel...@holobit.net:
  We cannot remove it just because you think so. If it's removed we need to
  test consequences on gtk, gtk2 and qt.
 
 I know, I was counting on someone saying that it is needed and why.
 
 
 With copying to clipboard, I found this in LCLQT in
 TQtClipboard.GetOwnerShip:
 
   if (QByteArray_length(Data)  1) and QByteArray_endsWith(Data, #0)
 then QByteArray_chop(Data, 1);
 
 
 With pasting from clipboard, there is this in LCL:
 
 TClipboard.GetAsText:
 
   if (ASize0) and (pchar(MemStream.Memory)[ASize-1]=#0) then
 Dec(ASize);
 
 If the #0 is specifically removed then maybe it doesn't need to be
 added as well. As I see it, the stream (or array) size determines the
 length, not the #0.
 
 I can only test by installing lots of applications and testing if
 copying/pasting still works after removing the #0.

Yeah, just try to copy something from openoffice under X11 and paste it into 
qt application (or to win32 app running under wine) and you'll see problem 
(and that comes from gtk2).
My wild guess is that #0 was added because of gtk2.
I'll fix qt in any case ... .whatever you put at the end, but who will fix 
gtk2 or carbon ?

zeljko

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread cobines
2012/3/9 zeljko zel...@holobit.net:
 Yeah, just try to copy something from openoffice under X11 and paste it into
 qt application (or to win32 app running under wine) and you'll see problem
 (and that comes from gtk2).

 My wild guess is that #0 was added because of gtk2.

 I'll fix qt in any case ... .whatever you put at the end, but who will fix
 gtk2 or carbon ?

I don't understand what you mean, because for me copying from
OpenOffice to native QT app, or to Windows notepad under wine doesn't
give any problems. I have GTK 2.24.10, QT 4.7.4, wine 1.1.36.

I have checked 25 programs, copying from them and pasting to Lazarus
app, and copying from Lazarus app to them, and there was no
difference, whether trailing #0 was added by LCL or not. I tried
Lazarus app built with LCLGTK2 and then with LCLQT.

Also none of the programs I checked, except for AbiWord, added
trailing zero to the text copied to clipboard. I checked directly with
X using XConvertSelection.

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread zeljko
On Friday 09 of March 2012 19:00:29 cobines wrote:
 2012/3/9 zeljko zel...@holobit.net:
  Yeah, just try to copy something from openoffice under X11 and paste it
  into qt application (or to win32 app running under wine) and you'll see
  problem (and that comes from gtk2).
  
  My wild guess is that #0 was added because of gtk2.
  
  I'll fix qt in any case ... .whatever you put at the end, but who will
  fix gtk2 or carbon ?
 
 I don't understand what you mean, because for me copying from
 OpenOffice to native QT app, or to Windows notepad under wine doesn't
 give any problems. I have GTK 2.24.10, QT 4.7.4, wine 1.1.36.
 
 I have checked 25 programs, copying from them and pasting to Lazarus
 app, and copying from Lazarus app to them, and there was no
 difference, whether trailing #0 was added by LCL or not. I tried
 Lazarus app built with LCLGTK2 and then with LCLQT.
 
 Also none of the programs I checked, except for AbiWord, added
 trailing zero to the text copied to clipboard. I checked directly with
 X using XConvertSelection.

Good, then prepare patch and that's it :) My observation about openoffice IS 
about OpenOffice (not LibreOffice) maybe 2yrs ago, and probably gtk2  2.20 or 
something like that.Also when i said copy from OO, I didn't mean copy via 
Ctrl + C , but via mouse selection and then middle click into eg TEdit or 
TMemo - that problem existed definitelly.

zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread Felipe Monteiro de Carvalho
2012/3/9 zeljko zel...@holobit.net:
 I'll fix qt in any case ... .whatever you put at the end, but who will fix
 gtk2 or carbon ?

I have never seen this final #0 problem in Carbon

-- 
Felipe Monteiro de Carvalho

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-09 Thread zeljko
On Saturday 10 of March 2012 07:34:11 Felipe Monteiro de Carvalho wrote:
 2012/3/9 zeljko zel...@holobit.net:
  I'll fix qt in any case ... .whatever you put at the end, but who will
  fix gtk2 or carbon ?
 
 I have never seen this final #0 problem in Carbon

ok, then gtk/gtk2 should be tested.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Setting clipboard on Linux adds ending #0

2012-03-08 Thread cobines
Hello.

Putting a string to a clipboard is done in TClipboard.SetAsText():

  SetBuffer(PredefinedClipboardFormat(pcfText),s[1],length(Value)+1);

Note that there is length(Value)+1, ending zero included. This comes
from the following revision:

r7259 | vincents | 2005-06-21 13:42:35 +0200 (wto) | 2 linie

copy terminating #0 to clipboard too, windows expects it.

But some programs on Linux treat this ending zero as part of the
clipboard data. I also checked how a few non-Lazarus programs copy to
clipboard and they don't include ending zero. I don't think it is
needed.

Can adding trailing zero be moved to the win32 widgetset only?

--
cobines

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-08 Thread zeljko
On Thursday 08 of March 2012 18:01:14 cobines wrote:
 Hello.
 
 Putting a string to a clipboard is done in TClipboard.SetAsText():
 
   SetBuffer(PredefinedClipboardFormat(pcfText),s[1],length(Value)+1);
 
 Note that there is length(Value)+1, ending zero included. This comes
 from the following revision:
 
 r7259 | vincents | 2005-06-21 13:42:35 +0200 (wto) | 2 linie
 
 copy terminating #0 to clipboard too, windows expects it.
 
 But some programs on Linux treat this ending zero as part of the
 clipboard data. I also checked how a few non-Lazarus programs copy to

What programs treat terminator as part of data ?
from qt docs, #0 means eod afair (QMimeData).

 clipboard and they don't include ending zero. I don't think it is
 needed.

We cannot remove it just because you think so. If it's removed we need to test 
consequences on gtk, gtk2 and qt.


 
 Can adding trailing zero be moved to the win32 widgetset only?

theoretically yes, if it won't disturb others.


zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-08 Thread Hans-Peter Diettrich

zeljko schrieb:

We cannot remove it just because you think so. If it's removed we need 
to test consequences on gtk, gtk2 and qt.


Why do you think that an additional #0 should be added, if not required?

DoDi


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Setting clipboard on Linux adds ending #0

2012-03-08 Thread zeljko
On Thursday 08 of March 2012 21:01:51 Hans-Peter Diettrich wrote:
 zeljko schrieb:
  We cannot remove it just because you think so. If it's removed we need
  to test consequences on gtk, gtk2 and qt.
 
 Why do you think that an additional #0 should be added, if not required?

I didn't say so. I just said that it shuoldn't be removed just like that 
without testing all widgetsets.

zeljko
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus