Skip to content
Browse files

Merge branch 'master' into macvim73

  • Loading branch information...
2 parents 5dcf4f9 + 3b984bf commit 7f753e884156a341813b8c320554de5b1c0b97a8 @b4winckler committed Jul 23, 2010
View
2 src/MacVim/Info.plist
@@ -1251,6 +1251,8 @@
<string>http://bjorn.winckler.googlepages.com/macvim_latest.xml</string>
<key>NSAppleScriptEnabled</key>
<true/>
+ <key>OSAScriptingDefinition</key>
+ <string>MacVim.sdef</string>
<!-- In order for Quick Look to work we must add entries to
UTExportedTypeDeclarations. When possible a "proper" UTI is used,
View
1 src/MacVim/MMAtsuiTextView.h
@@ -68,6 +68,7 @@ enum { MMMaxCellsPerChar = 2 };
//
// MMTextView methods
//
+- (void)deleteSign:(NSString *)signName;
- (void)setPreEditRow:(int)row column:(int)col;
- (void)setMouseShape:(int)shape;
- (void)setAntialias:(BOOL)state;
View
4 src/MacVim/MMAtsuiTextView.m
@@ -336,6 +336,10 @@ - (void)setShouldDrawInsertionPoint:(BOOL)on
{
}
+- (void)deleteSign:(NSString *)signName
+{
+}
+
- (void)setPreEditRow:(int)row column:(int)col
{
[helper setPreEditRow:row column:col];
View
5 src/MacVim/MMBackend.h
@@ -85,6 +85,11 @@
fraction:(int)percent color:(int)color;
- (void)drawInvertedRectAtRow:(int)row column:(int)col numRows:(int)nr
numColumns:(int)nc invert:(int)invert;
+- (void)drawSign:(NSString *)imgName
+ atRow:(int)row
+ column:(int)col
+ width:(int)width
+ height:(int)height;
- (void)update;
- (void)flushQueue:(BOOL)force;
- (BOOL)waitForInput:(int)milliseconds;
View
20 src/MacVim/MMBackend.m
@@ -589,6 +589,26 @@ - (void)drawInvertedRectAtRow:(int)row column:(int)col numRows:(int)nr
[drawData appendBytes:&invert length:sizeof(int)];
}
+- (void)drawSign:(NSString *)imgName
+ atRow:(int)row
+ column:(int)col
+ width:(int)width
+ height:(int)height
+{
+ int type = DrawSignDrawType;
+ [drawData appendBytes:&type length:sizeof(int)];
+
+ const char* utf8String = [imgName UTF8String];
+ int strSize = (int)strlen(utf8String) + 1;
+ [drawData appendBytes:&strSize length:sizeof(int)];
+ [drawData appendBytes:utf8String length:strSize];
+
+ [drawData appendBytes:&col length:sizeof(int)];
+ [drawData appendBytes:&row length:sizeof(int)];
+ [drawData appendBytes:&width length:sizeof(int)];
+ [drawData appendBytes:&height length:sizeof(int)];
+}
+
- (void)update
{
// Keep running the run-loop until there is no more input to process.
View
1 src/MacVim/MMCoreTextView.h
@@ -66,6 +66,7 @@
//
// MMTextView methods
//
+- (void)deleteSign:(NSString *)signName;
- (void)setShouldDrawInsertionPoint:(BOOL)on;
- (void)setPreEditRow:(int)row column:(int)col;
- (void)setMouseShape:(int)shape;
View
33 src/MacVim/MMCoreTextView.m
@@ -47,14 +47,6 @@
#define DRAW_CURSOR 0x20
#define DRAW_WIDE 0x40 /* draw wide text */
-
-#define BLUE(argb) ((argb & 0xff)/255.0f)
-#define GREEN(argb) (((argb>>8) & 0xff)/255.0f)
-#define RED(argb) (((argb>>16) & 0xff)/255.0f)
-#define ALPHA(argb) (((argb>>24) & 0xff)/255.0f)
-
-
-
@interface MMCoreTextView (Private)
- (MMWindowController *)windowController;
- (MMVimController *)vimController;
@@ -377,6 +369,11 @@ - (void)setLinespace:(float)newLinespace
+- (void)deleteSign:(NSString *)signName
+{
+ [helper deleteImage:signName];
+}
+
- (void)setShouldDrawInsertionPoint:(BOOL)on
{
}
@@ -907,6 +904,26 @@ - (void)batchDrawData:(NSData *)data
[self deleteLinesFromRow:row lineCount:count
scrollBottom:bot left:left right:right
color:color];
+ } else if (DrawSignDrawType == type) {
+ int strSize = *((int*)bytes); bytes += sizeof(int);
+ NSString *imgName =
+ [NSString stringWithUTF8String:(const char*)bytes];
+ bytes += strSize;
+
+ int col = *((int*)bytes); bytes += sizeof(int);
+ int row = *((int*)bytes); bytes += sizeof(int);
+ int width = *((int*)bytes); bytes += sizeof(int);
+ int height = *((int*)bytes); bytes += sizeof(int);
+
+ NSImage *signImg = [helper signImageForName:imgName];
+ NSRect r = [self rectForRow:row
+ column:col
+ numRows:height
+ numColumns:width];
+ [signImg drawInRect:r
+ fromRect:NSZeroRect
+ operation:NSCompositeSourceOver
+ fraction:1.0];
} else if (DrawStringDrawType == type) {
int bg = *((int*)bytes); bytes += sizeof(int);
int fg = *((int*)bytes); bytes += sizeof(int);
View
2 src/MacVim/MMTextView.h
@@ -59,10 +59,10 @@
- (NSSize)desiredSize;
- (NSSize)minSize;
-
- (BOOL)convertPoint:(NSPoint)point toRow:(int *)row column:(int *)column;
- (NSPoint)pointForRow:(int)row column:(int)col;
- (NSRect)rectForRow:(int)row column:(int)col numRows:(int)nr
numColumns:(int)nc;
+- (void)deleteSign:(NSString *)signName;
@end
View
4 src/MacVim/MMTextView.m
@@ -492,6 +492,10 @@ - (NSRect)rectForRow:(int)row column:(int)col numRows:(int)nr
return rect;
}
+- (void)deleteSign:(NSString *)signName
+{
+}
+
- (BOOL)isOpaque
{
return NO;
View
12 src/MacVim/MMTextViewHelper.h
@@ -16,6 +16,12 @@
#endif
+#define BLUE(argb) ((argb & 0xff)/255.0f)
+#define GREEN(argb) (((argb>>8) & 0xff)/255.0f)
+#define RED(argb) (((argb>>16) & 0xff)/255.0f)
+#define ALPHA(argb) (((argb>>24) & 0xff)/255.0f)
+
+
enum {
// These values are chosen so that the min text view size is not too small
// with the default font (they only affect resizing with the mouse, you can
@@ -38,12 +44,13 @@ enum {
NSColor *insertionPointColor;
BOOL interpretKeyEventsSwallowedKey;
NSEvent *currentEvent;
+ NSMutableDictionary *signImages;
// Input Manager
NSRange imRange;
NSRange markedRange;
NSDictionary *markedTextAttributes;
- NSMutableAttributedString *markedText;
+ NSMutableAttributedString *markedText;
int preEditRow;
int preEditColumn;
BOOL imControl;
@@ -54,6 +61,7 @@ enum {
#endif
}
+- (id)init;
- (void)setTextView:(id)view;
- (void)setInsertionPointColor:(NSColor *)color;
- (NSColor *)insertionPointColor;
@@ -77,6 +85,8 @@ enum {
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
- (void)setMouseShape:(int)shape;
- (void)changeFont:(id)sender;
+- (NSImage *)signImageForName:(NSString *)imgName;
+- (void)deleteImage:(NSString *)imgName;
// Input Manager
- (BOOL)hasMarkedText;
View
31 src/MacVim/MMTextViewHelper.m
@@ -70,13 +70,24 @@ - (void)abandonMarkedText;
@implementation MMTextViewHelper
+- (id)init
+{
+ if (!(self = [super init]))
+ return nil;
+
+ signImages = [[NSMutableDictionary alloc] init];
+
+ return self;
+}
+
- (void)dealloc
{
ASLogDebug(@"");
[insertionPointColor release]; insertionPointColor = nil;
[markedText release]; markedText = nil;
[markedTextAttributes release]; markedTextAttributes = nil;
+ [signImages release]; signImages = nil;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
if (asciiImSource) {
@@ -607,6 +618,26 @@ - (void)changeFont:(id)sender
}
}
+- (NSImage *)signImageForName:(NSString *)imgName
+{
+ NSImage *img = [signImages objectForKey:imgName];
+ if (img)
+ return img;
+
+ img = [[NSImage alloc] initWithContentsOfFile:imgName];
+ if (img) {
+ [signImages setObject:img forKey:imgName];
+ [img autorelease];
+ }
+
+ return img;
+}
+
+- (void)deleteImage:(NSString *)imgName
+{
+ [signImages removeObjectForKey:imgName];
+}
+
- (BOOL)hasMarkedText
{
return markedRange.length > 0 ? YES : NO;
View
10 src/MacVim/MMVimController.m
@@ -97,6 +97,7 @@ - (void)connectionDidDie:(NSNotification *)notification;
- (void)scheduleClose;
- (void)handleBrowseForFile:(NSDictionary *)attr;
- (void)handleShowDialog:(NSDictionary *)attr;
+- (void)handleDeleteSign:(NSDictionary *)attr;
@end
@@ -819,6 +820,10 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
if (dict)
[self handleShowDialog:dict];
+ } else if (DeleteSignMsgID == msgid) {
+ NSDictionary *dict = [NSDictionary dictionaryWithData:data];
+ if (dict)
+ [self handleDeleteSign:dict];
} else if (ZoomMsgID == msgid) {
const void *bytes = [data bytes];
int rows = *((int*)bytes); bytes += sizeof(int);
@@ -1438,6 +1443,11 @@ - (void)handleShowDialog:(NSDictionary *)attr
[alert release];
}
+- (void)handleDeleteSign:(NSDictionary *)attr
+{
+ MMTextView *view = [[windowController vimView] textView];
+ [view deleteSign:[attr objectForKey:@"imgName"]];
+}
@end // MMVimController (Private)
View
2 src/MacVim/MacVim.h
@@ -192,6 +192,7 @@ enum {
SetMarkedTextMsgID,
ZoomMsgID,
SetWindowPositionMsgID,
+ DeleteSignMsgID,
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
};
@@ -205,6 +206,7 @@ enum {
DrawCursorDrawType,
SetCursorPosDrawType,
DrawInvertedRectDrawType,
+ DrawSignDrawType,
};
enum {
View
1 src/MacVim/MacVim.m
@@ -95,6 +95,7 @@
"SetMarkedTextMsgID",
"ZoomMsgID",
"SetWindowPositionMsgID",
+ "DeleteSignMsgID",
"END OF MESSAGE IDs" // NOTE: Must be last!
};
View
5 src/MacVim/MacVim.sdef
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">
+<dictionary xmlns:xi="http://www.w3.org/2003/XInclude">
+ <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>
+</dictionary>
View
4 src/MacVim/MacVim.xcodeproj/project.pbxproj
@@ -77,6 +77,7 @@
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
+ B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */ = {isa = PBXBuildFile; fileRef = B59228A511F7572F00E7F584 /* MacVim.sdef */; };
BD476E300DAAD74400F08A5C /* RBSplitSubview.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */; };
BD476E310DAAD74400F08A5C /* RBSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD476E2E0DAAD74400F08A5C /* RBSplitView.m */; };
BD943D530DA3050B00A02D9B /* PlugInImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = BD943D520DA3050B00A02D9B /* PlugInImpl.m */; };
@@ -261,6 +262,7 @@
32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacVim_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* MacVim.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacVim.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ B59228A511F7572F00E7F584 /* MacVim.sdef */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.sdef; path = MacVim.sdef; sourceTree = "<group>"; };
BD476E2B0DAAD74400F08A5C /* RBSplitSubview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitSubview.h; sourceTree = "<group>"; };
BD476E2C0DAAD74400F08A5C /* RBSplitSubview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RBSplitSubview.m; sourceTree = "<group>"; };
BD476E2D0DAAD74400F08A5C /* RBSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RBSplitView.h; sourceTree = "<group>"; };
@@ -477,6 +479,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ B59228A511F7572F00E7F584 /* MacVim.sdef */,
1D384A0D100D671700D3C22F /* KeyBinding.plist */,
1D9C602E0EF79C0C0034AD44 /* MacVim.icns */,
1D8BEA73104992290069B072 /* FindAndReplace.nib */,
@@ -636,6 +639,7 @@
1D8BEA74104992290069B072 /* FindAndReplace.nib in Resources */,
1D9C60520EF79C0C0034AD44 /* MacVim.icns in Resources */,
1D384A0E100D671700D3C22F /* KeyBinding.plist in Resources */,
+ B59228A611F7572F00E7F584 /* MacVim.sdef in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
71 src/MacVim/gui_macvim.m
@@ -22,6 +22,7 @@
// HACK! Used in gui.c to determine which string drawing code to use.
int use_gui_macvim_draw_string = 1;
+static int use_graphical_sign = 0;
// NOTE: The default font is bundled with the application.
static NSString *MMDefaultFontName = @"DejaVu Sans Mono";
@@ -148,6 +149,10 @@
if (keyValid) {
ASLogInfo(@"Use renderer=%d", val);
use_gui_macvim_draw_string = (val != MMRendererCoreText);
+
+ // For now only the Core Text renderer knows how to render graphical
+ // signs.
+ use_graphical_sign = (val == MMRendererCoreText);
}
}
@@ -2134,3 +2139,69 @@ static int vimModMaskToEventModifierFlags(int mods)
}
#endif // FEAT_NETBEANS_INTG
+
+
+
+// -- Graphical Sign Support ------------------------------------------------
+
+#if defined(FEAT_SIGN_ICONS)
+ void
+gui_mch_drawsign(int row, int col, int typenr)
+{
+ if (!gui.in_use)
+ return;
+
+ NSString *imgName = (NSString *)sign_get_image(typenr);
+ if (!imgName)
+ return;
+
+ char_u *txt = sign_get_text(typenr);
+ int txtSize = txt ? strlen((char*)txt) : 2;
+
+ [[MMBackend sharedInstance] drawSign:imgName
+ atRow:row
+ column:col
+ width:txtSize
+ height:1];
+}
+
+ void *
+gui_mch_register_sign(char_u *signfile)
+{
+ if (!use_graphical_sign)
+ return NULL;
+
+ NSString *imgName = [NSString stringWithVimString:signfile];
+ NSImage *img = [[NSImage alloc] initWithContentsOfFile:imgName];
+ if (!img) {
+ EMSG(_(e_signdata));
+ return NULL;
+ }
+
+ [img release];
+
+ return (void*)[imgName retain];
+}
+
+ void
+gui_mch_destroy_sign(void *sign)
+{
+ NSString *imgName = (NSString *)sign;
+ if (!imgName)
+ return;
+
+ [[MMBackend sharedInstance]
+ queueMessage:DeleteSignMsgID
+ properties:[NSDictionary dictionaryWithObjectsAndKeys:
+ imgName, @"imgName", nil]];
+ [imgName release];
+}
+
+# ifdef FEAT_NETBEANS_INTG
+ void
+netbeans_draw_multisign_indicator(int row)
+{
+}
+# endif // FEAT_NETBEANS_INTG
+
+#endif // FEAT_SIGN_ICONS
View
1 src/feature.h
@@ -1249,6 +1249,7 @@
# if ((defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_ATHENA)) \
&& defined(HAVE_X11_XPM_H)) \
|| defined(FEAT_GUI_GTK) \
+ || defined(FEAT_GUI_MACVIM) \
|| (defined(WIN32) && defined(FEAT_GUI))
# define FEAT_SIGN_ICONS
# endif
View
10 src/proto/gui_macvim.pro
@@ -224,3 +224,13 @@ im_set_control(int enable);
void
gui_macvim_set_netbeans_socket(int socket);
+
+ void
+gui_mch_drawsign(int row, int col, int typenr);
+
+ void *
+gui_mch_register_sign(char_u *signfile);
+
+ void
+gui_mch_destroy_sign(void *sign);
+

0 comments on commit 7f753e8

Please sign in to comment.
Something went wrong with that request. Please try again.