Unicode clipboard in Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Unicode clipboard in Windows

Chris Petsos
 
Ok i am trying to brake down the clipboard-responsible code so that i can add unicode clipboard support.. the news are not so good.
 
First, i saw that the code for sending text to the clipboard is
 
    int clipboardWriteFromAt(int count, int byteArrayIndex, int startIndex)
in
    sqWin32Window.c
 
The thing is that we are trying to create a fully Unicode VM...this means that the characters that are sent to the VM are Unicode (> 256) and we are using a unicode TT font to render them.
Now... when i evaluate this
 
c:=Clipboard new.
c primitiveClipboardText:'α'    "α is unicode char 945"
 
the clipboardWriteFromAt is never invoked.
That's because in
    interp.c
at
    sqInt primitiveClipboardText(void)
 
the following expression is evaluated to TRUE
 
if (!(((s & 1) == 0) && (((((usqInt) (longAt(s))) >> 8) & 15) >= 8))) {
   /* begin primitiveFail */
   successFlag = 0;
   printf("primitive failed 1\n");    "This printf is mine"
   return null;
  }
 
Now what in earth is THIS?
    (!(((s & 1) == 0) && (((((usqInt) (longAt(s))) >> 8) & 15) >= 8)))
Also further down it has
 
if (successFlag) {
   sz = stSizeOf(s);
   clipboardWriteFromAt(sz, s + BaseHeaderSize, 0);
   /* begin pop: */
   stackPointer -= 1 * BytesPerWord;
  }
 
where stSizeOf goes down to assembly...
I think i am starting to abandon the fully-unicode vision and follow your instructions from the start to use code pages and preserve the internal representation of Squeak...
I don't think that i will be able to make everything unicode in a life time (does it worth it?)...
 
Christos.
Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Bert Freudenberg
 
On May 29, 2007, at 12:33 , Chris Petsos wrote:

> Ok i am trying to brake down the clipboard-responsible code so that  
> i can add unicode clipboard support.

Did you succeed with the keyboard input, yet?

Take a look at the ExtendedClipboard classes and plugin that Takashi  
ported from Sophie to OLPC.

> Now what in earth is THIS?
>     (!(((s & 1) == 0) && (((((usqInt) (longAt(s))) >> 8) & 15) >= 8)))

You should not try to derive meaning from this generated C code but  
look at the original sources.

> I think i am starting to abandon the fully-unicode vision and  
> follow your instructions from the start to use code pages and  
> preserve the internal representation of Squeak...
> I don't think that i will be able to make everything unicode in a  
> life time (does it worth it?)...

We will definitely have unicode support in the OLPC version. Right  
now, we can already copy/paste and drag/drop unicode text from other  
applications into Squeak.

We generally prefer solutions that are portable to other platforms,  
although the core OLPC developers will probably not spend too much  
time on other platforms.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Chris Petsos
 
On Tue, 2007-05-29 at 13:35 +0200, Bert Freudenberg wrote:
>  On May 29, 2007, at 12:33 , Chris Petsos wrote:
>
> > Ok i am trying to brake down the clipboard-responsible code so that  
> > i can add unicode clipboard support.
>
> Did you succeed with the keyboard input, yet?

Yes, but i couldn't handle WM_UNICHAR. We did it the other way...

 +/* Force Unicode WM_CHAR */

+SetWindowLongW(stWindow,GWL_WNDPROC,GetWindowLong(stWindow,GWL_WNDPROC));

+SetWindowLongW(consoleWindow,GWL_WNDPROC,GetWindowLong(consoleWindow,GWL_WN
 DPROC));
>

> Take a look at the ExtendedClipboard classes and plugin that Takashi  
> ported from Sophie to OLPC.
>
> > Now what in earth is THIS?
> >     (!(((s & 1) == 0) && (((((usqInt) (longAt(s))) >> 8) & 15) >= 8)))
>
> You should not try to derive meaning from this generated C code but  
> look at the original sources.
>
> > I think i am starting to abandon the fully-unicode vision and  
> > follow your instructions from the start to use code pages and  
> > preserve the internal representation of Squeak...
> > I don't think that i will be able to make everything unicode in a  
> > life time (does it worth it?)...
>
> We will definitely have unicode support in the OLPC version. Right  
> now, we can already copy/paste and drag/drop unicode text from other  
> applications into Squeak.

Only for the Unix version i suppose...

>
> We generally prefer solutions that are portable to other platforms,  
> although the core OLPC developers will probably not spend too much  
> time on other platforms.

