RE: Right to left writing in text widget
"Hidasi Zsolt" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
I'm back again,
Now you can see how lasy i am. I have tried to do something like this:
use Tk;
use Tk::Text;
require Tk::Adjuster;
use strict;
my $mw = MainWindow->new;
my $t2 = $mw->Scrolled('Text', -scrollbars=> 'ose', -height=> 5, -background =>'SystemButtonFace')->pack(-side=>'bottom', -fill=> 'both', -expand=> '1');
my $t1 = $mw->Scrolled('Text', -scrollbars=> 'ose', -height=> 5, -background =>'SystemWindow')->pack(-side=>'bottom', -fill=> 'both', -expand=> '1');
$t2->tagConfigure('right', -justify => 'right');
$mw->Adjuster->packAfter($t2, -side => 'bottom', -fill => 'both');
$t1->focus;
$t1->bind('<KeyPress>' => sub {
my @revlines;
my $str = $t1->get('1.0', 'end');
my @lines = split(/\n/,$str);
foreach (@lines) {
my $revstr = reverse $_;
@revlines = (@revlines, $revstr);
}
$t2->delete('1.0','end');
foreach (@revlines) {
$t2->insert('end', "$_\n", 'right');
}
my $idx1 = $t1->index('insert');
$t2->SetCursor($idx1);});
MainLoop;
It's OK if you use linebreak at the end of each line, before the end of the edge of the text window, but in the case of wrapping a line, the view of the reversed text will be changed (off course, because in fact it's one line). I think the text must be allways rebreak to the size of the window (not by wrap but real linebreak) to solve this problem.
Any remark is welcome.
Zsolt
PS.: Sorry for my poor English
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]