Re: Can't type non ASCII characters in qt body

2009-02-23 Thread Ville M. Vainio

On Fri, Feb 20, 2009 at 6:57 PM, Ville M. Vainio vivai...@gmail.com wrote:

 It's my guess these would all be fixed if leo started to call
 unicode(s) instead of ...toUnicode(s). Perhaps g.app.gui.toUnicode
 should be direct call to unicode()?

I tried this, i.e. changed this:

--- leo/plugins/qtGui.py2009-02-23 15:20:58 +
+++ leo/plugins/qtGui.py2009-02-23 15:36:54 +
@@ -4421,7 +4421,9 @@
 #...@-node:ekr.20081121105001.501:isTextWidget
 #...@+node:ekr.20081121105001.502:toUnicode (qtGui)
 def toUnicode (self,s,encoding='utf-8',reportErrors=True):
+return unicode(s)

Unit tests pass. Either the unicode support is missing unit tests, or
the fix is good ;-).

I think it should be done, though I also think all the calls that get
QStrings should use unicode(s) direcly.


-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-23 Thread Vicent

Hi,

I've commented out the sys.setdefaultencoding('utf-8') call in my
sitecustomize.py script and changed qtGui.py as you suggest.
Everything seems to work fine (not tested in depth, however): I can
enter unicode chars in headlines and body text, save and close the
file. When I open the file again all chars look fine.

Vicent

On 23 Feb, 16:43, Ville M. Vainio vivai...@gmail.com wrote:
 On Fri, Feb 20, 2009 at 6:57 PM, Ville M. Vainio vivai...@gmail.com wrote:

  It's my guess these would all be fixed if leo started to call
  unicode(s) instead of ...toUnicode(s). Perhaps g.app.gui.toUnicode
  should be direct call to unicode()?

 I tried this, i.e. changed this:

 --- leo/plugins/qtGui.py        2009-02-23 15:20:58 +
 +++ leo/plugins/qtGui.py        2009-02-23 15:36:54 +
 @@ -4421,7 +4421,9 @@
     �...@-node:ekr.20081121105001.501:isTextWidget
     �...@+node:ekr.20081121105001.502:toUnicode (qtGui)
      def toUnicode (self,s,encoding='utf-8',reportErrors=True):
 +        return unicode(s)

 Unit tests pass. Either the unicode support is missing unit tests, or
 the fix is good ;-).

 I think it should be done, though I also think all the calls that get
 QStrings should use unicode(s) direcly.

 --
 Ville M. Vainiohttp://tinyurl.com/vainio
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-23 Thread Edward K. Ream
On Mon, Feb 23, 2009 at 9:43 AM, Ville M. Vainio vivai...@gmail.com wrote:


 On Fri, Feb 20, 2009 at 6:57 PM, Ville M. Vainio vivai...@gmail.com
 wrote:

  It's my guess these would all be fixed if leo started to call
  unicode(s) instead of ...toUnicode(s). Perhaps g.app.gui.toUnicode
  should be direct call to unicode()?

 I tried this, i.e. changed this:

 --- leo/plugins/qtGui.py2009-02-23 15:20:58 +
 +++ leo/plugins/qtGui.py2009-02-23 15:36:54 +
 @@ -4421,7 +4421,9 @@
 #...@-node:ekr.20081121105001.501:isTextWidget
 #...@+node:ekr.20081121105001.502:toUnicode (qtGui)
 def toUnicode (self,s,encoding='utf-8',reportErrors=True):
 +return unicode(s)

 Unit tests pass. Either the unicode support is missing unit tests, or
 the fix is good ;-).


I suspect that there are missing unit test.  The intention of toUnicode was
to handle unicode errors so that callers don't have to worry about catching
exceptions.

Off hand, I'm not sure whether this is vestigial code or not.

But if it solves problems for the qt gui, I don't mind trying it...


 I think it should be done, though I also think all the calls that get
 QStrings should use unicode(s) directly.


For QStrings, the situation is clearer.  No exceptions are expected because
QString is just a wrapper for unicode.  So yes, a direct call to unicode to
convert from QString to Python unicode string is simple and good.

Edward

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-23 Thread Ville M. Vainio

On Mon, Feb 23, 2009 at 7:05 PM, Edward K. Ream edream...@gmail.com wrote:

 But if it solves problems for the qt gui, I don't mind trying it...

So do you want me to push it, or will you do it yourself?

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Ville M. Vainio

On Fri, Feb 20, 2009 at 6:50 PM, vitalije vitali...@gmail.com wrote:

 I can't type any non ASCII character like Виталије in Leo's body
 when using Qt gui.
 Instead of characters that I type Leo shows only ?-s. It displays
 correct text that I have typed in using Tk as gui.

 If it would help the this bug was introduced in revision 1527.

It's my guess these would all be fixed if leo started to call
unicode(s) instead of ...toUnicode(s). Perhaps g.app.gui.toUnicode
should be direct call to unicode()?

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Vicent

