1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
use strict;
use warnings;
use constant GEOMETRY_WIDTH => 0;
use constant GEOMETRY_HEIGHT => 1;
use constant GEOMETRY_X => 2;
use constant GEOMETRY_Y => 3;
my $geom = "800x600-750-1010";
print "'$geom' liefert '", join(", ", parse_geometry_string($geom)), "'.\n";
sub parse_geometry_string {
my $geometry = shift;
my @extends = (0, 0, 0, 0);
if ($geometry =~ /([-+]?\d+)x([-+]?\d+)/) {
$extends[GEOMETRY_WIDTH] = $1;
$extends[GEOMETRY_HEIGHT] = $2;
}
if ($geometry =~ /[-+]([-+]?\d+)[-+]([-+]?\d+)/) {
$extends[GEOMETRY_X] = $1;
$extends[GEOMETRY_Y] = $2;
}
@extends;
}
=>
'800x600-750-1010' liefert '800, 600, 750, 1010'.
Richtig wäre aber, entweder die Bildschirmgröße zu bestimmen und die negativen Werte von den Ausdehnungen abzuziehen, oder aber die negativen Werte als solche weiter zu reichen.
Die negativen Werte zu bekommen, erreicht man z.B. so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
use strict;
use warnings;
use constant GEOMETRY_WIDTH => 0;
use constant GEOMETRY_HEIGHT => 1;
use constant GEOMETRY_X => 2;
use constant GEOMETRY_Y => 3;
my $geom = "800x600-750-1010";
print "'$geom' liefert '", join(", ", parse_geometry_string2($geom)), "'.\n";
sub parse_geometry_string {
my $geometry = shift;
my @extends = (0, 0, 0, 0);
if ($geometry =~ /([-+]?\d+)x([-+]?\d+)/) {
$extends[GEOMETRY_WIDTH] = $1;
$extends[GEOMETRY_HEIGHT] = $2;
}
if ($geometry =~ /[-+]([-+]?\d+)[-+]([-+]?\d+)/) {
$extends[GEOMETRY_X] = $1;
$extends[GEOMETRY_Y] = $2;
}
@extends;
}
sub parse_geometry_string2 {
my $geometry = shift;
my @extends = (0, 0, 0, 0);
if ($geometry =~ /([-+]?\d+)x([-+]?\d+)/) {
$extends[GEOMETRY_WIDTH] = $1;
$extends[GEOMETRY_HEIGHT] = $2;
}
if ($geometry =~ /([-+]\d+)([-+]\d+)/) {
$extends[GEOMETRY_X] = $1;
$extends[GEOMETRY_Y] = $2;
}
@extends;
}
=>
'800x600-750-1010' liefert '800, 600, -750, -1010'.
Will man den anderen Weg beschreiten, bekommt man die Auflösung so heraus:
my $screenHeight = $mw->screenheight();
my $screenWidth = $mw->screenwidth();
\n\n
<!--EDIT|Crian|1086706900-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;
use strict; use warnings; Link zu meiner Perlseite