… | |
… | |
1976 | } elsif ($sym == CFPlus::SDLK_LEFT) { |
1976 | } elsif ($sym == CFPlus::SDLK_LEFT) { |
1977 | --$self->{cursor} if $self->{cursor}; |
1977 | --$self->{cursor} if $self->{cursor}; |
1978 | } elsif ($sym == CFPlus::SDLK_RIGHT) { |
1978 | } elsif ($sym == CFPlus::SDLK_RIGHT) { |
1979 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
1979 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
1980 | } elsif ($sym == CFPlus::SDLK_HOME) { |
1980 | } elsif ($sym == CFPlus::SDLK_HOME) { |
|
|
1981 | # what a hack |
1981 | $self->{cursor} = 0; |
1982 | $self->{cursor} = |
|
|
1983 | (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ |
|
|
1984 | ? length $1 |
|
|
1985 | : 0; |
1982 | } elsif ($sym == CFPlus::SDLK_END) { |
1986 | } elsif ($sym == CFPlus::SDLK_END) { |
|
|
1987 | # uh, again |
|
|
1988 | $self->{cursor} = |
|
|
1989 | (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ |
1983 | $self->{cursor} = length $text; |
1990 | ? $self->{cursor} + length $1 |
|
|
1991 | : length $self->{text}; |
1984 | } elsif ($uni == 21) { # ctrl-u |
1992 | } elsif ($uni == 21) { # ctrl-u |
1985 | $text = ""; |
1993 | $text = ""; |
1986 | $self->{cursor} = 0; |
1994 | $self->{cursor} = 0; |
1987 | } elsif ($uni == 27) { |
1995 | } elsif ($uni == 27) { |
1988 | $self->emit ('escape'); |
1996 | $self->emit ('escape'); |
1989 | } elsif ($uni >= 0x20 || $uni == 0x0d) { |
1997 | } elsif ($uni == 0x0d) { |
|
|
1998 | substr $text, $self->{cursor}++, 0, "\012"; |
|
|
1999 | } elsif ($uni >= 0x20) { |
1990 | substr $text, $self->{cursor}++, 0, chr $uni; |
2000 | substr $text, $self->{cursor}++, 0, chr $uni; |
1991 | } else { |
2001 | } else { |
1992 | return 0; |
2002 | return 0; |
1993 | } |
2003 | } |
1994 | |
2004 | |
… | |
… | |
2698 | sub invoke_mouse_wheel { |
2708 | sub invoke_mouse_wheel { |
2699 | my ($self, $ev) = @_; |
2709 | my ($self, $ev) = @_; |
2700 | |
2710 | |
2701 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
2711 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
2702 | |
2712 | |
|
|
2713 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
|
|
2714 | |
2703 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * 0.2); |
2715 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
2704 | |
2716 | |
2705 | ! ! $delta |
2717 | ! ! $delta |
2706 | } |
2718 | } |
2707 | |
2719 | |
2708 | sub update { |
2720 | sub update { |
… | |
… | |
2818 | #font => default_font |
2830 | #font => default_font |
2819 | @_, |
2831 | @_, |
2820 | |
2832 | |
2821 | layout => (new CFPlus::Layout), |
2833 | layout => (new CFPlus::Layout), |
2822 | par => [], |
2834 | par => [], |
|
|
2835 | max_par => 0, |
2823 | height => 0, |
2836 | height => 0, |
2824 | children => [ |
2837 | children => [ |
2825 | (new CFPlus::UI::Empty expand => 1), |
2838 | (new CFPlus::UI::Empty expand => 1), |
2826 | (new CFPlus::UI::Slider vertical => 1), |
2839 | (new CFPlus::UI::Slider vertical => 1), |
2827 | ], |
2840 | ], |
… | |
… | |
2950 | wrapped => 1, |
2963 | wrapped => 1, |
2951 | }; |
2964 | }; |
2952 | |
2965 | |
2953 | $self->add (@{ $para->{widget} }) if @{ $para->{widget} }; |
2966 | $self->add (@{ $para->{widget} }) if @{ $para->{widget} }; |
2954 | push @{$self->{par}}, $para; |
2967 | push @{$self->{par}}, $para; |
|
|
2968 | } |
|
|
2969 | |
|
|
2970 | if (my $max = $self->{max_par}) { |
|
|
2971 | shift @{$self->{par}} while @{$self->{par}} > $max; |
2955 | } |
2972 | } |
2956 | |
2973 | |
2957 | $self->{need_reflow}++; |
2974 | $self->{need_reflow}++; |
2958 | $self->update; |
2975 | $self->update; |
2959 | } |
2976 | } |