1 | #! perl |
1 | #! perl |
|
|
2 | |
|
|
3 | =head1 NAME |
|
|
4 | |
|
|
5 | xim-onthespot - implement XIM "on-the-spot" behaviour |
|
|
6 | |
|
|
7 | =head1 DESCRIPTION |
|
|
8 | |
|
|
9 | This perl extension implements OnTheSpot editing. It does not work |
|
|
10 | perfectly, and some input methods don't seem to work well with OnTheSpot |
|
|
11 | editing in general, but it seems to work at least for SCIM and kinput2. |
|
|
12 | |
|
|
13 | You enable it by specifying this extension and a preedit style of |
|
|
14 | C<OnTheSpot>, i.e.: |
|
|
15 | |
|
|
16 | urxvt -pt OnTheSpot -pe xim-onthespot |
|
|
17 | |
|
|
18 | =cut |
2 | |
19 | |
3 | # |
20 | # |
4 | # problems with this implementation include |
21 | # problems with this implementation include |
5 | # |
22 | # |
6 | # - primary, secondary, teriary is NOT different to other hilighting |
23 | # - primary, secondary, tertiary are NO different to other highlighting styles |
7 | # - if rend values are missing, they are not interpolated |
24 | # - if rend values are missing, they are not being interpolated |
8 | # |
25 | # |
9 | |
26 | |
10 | my $SIZEOF_LONG = length pack "l!", 0; |
27 | my $SIZEOF_LONG = length pack "l!", 0; |
11 | |
28 | |
12 | sub refresh { |
29 | sub refresh { |
… | |
… | |
25 | my @rend = map { |
42 | my @rend = map { |
26 | my $rstyle = $self->{caret} == $idx ? urxvt::OVERLAY_RSTYLE : $self->rstyle; |
43 | my $rstyle = $self->{caret} == $idx ? urxvt::OVERLAY_RSTYLE : $self->rstyle; |
27 | |
44 | |
28 | $rstyle |= urxvt::RS_Uline if $_ & (urxvt::XIMUnderline | urxvt::XIMPrimary); |
45 | $rstyle |= urxvt::RS_Uline if $_ & (urxvt::XIMUnderline | urxvt::XIMPrimary); |
29 | $rstyle |= urxvt::RS_RVid if $_ & (urxvt::XIMReverse | urxvt::XIMSecondary); |
46 | $rstyle |= urxvt::RS_RVid if $_ & (urxvt::XIMReverse | urxvt::XIMSecondary); |
30 | $rstyle |= urxvt::RS_Blink if $_ & (urxvt::XIMHighlight | urxvt::XIMTertiary); |
47 | $rstyle |= urxvt::RS_Italic if $_ & (urxvt::XIMHighlight | urxvt::XIMTertiary); |
31 | |
48 | |
32 | ($rstyle) x ($self->strwidth (substr $text, $idx++, 1)) |
49 | ($rstyle) x ($self->strwidth (substr $text, $idx++, 1)) |
33 | } unpack "l!*", $self->{rend}; |
50 | } unpack "l!*", $self->{rend}; |
34 | |
51 | |
35 | if ($self->{caret} >= length $text) { |
52 | if ($self->{caret} >= length $text) { |
… | |
… | |
55 | delete $self->{rend}; |
72 | delete $self->{rend}; |
56 | |
73 | |
57 | () |
74 | () |
58 | } |
75 | } |
59 | |
76 | |
60 | sub on_xim_preedit_caret { |
|
|
61 | my ($self, $pos, $dir, $style) = @_; |
|
|
62 | warn "preedit_caret(@_)\n"; |
|
|
63 | () |
|
|
64 | } |
|
|
65 | |
|
|
66 | sub on_xim_preedit_draw { |
77 | sub on_xim_preedit_draw { |
67 | my ($self, $caret, $pos, $len, $feedback, $chars) = @_; |
78 | my ($self, $caret, $pos, $len, $feedback, $chars) = @_; |
68 | |
79 | |
69 | $self->{caret} = $caret; |
80 | $self->{caret} = $caret; |
70 | |
81 | |