Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions runtime/doc/gui_mac.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ to your .gvimrc file to revert back to the default Vim tab label.
*macvim-options*
These are the non-standard options that MacVim supports:
'antialias' 'blurradius' 'fullscreen'
'fuoptions' 'macligatures' 'macmeta' 'toolbariconsize'
'transparency'
'fuoptions' 'macligatures' 'macmeta' 'macthinstrokes'
'toolbariconsize' 'transparency'

*macvim-commands*
These are the non-standard commands that MacVim supports:
Expand Down
12 changes: 12 additions & 0 deletions runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5043,6 +5043,18 @@ A jump table for the options with a short description can be found at |Q_op|.
'guifont' supports them. Examples for such fonts are Fira Code or
Haskelig.
Note: Currently this option only has an effect if
'Use Core Text renderer' is enabled in the GUI preferences pane.

*'macthinstrokes'* *'nomacthinstrokes'*
'macthinstrokes' boolean (default off)
global
{not in Vi}
{only available when compiled with GUI enabled on
Mac OS X}
This option only has an effect in the GUI version of Vim on Mac OS X
v10.8 or later. When on, Vim will render the text a little lighter
which looks nice with a dark colorscheme.
Note: Currently this option only has an effect if
'Use Core Text renderer' is enabled in the GUI preferences pane.