This means that i am all alone for the Windows front? Why is that?
I just want to state that i am not a Windows fan (although new to
Linux...about three months...OLPC was the cause...i am loving it
though), but...at least here in Greece... many teachers have no
experience with Unix platforms and i don't know if they are willing to
start using Linux just for eToys. I am just saying that i am afraid that
utilisation of the eToys platform may end up in failure if we don't
support the Windows version too .
I know it's not your responsibility for the OLPC to succeed, nor the
core OLPC developers will ever spend much time on the Windows version
but shouldn't we consider what we are trying to accomplish here in a
more general manner?
What do you say?

Christos.


Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Bert Freudenberg
 
On May 29, 2007, at 16:59 , Chris Petsos wrote:

> On Tue, 2007-05-29 at 13:35 +0200, Bert Freudenberg wrote:
>> We will definitely have unicode support in the OLPC version. Right
>> now, we can already copy/paste and drag/drop unicode text from other
>> applications into Squeak.
>
> Only for the Unix version i suppose...

Sure, the OLPC runs on Linux.

>> We generally prefer solutions that are portable to other platforms,
>> although the core OLPC developers will probably not spend too much
>> time on other platforms.
>
> This means that i am all alone for the Windows front? Why is that?
> I just want to state that i am not a Windows fan (although new to
> Linux...about three months...OLPC was the cause...i am loving it
> though), but...at least here in Greece... many teachers have no
> experience with Unix platforms and i don't know if they are willing to
> start using Linux just for eToys. I am just saying that i am afraid  
> that
> utilisation of the eToys platform may end up in failure if we don't
> support the Windows version too .
> I know it's not your responsibility for the OLPC to succeed, nor the
> core OLPC developers will ever spend much time on the Windows version
> but shouldn't we consider what we are trying to accomplish here in a
> more general manner?
> What do you say?

I say that this is the Squeak VM developer's list, which is not OLPC  
specific. So this discussion is a bit distorted.

I'm pretty sure others want to have unicode input on Windows, too,  
you can try to find allies here or on the Squeak-dev list. For  
example, I'm pretty sure this is still on the todo-list for Sophie  
(which supports Unicode input on the Mac only so far - they do have  
full clipboard support via ffi on windows though). It would be great  
if you and others add that functionality to the Windows VM. This is  
how it has worked in the past - for example, much of the multi-
language support comes from the Japanese community.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Chris Petsos
 
> I'm pretty sure others want to have unicode input on Windows, too,  
> you can try to find allies here or on the Squeak-dev list. For  
> example, I'm pretty sure this is still on the todo-list for Sophie  
> (which supports Unicode input on the Mac only so far - they do have  
> full clipboard support via ffi on windows though). It would be great  
> if you and others add that functionality to the Windows VM. This is  
> how it has worked in the past - for example, much of the multi-
> language support comes from the Japanese community.

OK then... any allies?

Christos.
Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Andreas.Raab
In reply to this post by Chris Petsos
 
Chris Petsos wrote:

> Ok i am trying to brake down the clipboard-responsible code so that i
> can add unicode clipboard support.. the news are not so good.
>  
> First, i saw that the code for sending text to the clipboard is
>  
>     int clipboardWriteFromAt(int count, int byteArrayIndex, int startIndex)
> in
>     sqWin32Window.c
>  
> The thing is that we are trying to create a fully Unicode VM...this
> means that the characters that are sent to the VM are Unicode (>
> 256) and we are using a unicode TT font to render them.
> Now... when i evaluate this
>  
> c:=Clipboard new.
> c primitiveClipboardText:'α'    "α is unicode char 945"
>  
> the clipboardWriteFromAt is never invoked.

Indeed. I would recommended using UTF-8 instead. It is well supported on
Windows (a one-liner to convert to TCHAR) and takes a huge amount of
pain out of the conversions.

Cheers,
   - Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Unicode clipboard in Windows

Takashi Yamamiya
In reply to this post by Chris Petsos
 
Hi Christos,

>> I'm pretty sure others want to have unicode input on Windows, too,  
>> you can try to find allies here or on the Squeak-dev list. For  
>> example, I'm pretty sure this is still on the todo-list for Sophie  
>> (which supports Unicode input on the Mac only so far - they do have  
>> full clipboard support via ffi on windows though). It would be great  
>> if you and others add that functionality to the Windows VM. This is  
>> how it has worked in the past - for example, much of the multi-
>> language support comes from the Japanese community.
>
> OK then... any allies?

I only work for Unix clipboard because my immediate goal is for
OLPC. But my main PC is Windows, so I'm happy to help you. I don't
have a good advice for you because I'm just beginning to hack the vm
code though, I could test your code at least.

Cheers,
- Takashi