Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZjnY5-0005IE-L9 for pgadmin-hackers@arkaria.postgresql.org; Wed, 07 Oct 2015 12:10:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZjnY5-0005Kr-6L for pgadmin-hackers@arkaria.postgresql.org; Wed, 07 Oct 2015 12:10:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZjnXr-00052S-JN for pgadmin-hackers@postgresql.org; Wed, 07 Oct 2015 12:10:07 +0000 Received: from mail-io0-f174.google.com ([209.85.223.174]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZjnXn-0007pH-Iw for pgadmin-hackers@postgresql.org; Wed, 07 Oct 2015 12:10:06 +0000 Received: by iofh134 with SMTP id h134so19629580iof.0 for ; Wed, 07 Oct 2015 05:10:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=6yJWOreSWvLi3XQXJiTW6P5/bqlbcZmcZT3ehkvRAH0=; b=Ppz6iRhe/YKayWZBvXZ2zECdPAis3IkuTB/y5T2yWtUGzGaJo0lE59L6hLer0REAPa YA0r2hok8f9acPCa898Y84ifm+wRnh7XQ5DvzodUl66mfIS+FSvs08alIUZ92aZMWYUa hB5rCf15O8skZvROsscsA8iJB/t1HowfgNg05JsV/fJ1XI09mM4uzvkZEQs0rSgtUp0g bNK8d7YgFlmpXxF5idnT0VLYh0h8JMWvC+yLLTuEqXCkK60qnpbhAH+k7HVb71t6D4Cb f6uAf9ISNqyeGPrzWm/0qbnZfTQS75syPZh7haZNz08CuphBUX5//KRuHn6BEQxg5r+m n6GQ== X-Gm-Message-State: ALoCoQknJ9aomcsoG/vYQdUFXBjjIcDFGimWdt8owJhOkHT2o72f0U4Z7j+6DDO2lJ/S9qJ8/Z7b MIME-Version: 1.0 X-Received: by 10.107.15.69 with SMTP id x66mr1275908ioi.156.1444219802557; Wed, 07 Oct 2015 05:10:02 -0700 (PDT) Received: by 10.64.110.37 with HTTP; Wed, 7 Oct 2015 05:10:02 -0700 (PDT) In-Reply-To: <561462E3.606@yandex.ru> References: <5613D05E.1050702@yandex.ru> <561449E1.6050100@yandex.ru> <561462E3.606@yandex.ru> Date: Wed, 7 Oct 2015 13:10:02 +0100 Message-ID: Subject: Re: [PATCH] Perform conversion to platform line-ends when copying to clipboard (Was: Copy to clipboard from ctlSQLBox on windows has line ends broken) From: Dave Page To: Nikolai Zhubr Cc: pgadmin-hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org Thanks - applied. On Wed, Oct 7, 2015 at 1:10 AM, Nikolai Zhubr wrote: > Hello Dave, > > Apparently the problem was accidentally introduced by some little > refactoring as a part of this big commit: > > http://git.postgresql.org/gitweb/?p=pgadmin3.git;a=commitdiff;h=ac60bb573155cd24fc45aa08a41887c1bb612677 > > Previously, frmMain::OnCopy() used to call sqlPane->Copy() to push contents > from ctlSQLbox (of SQL Pane) to clipboard. I think that call performed the > appropriate line-ends conversions automagically. > > After the change, it turned essentially into: > text = sqlPane->GetSelectedText(); > wxTheClipboard->SetData(new wxTextDataObject(text)); > and line-ends conversion was gone. > > Now looking at ScintillaWX::CopyToClipboard(...) as an example we see: > wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1)); > wxTheClipboard->SetData(new wxTextDataObject(text)); > > The difference is that there is a wxTextBuffer::Translate() in between. > > Adding it to frmMain::OnCopy() fixed the problem for me. > So I'd propose the following patch: > > --- pgadmin/frm/frmMain.cpp.orig Mon Oct 05 18:16:13 2015 > +++ pgadmin/frm/frmMain.cpp Wed Oct 07 01:47:41 2015 > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > #include > > // wxAUI > @@ -672,7 +673,7 @@ > ctlSQLBox *sb = dynamic_cast(currentControl); > if (sb) > { > - text = sb->GetSelectedText(); > + text = wxTextBuffer::Translate(sb->GetSelectedText()); > } > > // Set the clipboard text > > > Thank you, > Nikolai > > > 07.10.2015 1:23, I wrote: >> >> Hi all, >> >> As I've now found, a lot of pgXXX::GetSql() functions autogenerate sql >> code using hardcoded LF line ends ('\n\n'), and this has been so for >> ages, therefore probably it is OK. >> >> But, in order for 'copy to clipboard' to work well (also on ms windows), >> these LF line ends have to be somehow "compensated". Generally, it could >> possibly be arranged in two places: >> >> -- convert to the system line ending before passing it _to_ ctlSQLBox; >> -- or convert just before copying to clipboard _from_ ctlSQLBox. >> >> I'm not quite sure how it was initially supposed to work, but it did >> work correctly on windows previously. Right now though I can not see any >> such automatic conversions anywhere. Sure I could add some, but I'd like >> to understand the whole picture first... >> >> >> Thank you, >> Nikolai > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers