… | |
… | |
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 | |