*'macmeta'* *'mmta'* *'nomacmeta'* *'nommta'*
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/quickref.txt
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ Short explanation of each option: *option-list*
'macatsui' Mac GUI: use ATSUI text drawing
'macligatures' display ligatures (MacVim GUI only)
'macmeta' 'mmta' use option as meta key (MacVim GUI only)
'macthinstrokes' render the text lighter by using thin strokes (MacVim GUI only)
'magic' changes special characters in search patterns
'makeef' 'mef' name of the errorfile for ":make"
'makeprg' 'mp' program to use for the ":make" command
Expand Down
2 changes: 2 additions & 0 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
'macatsui' options.txt /*'macatsui'*
'macligatures' options.txt /*'macligatures'*
'macmeta' options.txt /*'macmeta'*
'macthinstrokes' options.txt /*'macthinstrokes'*
'magic' options.txt /*'magic'*
'makeef' options.txt /*'makeef'*
'makeprg' options.txt /*'makeprg'*
Expand Down Expand Up @@ -614,6 +615,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
'nomacatsui' options.txt /*'nomacatsui'*
'nomacligatures' options.txt /*'nomacligatures'*
'nomacmeta' options.txt /*'nomacmeta'*
'nomacthinstrokes' options.txt /*'nomacthinstrokes'*
'nomagic' options.txt /*'nomagic'*
'nomh' options.txt /*'nomh'*
'noml' options.txt /*'noml'*
Expand Down
2 changes: 2 additions & 0 deletions runtime/optwin.vim
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@ if has("gui")
call <SID>BinOptionG("macligatures", &macligatures)
call append("$", "macmeta\tuse option as meta key")
call append("$", "\t(local to buffer)")
call append("$", "macthinstrokes\tuse thin strokes")
call <SID>BinOptionG("macthinstrokes", &macthinstrokes)
call <SID>BinOptionL("mmta")
endif
endif
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/MMBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ extern NSTimeInterval MMBalloonEvalInternalDelay;

- (void)setAntialias:(BOOL)antialias;
- (void)setLigatures:(BOOL)ligatures;
- (void)setThinStrokes:(BOOL)thinStrokes;
- (void)setBlurRadius:(int)radius;

- (void)updateModifiedFlag;
Expand Down
7 changes: 7 additions & 0 deletions src/MacVim/MMBackend.m
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,13 @@ - (void)setLigatures:(BOOL)ligatures
[self queueMessage:msgid data:nil];
}

- (void)setThinStrokes:(BOOL)thinStrokes
{
int msgid = thinStrokes ? EnableThinStrokesMsgID : DisableThinStrokesMsgID;

[self queueMessage:msgid data:nil];
}

- (void)setBlurRadius:(int)radius
{
NSMutableData *data = [NSMutableData data];
Expand Down
2 changes: 2 additions & 0 deletions src/MacVim/MMCoreTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
float fontDescent;
BOOL antialias;
BOOL ligatures;
BOOL thinStrokes;
NSMutableArray *drawData;

MMTextViewHelper *helper;
Expand Down Expand Up @@ -77,6 +78,7 @@
- (void)setMouseShape:(int)shape;
- (void)setAntialias:(BOOL)state;
- (void)setLigatures:(BOOL)state;
- (void)setThinStrokes:(BOOL)state;
- (void)setImControl:(BOOL)enable;
- (void)activateIm:(BOOL)enable;
- (void)checkImState;
Expand Down
18 changes: 18 additions & 0 deletions src/MacVim/MMCoreTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#define kCTFontOrientationDefault kCTFontDefaultOrientation
#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8

extern void CGContextSetFontSmoothingStyle(CGContextRef, int);
extern int CGContextGetFontSmoothingStyle(CGContextRef);
#define fontSmoothingStyleLight (2 << 3)

#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
static void
CTFontDrawGlyphs(CTFontRef fontRef, const CGGlyph glyphs[],
Expand Down Expand Up @@ -396,6 +400,11 @@ - (void)setLigatures:(BOOL)state
ligatures = state;
}

- (void)setThinStrokes:(BOOL)state
{
thinStrokes = state;
}

- (void)setImControl:(BOOL)enable
{
[helper setImControl:enable];
Expand Down Expand Up @@ -1299,6 +1308,13 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length

CGContextSaveGState(context);

int originalFontSmoothingStyle = 0;
if (thinStrokes) {
CGContextSetShouldSmoothFonts(context, YES);
originalFontSmoothingStyle = CGContextGetFontSmoothingStyle(context);
CGContextSetFontSmoothingStyle(context, fontSmoothingStyleLight);
}

// NOTE! 'cells' is zero if we're drawing a composing character
CGFloat clipWidth = cells > 0 ? cells*cellSize.width : w;
CGRect clipRect = { {x, y}, {clipWidth, cellSize.height} };
Expand Down Expand Up @@ -1389,6 +1405,8 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
recurseDraw(chars, glyphs, positions, length, context, fontRef, fontCache, ligatures);

CFRelease(fontRef);
if (thinStrokes)
CGContextSetFontSmoothingStyle(context, originalFontSmoothingStyle);
CGContextRestoreGState(context);
}

Expand Down
2 changes: 2 additions & 0 deletions src/MacVim/MMTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
int insertionPointFraction;
BOOL antialias;
BOOL ligatures;
BOOL thinStrokes;
NSRect *invertRects;
int numInvertRects;

Expand All @@ -34,6 +35,7 @@
- (void)setMouseShape:(int)shape;
- (void)setAntialias:(BOOL)antialias;
- (void)setLigatures:(BOOL)ligatures;
- (void)setThinStrokes:(BOOL)thinStrokes;
- (void)setImControl:(BOOL)enable;
- (void)activateIm:(BOOL)enable;
- (void)checkImState;
Expand Down
5 changes: 5 additions & 0 deletions src/MacVim/MMTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ - (void)setLigatures:(BOOL)state
ligatures = state;
}

- (void)setThinStrokes:(BOOL)state
{
thinStrokes = state;
}

- (void)setImControl:(BOOL)enable
{
[helper setImControl:enable];
Expand Down
4 changes: 4 additions & 0 deletions src/MacVim/MMVimController.m
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ - (void)handleMessage:(int)msgid data:(NSData *)data
[[[windowController vimView] textView] setLigatures:YES];
} else if (DisableLigaturesMsgID == msgid) {
[[[windowController vimView] textView] setLigatures:NO];
} else if (EnableThinStrokesMsgID == msgid) {
[[[windowController vimView] textView] setThinStrokes:YES];
} else if (DisableThinStrokesMsgID == msgid) {
[[[windowController vimView] textView] setThinStrokes:NO];
} else if (SetVimStateMsgID == msgid) {
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
if (dict) {
Expand Down
2 changes: 2 additions & 0 deletions src/MacVim/MacVim.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ enum {
SetBlurRadiusMsgID,
EnableLigaturesMsgID,
DisableLigaturesMsgID,
EnableThinStrokesMsgID,
DisableThinStrokesMsgID,
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
};

Expand Down
2 changes: 2 additions & 0 deletions src/MacVim/MacVim.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
"SetBlurRadiusMsgID",
"EnableLigaturesMsgID",
"DisableLigaturesMsgID",
"EnableThinStrokesMsgID",
"DisableThinStrokesMsgID",
"END OF MESSAGE IDs" // NOTE: Must be last!
};

Expand Down
5 changes: 5 additions & 0 deletions src/MacVim/gui_macvim.m
Original file line number Diff line number Diff line change
Expand Up @@ -1818,6 +1818,11 @@
{
[[MMBackend sharedInstance] setLigatures:ligatures];
}
void
gui_macvim_set_thinstrokes(int thinStrokes)
{
[[MMBackend sharedInstance] setThinStrokes:thinStrokes];
}

void
gui_macvim_wait_for_startup()
Expand Down
9 changes: 9 additions & 0 deletions src/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,11 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)FALSE, (char_u *)0L}},
#ifdef FEAT_GUI_MACVIM
{"macthinstrokes", NULL, P_BOOL|P_VI_DEF|P_RCLR,
(char_u *)&p_macthinstrokes, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}},
#endif
{"magic", NULL, P_BOOL|P_VI_DEF,
(char_u *)&p_magic, PV_NONE,
{(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Expand Down Expand Up @@ -8238,6 +8243,10 @@ set_bool_option(
{
gui_macvim_set_ligatures(p_macligatures);
}
else if ((int*)varp == &p_macthinstrokes)
{
gui_macvim_set_thinstrokes(p_macthinstrokes);
}
#endif

/* when 'textauto' is set or reset also change 'fileformats' */
Expand Down
1 change: 1 addition & 0 deletions src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ EXTERN int p_macatsui; /* 'macatsui' */
#endif
#ifdef FEAT_GUI_MACVIM
EXTERN int p_macligatures; /* 'macligatures' */
EXTERN int p_macthinstrokes; /* 'macthinstrokes' */
#endif
EXTERN int p_magic; /* 'magic' */
#ifdef FEAT_QUICKFIX
Expand Down
1 change: 1 addition & 0 deletions src/proto/gui_macvim.pro
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ void gui_macvim_update_modified_flag();
void gui_macvim_add_to_find_pboard(char_u *pat);
void gui_macvim_set_antialias(int antialias);
void gui_macvim_set_ligatures(int ligatures);
void gui_macvim_set_thinstrokes(int thinStrokes);
void gui_macvim_set_blur(int blur);

int16_t odb_buffer_close(buf_T *buf);
Expand Down