Mercurial > my-enso-commands
comparison my-enso-commands.py @ 6:c41c4896c97e
upload image cmd now accepts more image types in clipboard, changed cmd_monospace to use tt instead of pre.
| author | Atul Varma <varmaa@toolness.com> |
|---|---|
| date | Wed, 20 Aug 2008 11:10:05 -0700 |
| parents | 56d44190362e |
| children | 41bc59775872 |
comparison
equal
deleted
inserted
replaced
| 5:56d44190362e | 6:c41c4896c97e |
|---|---|
| 56 | 56 |
| 57 def _get_clipboard_img_datafile(): | 57 def _get_clipboard_img_datafile(): |
| 58 import AppKit | 58 import AppKit |
| 59 | 59 |
| 60 pb = AppKit.NSPasteboard.generalPasteboard() | 60 pb = AppKit.NSPasteboard.generalPasteboard() |
| 61 tiffbytes = None | |
| 61 if pb.availableTypeFromArray_([AppKit.NSTIFFPboardType]): | 62 if pb.availableTypeFromArray_([AppKit.NSTIFFPboardType]): |
| 62 bytes = pb.dataForType_(AppKit.NSTIFFPboardType).bytes() | 63 tiffbytes = pb.dataForType_(AppKit.NSTIFFPboardType).bytes() |
| 63 datafile = StringIO(str(bytes)) | 64 elif pb.availableTypeFromArray_([AppKit.NSPICTPboardType]): |
| 64 return datafile | 65 img = AppKit.NSImage.alloc().initWithPasteboard_(pb) |
| 65 else: | 66 tiffbytes = img.TIFFRepresentation().bytes() |
| 66 return None | 67 |
| 68 if tiffbytes: | |
| 69 return StringIO(str(tiffbytes)) | |
| 70 return None | |
| 67 | 71 |
| 68 def image_command(func): | 72 def image_command(func): |
| 69 def wrapper(ensoapi): | 73 def wrapper(ensoapi): |
| 70 import Image | 74 import Image |
| 71 | 75 |
| 199 def cmd_italics(ensoapi, text): | 203 def cmd_italics(ensoapi, text): |
| 200 return "<i>%s</i>" % text | 204 return "<i>%s</i>" % text |
| 201 | 205 |
| 202 @htmlifier | 206 @htmlifier |
| 203 def cmd_monospace(ensoapi, text): | 207 def cmd_monospace(ensoapi, text): |
| 204 return "<pre>%s</pre>" % text | 208 return "<tt>%s</tt>" % text |
| 205 | 209 |
| 206 def cmd_normalize(ensoapi): | 210 def cmd_normalize(ensoapi): |
| 207 normal_template = "<span style=\"font-weight: normal;\">%s</span>" | 211 normal_template = "<span style=\"font-weight: normal;\">%s</span>" |
| 208 seldict = ensoapi.get_selection() | 212 seldict = ensoapi.get_selection() |
| 209 text = seldict.get("text", "") | 213 text = seldict.get("text", "") |
