mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Added support for font panel.
git-svn-id: http://macvim.googlecode.com/svn/trunk@106 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
<string></string>
|
||||
<key>orderFrontCharacterPalette:</key>
|
||||
<string></string>
|
||||
<key>orderFrontFontPanel:</key>
|
||||
<string></string>
|
||||
<key>performClose:</key>
|
||||
<string></string>
|
||||
<key>performMiniaturize:</key>
|
||||
|
||||
+21
-1
@@ -906,6 +906,25 @@ static int specialKeyToNSKey(int key);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (SetFontMsgID == msgid) {
|
||||
if (!data) return;
|
||||
const void *bytes = [data bytes];
|
||||
float pointSize = *((float*)bytes); bytes += sizeof(float);
|
||||
//unsigned len = *((unsigned*)bytes); bytes += sizeof(unsigned);
|
||||
bytes += sizeof(unsigned); // len not used
|
||||
|
||||
NSMutableString *name = [NSMutableString stringWithUTF8String:bytes];
|
||||
[name appendString:[NSString stringWithFormat:@":h%f", pointSize]];
|
||||
|
||||
gui_init_font((char_u*)[name UTF8String], FALSE);
|
||||
|
||||
// Force screen redraw (does it have to be this complicated?).
|
||||
redraw_all_later(CLEAR);
|
||||
update_screen(NOT_VALID);
|
||||
setcursor();
|
||||
out_flush();
|
||||
gui_update_cursor(FALSE, FALSE);
|
||||
gui_mch_flush();
|
||||
} else if (VimShouldCloseMsgID == msgid) {
|
||||
gui_shell_closed();
|
||||
} else if (DropFilesMsgID == msgid) {
|
||||
@@ -960,7 +979,8 @@ static int specialKeyToNSKey(int key);
|
||||
|
||||
do_cmdline_cmd((char_u*)[cmd UTF8String]);
|
||||
|
||||
// This code was taken from the end of gui_handle_drop().
|
||||
// Force screen redraw (does it have to be this complicated?).
|
||||
// (This code was taken from the end of gui_handle_drop().)
|
||||
update_screen(NOT_VALID);
|
||||
setcursor();
|
||||
out_flush();
|
||||
|
||||
@@ -334,6 +334,32 @@
|
||||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
- (void)changeFont:(id)sender
|
||||
{
|
||||
MMTextStorage *ts = (MMTextStorage*)[self textStorage];
|
||||
if (!ts) return;
|
||||
|
||||
NSFont *oldFont = [ts font];
|
||||
NSFont *newFont = [sender convertFont:oldFont];
|
||||
|
||||
if (newFont) {
|
||||
NSString *name = [newFont displayName];
|
||||
unsigned len = [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
if (len > 0) {
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
float pointSize = [newFont pointSize];
|
||||
|
||||
[data appendBytes:&pointSize length:sizeof(float)];
|
||||
|
||||
++len; // include NUL byte
|
||||
[data appendBytes:&len length:sizeof(unsigned)];
|
||||
[data appendBytes:[name UTF8String] length:len];
|
||||
|
||||
[[self vimController] sendMessage:SetFontMsgID data:data wait:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end // MMTextView
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user