Skip to content

Commit 6959bce

Browse files
authored
Merge pull request #321 from tkonolige/master
Added columnspace
2 parents 36d5d30 + 08b0bde commit 6959bce

21 files changed

Lines changed: 127 additions & 2 deletions

runtime/doc/options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,16 @@ A jump table for the options with a short description can be found at |Q_op|.
17001700
:set columns=9999
17011701
< Minimum value is 12, maximum value is 10000.
17021702

1703+
*'columnspace'* *'csp'*
1704+
'columnspace' 'csp' number (default 0)
1705+
global
1706+
{not in Vi}
1707+
{only in the MacVim GUI}
1708+
Number of pixel columns inserted between characters. With some fonts
1709+
there can be too much room between characters. Then it makes sense
1710+
to set 'columnspace' to a negative value. This may cause display
1711+
problems though!
1712+
17031713
*'comments'* *'com'* *E524* *E525*
17041714
'comments' 'com' string (default
17051715
"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-")

runtime/doc/quickref.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ Short explanation of each option: *option-list*
645645
'cmdwinheight' 'cwh' height of the command-line window
646646
'colorcolumn' 'cc' columns to highlight
647647
'columns' 'co' number of columns in the display
648+
'columnspace' 'csp' number of pixel columns to use between characters
648649
'comments' 'com' patterns that can start a comment line
649650
'commentstring' 'cms' template for comments; used for fold marker
650651
'compatible' 'cp' behave Vi-compatible as much as possible

runtime/optwin.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ if has("gui")
638638
endif
639639
call append("$", "linespace\tnumber of pixel lines to use between characters")
640640
call append("$", " \tset lsp=" . &lsp)
641+
call append("$", "columnspace\tnumber of pixel columns to use between characters")
642+
call append("$", " \tset csp=" . &csp)
641643
if has("balloon_eval")
642644
call append("$", "balloondelay\tdelay in milliseconds before a balloon may pop up")
643645
call append("$", " \tset bdlay=" . &bdlay)

src/MacVim/MMBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;
123123
- (void)startBlink;
124124
- (void)stopBlink;
125125
- (void)adjustLinespace:(int)linespace;
126+
- (void)adjustColumnspace:(int)columnspace;
126127
- (void)activate;
127128
- (void)setPreEditRow:(int)row column:(int)col;
128129

src/MacVim/MMBackend.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,13 @@ - (void)adjustLinespace:(int)linespace
10951095
[self queueMessage:AdjustLinespaceMsgID data:data];
10961096
}
10971097

1098+
- (void)adjustColumnspace:(int)columnspace
1099+
{
1100+
NSMutableData *data = [NSMutableData data];
1101+
[data appendBytes:&columnspace length:sizeof(int)];
1102+
[self queueMessage:AdjustColumnspaceMsgID data:data];
1103+
}
1104+
10981105
- (void)activate
10991106
{
11001107
[self queueMessage:ActivateMsgID data:nil];

src/MacVim/MMCoreTextView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
NSFont *font;
2323
NSFont *fontWide;
2424
float linespace;
25+
float columnspace;
2526

2627
// From NSTextView
2728
NSSize insetSize;

src/MacVim/MMCoreTextView.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ - (void)setFont:(NSFont *)newFont
311311
// only render at integer sizes. Hence, we restrict the cell width to
312312
// an integer here, otherwise the window width and the actual text
313313
// width will not match.
314-
cellSize.width = ceil(em * cellWidthMultiplier);
314+
cellSize.width = columnspace + ceil(em * cellWidthMultiplier);
315315
cellSize.height = linespace + defaultLineHeightForFont(font);
316316

317317
fontDescent = ceil(CTFontGetDescent(fontRef));
@@ -372,6 +372,17 @@ - (void)setLinespace:(float)newLinespace
372372
cellSize.height = linespace + defaultLineHeightForFont(font);
373373
}
374374

375+
- (void)setColumnspace:(float)newColumnspace
376+
{
377+
columnspace = newColumnspace;
378+
379+
double em = round(defaultAdvanceForFont(font));
380+
float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults]
381+
floatForKey:MMCellWidthMultiplierKey];
382+
383+
cellSize.width = columnspace + ceil(em * cellWidthMultiplier);
384+
}
385+
375386

376387

377388

src/MacVim/MMTextStorage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ typedef struct {
4141
NSColor *defaultForegroundColor;
4242
NSSize cellSize;
4343
float linespace;
44+
float columnspace;
4445
#if MM_USE_ROW_CACHE
4546
MMRowCacheEntry *rowCache;
4647
#endif
@@ -59,7 +60,9 @@ typedef struct {
5960
- (int)actualRows;
6061
- (int)actualColumns;
6162
- (float)linespace;
63+
- (float)columnspace;
6264
- (void)setLinespace:(float)newLinespace;
65+
- (void)setColumnspace:(float)newColumnspace;
6366
- (void)getMaxRows:(int*)rows columns:(int*)cols;
6467
- (void)setMaxRows:(int)rows columns:(int)cols;
6568
- (void)drawString:(NSString *)string atRow:(int)row column:(int)col

src/MacVim/MMTextStorage.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ - (float)linespace
202202
return linespace;
203203
}
204204

205+
- (float)columnspace
206+
{
207+
return columnspace;
208+
}
209+
205210
- (void)setLinespace:(float)newLinespace
206211
{
207212
NSLayoutManager *lm = [[self layoutManagers] objectAtIndex:0];
@@ -221,6 +226,25 @@ - (void)setLinespace:(float)newLinespace
221226
cellSize.height = linespace + [lm defaultLineHeightForFont:font];
222227
}
223228

229+
- (void)setColumnspace:(float)newColumnspace
230+
{
231+
NSLayoutManager *lm = [[self layoutManagers] objectAtIndex:0];
232+
if (!lm) {
233+
ASLogWarn(@"No layout manager available");
234+
return;
235+
}
236+
237+
columnspace = newColumnspace;
238+
239+
float em = [@"m" sizeWithAttributes:
240+
[NSDictionary dictionaryWithObject:font
241+
forKey:NSFontAttributeName]].width;
242+
float cellWidthMultiplier = [[NSUserDefaults standardUserDefaults]
243+
floatForKey:MMCellWidthMultiplierKey];
244+
245+
cellSize.width = columnspace + ceilf(em * cellWidthMultiplier);
246+
}
247+
224248
- (void)getMaxRows:(int*)rows columns:(int*)cols
225249
{
226250
if (rows) *rows = maxRows;
@@ -662,6 +686,7 @@ - (void)setFont:(NSFont*)newFont
662686
NSLayoutManager *lm = [[self layoutManagers] objectAtIndex:0];
663687
if (lm) {
664688
cellSize.height = linespace + [lm defaultLineHeightForFont:font];
689+
cellSize.width = columnspace + ceilf(em * cellWidthMultiplier);
665690
} else {
666691
// Should never happen, set some bogus value for cell height.
667692
ASLogWarn(@"No layout manager available");

src/MacVim/MMTextView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- (void)setWideFont:(NSFont *)newFont;
5050
- (NSSize)cellSize;
5151
- (void)setLinespace:(float)newLinespace;
52+
- (void)setColumnspace:(float)newColumnspace;
5253
- (int)maxRows;
5354
- (int)maxColumns;
5455
- (void)getMaxRows:(int*)rows columns:(int*)cols;

0 commit comments

Comments
 (0)