Hi,

I'm using lots of non ASCII characters (qith qt being my default gui)
in my daily work and everything
is fine here. I'm using rev 1589 now.

Have you had a look to the (invalid) bug http://launchpad.net/bugs/323105
? Setting the
sys.defaultencoding() to 'utf-8' fixed the problem for me in rev 1447
and I have had no issues
(IIRC) with unicode since then.

Hope it helps.

Vicent


On 20 Feb, 17:50, vitalije vitali...@gmail.com wrote:
 Hi.

 I can't type any non ASCII character like Виталије in Leo's body
 when using Qt gui.
 Instead of characters that I type Leo shows only ?-s. It displays
 correct text that I have typed in using Tk as gui.

 If it would help the this bug was introduced in revision 1527.
 Although in that revision Leo was corrupting body text of nodes that
 contain non ASCII characters. It displays correct body text when node
 is first selected, but after selecting another node and then selecting
 again node with non ASCII characters, all those characters are
 replaced with ?-s. That behavior is since revision 1447.

 I have also noticed that when in Qt gui, after changing chapter by
 using command select-chapter there is no visible change in outline,
 until I manually call c.redraw(). That is confusing.

 I am using revision no. 1588.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Ville M. Vainio

On Fri, Feb 20, 2009 at 7:28 PM, Vicent uve...@gmail.com wrote:

 Have you had a look to the (invalid) bug http://launchpad.net/bugs/323105
 ? Setting the
 sys.defaultencoding() to 'utf-8' fixed the problem for me in rev 1447
 and I have had no issues
 (IIRC) with unicode since then.

sys.setdefaultencoding is a hack that they suggest avoiding on all
occasions. Not encoding/decoding anything ever (apart from when you
are serializing to a file) is the right approach. Qt controls use
unicode natively (QString), and leo stores the text as unicode in its
model. Any encoding/decoding happening in between should be considered
a bug.

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Vicent

Hi,

I don't understand. I'm not encoding/decoding anything. I just have
set  sys.defaultencoding in my sitecustomize.py. So when leo uses
this value (and it seems it does, at least that is what I understand
from thread copy + paste erratic behavior in qt-plugin) it produces
the right results (at least in my case).

Vicent

On 20 Feb, 18:32, Ville M. Vainio vivai...@gmail.com wrote:
 On Fri, Feb 20, 2009 at 7:28 PM, Vicent uve...@gmail.com wrote:
  Have you had a look to the (invalid) bughttp://launchpad.net/bugs/323105
  ? Setting the
  sys.defaultencoding() to 'utf-8' fixed the problem for me in rev 1447
  and I have had no issues
  (IIRC) with unicode since then.

 sys.setdefaultencoding is a hack that they suggest avoiding on all
 occasions. Not encoding/decoding anything ever (apart from when you
 are serializing to a file) is the right approach. Qt controls use
 unicode natively (QString), and leo stores the text as unicode in its
 model. Any encoding/decoding happening in between should be considered
 a bug.

 --
 Ville M. Vainiohttp://tinyurl.com/vainio
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Ville M. Vainio

On Fri, Feb 20, 2009 at 7:55 PM, Vicent uve...@gmail.com wrote:

 I don't understand. I'm not encoding/decoding anything. I just have
 set  sys.defaultencoding in my sitecustomize.py. So when leo uses
 this value (and it seems it does, at least that is what I understand
 from thread copy + paste erratic behavior in qt-plugin) it produces
 the right results (at least in my case).

Yes, I'm not saying you were doing the wrong thing, leo is ;-).

The main point is that changing sys.defaultencoding is not a
sufficient answer to this problem, this needs to be fixed in leo. End
users should not need to care about this stuff at all.

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread Vicent

Hi,

thanks for the explanation. Now I understand you. And agree with
you :-)

Vicent

On 20 Feb, 19:02, Ville M. Vainio vivai...@gmail.com wrote:
 On Fri, Feb 20, 2009 at 7:55 PM, Vicent uve...@gmail.com wrote:
  I don't understand. I'm not encoding/decoding anything. I just have
  set  sys.defaultencoding in my sitecustomize.py. So when leo uses
  this value (and it seems it does, at least that is what I understand
  from thread copy + paste erratic behavior in qt-plugin) it produces
  the right results (at least in my case).

 Yes, I'm not saying you were doing the wrong thing, leo is ;-).

 The main point is that changing sys.defaultencoding is not a
 sufficient answer to this problem, this needs to be fixed in leo. End
 users should not need to care about this stuff at all.

 --
 Ville M. Vainiohttp://tinyurl.com/vainio
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---



Re: Can't type non ASCII characters in qt body

2009-02-20 Thread vitalije

Thanks for advise.

Indeed, creating sitecustomize.py with sys.setdefaultencoding('utf-8')
in it solved problem,
but ojn the other hand I agree that Leo should not require such a hack
from user in order
to work properly.

Vitalije.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
leo-editor group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~--~~~~--~~--~--~---