Skip to content

Instantly share code, notes, and snippets.

@yankcrime
Created July 12, 2016 20:10
Show Gist options
  • Save yankcrime/84266435aa69a513e39482938eb40204 to your computer and use it in GitHub Desktop.
Save yankcrime/84266435aa69a513e39482938eb40204 to your computer and use it in GitHub Desktop.
diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m
index a9e8b9b..f30a8da 100644
--- a/src/MacVim/MMCoreTextView.m
+++ b/src/MacVim/MMCoreTextView.m
@@ -42,6 +42,7 @@
#define DRAW_UNDERC 0x08 /* draw undercurl text */
#define DRAW_ITALIC 0x10 /* draw italic text */
#define DRAW_CURSOR 0x20
+#define DRAW_BEVEL 0x3f
#define DRAW_WIDE 0x40 /* draw wide text */
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
@@ -821,6 +822,7 @@ - (NSRect)rectFromRow:(int)row1 column:(int)col1
toRow:(int)row2 column:(int)col2
{
NSRect frame = [self bounds];
+
return NSMakeRect(
insetSize.width + col1*cellSize.width,
frame.size.height - insetSize.height - (row2+1)*cellSize.height,
@@ -1291,6 +1293,9 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
float y = frame.size.height - insetSize.height - (1+row)*cellSize.height;
float w = cellSize.width;
+ // dphase
+ // NSLog(@"string! [%#x] %S", flags, chars);
+
if (flags & DRAW_WIDE) {
// NOTE: It is assumed that either all characters in 'chars' are wide
// or all are normal width.
@@ -1322,12 +1327,15 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
CGContextSetBlendMode(context, kCGBlendModeNormal);
}
+
if (flags & DRAW_UNDERL) {
// Draw underline
CGRect rect = { {x, y+0.4*fontDescent}, {cells*cellSize.width, 1} };
CGContextSetRGBFillColor(context, RED(sp), GREEN(sp), BLUE(sp),
ALPHA(sp));
CGContextFillRect(context, rect);
+ } else if (flags == DRAW_BEVEL) {
+ NSLog(@"dphase bevel: [%#x] %S", flags, chars);
} else if (flags & DRAW_UNDERC) {
// Draw curly underline
int k;
@@ -1371,8 +1379,9 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
CTFontRef fontRef = (CTFontRef)(flags & DRAW_WIDE ? [fontWide retain]
: [font retain]);
unsigned traits = 0;
- if (flags & DRAW_ITALIC)
+ if (flags & DRAW_ITALIC) {
traits |= kCTFontItalicTrait;
+ }
if (flags & DRAW_BOLD)
traits |= kCTFontBoldTrait;
diff --git a/src/eval.c b/src/eval.c
index f0051c6..78b7a59 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -19649,6 +19649,8 @@ f_synIDattr(typval_T *argvars UNUSED, typval_T *rettv)
case 'b':
if (TOLOWER_ASC(what[1]) == 'g') /* bg[#] */
p = highlight_color(id, what, modec);
+ else if (TOLOWER_ASC(what[1]) == 'e') /* bevel */
+ p = highlight_has_attr(id, HL_BEVEL, modec);
else /* bold */
p = highlight_has_attr(id, HL_BOLD, modec);
break;
diff --git a/src/gui.c b/src/gui.c
index c458a42..bbf771a 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -2405,6 +2405,10 @@ gui_outstr_nowrap(
if (hl_mask_todo & HL_UNDERCURL)
draw_flags |= DRAW_UNDERC;
+ /* Do we bevel text row */
+ if (hl_mask_todo & HL_BEVEL)
+ draw_flags |= DRAW_BEVEL;
+
/* Do we draw transparently? */
if (flags & GUI_MON_TRS_CURSOR)
draw_flags |= DRAW_TRANSP;
diff --git a/src/gui.h b/src/gui.h
index 6a4b32a..bb601c7 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -143,6 +143,7 @@
# define DRAW_ITALIC 0x10 /* draw italic text */
#endif
#define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
+#define DRAW_BEVEL 0x3f /* draw beveled row */
#define DRAW_WIDE 0x40 /* drawing wide char (MacVim) */
#define DRAW_COMP 0x80 /* drawing composing char (MacVim) */
diff --git a/src/hardcopy.c b/src/hardcopy.c
index 74fee2e..35b0f0b 100644
--- a/src/hardcopy.c
+++ b/src/hardcopy.c
@@ -281,6 +281,7 @@ prt_get_attr(
pattr->italic = (highlight_has_attr(hl_id, HL_ITALIC, modec) != NULL);
pattr->underline = (highlight_has_attr(hl_id, HL_UNDERLINE, modec) != NULL);
pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
+ pattr->bevel = (highlight_has_attr(hl_id, HL_BEVEL, modec) != NULL);
# ifdef FEAT_GUI
if (gui.in_use)
diff --git a/src/screen.c b/src/screen.c
index efc6607..f705c49 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -7858,7 +7858,7 @@ screen_start_highlight(int attr)
out_str(T_ME);
if ((attr & HL_STANDOUT) && T_SO != NULL) /* standout */
out_str(T_SO);
- if ((attr & (HL_UNDERLINE | HL_UNDERCURL)) && T_US != NULL)
+ if ((attr & (HL_UNDERLINE | HL_BEVEL | HL_UNDERCURL)) && T_US != NULL)
/* underline or undercurl */
out_str(T_US);
if ((attr & HL_ITALIC) && T_CZH != NULL) /* italic */
@@ -7954,7 +7954,7 @@ screen_stop_highlight(void)
else
out_str(T_SE);
}
- if (screen_attr & (HL_UNDERLINE | HL_UNDERCURL))
+ if (screen_attr & (HL_UNDERLINE | HL_BEVEL | HL_UNDERCURL))
{
if (STRCMP(T_UE, T_ME) == 0)
do_ME = TRUE;
diff --git a/src/structs.h b/src/structs.h
index fb8290f..f9ab481 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -2917,6 +2917,7 @@ typedef struct
int italic;
int underline;
int undercurl;
+ int bevel;
} prt_text_attr_T;
/*
diff --git a/src/syntax.c b/src/syntax.c
index 069e9df..3065352 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -82,10 +82,10 @@ static int include_link = 0; /* when 2 include "link" and "clear" */
* following names, separated by commas (but no spaces!).
*/
static char *(hl_name_table[]) =
- {"bold", "standout", "underline", "undercurl",
+ {"bold", "standout", "underline", "undercurl", "bevel",
"italic", "reverse", "inverse", "NONE"};
static int hl_attr_table[] =
- {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_ITALIC, HL_INVERSE, HL_INVERSE, 0};
+ {HL_BOLD, HL_STANDOUT, HL_UNDERLINE, HL_UNDERCURL, HL_BEVEL, HL_ITALIC, HL_INVERSE, HL_INVERSE, 0};
static int get_attr_entry(garray_T *table, attrentry_T *aep);
static void syn_unadd_group(void);
@@ -9546,6 +9546,8 @@ highlight_changed(void)
break;
case 'c': attr |= HL_UNDERCURL;
break;
+ case 'e': attr |= HL_BEVEL;
+ break;
case ':': ++p; /* highlight group name */
if (attr || *p == NUL) /* no combinations */
return FAIL;
diff --git a/src/vim.h b/src/vim.h
index a4e510d..b2081bc 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -631,7 +631,8 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
#define HL_UNDERLINE 0x08
#define HL_UNDERCURL 0x10
#define HL_STANDOUT 0x20
-#define HL_ALL 0x3f
+#define HL_BEVEL 0x40
+#define HL_ALL 0x4f
/* special attribute addition: Put message in history */
#define MSG_HIST 0x1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment