mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-02 11:19:22 +02:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57900025aa | |||
| 0d78cd385f | |||
| dd3bc8209b | |||
| 134218f290 | |||
| 998888524e | |||
| 315c8bd311 | |||
| 05e488d369 | |||
| dc8cacd018 | |||
| 6ea9b4ad26 | |||
| be450c3825 | |||
| f595588011 | |||
| 4a8c2cfc56 | |||
| c42b9c670e | |||
| 32f12120fc | |||
| abb224eaab | |||
| 68f4341bc1 | |||
| 970d2a871e | |||
| e32eccfe62 | |||
| 9bc01ebb95 | |||
| ac15324228 | |||
| 8def26a0f5 | |||
| 75e3ad0199 | |||
| f29a82dcd0 | |||
| 6f62fed349 |
+1
-1
@@ -3,7 +3,7 @@ language: c
|
||||
os:
|
||||
- osx
|
||||
|
||||
osx_image: xcode7.1
|
||||
osx_image: xcode7.2
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<!-- When adding support for a new file type:
|
||||
1. Add entry to CFBundleDocumentTypes
|
||||
2. Add entry to UTExportedTypeDeclarations below (for Quick Look)
|
||||
3. Add entry to icons/make_icons.py script (for document icon)
|
||||
|
||||
For a list of UTIs, see
|
||||
http://developer.apple.com/documentation/Carbon/Conceptual/
|
||||
@@ -1256,7 +1255,7 @@
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>87</string>
|
||||
<string>88</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
|
||||
@@ -1261,6 +1261,12 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGPoint *positions,
|
||||
CFRelease(fallback);
|
||||
}
|
||||
|
||||
if (glyphs == g) {
|
||||
// No valid chars in the glyphs. Exit from the possible infinite
|
||||
// recursive call.
|
||||
break;
|
||||
}
|
||||
|
||||
chars = c;
|
||||
glyphs = g;
|
||||
positions = p;
|
||||
|
||||
+1
-8
@@ -162,18 +162,11 @@ be in when executing these commands):
|
||||
1. Configure Vim (call "./configure --help" to see a list of flags)
|
||||
src/$ ./configure
|
||||
|
||||
2. Generate document icons (OPTIONAL)
|
||||
src/MacVim/icons$ make getenvy
|
||||
src/MacVim/icons$ make all
|
||||
|
||||
3. Build
|
||||
2. Build
|
||||
src/$ make
|
||||
|
||||
The application bundle can be found inside "src/MacVim/build/Release".
|
||||
|
||||
If step 2 is skipped a generic document icon will be used for all file types.
|
||||
It is also possible to download the document icons if this step fails.
|
||||
|
||||
|
||||
Bjorn Winckler <bjorn.winckler@gmail.com>
|
||||
March 21, 2011
|
||||
|
||||
@@ -2,44 +2,7 @@
|
||||
|
||||
OUTDIR ?= .
|
||||
|
||||
# This script is called during the build phase with OUTDIR set to the Resources
|
||||
# folder of the app bundle. The default action is to simply copy all files
|
||||
# named MacVim-*.icns to OUTDIR.
|
||||
#
|
||||
# The files in version control are all links to the MacVim-generic.icns file.
|
||||
# In order to get prettier document icons, call "make all" in this folder
|
||||
# before building. This will call the document generation program which
|
||||
# overwrites the MacVim-*.icns links with actual icons (see make_icons.py).
|
||||
#
|
||||
# The Envy Code R font can be used to render small icons that are more legible.
|
||||
# In order to use ECR, call "make getenvy" before calling "make all". This
|
||||
# step requires an internet connection.
|
||||
|
||||
$(OUTDIR)/MacVim-generic.icns:
|
||||
cp -pR MacVim-*.icns "$(OUTDIR)"/
|
||||
|
||||
all: make_icons.py vim-noshadow-512.png loadfont.so
|
||||
rm -f MacVim-*.icns
|
||||
$(MAKE) -C makeicns
|
||||
/usr/bin/python make_icons.py "$(OUTDIR)"
|
||||
|
||||
loadfont.so: loadfont.c
|
||||
/usr/bin/python setup.py install --install-lib .
|
||||
|
||||
getenvy: Envy\ Code\ R\ Bold.ttf
|
||||
|
||||
Envy\ Code\ R\ Bold.ttf: EnvyCodeR.zip
|
||||
unzip -jo EnvyCodeR.zip
|
||||
# unzip uses the file date from the zip file. Change the file date to
|
||||
# "now", so that the zip is not unzipped in every `make` run.`
|
||||
touch Envy\ Code\ R\ Bold.ttf
|
||||
|
||||
ENVYCODE_URL=http://download.damieng.com/fonts/original/EnvyCodeR-PR7.zip
|
||||
EnvyCodeR.zip:
|
||||
curl ${ENVYCODE_URL} --location -o EnvyCodeR.zip
|
||||
|
||||
clean:
|
||||
$(MAKE) -C makeicns clean
|
||||
rm -f "$(OUTDIR)"/MacVim-*.icns loadfont.so *.pyc \
|
||||
EnvyCodeR.zip *.ttf *.reg *.txt
|
||||
rm -rf *.egginfo build # Created by setup.py
|
||||
all:
|
||||
|
||||
@@ -1,616 +0,0 @@
|
||||
from Foundation import *
|
||||
from AppKit import *
|
||||
|
||||
import itertools
|
||||
import math
|
||||
import operator
|
||||
import os
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
|
||||
# Resources
|
||||
DEFAULT_BACKGROUND = '/System/Library/CoreServices/CoreTypes.bundle/' + \
|
||||
'Contents/Resources/GenericDocumentIcon.icns' # might require leopard?
|
||||
|
||||
|
||||
# Cache both images and background renderers globally
|
||||
imageCache = {}
|
||||
bgCache = {}
|
||||
|
||||
|
||||
# Make us not crash
|
||||
# http://www.cocoabuilder.com/archive/message/cocoa/2008/8/6/214964
|
||||
NSApplicationLoad()
|
||||
|
||||
|
||||
class Surface(object):
|
||||
"""Represents a simple bitmapped image."""
|
||||
|
||||
def __init__(self, *p, **kw):
|
||||
if not 'premultiplyAlpha' in kw:
|
||||
kw['premultiplyAlpha'] = True
|
||||
if len(p) == 1 and isinstance(p[0], NSBitmapImageRep):
|
||||
self.bitmapRep = p[0]
|
||||
elif len(p) == 2 and isinstance(p[0], int) and isinstance(p[1], int):
|
||||
format = NSAlphaFirstBitmapFormat
|
||||
if not kw['premultiplyAlpha']:
|
||||
format += NSAlphaNonpremultipliedBitmapFormat
|
||||
self.bitmapRep = NSBitmapImageRep.alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
|
||||
None, p[0], p[1], 8, 4, True, False, NSDeviceRGBColorSpace,
|
||||
format, 0, 0)
|
||||
|
||||
if not hasattr(self, 'bitmapRep') or not self.bitmapRep:
|
||||
raise Exception('Failed to create surface: ' + str(p))
|
||||
|
||||
def size(self):
|
||||
return map(int, self.bitmapRep.size()) # cocoa returns floats. cocoa ftw
|
||||
|
||||
def data(self):
|
||||
"""Returns data in ARGB order (on intel, at least)."""
|
||||
r = self.bitmapRep
|
||||
if (r.bitmapFormat() & ~NSAlphaFirstBitmapFormat !=
|
||||
NSAlphaNonpremultipliedBitmapFormat) or \
|
||||
r.bitsPerPixel() != 32 or \
|
||||
r.isPlanar() or \
|
||||
r.samplesPerPixel() != 4:
|
||||
raise Exception("Unsupported image format")
|
||||
return self.bitmapRep.bitmapData()
|
||||
|
||||
def rgbaIndices(self):
|
||||
r = self.bitmapRep
|
||||
if r.bitmapFormat() & NSAlphaFirstBitmapFormat != 0:
|
||||
return 1, 2, 3, 0
|
||||
else:
|
||||
return 0, 1, 2, 3
|
||||
|
||||
def save(self, filename):
|
||||
"""Saves image as png file."""
|
||||
self.bitmapRep.representationUsingType_properties_(NSPNGFileType, None) \
|
||||
.writeToFile_atomically_(filename, True)
|
||||
|
||||
def draw(self):
|
||||
self.bitmapRep.draw()
|
||||
|
||||
def context(self):
|
||||
# Note: Cocoa only supports contexts with premultiplied alpha
|
||||
return NSGraphicsContext.graphicsContextWithBitmapImageRep_(self.bitmapRep)
|
||||
|
||||
def copy(self):
|
||||
return Surface(self.bitmapRep.copy())
|
||||
|
||||
|
||||
class Image(object):
|
||||
"""Represents an image that can consist of several Surfaces."""
|
||||
|
||||
def __init__(self, param):
|
||||
if isinstance(param, str):
|
||||
self.image = NSImage.alloc().initWithContentsOfFile_(param)
|
||||
elif isinstance(param, Surface):
|
||||
self.image = NSImage.alloc().initWithSize_( param.size() )
|
||||
self.image.addRepresentation_(param.bitmapRep)
|
||||
|
||||
if not self.image:
|
||||
raise Exception('Failed to load image: ' + str(param))
|
||||
|
||||
def surfaceOfSize(self, w, h):
|
||||
"""Returns an ARGB, non-premultiplied surface of size w*h or throws."""
|
||||
r = None
|
||||
for rep in self.image.representations():
|
||||
# Cocoa reports fraction widths for pngs (wtf?!), so use round()
|
||||
if map(lambda x: int(round(x)), rep.size()) == [w, h]:
|
||||
r = rep
|
||||
break
|
||||
|
||||
# XXX: Resample in this case? That'd make the program easier to use, but
|
||||
# can silently create blurry backgrounds. Since this happens with
|
||||
# the app icon anyways, this might not be a huge deal?
|
||||
if not r:
|
||||
raise Exception('Unsupported size %dx%d', w, h)
|
||||
return Surface(r)
|
||||
|
||||
def blend(self):
|
||||
self.compositeInRect( ((0, 0), self.image.size()) )
|
||||
|
||||
def compositeInRect(self, r, mode=NSCompositeSourceOver):
|
||||
self.image.drawInRect_fromRect_operation_fraction_(r, NSZeroRect,
|
||||
mode, 1.0)
|
||||
|
||||
def sizes(self):
|
||||
s = set()
|
||||
for rep in self.image.representations():
|
||||
s.add(tuple(map(lambda x: int(round(x)), rep.size())))
|
||||
return s
|
||||
|
||||
|
||||
class Context(object):
|
||||
# Tiger has only Python2.3, so we can't use __enter__ / __exit__ for this :-(
|
||||
|
||||
def __init__(self, surface):
|
||||
NSGraphicsContext.saveGraphicsState()
|
||||
c = surface.context()
|
||||
c.setShouldAntialias_(True);
|
||||
c.setImageInterpolation_(NSImageInterpolationHigh);
|
||||
NSGraphicsContext.setCurrentContext_(c)
|
||||
|
||||
def done(self):
|
||||
NSGraphicsContext.restoreGraphicsState()
|
||||
|
||||
|
||||
class SplittableBackground(object):
|
||||
|
||||
def __init__(self, unsplitted, shouldSplit=True):
|
||||
self.unsplitted = unsplitted
|
||||
self.shouldSplit = shouldSplit
|
||||
self.ground = {}
|
||||
self.shadow = {}
|
||||
|
||||
def rawGroundAtSize(self, s):
|
||||
return self.unsplitted.surfaceOfSize(s, s)
|
||||
|
||||
def groundAtSize(self, s):
|
||||
if not self.shouldSplit:
|
||||
return self.rawGroundAtSize(s)
|
||||
self._performSplit(s)
|
||||
return self.ground[s]
|
||||
|
||||
def shadowAtSize(self, s):
|
||||
if not self.shouldSplit:
|
||||
return None
|
||||
self._performSplit(s)
|
||||
return self.shadow[s]
|
||||
|
||||
def _performSplit(self, s):
|
||||
if s in self.ground:
|
||||
assert s in self.shadow
|
||||
return
|
||||
assert s not in self.shadow
|
||||
ground, shadow = splitGenericDocumentIcon(self.unsplitted, s)
|
||||
self.ground[s] = ground
|
||||
self.shadow[s] = shadow
|
||||
|
||||
|
||||
class BackgroundRenderer(object):
|
||||
|
||||
def __init__(self, bg, icon=None, r={}):
|
||||
self.bgRenderer = bg
|
||||
self.icon = icon
|
||||
self.cache = {}
|
||||
self.rect = r
|
||||
|
||||
def drawIcon(self, s):
|
||||
if not self.icon:
|
||||
return
|
||||
|
||||
assert s in [16, 32, 128, 256, 512]
|
||||
a = list(self.rect[s])
|
||||
|
||||
# convert from `flow` coords to cocoa
|
||||
a[2] = -a[2] # mirror y
|
||||
|
||||
w, h = s*a[1], s*a[3]
|
||||
self.icon.compositeInRect( (((s-w)/2 + a[0], (s-h)/2 + a[2]), (w, h)) )
|
||||
|
||||
def drawAtSize(self, s):
|
||||
if not self.icon:
|
||||
# No need to split the background if no icons is interleaved -- take
|
||||
# the faster code path in that case.
|
||||
self.bgRenderer.rawGroundAtSize(s).draw()
|
||||
return
|
||||
|
||||
self.bgRenderer.groundAtSize(s).draw()
|
||||
self.drawIcon(s)
|
||||
if self.bgRenderer.shouldSplit:
|
||||
# shadow needs to be composited, so it needs to be in an image
|
||||
Image(self.bgRenderer.shadowAtSize(s)).blend()
|
||||
|
||||
def backgroundAtSize(self, s):
|
||||
if not s in self.cache:
|
||||
result = Surface(s, s)
|
||||
context = Context(result)
|
||||
self.drawAtSize(s)
|
||||
context.done()
|
||||
self.cache[s] = result
|
||||
return self.cache[s]
|
||||
|
||||
|
||||
def splitGenericDocumentIcon(img, s):
|
||||
"""Takes the generic document icon and splits it into a background and a
|
||||
shadow layer. For the 32x32 and 16x16 variants, the white pixels of the page
|
||||
curl are hardcoded into the otherwise transparent shadow layer."""
|
||||
|
||||
w, h = s, s
|
||||
r = img.surfaceOfSize(w, h)
|
||||
bps = 4*w
|
||||
data = r.data()
|
||||
dr, dg, db, da = r.rgbaIndices()
|
||||
|
||||
ground = Surface(w, h, premultiplyAlpha=False)
|
||||
shadow = Surface(w, h, premultiplyAlpha=False)
|
||||
|
||||
grounddata = ground.data()
|
||||
shadowdata = shadow.data()
|
||||
|
||||
for y in xrange(h):
|
||||
for x in xrange(w):
|
||||
idx = y*bps + 4*x
|
||||
ia = data[idx + da]
|
||||
ir = data[idx + dr]
|
||||
ig = data[idx + dg]
|
||||
ib = data[idx + db]
|
||||
if ia != chr(255):
|
||||
# buffer objects don't support slice assignment :-(
|
||||
grounddata[idx] = ia
|
||||
grounddata[idx + 1] = ir
|
||||
grounddata[idx + 2] = ig
|
||||
grounddata[idx + 3] = ib
|
||||
shadowdata[idx] = chr(0)
|
||||
shadowdata[idx + 1] = chr(0)
|
||||
shadowdata[idx + 2] = chr(0)
|
||||
shadowdata[idx + 3] = chr(0)
|
||||
continue
|
||||
|
||||
assert ir == ig == ib
|
||||
grounddata[idx] = chr(255)
|
||||
grounddata[idx + 1] = chr(255)
|
||||
grounddata[idx + 2] = chr(255)
|
||||
grounddata[idx + 3] = chr(255)
|
||||
shadowdata[idx] = chr(255 - ord(ir))
|
||||
shadowdata[idx + 1] = chr(0)
|
||||
shadowdata[idx + 2] = chr(0)
|
||||
shadowdata[idx + 3] = chr(0)
|
||||
|
||||
# Special-case 16x16 and 32x32 cases: Make some pixels on the fold white.
|
||||
# Ideally, I could make the fold whiteish in all variants, but I can't.
|
||||
whitePix = { 16: [(10, 2), (10, 3), (11, 3), (10, 4), (11, 4), (12, 4)],
|
||||
32: [(21, 4), (21, 5), (22, 5), (21, 6), (22, 6), (23, 6)]}
|
||||
if (w, h) in [(16, 16), (32, 32)]:
|
||||
for x, y in whitePix[w]:
|
||||
idx = y*bps + 4*x
|
||||
shadowdata[idx] = chr(255)
|
||||
shadowdata[idx + 1] = chr(255)
|
||||
shadowdata[idx + 2] = chr(255)
|
||||
shadowdata[idx + 3] = chr(255)
|
||||
|
||||
return ground, shadow
|
||||
|
||||
|
||||
class TextRenderer(object):
|
||||
|
||||
def __init__(self):
|
||||
self.cache = {}
|
||||
|
||||
def attribsAtSize(self, s):
|
||||
if s not in self.cache:
|
||||
self.cache[s] = self._attribsAtSize(s)
|
||||
return self.cache[s]
|
||||
|
||||
def centeredStyle(self):
|
||||
style = NSMutableParagraphStyle.new()
|
||||
style.setParagraphStyle_(NSParagraphStyle.defaultParagraphStyle())
|
||||
style.setAlignment_(NSCenterTextAlignment)
|
||||
return style
|
||||
|
||||
def _attribsAtSize(self, s):
|
||||
# This looks not exactly like the font on Preview.app's document icons,
|
||||
# but I believe that's because Preview's icons are drawn by Photoshop,
|
||||
# and Adobe's font rendering is different from Apple's.
|
||||
fontname = 'LucidaGrande-Bold'
|
||||
|
||||
# Prepare text format
|
||||
fontsizes = { 512: 72.0, 256: 36.0, 128: 18.0, 32: 7.0, 16: 3.0 }
|
||||
# http://developer.apple.com/documentation/Cocoa/Conceptual/AttributedStrings/Articles/standardAttributes.html#//apple_ref/doc/uid/TP40004903
|
||||
attribs = {
|
||||
NSParagraphStyleAttributeName: self.centeredStyle(),
|
||||
NSForegroundColorAttributeName: NSColor.colorWithDeviceWhite_alpha_(
|
||||
0.34, 1),
|
||||
NSFontAttributeName: NSFont.fontWithName_size_(fontname, fontsizes[s])
|
||||
}
|
||||
|
||||
# tighten font a bit for some sizes
|
||||
if s in [256, 512]:
|
||||
attribs[NSKernAttributeName] = -1.0
|
||||
elif s == 32:
|
||||
attribs[NSKernAttributeName] = -0.25
|
||||
|
||||
if not attribs[NSFontAttributeName]:
|
||||
raise Exception('Failed to load font %s' % fontname)
|
||||
return attribs
|
||||
|
||||
def drawTextAtSize(self, text, s):
|
||||
"""Draws text `s` into the current context of size `s`."""
|
||||
|
||||
textRects = {
|
||||
512: ((0, 7), (512, 119)),
|
||||
128: ((0, 6), (128, 26.5)),
|
||||
256: ((0, 7), (256, 57)),
|
||||
16: ((1, 1), (15, 5)),
|
||||
#32: ((1, 1), (31, 9))
|
||||
}
|
||||
|
||||
attribs = self.attribsAtSize(s)
|
||||
text = NSString.stringWithString_(text)
|
||||
if s in [16, 128, 256, 512]:
|
||||
text.drawInRect_withAttributes_(textRects[s], attribs)
|
||||
elif s == 32:
|
||||
# Try to align text on pixel boundary:
|
||||
attribs = attribs.copy()
|
||||
attribs[NSParagraphStyleAttributeName] = \
|
||||
NSParagraphStyle.defaultParagraphStyle()
|
||||
ts = text.sizeWithAttributes_(attribs)
|
||||
text.drawAtPoint_withAttributes_( (math.floor((32.0-ts[0])/2) + 0.5, 1.5),
|
||||
attribs)
|
||||
|
||||
|
||||
class OfficeTextRenderer(TextRenderer):
|
||||
"""Uses Office's LucidaSans font for 32x32.
|
||||
|
||||
This font looks much better for certain strings (e.g. "PDF") but much worse
|
||||
for most others (e.g. "VIM", "JAVA") -- and office fonts are usually not
|
||||
installed. Hence, this class is better not used.
|
||||
"""
|
||||
|
||||
def _attribsAtSize(self, s):
|
||||
self.useOfficeFont = False
|
||||
attribs = TextRenderer._attribsAtSize(self, s)
|
||||
if s == 32:
|
||||
font = NSFont.fontWithName_size_('LucidaSans-Demi', 7.0)
|
||||
if font:
|
||||
attribs[NSFontAttributeName] = font
|
||||
attribs[NSKernAttributeName] = 0
|
||||
self.useOfficeFont = True
|
||||
return attribs
|
||||
|
||||
def drawTextAtSize(self, text, s):
|
||||
attribs = self.attribsAtSize(s)
|
||||
if not self.useOfficeFont or s != 32:
|
||||
TextRenderer.drawTextAtSize(self, text, s)
|
||||
return
|
||||
text = NSString.stringWithString_(text)
|
||||
text.drawInRect_withAttributes_( ((0, 1), (31, 11)), attribs)
|
||||
|
||||
|
||||
def createIcon(s, bg, textRenderer, text):
|
||||
|
||||
# Fill in background
|
||||
output = bg.backgroundAtSize(s).copy()
|
||||
|
||||
# Draw text on top of shadow
|
||||
context = Context(output)
|
||||
if s in text and text[s]:
|
||||
textRenderer.drawTextAtSize(text[s], s)
|
||||
context.done()
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def textDictFromTextList(l):
|
||||
assert 1 <= len(l) <= 3
|
||||
if len(l) == 1:
|
||||
return dict.fromkeys([16, 32, 128, 256, 512], l[0])
|
||||
elif len(l) == 2:
|
||||
return dict(zip([16, 32], 2*[l[1]]) + zip((128, 256, 512), 3*[l[0]]))
|
||||
elif len(l) == 3:
|
||||
return dict([(16, l[2]), (32, l[1])] + zip((128, 256, 512), 3*[l[0]]))
|
||||
|
||||
|
||||
def saveIcns(icons, icnsName, makeIcns='./makeicns'):
|
||||
"""Creates an icns file with several variants.
|
||||
|
||||
Params:
|
||||
icons: A dict that contains icon size as key and Surface as value.
|
||||
Valid keys are 512, 256, 128, 32, 16
|
||||
icnsname: Name of the output file
|
||||
"""
|
||||
# If IconFamily was less buggy, we could wrap it into a python module and
|
||||
# call it directly, which is about a lot faster. However, IconFamily does not
|
||||
# work with NSAlphaNonpremultipliedBitmapFormat correctly, so this has to
|
||||
# wait.
|
||||
#import IconFamily
|
||||
#typeDict = {
|
||||
#16: IconFamily.kSmall32BitData,
|
||||
#32: IconFamily.kLarge32BitData,
|
||||
#128: IconFamily.kThumbnail32BitData,
|
||||
#256: IconFamily.kIconServices256PixelDataARGB,
|
||||
#512: IconFamily.IconServices512PixelDataARGB,
|
||||
#}
|
||||
#maskDict = {
|
||||
#16: IconFamily.kSmall8BitMask,
|
||||
#32: IconFamily.kLarge8BitMask,
|
||||
#128: IconFamily.kThumbnail8BitMask,
|
||||
#}
|
||||
#output = IconFamily.IconFamily.iconFamily()
|
||||
#for s, icon in icons.items():
|
||||
#output.setIconFamilyElement_fromBitmapImageRep_(typeDict[s], icon.bitmapRep)
|
||||
#if s in maskDict:
|
||||
#output.setIconFamilyElement_fromBitmapImageRep_(
|
||||
#maskDict[s], icon.bitmapRep)
|
||||
#output.writeToFile_(icnsName)
|
||||
TMPFILE = 'docerator_tmp_%d.png'
|
||||
try:
|
||||
args = []
|
||||
for s, icon in icons.items():
|
||||
assert s in [512, 256, 128, 32, 16]
|
||||
assert icon.size() == [s, s]
|
||||
icon.save(TMPFILE % s)
|
||||
args.append('-%d %s' % (s, TMPFILE % s))
|
||||
return \
|
||||
os.system('%s %s -out %s' % (makeIcns, ' '.join(args), icnsName)) == 0
|
||||
finally:
|
||||
for s in icons:
|
||||
if os.access(TMPFILE % s, os.F_OK):
|
||||
os.remove(TMPFILE % s)
|
||||
|
||||
|
||||
def getOutname(options):
|
||||
def saneBasename(p):
|
||||
""" '/my/path/to/file.txt' -> 'file' """
|
||||
return os.path.splitext(os.path.basename(p))[0]
|
||||
textPart = 'Generic'
|
||||
if options.text:
|
||||
textPart = options.text.split(',')[0]
|
||||
if options.appicon:
|
||||
base = saneBasename(options.appicon)
|
||||
else:
|
||||
base = saneBasename(getBgName(options))
|
||||
return '%s-%s.icns' % (base, textPart)
|
||||
|
||||
|
||||
def cachedImage(filename):
|
||||
absPath = os.path.abspath(filename)
|
||||
if not absPath in imageCache:
|
||||
imageCache[absPath] = Image(absPath)
|
||||
return imageCache[absPath]
|
||||
|
||||
|
||||
def cachedBackground(img, split):
|
||||
key = (img, split)
|
||||
if not key in bgCache:
|
||||
bgCache[key] = SplittableBackground(img, shouldSplit=split)
|
||||
return bgCache[key]
|
||||
|
||||
|
||||
# taken from running flow on preview
|
||||
defaultRects = {
|
||||
16: (-0.30890000000000001, 0.4919, -1.2968, 0.4743),
|
||||
32: (-0.27810000000000001,
|
||||
0.58930000000000005,
|
||||
-2.2292999999999998,
|
||||
0.57140000000000002),
|
||||
128: (1.1774, 0.56820000000000004, -0.8246, 0.56799999999999995),
|
||||
256: (0.5917, 0.56489999999999996, -1.8994, 0.56499999999999995),
|
||||
512: (0.68700000000000006,
|
||||
0.56530000000000002,
|
||||
-4.2813999999999997,
|
||||
0.56540000000000001)
|
||||
}
|
||||
|
||||
|
||||
def getBgName(options):
|
||||
if not hasattr(options, 'background') \
|
||||
or options.background in ['default-split', 'default-unsplit']:
|
||||
return DEFAULT_BACKGROUND
|
||||
else:
|
||||
return options.background
|
||||
|
||||
|
||||
class IconGenerator(object):
|
||||
def __init__(self, options):
|
||||
if hasattr(options, 'textrenderer') and options.textrenderer:
|
||||
self.textRenderer = options.textrenderer()
|
||||
else:
|
||||
self.textRenderer = TextRenderer()
|
||||
|
||||
# Prepare input images
|
||||
splitBackground = options.background == 'default-split'
|
||||
self.bgIcon = cachedImage(getBgName(options))
|
||||
|
||||
self.testIcon = None
|
||||
if options.appicon:
|
||||
self.testIcon = cachedImage(options.appicon)
|
||||
|
||||
rects = defaultRects.copy()
|
||||
rects[16] = [ 0.0000, 0.5000, -1.0000, 0.5000] # manually, better
|
||||
if hasattr(options, 'rects'):
|
||||
rects.update(options.rects)
|
||||
|
||||
bg = cachedBackground(self.bgIcon, splitBackground)
|
||||
|
||||
if hasattr(options, 'backgroundrenderer') and options.backgroundrenderer:
|
||||
self.bgRenderer = options.backgroundrenderer(bg, self.testIcon, rects)
|
||||
else:
|
||||
self.bgRenderer = BackgroundRenderer(bg, self.testIcon, rects)
|
||||
|
||||
self.testtext = textDictFromTextList(options.text.split(','))
|
||||
|
||||
def createIconAtSize(self, s):
|
||||
return createIcon(s, self.bgRenderer, self.textRenderer, self.testtext)
|
||||
|
||||
|
||||
def iconGenerator(**kwargs):
|
||||
return IconGenerator(optsFromDict(**kwargs))
|
||||
|
||||
|
||||
def makedocicon_opts(options):
|
||||
renderer = IconGenerator(options)
|
||||
|
||||
if hasattr(options, 'sizes') and options.sizes:
|
||||
if isinstance(options.sizes, list):
|
||||
sizes = options.sizes
|
||||
else:
|
||||
sizes = map(int, options.sizes.split(','))
|
||||
else:
|
||||
sizes = renderer.bgIcon.sizes()
|
||||
if renderer.testIcon:
|
||||
sizes = sizes.intersection(renderer.testIcon.sizes())
|
||||
sizes = sorted(map(operator.itemgetter(0), sizes))
|
||||
|
||||
icons = dict([(s, renderer.createIconAtSize(s)) for s in sizes])
|
||||
|
||||
if options.debug:
|
||||
for s, icon in icons.iteritems():
|
||||
icon.save(options.debug % s)
|
||||
|
||||
if hasattr(options, 'outname') and options.outname:
|
||||
outname = options.outname
|
||||
else:
|
||||
outname = getOutname(options)
|
||||
if saveIcns(icons, outname, options.makeicns):
|
||||
print 'Wrote', outname
|
||||
else:
|
||||
print 'Failed to write %s. Make sure makeicns is in your path.' % outname
|
||||
|
||||
|
||||
def optsFromDict(**kwargs):
|
||||
options, _ = getopts().parse_args([]) # get default options
|
||||
for k in kwargs:
|
||||
setattr(options, k, kwargs[k])
|
||||
return options
|
||||
|
||||
|
||||
def makedocicon(**kwargs):
|
||||
makedocicon_opts(optsFromDict(**kwargs))
|
||||
|
||||
|
||||
def makedocicons_opts(options):
|
||||
if not hasattr(options, 'text') or not options.text:
|
||||
options.text = ['']
|
||||
texts = options.text
|
||||
for text in texts:
|
||||
options.text = text
|
||||
makedocicon_opts(options)
|
||||
|
||||
|
||||
def makedocicons(**kwargs):
|
||||
makedocicons_opts(optsFromDict(**kwargs))
|
||||
|
||||
|
||||
def getopts():
|
||||
parser = OptionParser(usage='%prog [options]', version='%prog 1.01')
|
||||
parser.add_option('--background', '--bg', default='default-split',
|
||||
help='Used as background (special values: "default-split" (default), ' \
|
||||
'"default-unsplit").')
|
||||
parser.add_option('--appicon', help='App icon, defaults to no icon.')
|
||||
|
||||
parser.add_option('--text', help='Text on icon. Defaults to empty. '
|
||||
'More than one text is supported, multiple docicons are generated in '
|
||||
'that case.', action='append')
|
||||
parser.add_option('--sizes', help='Sizes of icons. ' \
|
||||
'Defaults to all sizes available in input appicon. Example: "512,128,16"')
|
||||
# XXX(Nico): This has to go
|
||||
parser.add_option('--debug', help='If set, write out pngs for all variants.' \
|
||||
' This needs to look like "debug%d.png".')
|
||||
# XXX(Nico): This has to go once IconFamily is less buggy and can be used
|
||||
# directly
|
||||
parser.add_option('--makeicns', help='Path to makeicns binary',
|
||||
default='./makeicns')
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
options, args = getopts().parse_args()
|
||||
makedocicons_opts(options)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,65 +0,0 @@
|
||||
import docerator
|
||||
import unittest
|
||||
|
||||
|
||||
class TextDictFromTextListTest(unittest.TestCase):
|
||||
|
||||
def testBasic(self):
|
||||
|
||||
self.assertEquals({16: 'a', 32: 'a', 128: 'a', 256: 'a', 512: 'a'},
|
||||
docerator.textDictFromTextList(['a']))
|
||||
self.assertEquals({16: 'b', 32: 'b', 128: 'a', 256: 'a', 512: 'a'},
|
||||
docerator.textDictFromTextList(['a', 'b']))
|
||||
self.assertEquals({16: 'c', 32: 'b', 128: 'a', 256: 'a', 512: 'a'},
|
||||
docerator.textDictFromTextList(['a', 'b', 'c']))
|
||||
|
||||
|
||||
class OutnameTest(unittest.TestCase):
|
||||
|
||||
class FakeOptions(object):
|
||||
def __init__(self, **kwargs):
|
||||
for k in kwargs:
|
||||
self.__setattr__(k, kwargs[k])
|
||||
|
||||
def testBasic(self):
|
||||
options = OutnameTest.FakeOptions(
|
||||
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
|
||||
text='MP3')
|
||||
self.assertEquals('iTunes-MP3.icns', docerator.getOutname(options))
|
||||
|
||||
def testTextList(self):
|
||||
options = OutnameTest.FakeOptions(
|
||||
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
|
||||
text='PYTHON,PY')
|
||||
self.assertEquals('iTunes-PYTHON.icns',
|
||||
docerator.getOutname(options))
|
||||
|
||||
def testEmptyText(self):
|
||||
options = OutnameTest.FakeOptions(
|
||||
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
|
||||
text='')
|
||||
self.assertEquals('iTunes-Generic.icns', docerator.getOutname(options))
|
||||
options = OutnameTest.FakeOptions(
|
||||
appicon = '/Applications/iTunes.app/Contents/Resources/iTunes.icns',
|
||||
text=None)
|
||||
self.assertEquals('iTunes-Generic.icns',
|
||||
docerator.getOutname(options))
|
||||
|
||||
def testEmptyIcon(self):
|
||||
options = OutnameTest.FakeOptions(appicon=None, text='MP3')
|
||||
self.assertEquals('GenericDocumentIcon-MP3.icns',
|
||||
docerator.getOutname(options))
|
||||
options = OutnameTest.FakeOptions(appicon=None, text='')
|
||||
self.assertEquals('GenericDocumentIcon-Generic.icns',
|
||||
docerator.getOutname(options))
|
||||
options = OutnameTest.FakeOptions(appicon=None, text='',
|
||||
background='/Applications/Bla/bgicon.icns')
|
||||
self.assertEquals('bgicon-Generic.icns',
|
||||
docerator.getOutname(options))
|
||||
|
||||
|
||||
# XXX(Nico): Look at the doctest module.
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,56 +0,0 @@
|
||||
// A small python module that registers a font with ATS, given the name of
|
||||
// the font.
|
||||
|
||||
#include <Python/Python.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
static PyObject* loadfont(PyObject* self, PyObject* args) {
|
||||
PyObject* result = Py_False;
|
||||
const char* path = NULL;
|
||||
int ok = PyArg_ParseTuple(args, "s", &path);
|
||||
|
||||
if (ok) {
|
||||
CFStringRef componentPath = CFStringCreateWithCString(kCFAllocatorDefault,
|
||||
path, kCFStringEncodingUTF8);
|
||||
CFURLRef componentURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
|
||||
componentPath, kCFURLPOSIXPathStyle, false);
|
||||
FSRef fsref;
|
||||
|
||||
if (CFURLGetFSRef(componentURL, &fsref)) {
|
||||
OSStatus err = noErr;
|
||||
ATSFontContainerRef fontContainerRef; // we don't deactivate the font
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4)
|
||||
err = ATSFontActivateFromFileReference(&fsref,
|
||||
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
|
||||
kATSOptionFlagsDefault, &fontContainerRef);
|
||||
#else
|
||||
FSSpec fsSpec;
|
||||
FSRef fsRef;
|
||||
if ((err = FSGetCatalogInfo(
|
||||
&fsRef, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL)) == noErr) {
|
||||
err = ATSFontActivateFromFileSpecification(&fsSpec,
|
||||
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
|
||||
kATSOptionFlagsDefault, &fontContainerRef);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (err == noErr) {
|
||||
result = Py_True;
|
||||
}
|
||||
}
|
||||
CFRelease(componentURL);
|
||||
CFRelease(componentPath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyMethodDef LoadfontMethods[] = {
|
||||
{ "loadfont", loadfont, METH_VARARGS, "Locally activates font from file." },
|
||||
{ NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
PyMODINIT_FUNC initloadfont(void) {
|
||||
Py_InitModule("loadfont", LoadfontMethods);
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
# Creates all of MacVim document icons.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
fontname = ''
|
||||
facename = None
|
||||
|
||||
# http://www.macresearch.org/cocoa-scientists-part-xx-python-scriptersmeet-cocoa
|
||||
try:
|
||||
# Make us independent of sysprefs->appearance->antialias fonts smaller than...
|
||||
# Needs to happen before docerator is imported.
|
||||
from AppKit import NSUserDefaults
|
||||
prefs = NSUserDefaults.standardUserDefaults()
|
||||
prefs.setInteger_forKey_(4, 'AppleAntiAliasingThreshold')
|
||||
|
||||
import docerator
|
||||
import loadfont
|
||||
|
||||
from Foundation import NSString
|
||||
from AppKit import *
|
||||
|
||||
dont_create = False
|
||||
except Exception, e:
|
||||
print e
|
||||
dont_create = True # most likely because we're on tiger
|
||||
|
||||
|
||||
# icon types
|
||||
LARGE = 0 # 512, 128, 32, 16; about 96kB
|
||||
SMALL = 1 # 128, 32, 16; about 36kB
|
||||
LINK = 2 # Create link to generic icon; 4kB (== smallest block size on HFS+)
|
||||
|
||||
iconsizes = {
|
||||
SMALL: [128, 32, 16],
|
||||
LARGE: [512, 128, 32, 16],
|
||||
}
|
||||
|
||||
|
||||
# Resources
|
||||
MAKEICNS = 'makeicns/makeicns'
|
||||
APPICON = 'vim-noshadow-512.png'
|
||||
DEFAULT_BACKGROUND = '/System/Library/CoreServices/CoreTypes.bundle/' + \
|
||||
'Contents/Resources/GenericDocumentIcon.icns'
|
||||
|
||||
|
||||
# List of icons to create
|
||||
GENERIC_ICON_NAME = 'MacVim-generic'
|
||||
vimIcons = {
|
||||
GENERIC_ICON_NAME: [u'', LARGE],
|
||||
'MacVim-vim': [u'VIM', LARGE],
|
||||
'MacVim-txt': [u'TXT', SMALL],
|
||||
'MacVim-tex': [u'TEX', SMALL],
|
||||
'MacVim-h': [u'H', SMALL],
|
||||
'MacVim-c': [u'C', SMALL],
|
||||
'MacVim-m': [u'M', SMALL],
|
||||
'MacVim-mm': [u'MM', SMALL],
|
||||
'MacVim-cpp': [u'C\uff0b\uff0b,C++,C++', SMALL], # fullwidth plusses
|
||||
'MacVim-java': [u'JAVA', SMALL],
|
||||
'MacVim-f': [u'FTRAN', SMALL],
|
||||
'MacVim-html': [u'HTML', SMALL],
|
||||
'MacVim-xml': [u'XML', SMALL],
|
||||
'MacVim-js': [u'JS', SMALL],
|
||||
'MacVim-perl': [u'PERL,PL', SMALL],
|
||||
'MacVim-py': [u'PYTHON,PY', SMALL],
|
||||
'MacVim-php': [u'PHP', SMALL],
|
||||
'MacVim-rb': [u'RUBY,RB', SMALL],
|
||||
'MacVim-bash': [u'SH', SMALL],
|
||||
'MacVim-patch': [u'DIFF', SMALL],
|
||||
'MacVim-applescript': [u'\uf8ffSCPT,\uf8ffS', SMALL], # apple sign
|
||||
'MacVim-as': [u'FLASH', LINK],
|
||||
'MacVim-asp': [u'ASP', LINK],
|
||||
'MacVim-bib': [u'BIB', LINK],
|
||||
'MacVim-cs': [u'C#', LINK],
|
||||
'MacVim-csfg': [u'CFDG', LINK],
|
||||
'MacVim-csv': [u'CSV', LINK],
|
||||
'MacVim-tsv': [u'TSV', LINK],
|
||||
'MacVim-cgi': [u'CGI', LINK],
|
||||
'MacVim-cfg': [u'CFG', LINK],
|
||||
'MacVim-css': [u'CSS', SMALL],
|
||||
'MacVim-dtd': [u'DTD', LINK],
|
||||
'MacVim-dylan': [u'DYLAN', LINK],
|
||||
'MacVim-erl': [u'ERLANG,ERL', SMALL],
|
||||
'MacVim-fscript': [u'FSCPT,FSCR,FS', SMALL],
|
||||
'MacVim-hs': [u'HS', SMALL],
|
||||
'MacVim-inc': [u'INC', LINK],
|
||||
'MacVim-ics': [u'ICS', SMALL],
|
||||
'MacVim-ini': [u'INI', LINK],
|
||||
'MacVim-io': [u'IO', LINK],
|
||||
'MacVim-bsh': [u'BSH', LINK],
|
||||
'MacVim-properties': [u'PROP', LINK],
|
||||
'MacVim-jsp': [u'JSP', SMALL],
|
||||
'MacVim-lisp': [u'LISP,LISP,LSP', SMALL],
|
||||
'MacVim-log': [u'LOG', SMALL],
|
||||
'MacVim-wiki': [u'WIKI', SMALL],
|
||||
'MacVim-ps': [u'PS', LINK],
|
||||
#'MacVim-plist': [u'PLIST', SMALL],
|
||||
'MacVim-sch': [u'SCHEME,SCM', SMALL],
|
||||
'MacVim-sql': [u'SQL', SMALL],
|
||||
'MacVim-tcl': [u'TCL', SMALL],
|
||||
'MacVim-xsl': [u'XSL', LINK],
|
||||
'MacVim-vcf': [u'VCARD,VCF', SMALL],
|
||||
'MacVim-vb': [u'VBASIC,VB', LINK],
|
||||
'MacVim-yaml': [u'YAML,YAML,YML', SMALL],
|
||||
'MacVim-gtd': [u'GTD', LINK],
|
||||
'MacVim-markdown': [u'MARK\u2193,M\u2193', LINK], # down arrow
|
||||
'MacVim-rst': [u'RST', LINK],
|
||||
'MacVim-vba': [u'VBA', LINK],
|
||||
}
|
||||
|
||||
|
||||
def createLinks(icons, target):
|
||||
assert len(icons) > 0
|
||||
for name in icons:
|
||||
icnsName = '%s.icns' % name
|
||||
if os.access(icnsName, os.F_OK):
|
||||
os.remove(icnsName)
|
||||
os.symlink(target, icnsName)
|
||||
|
||||
if not dont_create:
|
||||
# define a few classes to render custom 16x16 icons
|
||||
|
||||
class NoTextRenderer(docerator.TextRenderer):
|
||||
def drawTextAtSize(self, text, s):
|
||||
if s == 16: return # No text at 16x16
|
||||
docerator.TextRenderer.drawTextAtSize(self, text, s)
|
||||
|
||||
class NoIconRenderer(docerator.BackgroundRenderer):
|
||||
def drawIcon(self, s):
|
||||
if s == 16: return # no "MacVim" icon on the sheet at 16x16
|
||||
docerator.BackgroundRenderer.drawIcon(self, s)
|
||||
|
||||
class SmallTextRenderer(docerator.TextRenderer):
|
||||
def _attribsAtSize(self, s):
|
||||
global facename
|
||||
attribs = docerator.TextRenderer._attribsAtSize(self, s)
|
||||
if s == 16 and facename is not None:
|
||||
font = NSFont.fontWithName_size_(facename, 7.0)
|
||||
assert font
|
||||
attribs[NSFontAttributeName] = font
|
||||
attribs[NSForegroundColorAttributeName] = \
|
||||
NSColor.colorWithDeviceRed_green_blue_alpha_(
|
||||
0/255.0, 82/255.0, 0/255.0, 1)
|
||||
return attribs
|
||||
|
||||
def drawTextAtSize(self, text, s):
|
||||
if s != 16:
|
||||
docerator.TextRenderer.drawTextAtSize(self, text, s)
|
||||
return
|
||||
text = NSString.stringWithString_(text.lower()[0:3]) # at most 3 chars
|
||||
attribs = self.attribsAtSize(s)
|
||||
if len(text) <= 2:
|
||||
attribs[NSKernAttributeName] = 0 # we have some space
|
||||
else:
|
||||
attribs[NSKernAttributeName] = -1 # we need all the room we can get
|
||||
text.drawInRect_withAttributes_( ((1, 2), (15, 11)), attribs)
|
||||
|
||||
def main():
|
||||
if dont_create:
|
||||
print "PyObjC not found, only using a stock icon for document icons."
|
||||
# Can't use the constants from docerator in this case
|
||||
import shutil
|
||||
shutil.copyfile(DEFAULT_BACKGROUND, '%s.icns' % GENERIC_ICON_NAME)
|
||||
createLinks([name for name in vimIcons if name != GENERIC_ICON_NAME],
|
||||
'%s.icns' % GENERIC_ICON_NAME)
|
||||
return
|
||||
|
||||
# choose an icon font
|
||||
global fontname, facename
|
||||
# Thanks to DamienG for Envy Code R (redistributed with permission):
|
||||
# http://damieng.com/blog/2008/05/26/envy-code-r-preview-7-coding-font-released
|
||||
fonts = [('Envy Code R Bold.ttf', 'EnvyCodeR-Bold'),
|
||||
('/System/Library/Fonts/Monaco.dfont', 'Monaco')]
|
||||
for font in fonts:
|
||||
if loadfont.loadfont(font[0]):
|
||||
fontname, facename = font
|
||||
break
|
||||
print "Building icons with font '" + fontname + "'."
|
||||
|
||||
srcdir = os.getcwd()
|
||||
if len(sys.argv) > 1:
|
||||
os.chdir(sys.argv[1])
|
||||
appIcon = os.path.join(srcdir, APPICON)
|
||||
makeIcns = os.path.join(srcdir, MAKEICNS)
|
||||
|
||||
# create LARGE and SMALL icons first...
|
||||
for name, t in vimIcons.iteritems():
|
||||
text, size = t
|
||||
if size == LINK: continue
|
||||
print name
|
||||
if name == GENERIC_ICON_NAME:
|
||||
# The generic icon has no text; make the appicon a bit larger
|
||||
docerator.makedocicon(outname='%s.icns' % name, appicon=appIcon,
|
||||
text=text, sizes=iconsizes[size], makeicns=makeIcns,
|
||||
textrenderer=NoTextRenderer, rects={16:(0.0, 0.5533, 0.0, 0.5533)})
|
||||
else:
|
||||
# For the other icons, leave out appicon and render text in Envy Code R
|
||||
docerator.makedocicon(outname='%s.icns' % name, appicon=appIcon,
|
||||
text=text, sizes=iconsizes[size], makeicns=makeIcns,
|
||||
textrenderer=SmallTextRenderer, backgroundrenderer=NoIconRenderer)
|
||||
|
||||
# ...create links later (to make sure the link targets exist)
|
||||
createLinks([name for (name, t) in vimIcons.items() if t[1] == LINK],
|
||||
'%s.icns' % GENERIC_ICON_NAME)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,190 +0,0 @@
|
||||
// IconFamily.h
|
||||
// IconFamily class interface
|
||||
// by Troy Stephens, Thomas Schnitzer, David Remahl, Nathan Day, Ben Haller, Sven Janssen, Peter Hosey, Conor Dearden, Elliot Glaysher, and Dave MacLachlan
|
||||
// version 0.9.3
|
||||
//
|
||||
// Project Home Page:
|
||||
// http://iconfamily.sourceforge.net/
|
||||
//
|
||||
// Problems, shortcomings, and uncertainties that I'm aware of are flagged with "NOTE:". Please address bug reports, bug fixes, suggestions, etc. to the project Forums and bug tracker at https://sourceforge.net/projects/iconfamily/
|
||||
|
||||
/*
|
||||
Copyright (c) 2001-2006 Troy N. Stephens
|
||||
Portions Copyright (c) 2007 Google Inc.
|
||||
|
||||
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
// This class is a Cocoa/Objective-C wrapper for the Mac OS X Carbon API's
|
||||
// "icon family" data type. Its main purpose is to enable Cocoa applications
|
||||
// to easily create custom file icons from NSImage instances, and thus take
|
||||
// advantage of Mac OS X's new larger RGBA "thumbnail" icon format to provide
|
||||
// richly detailed thumbnail previews of the files' contents.
|
||||
//
|
||||
// Using IconFamily, this becomes as simple as:
|
||||
//
|
||||
// id iconFamily = [IconFamily iconFamilyWithThumbnailsOfImage:anImage];
|
||||
// [iconFamily setAsCustomIconForFile:anExistingFile];
|
||||
//
|
||||
// You can also write an icon family to an .icns file using the -writeToFile:
|
||||
// method.
|
||||
|
||||
@interface IconFamily : NSObject
|
||||
{
|
||||
IconFamilyHandle hIconFamily;
|
||||
}
|
||||
|
||||
// Convenience methods. These use the corresponding -init... methods to return
|
||||
// an autoreleased IconFamily instance.
|
||||
|
||||
+ (IconFamily*) iconFamily;
|
||||
+ (IconFamily*) iconFamilyWithContentsOfFile:(NSString*)path;
|
||||
+ (IconFamily*) iconFamilyWithIconOfFile:(NSString*)path;
|
||||
+ (IconFamily*) iconFamilyWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
|
||||
+ (IconFamily*) iconFamilyWithSystemIcon:(int)fourByteCode;
|
||||
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image;
|
||||
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
|
||||
|
||||
// Initializes as a new, empty IconFamily. This is IconFamily's designated
|
||||
// initializer method.
|
||||
|
||||
- init;
|
||||
|
||||
// Initializes an IconFamily by loading the contents of an .icns file.
|
||||
|
||||
- initWithContentsOfFile:(NSString*)path;
|
||||
|
||||
// Initializes an IconFamily from an existing Carbon IconFamilyHandle.
|
||||
|
||||
- initWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
|
||||
|
||||
// Initializes an IconFamily by loading the Finder icon that's assigned to a
|
||||
// file.
|
||||
|
||||
- initWithIconOfFile:(NSString*)path;
|
||||
|
||||
// Initializes an IconFamily by referencing a standard system icon.
|
||||
|
||||
- initWithSystemIcon:(int)fourByteCode;
|
||||
|
||||
// Initializes an IconFamily by creating its elements from a resampled
|
||||
// NSImage. The second form of this method allows you to specify the degree
|
||||
// of antialiasing to be used in resampling the image, by passing in one of
|
||||
// the NSImageInterpolation... constants that are defined in
|
||||
// NSGraphicsContext.h. The first form of this initializer simply calls the
|
||||
// second form with imageInterpolation set to NSImageInterpolationHigh, which
|
||||
// produces highly smoothed thumbnails.
|
||||
|
||||
- initWithThumbnailsOfImage:(NSImage*)image;
|
||||
- initWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
|
||||
|
||||
// Writes the icon family to an .icns file.
|
||||
|
||||
- (BOOL) writeToFile:(NSString*)path;
|
||||
|
||||
// Sets the image data for one of the icon family's elements from an
|
||||
// NSBitmapImageRep. The "elementType" parameter must be one of the icon
|
||||
// family element types listed below, and the format of the "bitmapImageRep"
|
||||
// must match the corresponding requirements specified below. Regardless of
|
||||
// the elementType, the bitmapImageRep must also be non-planar and have 8 bits
|
||||
// per sample.
|
||||
//
|
||||
// elementType dimensions format
|
||||
// ------------------- ---------- ---------------------------------------
|
||||
// kIconServices512PixelDataARGB 512 x 512 32-bit RGBA, 32-bit RGB, or 24-bit RGB
|
||||
// kIconServices256PixelDataARGB 256 x 256 32-bit RGBA, 32-bit RGB, or 24-bit RGB
|
||||
// kThumbnail32BitData 128 x 128 32-bit RGBA, 32-bit RGB, or 24-bit RGB
|
||||
// kThumbnail8BitMask 128 x 128 32-bit RGBA or 8-bit intensity
|
||||
// kLarge32BitData 32 x 32 32-bit RGBA, 32-bit RGB, or 24-bit RGB
|
||||
// kLarge8BitMask 32 x 32 32-bit RGBA or 8-bit intensity
|
||||
// kLarge1BitMask 32 x 32 32-bit RGBA, 8-bit intensity, or 1-bit
|
||||
// kSmall32BitData 16 x 16 32-bit RGBA, 32-bit RGB, or 24-bit RGB
|
||||
// kSmall8BitMask 16 x 16 32-bit RGBA or 8-bit intensity
|
||||
// kSmall1BitMask 16 x 16 32-bit RGBA, 8-bit intensity, or 1-bit
|
||||
//
|
||||
// When an RGBA image is supplied to set a "Mask" element, the mask data is
|
||||
// taken from the image's alpha channel.
|
||||
//
|
||||
// NOTE: Setting an IconFamily's kLarge1BitMask seems to damage the IconFamily
|
||||
// for some as yet unknown reason. (If you then assign the icon family
|
||||
// as a file's custom icon using -setAsCustomIconForFile:, the custom
|
||||
// icon doesn't appear for the file in the Finder.) However, both
|
||||
// custom icon display and mouse-click hit-testing in the Finder seem to
|
||||
// work fine when we only set the other four elements (thus keeping the
|
||||
// existing kLarge1BitMask from the valid icon family from which we
|
||||
// initialized the IconFamily via -initWithContentsOfFile:, since
|
||||
// IconFamily's -init method is currently broken...), so it seems safe
|
||||
// to just leave the kLarge1BitMask alone.
|
||||
|
||||
- (BOOL) setIconFamilyElement:(OSType)elementType
|
||||
fromBitmapImageRep:(NSBitmapImageRep*)bitmapImageRep;
|
||||
|
||||
// Gets the image data for one of the icon family's elements as a new, 32-bit
|
||||
// RGBA NSBitmapImageRep. The specified elementType should be one of
|
||||
// kIconServices512PixelDataARGB, kIconServices256PixelDataARGB,
|
||||
// kThumbnail32BitData, kLarge32BitData, or kSmall32BitData.
|
||||
//
|
||||
// The returned NSBitmapImageRep will have the corresponding 8-bit mask data
|
||||
// in its alpha channel, or a fully opaque alpha channel if the icon family
|
||||
// has no 8-bit mask data for the specified alpha channel.
|
||||
//
|
||||
// Returns nil if the requested element cannot be retrieved (e.g. if the
|
||||
// icon family has no such 32BitData element).
|
||||
|
||||
- (NSBitmapImageRep*) bitmapImageRepWithAlphaForIconFamilyElement:(OSType)elementType;
|
||||
|
||||
// Creates and returns an NSImage that contains the icon family's various
|
||||
// elements as its NSImageReps.
|
||||
|
||||
- (NSImage*) imageWithAllReps;
|
||||
|
||||
// NOTE: Planned method -- not yet implemented.
|
||||
//
|
||||
// Gets the image data for one of the icon family's elements as a new
|
||||
// NSBitmapImageRep. The specified elementType should be one of
|
||||
// kThumbnail32BitData, kThumbnail8BitMask, kLarge32BitData, kLarge8BitMask,
|
||||
// kLarge1BitMask, kSmall32BitData, kSmall8BitMask, or kSmall1BitMask.
|
||||
|
||||
// - (NSBitmapImageRep*) bitmapImageRepForIconFamilyElement:(OSType)elementType;
|
||||
|
||||
// Writes the icon family to the resource fork of the specified file as its
|
||||
// kCustomIconResource, and sets the necessary Finder bits so the icon will
|
||||
// be displayed for the file in Finder views.
|
||||
|
||||
- (BOOL) setAsCustomIconForFile:(NSString*)path;
|
||||
- (BOOL) setAsCustomIconForFile:(NSString*)path withCompatibility:(BOOL)compat;
|
||||
|
||||
// Same as the -setAsCustomIconForFile:... methods, but for folders (directories).
|
||||
|
||||
- (BOOL) setAsCustomIconForDirectory:(NSString*)path;
|
||||
- (BOOL) setAsCustomIconForDirectory:(NSString*)path withCompatibility:(BOOL)compat;
|
||||
|
||||
// Removes the custom icon (if any) from the specified file's resource fork,
|
||||
// and clears the necessary Finder bits for the file. (Note that this is a
|
||||
// class method, so you don't need an instance of IconFamily to invoke it.)
|
||||
|
||||
+ (BOOL) removeCustomIconFromFile:(NSString*)path;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050 // Scrap Manager has been nixed on Snow Leopard
|
||||
// Methods for interfacing with the Carbon Scrap Manager (analogous to and
|
||||
// interoperable with the Cocoa Pasteboard).
|
||||
@interface IconFamily (ScrapAdditions)
|
||||
+ (BOOL) canInitWithScrap;
|
||||
+ (IconFamily*) iconFamilyWithScrap;
|
||||
- initWithScrap;
|
||||
- (BOOL) putOnScrap;
|
||||
@end
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +0,0 @@
|
||||
CFLAGS = -fpascal-strings -O2
|
||||
|
||||
.PHONY: clean dist
|
||||
|
||||
makeicns: makeicns.o IconFamily.o NSString+CarbonFSRefCreation.o
|
||||
g++ -o makeicns $^ -O2 \
|
||||
-framework Foundation -framework AppKit -framework Carbon
|
||||
|
||||
clean:
|
||||
rm -rf makeicns.o IconFamily.o NSString+CarbonFSRefCreation.o
|
||||
|
||||
dist: makeicns
|
||||
rm -rf makeicns-1.0.zip
|
||||
zip makeicns-1.0.zip Makefile makeicns.m IconFamily.m IconFamily.h \
|
||||
NSString+CarbonFSRefCreation.m NSString+CarbonFSRefCreation.h \
|
||||
makeicns
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2001-2006 Troy N. Stephens
|
||||
|
||||
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
|
||||
@interface NSString (CarbonFSRefCreation)
|
||||
|
||||
// Fills in the given FSRef struct so it specifies the file whose path is in this string.
|
||||
// If the file doesn't exist, and "createFile" is YES, this method will attempt to create
|
||||
// an empty file with the specified path. (The caller should insure that the directory
|
||||
// the file is to be placed in already exists.)
|
||||
|
||||
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile;
|
||||
|
||||
@end
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2001-2006 Troy N. Stephens
|
||||
|
||||
Use and distribution of this source code is governed by the MIT License, whose terms are as follows.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import "NSString+CarbonFSRefCreation.h"
|
||||
|
||||
@implementation NSString (CarbonFSRefCreation)
|
||||
|
||||
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile
|
||||
{
|
||||
NSFileManager* fileManager = [NSFileManager defaultManager];
|
||||
CFURLRef urlRef;
|
||||
Boolean gotFSRef;
|
||||
|
||||
// Check whether the file exists already. If not, create an empty file if requested.
|
||||
if (![fileManager fileExistsAtPath:self]) {
|
||||
if (createFile) {
|
||||
if (![@"" writeToFile:self atomically:YES]) {
|
||||
return NO;
|
||||
}
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a CFURL with the specified POSIX path.
|
||||
urlRef = CFURLCreateWithFileSystemPath( kCFAllocatorDefault,
|
||||
(CFStringRef) self,
|
||||
kCFURLPOSIXPathStyle,
|
||||
FALSE /* isDirectory */ );
|
||||
if (urlRef == NULL) {
|
||||
// printf( "** Couldn't make a CFURLRef for the file.\n" );
|
||||
return NO;
|
||||
}
|
||||
|
||||
// Try to create an FSRef from the URL. (If the specified file doesn't exist, this
|
||||
// function will return false, but if we've reached this code we've already insured
|
||||
// that the file exists.)
|
||||
gotFSRef = CFURLGetFSRef( urlRef, fsRef );
|
||||
CFRelease( urlRef );
|
||||
|
||||
if (!gotFSRef) {
|
||||
// printf( "** Couldn't get an FSRef for the file.\n" );
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,173 +0,0 @@
|
||||
// makeicns
|
||||
// Converts images to Apple's icns format.
|
||||
// Written by nicolasweber@gmx.de, released under MIT license.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "IconFamily.h"
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
|
||||
// This is defined in 10.5 and beyond in IconStorage.h
|
||||
enum {
|
||||
kIconServices512PixelDataARGB = 'ic09' /* non-premultiplied 512x512 ARGB bitmap*/
|
||||
};
|
||||
#endif
|
||||
|
||||
#define VERSION "1.0 (20081122)"
|
||||
|
||||
void usage() {
|
||||
fprintf(stderr,
|
||||
"makeicns v%s\n\n", VERSION);
|
||||
fprintf(stderr,
|
||||
"Usage: makeicns [k1=v1] [k2=v2] ...\n\n");
|
||||
fprintf(stderr,
|
||||
"Keys and values include:\n");
|
||||
fprintf(stderr,
|
||||
" 512: Name of input image for 512x512 variant of icon\n");
|
||||
fprintf(stderr,
|
||||
" 256: Name of input image for 256x256 variant of icon\n");
|
||||
fprintf(stderr,
|
||||
" 128: Name of input image for 128x128 variant of icon\n");
|
||||
fprintf(stderr,
|
||||
" 32: Name of input image for 32x32 variant of icon\n");
|
||||
fprintf(stderr,
|
||||
" 16: Name of input image for 16x16 variant of icon\n");
|
||||
fprintf(stderr,
|
||||
" in: Name of input image for all variants not having an explicit name\n");
|
||||
fprintf(stderr,
|
||||
" out: Name of output file, defaults to first nonempty input name,\n"
|
||||
" but with icns extension\n\n");
|
||||
fprintf(stderr,
|
||||
"Examples:\n\n"
|
||||
" icns -512 image.png -32 image.png\n"
|
||||
" Creates image.icns with only a 512x512 and a 32x32 variant.\n\n"
|
||||
" icns -in myfile.jpg -32 otherfile.png -out outfile.icns\n"
|
||||
" Creates outfile.icns with sizes 512, 256, 128, and 16 containing data\n"
|
||||
" from myfile.jpg and with size 32 containing data from otherfile.png.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
NSBitmapImageRep* getBitmapImageRepOfSize(NSImage* img, int size) {
|
||||
|
||||
// Don't resample if it's not necessary
|
||||
#if 0
|
||||
// IconFamily does not work correctly with
|
||||
// NSAlphaNonpremultipliedBitmapFormat images, so this has to stay disabled
|
||||
// until IconFamily is fixed (if ever).
|
||||
NSEnumerator* e = [[img representations] objectEnumerator];
|
||||
NSImageRep* ir;
|
||||
while ((ir = [e nextObject])) {
|
||||
if (![ir isKindOfClass:[NSBitmapImageRep class]]) continue;
|
||||
|
||||
NSBitmapImageRep* br = (NSBitmapImageRep*)ir;
|
||||
//NSLog(@"%@", br);
|
||||
if ([br pixelsWide] == size && [br pixelsHigh] == size
|
||||
&& ([[br colorSpaceName] isEqualToString:NSDeviceRGBColorSpace]
|
||||
|| [[br colorSpaceName] isEqualToString:NSCalibratedRGBColorSpace])
|
||||
&& ([br bitsPerPixel] == 24 || [br bitsPerPixel] == 32)
|
||||
)
|
||||
return br;
|
||||
}
|
||||
#endif
|
||||
|
||||
NSLog(@"Resampling for size %d", size);
|
||||
NSBitmapImageRep* r = [[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:size
|
||||
pixelsHigh:size
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bitmapFormat:0
|
||||
bytesPerRow:0
|
||||
bitsPerPixel:0];
|
||||
|
||||
[NSGraphicsContext saveGraphicsState];
|
||||
NSGraphicsContext* context = [NSGraphicsContext
|
||||
graphicsContextWithBitmapImageRep:r];
|
||||
[context setShouldAntialias:YES];
|
||||
[context setImageInterpolation:NSImageInterpolationHigh];
|
||||
[NSGraphicsContext setCurrentContext:context];
|
||||
|
||||
[img drawInRect:NSMakeRect(0, 0, size, size)
|
||||
fromRect:NSZeroRect
|
||||
operation:NSCompositeCopy
|
||||
fraction:1.0];
|
||||
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int i;
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
NSApplicationLoad();
|
||||
|
||||
struct {
|
||||
NSString* paramName;
|
||||
OSType type, mask;
|
||||
int size;
|
||||
NSString* inputName;
|
||||
} inputs[] = {
|
||||
{ @"512", kIconServices512PixelDataARGB, 0, 512, nil },
|
||||
{ @"256", kIconServices256PixelDataARGB, 0, 256, nil },
|
||||
{ @"128", kThumbnail32BitData, kThumbnail8BitMask, 128, nil },
|
||||
{ @"32", kLarge32BitData, kLarge8BitMask, 32, nil },
|
||||
{ @"16", kSmall32BitData, kSmall8BitMask, 16, nil },
|
||||
};
|
||||
const int N = sizeof(inputs)/sizeof(inputs[0]);
|
||||
|
||||
// Process arguments -- Thanks Greg!
|
||||
//http://unixjunkie.blogspot.com/2006/07/command-line-processing-in-cocoa.html
|
||||
NSUserDefaults* args = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
BOOL foundInputParam = NO;
|
||||
NSString* outputName = [args stringForKey:@"out"];
|
||||
NSString* defaultIn = [args stringForKey:@"in"];
|
||||
for (i = 0; i < N; ++i) {
|
||||
inputs[i].inputName = [args stringForKey:inputs[i].paramName];
|
||||
if (inputs[i].inputName == nil)
|
||||
inputs[i].inputName = defaultIn;
|
||||
foundInputParam = foundInputParam || inputs[i].inputName != nil;
|
||||
|
||||
// Create default output name if necessary
|
||||
if (outputName == nil && inputs[i].inputName != nil)
|
||||
outputName = [[inputs[i].inputName stringByDeletingPathExtension]
|
||||
stringByAppendingPathExtension:@"icns"];
|
||||
}
|
||||
|
||||
if (!foundInputParam)
|
||||
usage();
|
||||
|
||||
// Create output
|
||||
IconFamily* output = [IconFamily iconFamily];
|
||||
|
||||
for (i = 0; i < N; ++i) {
|
||||
if (inputs[i].inputName == nil) continue;
|
||||
NSImage* img = [[[NSImage alloc] initWithContentsOfFile:inputs[i].inputName]
|
||||
autorelease];
|
||||
|
||||
NSBitmapImageRep* rep = getBitmapImageRepOfSize(img, inputs[i].size);
|
||||
[output setIconFamilyElement:inputs[i].type fromBitmapImageRep:rep];
|
||||
if (inputs[i].mask != 0)
|
||||
[output setIconFamilyElement:inputs[i].mask fromBitmapImageRep:rep];
|
||||
}
|
||||
|
||||
// Write output
|
||||
if ([output writeToFile:outputName])
|
||||
NSLog(@"Wrote output file \"%@\"", outputName);
|
||||
else
|
||||
NSLog(@"Failed to write \"%@\"", outputName);
|
||||
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
from distutils.core import setup, Extension
|
||||
|
||||
setup(name="loadfont", version="1.0",
|
||||
ext_modules = [Extension("loadfont", ["loadfont.c"])])
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
+1
-1
@@ -2964,7 +2964,7 @@ macvim-dmg: macvim
|
||||
|
||||
macvimclean:
|
||||
if test -d MacVim; then \
|
||||
rm -rf MacVim/build xxd/xxd.dSYM; \
|
||||
rm -rf MacVim/build MacVim/qlstephen/build xxd/xxd.dSYM; \
|
||||
fi
|
||||
|
||||
|
||||
|
||||
Vendored
+15
-4
@@ -803,6 +803,7 @@ enable_pythoninterp
|
||||
with_python_config_dir
|
||||
enable_python3interp
|
||||
with_python3_config_dir
|
||||
with_properly_linked_python2_python3
|
||||
enable_tclinterp
|
||||
with_tclsh
|
||||
enable_rubyinterp
|
||||
@@ -1515,6 +1516,7 @@ Optional Packages:
|
||||
--with-plthome=PLTHOME Use PLTHOME.
|
||||
--with-python-config-dir=PATH Python's config directory
|
||||
--with-python3-config-dir=PATH Python's config directory
|
||||
--with-properly-linked-python2-python3 Link with properly linked Python 2 and Python 3.
|
||||
--with-tclsh=PATH which tclsh to use (default: tclsh8.0)
|
||||
--with-ruby-command=RUBY name of the Ruby command (default: ruby)
|
||||
--with-x use the X Window System
|
||||
@@ -6443,6 +6445,15 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
# Check whether --with-properly-linked-python2-python3 was given.
|
||||
if test "${with_properly_linked_python2_python3+set}" = set; then :
|
||||
withval=$with_properly_linked_python2_python3; vi_cv_with_properly_linked_python2_python3="yes"
|
||||
else
|
||||
vi_cv_with_properly_linked_python2_python3="no"
|
||||
fi
|
||||
|
||||
|
||||
if test "$python_ok" = yes && test "$python3_ok" = yes; then
|
||||
$as_echo "#define DYNAMIC_PYTHON 1" >>confdefs.h
|
||||
|
||||
@@ -6454,7 +6465,7 @@ $as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6;
|
||||
CFLAGS="$CFLAGS $PYTHON_CFLAGS"
|
||||
libs_save=$LIBS
|
||||
LIBS="-ldl $LIBS"
|
||||
if test "x$MACOSX" != "xyes"; then
|
||||
if test "x$MACOSX" != "xyes" || test "$vi_cv_with_properly_linked_python2_python3" = "yes"; then
|
||||
if test "$cross_compiling" = yes; then :
|
||||
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
||||
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
||||
@@ -9602,10 +9613,10 @@ fi
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN environment" >&5
|
||||
$as_echo_n "checking for CYGWIN environment... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN or MSYS environment" >&5
|
||||
$as_echo_n "checking for CYGWIN or MSYS environment... " >&6; }
|
||||
case `uname` in
|
||||
CYGWIN*) CYGWIN=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
CYGWIN*|MSYS*) CYGWIN=yes; { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CYGWIN clipboard support" >&5
|
||||
$as_echo_n "checking for CYGWIN clipboard support... " >&6; }
|
||||
|
||||
+8
-3
@@ -1510,6 +1510,11 @@ AC_SUBST(PYTHON3_CFLAGS)
|
||||
AC_SUBST(PYTHON3_SRC)
|
||||
AC_SUBST(PYTHON3_OBJ)
|
||||
|
||||
AC_ARG_WITH(properly-linked-python2-python3,
|
||||
[ --with-properly-linked-python2-python3 Link with properly linked Python 2 and Python 3.],
|
||||
[vi_cv_with_properly_linked_python2_python3="yes"],
|
||||
[vi_cv_with_properly_linked_python2_python3="no"])
|
||||
|
||||
dnl if python2.x and python3.x are enabled one can only link in code
|
||||
dnl with dlopen(), dlsym(), dlclose()
|
||||
if test "$python_ok" = yes && test "$python3_ok" = yes; then
|
||||
@@ -1521,7 +1526,7 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then
|
||||
libs_save=$LIBS
|
||||
dnl -ldl must go first to make this work on Archlinux (Roland Puntaier)
|
||||
LIBS="-ldl $LIBS"
|
||||
if test "x$MACOSX" != "xyes"; then
|
||||
if test "x$MACOSX" != "xyes" || test "$vi_cv_with_properly_linked_python2_python3" = "yes"; then
|
||||
AC_RUN_IFELSE([AC_LANG_SOURCE([
|
||||
#include <dlfcn.h>
|
||||
/* If this program fails, then RTLD_GLOBAL is needed.
|
||||
@@ -2861,9 +2866,9 @@ dnl end of GUI-checking
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
dnl Check for Cygwin, which needs an extra source file if not using X11
|
||||
AC_MSG_CHECKING(for CYGWIN environment)
|
||||
AC_MSG_CHECKING(for CYGWIN or MSYS environment)
|
||||
case `uname` in
|
||||
CYGWIN*) CYGWIN=yes; AC_MSG_RESULT(yes)
|
||||
CYGWIN*|MSYS*) CYGWIN=yes; AC_MSG_RESULT(yes)
|
||||
AC_MSG_CHECKING(for CYGWIN clipboard support)
|
||||
if test "x$with_x" = "xno" ; then
|
||||
OS_EXTRA_SRC=winclip.c; OS_EXTRA_OBJ=objects/winclip.o
|
||||
|
||||
+13
-3
@@ -1087,6 +1087,7 @@ ex_diffsplit(eap)
|
||||
exarg_T *eap;
|
||||
{
|
||||
win_T *old_curwin = curwin;
|
||||
buf_T *old_curbuf = curbuf;
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
need_mouse_correct = TRUE;
|
||||
@@ -1105,7 +1106,18 @@ ex_diffsplit(eap)
|
||||
{
|
||||
/* Set 'diff', 'scrollbind' on and 'wrap' off. */
|
||||
diff_win_options(curwin, TRUE);
|
||||
diff_win_options(old_curwin, TRUE);
|
||||
if (win_valid(old_curwin))
|
||||
{
|
||||
diff_win_options(old_curwin, TRUE);
|
||||
|
||||
if (buf_valid(old_curbuf))
|
||||
/* Move the cursor position to that of the old window. */
|
||||
curwin->w_cursor.lnum = diff_get_corresponding_line(
|
||||
old_curbuf,
|
||||
old_curwin->w_cursor.lnum,
|
||||
curbuf,
|
||||
curwin->w_cursor.lnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2541,7 +2553,6 @@ diff_move_to(dir, count)
|
||||
return OK;
|
||||
}
|
||||
|
||||
#if defined(FEAT_CURSORBIND) || defined(PROTO)
|
||||
linenr_T
|
||||
diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
|
||||
buf_T *buf1;
|
||||
@@ -2610,7 +2621,6 @@ diff_get_corresponding_line(buf1, lnum1, buf2, lnum3)
|
||||
|
||||
return lnum2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FEAT_FOLDING) || defined(PROTO)
|
||||
/*
|
||||
|
||||
+4
-3
@@ -540,10 +540,11 @@ ex_sort(eap)
|
||||
if (!unique || i == 0
|
||||
|| (sort_ic ? STRICMP(s, sortbuf1) : STRCMP(s, sortbuf1)) != 0)
|
||||
{
|
||||
if (ml_append(lnum++, s, (colnr_T)0, FALSE) == FAIL)
|
||||
/* Copy the line into a buffer, it may become invalid in
|
||||
* ml_append(). And it's needed for "unique". */
|
||||
STRCPY(sortbuf1, s);
|
||||
if (ml_append(lnum++, sortbuf1, (colnr_T)0, FALSE) == FAIL)
|
||||
break;
|
||||
if (unique)
|
||||
STRCPY(sortbuf1, s);
|
||||
}
|
||||
fast_breakcheck();
|
||||
if (got_int)
|
||||
|
||||
+2
-2
@@ -9664,7 +9664,7 @@ ex_redraw(eap)
|
||||
out_flush();
|
||||
#ifdef FEAT_GUI_MACVIM
|
||||
if (gui.in_use)
|
||||
gui_macvim_flush();
|
||||
gui_macvim_force_flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -9691,7 +9691,7 @@ ex_redrawstatus(eap)
|
||||
out_flush();
|
||||
# ifdef FEAT_GUI_MACVIM
|
||||
if (gui.in_use)
|
||||
gui_macvim_flush();
|
||||
gui_macvim_force_flush();
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
+3
-3
@@ -3079,12 +3079,12 @@ restore_cmdline_alloc(p)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* paste a yank register into the command line.
|
||||
* used by CTRL-R command in command-line mode
|
||||
* Paste a yank register into the command line.
|
||||
* Used by CTRL-R command in command-line mode.
|
||||
* insert_reg() can't be used here, because special characters from the
|
||||
* register contents will be interpreted as commands.
|
||||
*
|
||||
* return FAIL for failure, OK otherwise
|
||||
* Return FAIL for failure, OK otherwise.
|
||||
*/
|
||||
static int
|
||||
cmdline_paste(regname, literally, remcr)
|
||||
|
||||
+92
-11
@@ -1244,16 +1244,8 @@ utf_char2cells(c)
|
||||
static struct interval doublewidth[] =
|
||||
{
|
||||
{0x1100, 0x115f},
|
||||
{0x2300, 0x23ff},
|
||||
{0x2700, 0x2757},
|
||||
{0x275d, 0x2767},
|
||||
{0x2776, 0x27bf},
|
||||
{0x2b00, 0x2b1c},
|
||||
{0x2b1f, 0x2b29},
|
||||
{0x2b2c, 0x2b2d},
|
||||
{0x2b30, 0x2b55},
|
||||
{0x2b90, 0x2b91},
|
||||
{0x2e00, 0x2e99},
|
||||
{0x2329, 0x232a},
|
||||
{0x2e80, 0x2e99},
|
||||
{0x2e9b, 0x2ef3},
|
||||
{0x2f00, 0x2fd5},
|
||||
{0x2ff0, 0x2ffb},
|
||||
@@ -1279,11 +1271,98 @@ utf_char2cells(c)
|
||||
{0xfe68, 0xfe6b},
|
||||
{0xff01, 0xff60},
|
||||
{0xffe0, 0xffe6},
|
||||
{0x10000, 0x1fffd},
|
||||
{0x1b000, 0x1b001},
|
||||
{0x1f200, 0x1f202},
|
||||
{0x1f210, 0x1f23a},
|
||||
{0x1f240, 0x1f248},
|
||||
{0x1f250, 0x1f251},
|
||||
{0x20000, 0x2fffd},
|
||||
{0x30000, 0x3fffd}
|
||||
};
|
||||
|
||||
/* Sorted list of non-overlapping intervals of Emoji characters,
|
||||
* based on http://unicode.org/emoji/charts/emoji-list.html */
|
||||
static struct interval emoji[] =
|
||||
{
|
||||
{0x2196, 0x2199},
|
||||
{0x21a9, 0x21aa},
|
||||
{0x231a, 0x231b},
|
||||
{0x2328, 0x2328},
|
||||
{0x23cf, 0x23cf},
|
||||
{0x23e9, 0x23f3},
|
||||
{0x23f8, 0x23fa},
|
||||
{0x24c2, 0x24c2},
|
||||
{0x25b6, 0x25b6},
|
||||
{0x25c0, 0x25c0},
|
||||
{0x25fb, 0x25fe},
|
||||
{0x2600, 0x2604},
|
||||
{0x260e, 0x260e},
|
||||
{0x2611, 0x2611},
|
||||
{0x2614, 0x2615},
|
||||
{0x2618, 0x2618},
|
||||
{0x261d, 0x261d},
|
||||
{0x2620, 0x2620},
|
||||
{0x2622, 0x2623},
|
||||
{0x2626, 0x2626},
|
||||
{0x262a, 0x262a},
|
||||
{0x262e, 0x262f},
|
||||
{0x2638, 0x2639},
|
||||
{0x2648, 0x2653},
|
||||
{0x2668, 0x2668},
|
||||
{0x267b, 0x267b},
|
||||
{0x267f, 0x267f},
|
||||
{0x2692, 0x2694},
|
||||
{0x2696, 0x2697},
|
||||
{0x2699, 0x2699},
|
||||
{0x269b, 0x269c},
|
||||
{0x26a0, 0x26a1},
|
||||
{0x26aa, 0x26ab},
|
||||
{0x26b0, 0x26b1},
|
||||
{0x26bd, 0x26be},
|
||||
{0x26c4, 0x26c5},
|
||||
{0x26c8, 0x26c8},
|
||||
{0x26ce, 0x26cf},
|
||||
{0x26d1, 0x26d1},
|
||||
{0x26d3, 0x26d4},
|
||||
{0x26e9, 0x26ea},
|
||||
{0x26f0, 0x26f5},
|
||||
{0x26f7, 0x26fa},
|
||||
{0x26fd, 0x26fd},
|
||||
{0x2702, 0x2702},
|
||||
{0x2705, 0x2705},
|
||||
{0x2708, 0x270b},
|
||||
{0x270d, 0x270d},
|
||||
{0x270f, 0x270f},
|
||||
{0x2712, 0x2712},
|
||||
{0x2714, 0x2714},
|
||||
{0x2716, 0x2716},
|
||||
{0x271d, 0x271d},
|
||||
{0x2721, 0x2721},
|
||||
{0x2728, 0x2728},
|
||||
{0x2733, 0x2734},
|
||||
{0x2744, 0x2744},
|
||||
{0x2747, 0x2747},
|
||||
{0x274c, 0x274c},
|
||||
{0x274e, 0x274e},
|
||||
{0x2753, 0x2755},
|
||||
{0x2757, 0x2757},
|
||||
{0x2764, 0x2764},
|
||||
{0x2795, 0x2797},
|
||||
{0x27a1, 0x27a1},
|
||||
{0x27b0, 0x27b0},
|
||||
{0x27bf, 0x27bf},
|
||||
{0x2934, 0x2935},
|
||||
{0x2b05, 0x2b07},
|
||||
{0x2b1b, 0x2b1c},
|
||||
{0x2b50, 0x2b50},
|
||||
{0x2b55, 0x2b55},
|
||||
{0x3030, 0x3030},
|
||||
{0x303d, 0x303d},
|
||||
{0x3297, 0x3297},
|
||||
{0x3299, 0x3299},
|
||||
{0x1f000, 0x1fffd}
|
||||
};
|
||||
|
||||
/* Sorted list of non-overlapping intervals of East Asian Ambiguous
|
||||
* characters, generated with ../runtime/tools/unicode.vim. */
|
||||
static struct interval ambiguous[] =
|
||||
@@ -1482,6 +1561,8 @@ utf_char2cells(c)
|
||||
if (intable(doublewidth, sizeof(doublewidth), c))
|
||||
return 2;
|
||||
#endif
|
||||
if (intable(emoji, sizeof(emoji), c))
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Characters below 0x100 are influenced by 'isprint' option */
|
||||
|
||||
+3
-2
@@ -1032,8 +1032,9 @@ mf_read(mfp, hp)
|
||||
}
|
||||
|
||||
#ifdef FEAT_CRYPT
|
||||
/* Decrypt if 'key' is set and this is a data block. */
|
||||
if (*mfp->mf_buffer->b_p_key != NUL)
|
||||
/* Decrypt if 'key' is set and this is a data block. And when changing the
|
||||
* key. */
|
||||
if (*mfp->mf_buffer->b_p_key != NUL || mfp->mf_old_key != NULL)
|
||||
ml_decrypt_data(mfp, hp->bh_data, offset, size);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1577,7 +1577,7 @@ get_spec_reg(regname, argp, allocated, errmsg)
|
||||
cmdline_paste_reg(regname, literally, remcr)
|
||||
int regname;
|
||||
int literally; /* Insert text literally instead of "as typed" */
|
||||
int remcr; /* don't add trailing CR */
|
||||
int remcr; /* don't add CR characters */
|
||||
{
|
||||
long i;
|
||||
|
||||
@@ -1590,12 +1590,8 @@ cmdline_paste_reg(regname, literally, remcr)
|
||||
cmdline_paste_str(y_current->y_array[i], literally);
|
||||
|
||||
/* Insert ^M between lines and after last line if type is MLINE.
|
||||
* Don't do this when "remcr" is TRUE and the next line is empty. */
|
||||
if (y_current->y_type == MLINE
|
||||
|| (i < y_current->y_size - 1
|
||||
&& !(remcr
|
||||
&& i == y_current->y_size - 2
|
||||
&& *y_current->y_array[i + 1] == NUL)))
|
||||
* Don't do this when "remcr" is TRUE. */
|
||||
if ((y_current->y_type == MLINE || i < y_current->y_size - 1) && !remcr)
|
||||
cmdline_paste_str((char_u *)"\r", literally);
|
||||
|
||||
/* Check for CTRL-C, in case someone tries to paste a few thousand
|
||||
|
||||
+41
-36
@@ -3345,14 +3345,18 @@ win_line(wp, lnum, startrow, endrow, nochange)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* find start of trailing whitespace */
|
||||
if (wp->w_p_list && lcs_trail)
|
||||
if (wp->w_p_list)
|
||||
{
|
||||
trailcol = (colnr_T)STRLEN(ptr);
|
||||
while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
|
||||
--trailcol;
|
||||
trailcol += (colnr_T) (ptr - line);
|
||||
extra_check = TRUE;
|
||||
if (lcs_space || lcs_trail)
|
||||
extra_check = TRUE;
|
||||
/* find start of trailing whitespace */
|
||||
if (lcs_trail)
|
||||
{
|
||||
trailcol = (colnr_T)STRLEN(ptr);
|
||||
while (trailcol > (colnr_T)0 && vim_iswhite(ptr[trailcol - 1]))
|
||||
--trailcol;
|
||||
trailcol += (colnr_T) (ptr - line);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4354,35 +4358,6 @@ win_line(wp, lnum, startrow, endrow, nochange)
|
||||
#endif
|
||||
++ptr;
|
||||
|
||||
/* 'list': change char 160 to lcs_nbsp and space to lcs_space. */
|
||||
if (wp->w_p_list
|
||||
&& (((c == 160
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))
|
||||
#endif
|
||||
) && lcs_nbsp)
|
||||
|| (c == ' ' && lcs_space && ptr - line <= trailcol)))
|
||||
{
|
||||
c = (c == ' ') ? lcs_space : lcs_nbsp;
|
||||
if (area_attr == 0 && search_attr == 0)
|
||||
{
|
||||
n_attr = 1;
|
||||
extra_attr = hl_attr(HLF_8);
|
||||
saved_attr2 = char_attr; /* save current attr */
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
mb_c = c;
|
||||
if (enc_utf8 && (*mb_char2len)(c) > 1)
|
||||
{
|
||||
mb_utf8 = TRUE;
|
||||
u8cc[0] = 0;
|
||||
c = 0xc0;
|
||||
}
|
||||
else
|
||||
mb_utf8 = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (extra_check)
|
||||
{
|
||||
#ifdef FEAT_SPELL
|
||||
@@ -4567,6 +4542,36 @@ win_line(wp, lnum, startrow, endrow, nochange)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 'list': change char 160 to lcs_nbsp and space to lcs_space.
|
||||
*/
|
||||
if (wp->w_p_list
|
||||
&& (((c == 160
|
||||
#ifdef FEAT_MBYTE
|
||||
|| (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))
|
||||
#endif
|
||||
) && lcs_nbsp)
|
||||
|| (c == ' ' && lcs_space && ptr - line <= trailcol)))
|
||||
{
|
||||
c = (c == ' ') ? lcs_space : lcs_nbsp;
|
||||
if (area_attr == 0 && search_attr == 0)
|
||||
{
|
||||
n_attr = 1;
|
||||
extra_attr = hl_attr(HLF_8);
|
||||
saved_attr2 = char_attr; /* save current attr */
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
mb_c = c;
|
||||
if (enc_utf8 && (*mb_char2len)(c) > 1)
|
||||
{
|
||||
mb_utf8 = TRUE;
|
||||
u8cc[0] = 0;
|
||||
c = 0xc0;
|
||||
}
|
||||
else
|
||||
mb_utf8 = FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
|
||||
{
|
||||
c = lcs_trail;
|
||||
|
||||
@@ -2,6 +2,7 @@ Tests for the :cdo, :cfdo, :ldo and :lfdo commands
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:lang mess C
|
||||
:if !has('quickfix') | e! test.ok | wq! test.out | endif
|
||||
|
||||
:call writefile(["Line1", "Line2", "Line3"], 'Xtestfile1')
|
||||
|
||||
@@ -23,20 +23,24 @@ STARTTEST
|
||||
: $put =g:line
|
||||
: wincmd p
|
||||
:endfu
|
||||
:"
|
||||
:let g:test="Test 1: set linebreak"
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0))
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test="Test 2: set linebreak + set list"
|
||||
:set linebreak list listchars=
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0))
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test ="Test 3: set linebreak nolist"
|
||||
:set nolist linebreak
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0))
|
||||
:call DoRecordScreen()
|
||||
:"
|
||||
:let g:test ="Test 4: set linebreak with tab and 1 line as long as screen: should break!"
|
||||
:set nolist linebreak ts=8
|
||||
:let line="1\t".repeat('a', winwidth(0)-2)
|
||||
@@ -50,6 +54,7 @@ STARTTEST
|
||||
:$put =line
|
||||
:$
|
||||
:norm! zt
|
||||
:"
|
||||
:let g:test ="Test 5: set linebreak with conceal and set list and tab displayed by different char (line may not be truncated)"
|
||||
:set cpo&vim list linebreak conceallevel=2 concealcursor=nv listchars=tab:ab
|
||||
:syn match ConcealVar contained /_/ conceal
|
||||
@@ -57,6 +62,7 @@ STARTTEST
|
||||
:let line=ScreenChar(winwidth(0))
|
||||
:call DoRecordScreen()
|
||||
:set cpo&vim linebreak
|
||||
:"
|
||||
:let g:test ="Test 6: set linebreak with visual block mode"
|
||||
:let line="REMOVE: this not"
|
||||
:$put =g:test
|
||||
@@ -66,20 +72,24 @@ STARTTEST
|
||||
:1/^REMOVE:
|
||||
0jf x:$put
|
||||
:set cpo&vim linebreak
|
||||
:"
|
||||
:let g:test ="Test 7: set linebreak with visual block mode and v_b_A"
|
||||
:$put =g:test
|
||||
Golong line: 40afoobar aTARGET at end
|
||||
:exe "norm! $3B\<C-v>eAx\<Esc>"
|
||||
:set cpo&vim linebreak sbr=
|
||||
:"
|
||||
:let g:test ="Test 8: set linebreak with visual char mode and changing block"
|
||||
:$put =g:test
|
||||
Go1111-1111-1111-11-1111-1111-11110f-lv3lc2222bgj.
|
||||
:"
|
||||
:let g:test ="Test 9: using redo after block visual mode"
|
||||
:$put =g:test
|
||||
Go
|
||||
aaa
|
||||
aaa
|
||||
a2k2j~e.
|
||||
:"
|
||||
:let g:test ="Test 10: using normal commands after block-visual"
|
||||
:$put =g:test
|
||||
:set linebreak
|
||||
@@ -87,10 +97,22 @@ Go
|
||||
abcd{ef
|
||||
ghijklm
|
||||
no}pqrs2k0f{c%
|
||||
:"
|
||||
:let g:test ="Test 11: using block replace mode after wrapping"
|
||||
:$put =g:test
|
||||
:set linebreak wrap
|
||||
Go150aayypk147|jr0
|
||||
:"
|
||||
:let g:test ="Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$"
|
||||
:set list listchars=space:_,trail:-,tab:>-,eol:$
|
||||
:$put =g:test
|
||||
:let line="a aaaaaaaaaaaaaaaaaaaaaa\ta "
|
||||
:$put =line
|
||||
:$
|
||||
:norm! zt
|
||||
:redraw!
|
||||
:let line=ScreenChar(winwidth(0))
|
||||
:call DoRecordScreen()
|
||||
:%w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@@ -52,3 +52,11 @@ abcdpqrs
|
||||
Test 11: using block replace mode after wrapping
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0aaa
|
||||
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
|
||||
a aaaaaaaaaaaaaaaaaaaaaa a
|
||||
|
||||
Test 12: set linebreak list listchars=space:_,tab:>-,tail:-,eol:$
|
||||
a_
|
||||
aaaaaaaaaaaaaaaaaaaa
|
||||
aa>-----a-$
|
||||
~
|
||||
|
||||
@@ -756,6 +756,20 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
979,
|
||||
/**/
|
||||
978,
|
||||
/**/
|
||||
977,
|
||||
/**/
|
||||
976,
|
||||
/**/
|
||||
975,
|
||||
/**/
|
||||
974,
|
||||
/**/
|
||||
973,
|
||||
/**/
|
||||
972,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user