line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TabAwareEditor; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: TabAwareEditor.pm |
11
|
|
|
|
|
|
|
# Description: Use the TabConverter to fix characters |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 01/10/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 01/10/2005 Wanted to apply this to Javascript files |
17
|
|
|
|
|
|
|
# 01/10/2005 Added method: run |
18
|
|
|
|
|
|
|
# 15/10/2005 Created test file: TabAwareEditorTest.tpm |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################### |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
11888
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use Goo::Object; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
25
|
1
|
|
|
1
|
|
5
|
use Goo::TextEditor; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
20
|
|
26
|
1
|
|
|
1
|
|
6
|
use Goo::TabConverter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
24
|
|
27
|
1
|
|
|
1
|
|
6
|
use Goo::ThereDocManager; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
5
|
use base qw(Goo::Object); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
275
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# run - edit a file |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
############################################################################### |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub run { |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
0
|
|
|
my ($this, $thing, $line_number) = @_; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
while (1) { |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# edit text |
46
|
0
|
|
|
|
|
|
Goo::TextEditor::edit($thing->get_full_path(), $line_number); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $new_lines; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
foreach my $line (Goo::FileUtilities::getFileAsLines($thing->get_full_path())) { |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
$new_lines .= Goo::TabConverter::tabs_to_spaces($line); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# write tab-adjusted file |
57
|
0
|
|
|
|
|
|
Goo::FileUtilities::writeFile($thing->get_full_path(), $new_lines); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my ($theredoc_line_number, $target_thing, $target_action) = |
60
|
|
|
|
|
|
|
Goo::ThereDocManager->new()->process($thing->get_full_path()); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Prompter::notify("------------ $theredoc_line_number, $target_thing, $target_action"); |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
last unless ($target_thing); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# switch to this Thing |
67
|
0
|
|
|
|
|
|
$target_thing->do_action($target_action); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# return to the originating line |
70
|
0
|
|
|
|
|
|
$line_number = $theredoc_line_number; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
TabAwareEditor - Use the TabConverter to fix characters |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use TabAwareEditor; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Wrap an external editor like vi or nano. Replace tab characters with four space characters as |
93
|
|
|
|
|
|
|
per Damian Conway's "Perl Best Practices". |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=over |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item run |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
call an external editor. Replace tabs with four spaces. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SEE ALSO |
110
|
|
|
|
|
|
|
|