Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zjc3R-0004Q0-V7 for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Oct 2015 23:53:58 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zjc3R-0001MO-C9 for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Oct 2015 23:53:57 +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 1Zjc3Q-0001KB-Ed for pgadmin-hackers@postgresql.org; Tue, 06 Oct 2015 23:53:56 +0000 Received: from forward19j.cmail.yandex.net ([5.255.227.238]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zjc3M-00013R-Nk for pgadmin-hackers@postgresql.org; Tue, 06 Oct 2015 23:53:55 +0000 Received: from smtp12.mail.yandex.net (smtp12.mail.yandex.net [IPv6:2a02:6b8:0:801:1::11]) by forward19j.cmail.yandex.net (Yandex) with ESMTP id 475A92136A; Wed, 7 Oct 2015 02:53:48 +0300 (MSK) Received: from smtp12.mail.yandex.net (localhost [127.0.0.1]) by smtp12.mail.yandex.net (Yandex) with ESMTP id E1B9C16A047D; Wed, 7 Oct 2015 02:53:47 +0300 (MSK) Received: by smtp12.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Lzi1b8MgGw-rlleRpBT; Wed, 7 Oct 2015 02:53:47 +0300 (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1444175627; bh=3zOlRHWP7/geV0qq5FtXphy25ptmnl2wn0YLtoBcGho=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=XQKF4aOQBh/iP6f+Ka9lPUfllBx8IqnRn6e+qe0Kpur5YkOjdSLPHDCRagMDKv/2a 3flfdvQ68PlBUjLE4jA2USk3gf2QmNqxzgQ5+j50v8uCqWrDYB4uf62bOr/e32TfXs PT5Ko46h4+Qk01aHjGEN24Xx2WFHK9bLRIBF8pgw= Authentication-Results: smtp12.mail.yandex.net; dkim=pass header.i=@yandex.ru X-Yandex-ForeignMX: US Message-ID: <561462E3.606@yandex.ru> Date: Wed, 07 Oct 2015 03:10:11 +0300 From: Nikolai Zhubr User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: pgadmin-hackers@postgresql.org, Dave Page Subject: [PATCH] Perform conversion to platform line-ends when copying to clipboard (Was: Copy to clipboard from ctlSQLBox on windows has line ends broken) References: <5613D05E.1050702@yandex.ru> <561449E1.6050100@yandex.ru> In-Reply-To: <561449E1.6050100@yandex.ru> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) 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 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 -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers