• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
PBXOutput=ReplaceSelection question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PBXOutput=ReplaceSelection question


  • Subject: PBXOutput=ReplaceSelection question
  • From: Cem Karan <email@hidden>
  • Date: Mon, 10 Apr 2006 09:11:41 -0400

I've got a simple python user script that I'm having trouble getting to behave exactly as I want. Here is the script:

---------------------------- Start ------------------
#! /usr/bin/python
# -*- coding: utf-8 -*-

# -- PB User Script Info --
# %%%{PBXName=Wrap Selection}%%%
# %%%{PBXInput=Selection}%%%
# %%%{PBXOutput=ReplaceSelection}%%%
# %%%{PBXKeyEquivalent=}%%%
# That is the F6 function key above; apologies if it
# gets messed up in the mailing.

import textwrap
import re

whitespacePatternMatcher = re.compile(r"[\s]*")
stringToWrap = """%%%{PBXSelectedText}%%%"""

whitespace = whitespacePatternMatcher.match(stringToWrap).group()

myWrapper = textwrap.TextWrapper()
myWrapper.initial_indent = ""
myWrapper.subsequent_indent = whitespace
myWrapper.width = 80
myWrapper.fix_sentence_endings = True

outputString = myWrapper.fill(stringToWrap)

print outputString,
---------------------------- End --------------------

The problem is that when I replace the text, I always end up with an extra newline at the end. I can't tell if this is because XCode is throwing a newline in when it shouldn't, or if its a script problem. When I try to remove the last character from the wrapped string before printing, I end up missing characters rather than remove the newline, so I'm leaning towards XCode doing something funky, but I'd like either confirmation, or a note saying how to fix this before I file a bug.

Thanks,
Cem Karan _______________________________________________
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


  • Follow-Ups:
    • Re: PBXOutput=ReplaceSelection question
      • From: James Bucanek <email@hidden>
  • Prev by Date: Re: Simple Question
  • Next by Date: Re: A Note on your ADC Confidentiality Agreement
  • Previous by thread: Re: Simple Question
  • Next by thread: Re: PBXOutput=ReplaceSelection question
  • Index(es):
    • Date
    • Thread