public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] Beautify line-ends handling yet more.
6+ messages / 3 participants
[nested] [flat]

* [PATCH] Beautify line-ends handling yet more.
@ 2015-10-07 18:47 Nikolai Zhubr <[email protected]>
  2015-10-09 13:31 ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Nikolai Zhubr @ 2015-10-07 18:47 UTC (permalink / raw)
  To: pgadmin-hackers; Dave Page <[email protected]>

Hello Dave,

Attached are two more patches, mostly cosmetic:

*  Make a better guess of default line-end type based on platform type.
*  Get rid of #ifdef -- let wxTextBuffer::Translate do all the work.

Sending as attachments, let me know if inserting inline is preferred.

Tested on windows only, but I think should not break other platforms.


Thank you,
Nikolai



-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [text/x-patch] 01eoldef.patch (643B, 2-01eoldef.patch)
  download | inline diff:

 Make a better guess of line-end type default based on platform type.

--- pgadmin/include/utils/sysSettings.h.orig	Mon Oct 05 18:16:13 2015
+++ pgadmin/include/utils/sysSettings.h	Wed Oct 07 20:09:59 2015
@@ -433,7 +433,17 @@
 	int GetLineEndingType() const
 	{
 		int i;
-		Read(wxT("LineEndingType"), &i, 2);
+		int defval = 2;
+#ifdef __WXMAC__
+		defval = 1; /* SC_EOL_CR in Scintilla.h */
+#else
+#ifdef __WXMSW__
+		defval = 0; /* SC_EOL_CRLF in Scintilla.h */
+#else
+		defval = 2; /* SC_EOL_LF in Scintilla.h */
+#endif
+#endif
+		Read(wxT("LineEndingType"), &i, defval);
 		return i;
 	}
 	void SetLineEndingType(const int newval)



  [text/x-patch] 02delifdef.patch (900B, 3-02delifdef.patch)
  download | inline diff:

 Instead of ifdef, let wxTextBuffer::Translate do conversions in all the 
 cases automatically.

--- pgadmin/frm/frmMain.cpp.orig	Wed Oct 07 15:07:06 2015
+++ pgadmin/frm/frmMain.cpp	Wed Oct 07 20:28:09 2015
@@ -659,11 +659,7 @@
 			{
 				text.Append(lv->GetText(row, col) + wxT("\t"));
 			}
-#ifdef __WXMSW__
-			text.Append(wxT("\r\n"));
-#else
 			text.Append(wxT("\n"));
-#endif
 			row = lv->GetNextSelected(row);
 		}
 		text = text.Trim();
@@ -673,13 +669,13 @@
 	ctlSQLBox *sb = dynamic_cast<ctlSQLBox *>(currentControl);
 	if (sb)
 	{
-		text = wxTextBuffer::Translate(sb->GetSelectedText());
+		text = sb->GetSelectedText();
 	}
 
 	// Set the clipboard text
 	if (text.Length() > 0 && wxTheClipboard->Open())
 	{
-		wxTheClipboard->SetData(new wxTextDataObject(text));
+		wxTheClipboard->SetData(new wxTextDataObject(wxTextBuffer::Translate(text)));
 		wxTheClipboard->Close();
 	}
 }



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] Beautify line-ends handling yet more.
  2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
@ 2015-10-09 13:31 ` Dave Page <[email protected]>
  2015-10-10 12:33   ` Re: [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Page @ 2015-10-09 13:31 UTC (permalink / raw)
  To: Nikolai Zhubr <[email protected]>; +Cc: pgadmin-hackers

Hi

On Wed, Oct 7, 2015 at 7:47 PM, Nikolai Zhubr <[email protected]> wrote:
> Hello Dave,
>
> Attached are two more patches, mostly cosmetic:
>
> *  Make a better guess of default line-end type based on platform type.

I committed a modified version of this - Mac OS X uses \n as a
line-end, so that makes a better default than the old-style \r used on
Mac classic.

> *  Get rid of #ifdef -- let wxTextBuffer::Translate do all the work.

Committed.

> Sending as attachments, let me know if inserting inline is preferred.

Please use attachments created with "git diff > foo.diff". I had to
manually apply the patches above for some reason, but git diff should
usually work fine (and inlining them is just painful!) :-)

Thanks!


-- 
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 ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] Beautify line-ends handling yet more.
  2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-09 13:31 ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
@ 2015-10-10 12:33   ` Nikolai Zhubr <[email protected]>
  2015-10-10 13:51     ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Nikolai Zhubr @ 2015-10-10 12:33 UTC (permalink / raw)
  To: pgadmin-hackers

Hello Dave,
09.10.2015 16:31, Dave Page wrote:
[...]
> I committed a modified version of this - Mac OS X uses \n as a
> line-end, so that makes a better default than the old-style \r used on
> Mac classic.

Ah, I didn't know that, thanks for explanation.

I suppose it is unlikely someone will use current (and future) releases 
of pgamin3 on Mac classic, therefore I'd propose to also update the 
corresponding preferences menu. Right now it shows 3 possibilities:

* Unix (LF)
* DOS (CRLF)
* Mac (CR)

Maybe it would make sense to only provide 2 with the following naming:

* Unix/Mac (LF)
* DOS/Windows (CRLF)

If it is OK then I'll craft a git diff for that (eventually).


Thank you,
Nikolai


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] Beautify line-ends handling yet more.
  2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-09 13:31 ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
  2015-10-10 12:33   ` Re: [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
@ 2015-10-10 13:51     ` Dave Page <[email protected]>
  2015-10-10 14:36       ` Re: [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-10 18:45       ` Re: [PATCH] Beautify line-ends handling yet more. Szabolcs Hubai <[email protected]>
  0 siblings, 2 replies; 6+ messages in thread

From: Dave Page @ 2015-10-10 13:51 UTC (permalink / raw)
  To: Nikolai Zhubr <[email protected]>; +Cc: pgadmin-hackers



> On 10 Oct 2015, at 13:33, Nikolai Zhubr <[email protected]> wrote:
> 
> Hello Dave,
> 09.10.2015 16:31, Dave Page wrote:
> [...]
>> I committed a modified version of this - Mac OS X uses \n as a
>> line-end, so that makes a better default than the old-style \r used on
>> Mac classic.
> 
> Ah, I didn't know that, thanks for explanation.
> 
> I suppose it is unlikely someone will use current (and future) releases of pgamin3 on Mac classic, therefore I'd propose to also update the corresponding preferences menu. Right now it shows 3 possibilities:
> 
> * Unix (LF)
> * DOS (CRLF)
> * Mac (CR)
> 
> Maybe it would make sense to only provide 2 with the following naming:
> 
> * Unix/Mac (LF)
> * DOS/Windows (CRLF)
> 
> If it is OK then I'll craft a git diff for that (eventually).

I'm not sure we should - it may be useful for someone working with legacy systems, and it's not like it's a massive amount of code bloating the app or overly complicating the UI.

-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] Beautify line-ends handling yet more.
  2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-09 13:31 ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
  2015-10-10 12:33   ` Re: [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-10 13:51     ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
@ 2015-10-10 14:36       ` Nikolai Zhubr <[email protected]>
  1 sibling, 0 replies; 6+ messages in thread

From: Nikolai Zhubr @ 2015-10-10 14:36 UTC (permalink / raw)
  To: pgadmin-hackers

Hello Dave,
10.10.2015 16:51, Dave Page wrote:
[...]
>> * Unix/Mac (LF)
>> * DOS/Windows (CRLF)
>>
>> If it is OK then I'll craft a git diff for that (eventually).
>
> I'm not sure we should - it may be useful for someone working with legacy systems, and it's not like it's a massive amount of code bloating the app or overly complicating the UI.

Ok, understood.

And btw special thanks for bringing back windows xp compatability in 
beta1. It works fine for me so far.


Thank you,
Nikolai


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: [PATCH] Beautify line-ends handling yet more.
  2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-09 13:31 ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
  2015-10-10 12:33   ` Re: [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
  2015-10-10 13:51     ` Re: [PATCH] Beautify line-ends handling yet more. Dave Page <[email protected]>
@ 2015-10-10 18:45       ` Szabolcs Hubai <[email protected]>
  1 sibling, 0 replies; 6+ messages in thread

From: Szabolcs Hubai @ 2015-10-10 18:45 UTC (permalink / raw)
  To: pgadmin-hackers

As an alternative solution you could do it as Notepad++ does:
Unix/Mac, DOS/Windows, old Mac.

2015-10-10 15:51 GMT+02:00 Dave Page <[email protected]>:
>
>
>> On 10 Oct 2015, at 13:33, Nikolai Zhubr <[email protected]> wrote:
>>
>> Hello Dave,
>> 09.10.2015 16:31, Dave Page wrote:
>> [...]
>>> I committed a modified version of this - Mac OS X uses \n as a
>>> line-end, so that makes a better default than the old-style \r used on
>>> Mac classic.
>>
>> Ah, I didn't know that, thanks for explanation.
>>
>> I suppose it is unlikely someone will use current (and future) releases of pgamin3 on Mac classic, therefore I'd propose to also update the corresponding preferences menu. Right now it shows 3 possibilities:
>>
>> * Unix (LF)
>> * DOS (CRLF)
>> * Mac (CR)
>>
>> Maybe it would make sense to only provide 2 with the following naming:
>>
>> * Unix/Mac (LF)
>> * DOS/Windows (CRLF)
>>
>> If it is OK then I'll craft a git diff for that (eventually).
>
> I'm not sure we should - it may be useful for someone working with legacy systems, and it's not like it's a massive amount of code bloating the app or overly complicating the UI.
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2015-10-10 18:45 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-10-07 18:47 [PATCH] Beautify line-ends handling yet more. Nikolai Zhubr <[email protected]>
2015-10-09 13:31 ` Dave Page <[email protected]>
2015-10-10 12:33   ` Nikolai Zhubr <[email protected]>
2015-10-10 13:51     ` Dave Page <[email protected]>
2015-10-10 14:36       ` Nikolai Zhubr <[email protected]>
2015-10-10 18:45       ` Szabolcs Hubai <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox