After I had finished poking around with the ae* modules and gensuitemodule.py, I made a diff and applied it to a fresh CVS checkout on my Boss' laptop, since he was eager to play with the code I have been generating. (Side note: I figured out how to use diff and patch; "cvs diff | mydiff.diff" on one machine and "patch -p0
The patch applied quite easily, and soon enough I was controlling InDesign from Python. I thought to myself, "if only you could actually use the editor in the IDE..." Jack is working the political machinery on Python-dev trying to get his universal newlines patch accepted, and once he does, none of this will be required, but meanwhile, how about this hack...
When you open a file in the IDE, it gets read into a string. Check to see what kind of newlines the file has, and keep a record of it. Then, convert every newline in the string to \r.
When you save to disk, convert \r to the original newline character.
Ugly as hell, but it works! And isn't that really all that matters to most people?
While I was at it, I added the Advanced Editor from here, as well. All I needed to do was add "from Carbon " in front of all of the toolbox import statements.
Good things are happening in the world of UNIX/MacPython integration...
Here's a screenshot of the MacPython IDE opening and editing files with UNIX line endings, with the Advanced Editor patch applied.
No comments:
Post a Comment