mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-07 15:37:14 +02:00
Update 'gfw' on Cmd--/Cmd-+
This commit is contained in:
@@ -780,24 +780,7 @@ defaultLineHeightForFont(NSFont *font)
|
||||
|
||||
- (void)changeFont:(id)sender
|
||||
{
|
||||
NSFont *newFont = [sender convertFont:font];
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
[helper changeFont:sender];
|
||||
}
|
||||
|
||||
|
||||
|
||||
+28
-4
@@ -2159,21 +2159,45 @@ extern GuiFont gui_mch_retain_font(GuiFont font);
|
||||
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
|
||||
int pointSize = (int)*((float*)bytes); bytes += sizeof(float);
|
||||
|
||||
unsigned len = *((unsigned*)bytes); bytes += sizeof(unsigned);
|
||||
NSMutableString *name = [NSMutableString stringWithUTF8String:bytes];
|
||||
[name appendString:[NSString stringWithFormat:@":h%d", (int)pointSize]];
|
||||
bytes += len;
|
||||
|
||||
[name appendString:[NSString stringWithFormat:@":h%d", pointSize]];
|
||||
char_u *s = (char_u*)[name UTF8String];
|
||||
|
||||
unsigned wlen = *((unsigned*)bytes); bytes += sizeof(unsigned);
|
||||
char_u *ws = NULL;
|
||||
if (wlen > 0) {
|
||||
NSMutableString *wname = [NSMutableString stringWithUTF8String:bytes];
|
||||
bytes += wlen;
|
||||
|
||||
[wname appendString:[NSString stringWithFormat:@":h%d", pointSize]];
|
||||
ws = (char_u*)[wname UTF8String];
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
s = CONVERT_FROM_UTF8(s);
|
||||
if (ws) {
|
||||
ws = CONVERT_FROM_UTF8(ws);
|
||||
}
|
||||
#endif
|
||||
|
||||
set_option_value((char_u*)"guifont", 0, s, 0);
|
||||
|
||||
if (ws && gui.wide_font != NOFONT) {
|
||||
// NOTE: This message is sent on Cmd-+/Cmd-- and as such should only
|
||||
// change the wide font if 'gfw' is non-empty (the frontend always has
|
||||
// some wide font set, even if 'gfw' is empty).
|
||||
set_option_value((char_u*)"guifontwide", 0, ws, 0);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (ws) {
|
||||
CONVERT_FROM_UTF8_FREE(ws);
|
||||
}
|
||||
CONVERT_FROM_UTF8_FREE(s);
|
||||
#endif
|
||||
|
||||
|
||||
+1
-22
@@ -815,28 +815,7 @@
|
||||
|
||||
- (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];
|
||||
}
|
||||
}
|
||||
[helper changeFont:sender];
|
||||
}
|
||||
|
||||
- (void)resetCursorRects
|
||||
|
||||
@@ -65,6 +65,7 @@ enum {
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
|
||||
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender;
|
||||
- (void)setMouseShape:(int)shape;
|
||||
- (void)changeFont:(id)sender;
|
||||
|
||||
// Input Manager
|
||||
- (BOOL)hasMarkedText;
|
||||
|
||||
@@ -578,6 +578,40 @@ static float MMDragAreaSize = 73.0f;
|
||||
[self setCursor];
|
||||
}
|
||||
|
||||
- (void)changeFont:(id)sender
|
||||
{
|
||||
NSFont *newFont = [sender convertFont:[textView font]];
|
||||
NSFont *newFontWide = [sender convertFont:[textView fontWide]];
|
||||
|
||||
if (newFont) {
|
||||
NSString *name = [newFont displayName];
|
||||
NSString *wideName = [newFontWide displayName];
|
||||
unsigned len = [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
|
||||
unsigned wideLen = [wideName 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];
|
||||
|
||||
if (wideLen > 0) {
|
||||
++wideLen; // include NUL byte
|
||||
[data appendBytes:&wideLen length:sizeof(unsigned)];
|
||||
[data appendBytes:[wideName UTF8String] length:wideLen];
|
||||
} else {
|
||||
[data appendBytes:&wideLen length:sizeof(unsigned)];
|
||||
}
|
||||
|
||||
[[self vimController] sendMessage:SetFontMsgID data:data];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasMarkedText
|
||||
{
|
||||
return markedRange.length > 0 ? YES : NO;
|
||||
|
||||
Reference in New Issue
Block a user