/[Frey]/trunk/lib/Frey/Editor.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Frey/Editor.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 617 - (show annotations)
Sat Nov 29 15:05:55 2008 UTC (15 years, 4 months ago) by dpavlin
File size: 837 byte(s)
use xdotool to switch between termnial and firefox screen (super+Tab)

1 package Frey::Editor;
2 use Moose;
3
4 extends 'Frey::ClassLoader';
5
6 =head1 DESCRIPTION
7
8 Support for local editor invocation from web
9
10 <a target="editor" href="/editor+$path+$line">$class</a>
11
12 =head2 url
13
14 $path =~ $editor->url_regex
15
16 =cut
17
18 sub url_regex { qr{/editor\+?(.+?)\+(\d+)} }
19
20 =head2 command
21
22 my $system = $editor->command( $path );
23
24 =cut
25
26 sub switch_screen {
27 my $cmd = 'xdotool key super+Tab';
28 warn "# switch_screen $cmd";
29 system $cmd;
30 }
31
32 sub command {
33 my ( $self, $url ) = @_;
34 $url =~ url_regex;
35 my ( $path, $line ) = ( $1, $2 );
36 # FIXME SECURITY path verification for $path
37 my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
38 $path = $self->class_path( $path ) || $path if ! -e $path;
39 my $cmd = "$editor $path +$line";
40 warn "# $url -> system $cmd";
41 $self->switch_screen;
42 system $cmd;
43 $self->switch_screen;
44 }
45
46 1;

  ViewVC Help
Powered by ViewVC 1.1.26