1 |
root |
1.1 |
#! perl |
2 |
|
|
|
3 |
|
|
# |
4 |
|
|
# problems with this implementation include |
5 |
|
|
# |
6 |
sf-exg |
1.4 |
# - primary, secondary, tertiary are NO different to other highlighting styles |
7 |
root |
1.3 |
# - if rend values are missing, they are not being interpolated |
8 |
root |
1.1 |
# |
9 |
|
|
|
10 |
|
|
my $SIZEOF_LONG = length pack "l!", 0; |
11 |
|
|
|
12 |
|
|
sub refresh { |
13 |
|
|
my ($self) = @_; |
14 |
|
|
|
15 |
|
|
delete $self->{overlay}; |
16 |
|
|
|
17 |
|
|
my $text = $self->{text}; |
18 |
|
|
|
19 |
|
|
return unless length $text; |
20 |
|
|
|
21 |
|
|
my ($row, $col) = $self->screen_cur; |
22 |
|
|
|
23 |
|
|
my $idx = 0; |
24 |
|
|
|
25 |
|
|
my @rend = map { |
26 |
|
|
my $rstyle = $self->{caret} == $idx ? urxvt::OVERLAY_RSTYLE : $self->rstyle; |
27 |
|
|
|
28 |
|
|
$rstyle |= urxvt::RS_Uline if $_ & (urxvt::XIMUnderline | urxvt::XIMPrimary); |
29 |
|
|
$rstyle |= urxvt::RS_RVid if $_ & (urxvt::XIMReverse | urxvt::XIMSecondary); |
30 |
root |
1.2 |
$rstyle |= urxvt::RS_Italic if $_ & (urxvt::XIMHighlight | urxvt::XIMTertiary); |
31 |
root |
1.1 |
|
32 |
|
|
($rstyle) x ($self->strwidth (substr $text, $idx++, 1)) |
33 |
|
|
} unpack "l!*", $self->{rend}; |
34 |
|
|
|
35 |
|
|
if ($self->{caret} >= length $text) { |
36 |
|
|
$text .= " "; |
37 |
|
|
push @rend, urxvt::OVERLAY_RSTYLE; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
$self->{overlay} = $self->overlay ($col, $row, $self->strwidth ($text), 1, $self->rstyle, 0); |
41 |
|
|
$self->{overlay}->set (0, 0, $self->special_encode ($text), \@rend); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
sub on_xim_preedit_start { |
45 |
|
|
my ($self) = @_; |
46 |
|
|
|
47 |
|
|
() |
48 |
|
|
} |
49 |
|
|
|
50 |
|
|
sub on_xim_preedit_done { |
51 |
|
|
my ($self) = @_; |
52 |
|
|
|
53 |
|
|
delete $self->{overlay}; |
54 |
|
|
delete $self->{text}; |
55 |
|
|
delete $self->{rend}; |
56 |
|
|
|
57 |
|
|
() |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
sub on_xim_preedit_draw { |
61 |
|
|
my ($self, $caret, $pos, $len, $feedback, $chars) = @_; |
62 |
|
|
|
63 |
|
|
$self->{caret} = $caret; |
64 |
|
|
|
65 |
|
|
substr $self->{rend}, $pos * $SIZEOF_LONG, $len * $SIZEOF_LONG, $feedback; |
66 |
|
|
substr $self->{text}, $pos , $len , $chars if defined $feedback || !defined $chars; |
67 |
|
|
|
68 |
|
|
$self->refresh; |
69 |
|
|
|
70 |
|
|
() |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
|