Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Using JDIC from inside ..



"Stephen J. Turnbull" <stephen@example.com> wrote:
>> >>>>> "Jim" == Jim Breen <Jim.Breen@example.com> writes:
>>     Jim> Can you make it loop looking for something to turn up? That
>>     Jim> was a nice feature of the one that Todd & I started on. No
>>     Jim> keystrokes at all; just highlight the text. ISTR it sits in a
>>     Jim> 1000ms sleep loop doing a "catch" on the cut buffer.
>> 
>> First, I'm sure it's not a cut buffer.  :-)

No, it's a "selection" in X-speak.

>> Second, there's a way to register a callback on the PRIMARY selection
>> (what it is instead of a cut buffer ;-).  Look in the standard
>> distribution xclipboard application for how it's done (that app uses
>> the CLIPBOARD selection, however).  Motif also has a clipboard, but
>> its protocol is fairly complicated.  You'd also want to check the
>> ICCCM.  I don't think there are any gotchas if you just want to get
>> the selection, but you should check.

I want to see how far I can push it in Tcl/Tk before going into the
really hard stuff. I revisited my Tcl code and fiddled until it is 
working a lot better. Tcl has a "selection" operation which talks pretty
straight to X and claims to do the full ICCCM thang. It looks like:

	selection get -displayof "." -selection PRIMARY -type COMPOUND_TEXT

(in fact those displayof and selection options are the defaults.)

I've unsnarled some of the hassles. For Japanese text, the "selection"
only returns things for type "STRING" for Netscape/Mozilla/Galeon/etc.
and for type "COMPOUND_TEXT" for kterm/mlterm/yudit/etc., so I've put in
both and respond to whichever works first. Most return text in that
'orrible C2/C3 ICCCM format. mlterm, bless its heart, returns it in that
ISO-2022-JP-like format with Esc ( B $ or whatever in front.

The BIG problem, is that both kterm and yudit result in the selection
being stripped of the first character, which doesn't help the
functionality of the hover-in-the-background lookup. Anyone here had
experience of that happening? I'll try posting on the main tcltk
newsgroup and see if Jeff Hobbs or anyone recognizes the problem.

If anyone has Tcl/Tk installed, they might have some fun with the
attached. When run, it chases the mouse-pointer round he screen flashing
the last selection.

Cheers

Jim
===========================================================
encoding system euc-jp
wm withdraw .
toplevel .popup
wm overrideredirect .popup 1
label .popup.l -text "" -background linen -relief "raised" -justify "left" -borderwidth 3 
pack .popup.l
set startX 0
set startY 0

proc poller {} {
  set ntexte ""
  set ntext ""
  set x [winfo pointerx .]
  set y [winfo pointery .]

  catch {set ntext [selection get -type STRING]}
#  catch {set ntext [selection get -type COMPOUND_TEXT]}
  set ntexte [encoding convertfrom $ntext]
  set slen [string length $ntext]
  if {$slen == 0} then {set ntexte "Zero length string"}
  .popup.l configure -text "$ntext\n$ntexte"
  wm geometry .popup +$x+[expr $y+20]
  wm deiconify .popup
  after 1000 {wm withdraw .popup}
  after 2000 {poller}
}
after 2000 {poller}

===========================================================


-- 
Jim Breen                                http://www.csse.monash.edu.au/~jwb/
Computer Science & Software Engineering,                Tel: +61 3 9905 9554
Monash University, VIC 3800, Australia                  Fax: +61 3 9905 5146
(Monash Provider No. 00008C)                ジム・ブリーン@モナシュ大学

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links