mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
'linespace' now supported
git-svn-id: http://macvim.googlecode.com/svn/trunk@224 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
- (void)setBlinkWait:(int)wait on:(int)on off:(int)off;
|
||||
- (void)startBlink;
|
||||
- (void)stopBlink;
|
||||
- (void)adjustLinespace:(int)linespace;
|
||||
|
||||
- (int)lookupColorWithKey:(NSString *)key;
|
||||
- (BOOL)hasSpecialKeyWithValue:(NSString *)value;
|
||||
|
||||
@@ -836,6 +836,13 @@ enum {
|
||||
blinkState = MMBlinkStateNone;
|
||||
}
|
||||
|
||||
- (void)adjustLinespace:(int)linespace
|
||||
{
|
||||
NSMutableData *data = [NSMutableData data];
|
||||
[data appendBytes:&linespace length:sizeof(int)];
|
||||
[self queueMessage:AdjustLinespaceMsgID data:data];
|
||||
}
|
||||
|
||||
- (int)lookupColorWithKey:(NSString *)key
|
||||
{
|
||||
if (!(key && [key length] > 0))
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
NSColor *defaultBackgroundColor;
|
||||
NSColor *defaultForegroundColor;
|
||||
NSSize cellSize;
|
||||
float linespace;
|
||||
}
|
||||
|
||||
- (NSString *)string;
|
||||
@@ -38,6 +39,8 @@
|
||||
- (int)maxColumns;
|
||||
- (int)actualRows;
|
||||
- (int)actualColumns;
|
||||
- (float)linespace;
|
||||
- (void)setLinespace:(float)newLinespace;
|
||||
- (void)getMaxRows:(int*)rows columns:(int*)cols;
|
||||
- (void)setMaxRows:(int)rows columns:(int)cols;
|
||||
- (void)replaceString:(NSString *)string atRow:(int)row column:(int)col
|
||||
|
||||
+26
-2
@@ -39,6 +39,9 @@
|
||||
// NOTE! It does not matter which font is set here, Vim will set its
|
||||
// own font on startup anyway. Just set some bogus values.
|
||||
font = [[NSFont userFixedPitchFontOfSize:0] retain];
|
||||
boldFont = [font retain];
|
||||
italicFont = [font retain];
|
||||
boldItalicFont = [font retain];
|
||||
cellSize.height = [font pointSize];
|
||||
cellSize.width = [font defaultLineHeightForFont];
|
||||
}
|
||||
@@ -153,6 +156,27 @@
|
||||
return actualColumns;
|
||||
}
|
||||
|
||||
- (float)linespace
|
||||
{
|
||||
return linespace;
|
||||
}
|
||||
|
||||
- (void)setLinespace:(float)newLinespace
|
||||
{
|
||||
NSLayoutManager *lm = [[self layoutManagers] objectAtIndex:0];
|
||||
|
||||
linespace = newLinespace;
|
||||
|
||||
// NOTE: The linespace is added to the cell height in order for a multiline
|
||||
// selection not to have white (background color) gaps between lines. Also
|
||||
// this simplifies the code a lot because there is no need to check the
|
||||
// linespace when calculating the size of the text view etc. When the
|
||||
// linespace is non-zero the baseline will be adjusted as well; check
|
||||
// MMTypesetter.
|
||||
cellSize.height = linespace + (lm ? [lm defaultLineHeightForFont:font]
|
||||
: [font defaultLineHeightForFont]);
|
||||
}
|
||||
|
||||
- (void)getMaxRows:(int*)rows columns:(int*)cols
|
||||
{
|
||||
if (rows) *rows = maxRows;
|
||||
@@ -417,8 +441,8 @@
|
||||
[font retain];
|
||||
|
||||
NSLayoutManager *lm = [[self layoutManagers] objectAtIndex:0];
|
||||
cellSize.height = lm ? [lm defaultLineHeightForFont:font]
|
||||
: [font defaultLineHeightForFont];
|
||||
cellSize.height = linespace + (lm ? [lm defaultLineHeightForFont:font]
|
||||
: [font defaultLineHeightForFont]);
|
||||
|
||||
// NOTE: The font manager does not care about the 'font fixed advance'
|
||||
// attribute, so after converting the font we have to add this
|
||||
|
||||
+3
-1
@@ -52,7 +52,9 @@
|
||||
NSString *text = [ts string];
|
||||
unsigned textLen = [text length];
|
||||
NSSize cellSize = [ts cellSize];
|
||||
float baseline = [font descender];
|
||||
// NOTE: With non-zero linespace the baseline is adjusted so that the text
|
||||
// is centered within a line.
|
||||
float baseline = [font descender] - floor(.5*[ts linespace]);
|
||||
|
||||
if (!(ts && tv && tc && font && text && textLen))
|
||||
return;
|
||||
|
||||
@@ -744,6 +744,11 @@ static NSMenuItem *findMenuItemWithTagInMenu(NSMenu *root, int tag)
|
||||
int shape = *((int*)bytes); bytes += sizeof(int);
|
||||
|
||||
[windowController setMouseShape:shape];
|
||||
} else if (AdjustLinespaceMsgID == msgid) {
|
||||
const void *bytes = [data bytes];
|
||||
int linespace = *((int*)bytes); bytes += sizeof(int);
|
||||
|
||||
[windowController adjustLinespace:linespace];
|
||||
} else {
|
||||
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
- (void)showTabBar:(BOOL)on;
|
||||
- (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode;
|
||||
- (void)setMouseShape:(int)shape;
|
||||
- (void)adjustLinespace:(int)linespace;
|
||||
|
||||
- (IBAction)addNewTab:(id)sender;
|
||||
- (IBAction)toggleToolbar:(id)sender;
|
||||
|
||||
@@ -280,8 +280,6 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
|
||||
|
||||
[self addNewTabViewItem];
|
||||
|
||||
//[[self window] setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
setupDone = YES;
|
||||
|
||||
[self updateResizeIncrements];
|
||||
@@ -543,6 +541,14 @@ NSMutableArray *buildMenuAddress(NSMenu *menu)
|
||||
[NSCursor setHiddenUntilMouseMoves:YES];
|
||||
}
|
||||
|
||||
- (void)adjustLinespace:(int)linespace
|
||||
{
|
||||
if (textStorage) {
|
||||
[textStorage setLinespace:(float)linespace];
|
||||
shouldUpdateWindowSize = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)addNewTab:(id)sender
|
||||
{
|
||||
// NOTE! This can get called a lot if the user holds down the key
|
||||
|
||||
@@ -118,6 +118,7 @@ enum {
|
||||
LostFocusMsgID,
|
||||
MouseMovedMsgID,
|
||||
SetMouseShapeMsgID,
|
||||
AdjustLinespaceMsgID,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ char *MessageStrings[] =
|
||||
"LostFocusMsgID",
|
||||
"MouseMovedMsgID",
|
||||
"SetMouseShapeMsgID",
|
||||
"AdjustLinespaceMsgID",
|
||||
};
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -1073,7 +1073,8 @@ ex_action(eap)
|
||||
int
|
||||
gui_mch_adjust_charheight(void)
|
||||
{
|
||||
return 0;
|
||||
[[MMBackend sharedInstance] adjustLinespace:p_linespace];
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user