'linespace' now supported

git-svn-id: http://macvim.googlecode.com/svn/trunk@224 96c4425d-ca35-0410-94e5-3396d5c13a8f
This commit is contained in:
Bjorn Winckler
2007-08-31 17:15:15 +00:00
parent ccaaae3c00
commit 5db52978b5
11 changed files with 58 additions and 6 deletions
+1
View File
@@ -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;
+7
View File
@@ -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))
+3
View File
@@ -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
View File
@@ -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
View File
@@ -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;
+5
View File
@@ -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);
}
+1
View File
@@ -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;
+8 -2
View File
@@ -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
+1
View File
@@ -118,6 +118,7 @@ enum {
LostFocusMsgID,
MouseMovedMsgID,
SetMouseShapeMsgID,
AdjustLinespaceMsgID,
};
+1
View File
@@ -56,6 +56,7 @@ char *MessageStrings[] =
"LostFocusMsgID",
"MouseMovedMsgID",
"SetMouseShapeMsgID",
"AdjustLinespaceMsgID",
};
+2 -1
View File
@@ -1073,7 +1073,8 @@ ex_action(eap)
int
gui_mch_adjust_charheight(void)
{
return 0;
[[MMBackend sharedInstance] adjustLinespace:p_linespace];
return OK;
}