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:
Bjorn Winckler
2007-08-09 09:12:47 +00:00
parent a15c9110c0
commit 846d11d79c
4 changed files with 50 additions and 1 deletions
+2
View File
@@ -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
View File
@@ -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();
+26
View File
@@ -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
+1
View File
@@ -26,6 +26,7 @@ an 10.330 File.Close<Tab>:q :confirm q<CR>
"an 10.331 File.Close\ Tab :tabclose<CR>
an 20.460 Edit.-SEP4- <Nop>
an 20.465 Edit.Show\ Fonts\.\.\. :action orderFrontFontPanel:<CR>
an 20.470 Edit.Special\ Characters\.\.\. :action orderFrontCharacterPalette:<CR>