public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nikolai Zhubr <[email protected]>
To: [email protected]
To: Dave Page <[email protected]>
Subject: [PATCH] Perform conversion to platform line-ends when copying to clipboard (Was: Copy to clipboard from ctlSQLBox on windows has line ends broken)
Date: Wed, 07 Oct 2015 03:10:11 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
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=ac60bb573155cd24fc45aa08a41887c1bb61...
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 <wx/imaglist.h>
#include <wx/busyinfo.h>
#include <wx/sysopt.h>
+#include <wx/textbuf.h>
#include <wx/clipbrd.h>
// wxAUI
@@ -672,7 +673,7 @@
ctlSQLBox *sb = dynamic_cast<ctlSQLBox *>(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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
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)
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox