mirror of
https://codeberg.org/scip/leo.git
synced 2025-12-17 12:41:09 +01:00
fix column calc (a little)
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
1.42:
|
||||||
|
|
||||||
|
Better tabluar output (better column calc). However, russian
|
||||||
|
grapheme length is still wrong.
|
||||||
|
|
||||||
1.41:
|
1.41:
|
||||||
|
|
||||||
Generalized lang parsing and passing to dict.leo.org, which
|
Generalized lang parsing and passing to dict.leo.org, which
|
||||||
|
|||||||
18
Org.pm
18
Org.pm
@@ -7,7 +7,7 @@
|
|||||||
# or service marks of their respective holders.
|
# or service marks of their respective holders.
|
||||||
|
|
||||||
package WWW::Dict::Leo::Org;
|
package WWW::Dict::Leo::Org;
|
||||||
$WWW::Dict::Leo::Org::VERSION = "1.41";
|
$WWW::Dict::Leo::Org::VERSION = "1.42";
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -260,6 +260,7 @@ Accept-Language: en_US, en\r\n);
|
|||||||
|
|
||||||
|
|
||||||
sub hdr {
|
sub hdr {
|
||||||
|
# HTML::TableParser header callback
|
||||||
my ( $this, $tbl_id, $line_no, $data, $udata ) = @_;
|
my ( $this, $tbl_id, $line_no, $data, $udata ) = @_;
|
||||||
if ($data->[1] && $data->[0] eq $data->[1]) {
|
if ($data->[1] && $data->[0] eq $data->[1]) {
|
||||||
$this->debug("Probable start of a new section: $data->[1]");
|
$this->debug("Probable start of a new section: $data->[1]");
|
||||||
@@ -274,6 +275,7 @@ sub hdr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub row {
|
sub row {
|
||||||
|
# HTML::TableParser data row callback
|
||||||
#
|
#
|
||||||
# divide rows into titles and lang data.
|
# divide rows into titles and lang data.
|
||||||
# we get 2 items (left and right column), if they
|
# we get 2 items (left and right column), if they
|
||||||
@@ -282,10 +284,10 @@ sub row {
|
|||||||
# are forumposts and ignored as well as rows with
|
# are forumposts and ignored as well as rows with
|
||||||
# empty left cells.
|
# empty left cells.
|
||||||
my ( $this, $tbl_id, $line_no, $data, $udata ) = @_;
|
my ( $this, $tbl_id, $line_no, $data, $udata ) = @_;
|
||||||
|
my $len = length($data->[0]);
|
||||||
if ($data->[1] && $data->[0] && $data->[0] ne $data->[1] && $data->[0] !~ /\d{2}:\d{2}$/) {
|
if ($data->[1] && $data->[0] && $data->[0] ne $data->[1] && $data->[0] !~ /\d{2}:\d{2}$/) {
|
||||||
if (length($data->[0]) > $this->{Maxsize}) {
|
if ($len > $this->{Maxsize}) {
|
||||||
$this->{Maxsize} = length($data->[0]);
|
$this->{Maxsize} = $len;
|
||||||
}
|
}
|
||||||
$this->debug("line: $line_no, left: $data->[0], right: $data->[1]");
|
$this->debug("line: $line_no, left: $data->[0], right: $data->[1]");
|
||||||
push @{$this->{section}}, { left => $data->[0], right => $data->[1] };
|
push @{$this->{section}}, { left => $data->[0], right => $data->[1] };
|
||||||
@@ -293,6 +295,12 @@ sub row {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub grapheme_length {
|
||||||
|
my($this, $str) = @_;
|
||||||
|
my $count = 0;
|
||||||
|
while ($str =~ /\X/g) { $count++ };
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
sub maxsize {
|
sub maxsize {
|
||||||
my($this) = @_;
|
my($this) = @_;
|
||||||
@@ -534,6 +542,6 @@ Please don't forget to add debugging output!
|
|||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
1.41
|
1.42
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|||||||
12
leo
12
leo
@@ -14,7 +14,6 @@
|
|||||||
# or service marks of their respective holders.
|
# or service marks of their respective holders.
|
||||||
|
|
||||||
#use lib qw(blib/lib);
|
#use lib qw(blib/lib);
|
||||||
#use Org;
|
|
||||||
|
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ my $default_c = "\033[0m"; # reset default terminal color
|
|||||||
my $bold_c = "\033[0;34m"; # blue color
|
my $bold_c = "\033[0;34m"; # blue color
|
||||||
my $copy_c = "\033[0;35m"; # copyright message color (green)
|
my $copy_c = "\033[0;35m"; # copyright message color (green)
|
||||||
|
|
||||||
my $version = "1.41";
|
my $version = "1.42";
|
||||||
my $config = $ENV{HOME} . "/.leo";
|
my $config = $ENV{HOME} . "/.leo";
|
||||||
my $cache = $ENV{HOME} . "/.leo-CACHE.db";
|
my $cache = $ENV{HOME} . "/.leo-CACHE.db";
|
||||||
|
|
||||||
@@ -267,6 +266,10 @@ if(! @match) {
|
|||||||
$maxsize += 5;
|
$maxsize += 5;
|
||||||
print "Found $lines matches for '$string' on dict.leo.org:\n";
|
print "Found $lines matches for '$string' on dict.leo.org:\n";
|
||||||
|
|
||||||
|
my $fmt;
|
||||||
|
my $c = "\$fmt = \" %-${maxsize}s %s\n\"";
|
||||||
|
eval $c;
|
||||||
|
|
||||||
#
|
#
|
||||||
# print it out in a formated manner, keep the order of dict.leo.org
|
# print it out in a formated manner, keep the order of dict.leo.org
|
||||||
#
|
#
|
||||||
@@ -281,7 +284,6 @@ foreach my $section (@match) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $entry (@{$section->{data}}) {
|
foreach my $entry (@{$section->{data}}) {
|
||||||
$entry->{left} =~ s/^(.*)$/$1 . " " x ($maxsize - length($1))/e;
|
|
||||||
if ($conf{use_latin}) {
|
if ($conf{use_latin}) {
|
||||||
utf8::decode($entry->{left});
|
utf8::decode($entry->{left});
|
||||||
utf8::decode($entry->{right});
|
utf8::decode($entry->{right});
|
||||||
@@ -290,7 +292,7 @@ foreach my $section (@match) {
|
|||||||
$entry->{left} =~ s/(\Q$string\E)/$bold_c . $1 . $default_c/ei;
|
$entry->{left} =~ s/(\Q$string\E)/$bold_c . $1 . $default_c/ei;
|
||||||
$entry->{right} =~ s/(\Q$string\E)/$bold_c . $1 . $default_c/ei;
|
$entry->{right} =~ s/(\Q$string\E)/$bold_c . $1 . $default_c/ei;
|
||||||
}
|
}
|
||||||
print " $entry->{left}$entry->{right}\n";
|
printf $fmt, $entry->{left}, $entry->{right};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,6 +669,6 @@ browser, what is not prohibited. At least not today.
|
|||||||
|
|
||||||
=head1 VERSION
|
=head1 VERSION
|
||||||
|
|
||||||
This is the manpage for B<leo> version B<1.41>.
|
This is the manpage for B<leo> version B<1.42>.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|||||||
Reference in New Issue
Block a user