Scripts Menu ReplaceAllText Causes Editor to Break?
Scripts Menu ReplaceAllText Causes Editor to Break?
- Subject: Scripts Menu ReplaceAllText Causes Editor to Break?
- From: Jerry Krinock <email@hidden>
- Date: Fri, 23 Jun 2006 14:08:26 -0700
- Thread-topic: Scripts Menu ReplaceAllText Causes Editor to Break?
I wrote two perl scripts and added them to Xcode's Scripts menu. The first
script adds an NSLog printing "DebugLog:" followed by the character position
at the cursor location. The second "cleanup" script removes all such lines
which were previously added by the first script. Very handy for lazy,
high-level Cocoa programmers.
They work fine as long as I don't leave any of these DebugLog statements in
and close the project, then open it later. If I do that, and then later run
the cleanup script,
1. None of my DebugLogs get cleaned up.
2. The I-beam cursor no longer appears in this file.
3. The delete key no longer works in this file.
4. Possibly other issues.
To make a long story short, the editor is broken for this file, and to get
it back I have to close the file/project (I'm not sure which since I'm
all-in-one) and re-open it. To avoid recurrence, I must clean up my
DebugLogs "manually", i.e. do not use my cleanup script.
I added a section to my cleanup script to write the file being edited out to
another test file, and that works fine. So, apparently the problem is with:
print $outputString ;
which should replace all the text in the file being edited, since I have so
routed stdout by stating PBXOutput=ReplaceAllText.
Am I doing something wrong, or is this a bug or a feature? Very
strange....Xcode seems to have some memory between editing sessions? If I
look at those DebugLog lines in BBEdit, they look like the plain 'ol ASCII
text that they're supposed to be.
Jerry Krinock
##### SCRIPT FOR ADDING A DEBUG NSLOG AT CURSOR ##############
#! /usr/bin/perl -w
#
# -- PB User Script Info --
# %%%{PBXName=Add Debug NSLog At Cursor}%%%
# %%%{PBXInput=None}%%%
# %%%{PBXOutput=InsertAfterSelection}%%%
# %%%{PBXKeyEquivalent=@~d}%%%
#
my $logLine = "NSLog(@\"DebugLog: %%%{PBXSelectionStart}%%%\") ;\n";
print $logLine;
##### CLEANUP SCRIPT FOR REMOVING DEBUG NSLOGS #################
#! /usr/bin/perl -w
#
# -- PB User Script Info --
# %%%{PBXName=Remove All Debug NSLogs In File}%%%
# %%%{PBXInput=AllText}%%%
# %%%{PBXOutput=ReplaceAllText}%%%
# %%%{PBXKeyEquivalent=@~$d}%%%
#
my $outputString = "";
my @selection = <STDIN>; # read the file from standard input
foreach my $line (@selection) {
if($line !~ /DebugLog/) { # if a line does not contain "DebugLog"
$outputString .= $line ; # concatenate it onto the output
}
}
print $outputString ;
# Normally, that's the end of the script
# For script debugging, print $outputString to another file...
my $testFilePathName = "/Users/jk/Documents/Uploads/001Junk.txt" ;
open (FILE,">>$testFilePathName") ;
print FILE "$outputString" ;
close (FILE);
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden