mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
Extract cursor_shape.c from misc2.c and types/consts from structs.h
This commit is contained in:
parent
6089b26016
commit
1684bec635
247
src/cursor_shape.c
Normal file
247
src/cursor_shape.c
Normal file
@ -0,0 +1,247 @@
|
||||
#include "vim.h"
|
||||
#include "cursor_shape.h"
|
||||
#include "misc2.h"
|
||||
#include "charset.h"
|
||||
#include "syntax.h"
|
||||
|
||||
#if defined(CURSOR_SHAPE) || defined(PROTO)
|
||||
|
||||
/*
|
||||
* Handling of cursor and mouse pointer shapes in various modes.
|
||||
*/
|
||||
|
||||
static cursorentry_T shape_table[SHAPE_IDX_COUNT] =
|
||||
{
|
||||
/* The values will be filled in from the 'guicursor' and 'mouseshape'
|
||||
* defaults when Vim starts.
|
||||
* Adjust the SHAPE_IDX_ defines when making changes! */
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "m", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "ml", SHAPE_MOUSE},
|
||||
{0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR},
|
||||
};
|
||||
|
||||
/*
|
||||
* Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape'
|
||||
* ("what" is SHAPE_MOUSE).
|
||||
* Returns error message for an illegal option, NULL otherwise.
|
||||
*/
|
||||
char_u *parse_shape_opt(int what)
|
||||
{
|
||||
char_u *modep;
|
||||
char_u *colonp;
|
||||
char_u *commap;
|
||||
char_u *slashp;
|
||||
char_u *p, *endp;
|
||||
int idx = 0; /* init for GCC */
|
||||
int all_idx;
|
||||
int len;
|
||||
int i;
|
||||
long n;
|
||||
int found_ve = FALSE; /* found "ve" flag */
|
||||
int round;
|
||||
|
||||
/*
|
||||
* First round: check for errors; second round: do it for real.
|
||||
*/
|
||||
for (round = 1; round <= 2; ++round) {
|
||||
/*
|
||||
* Repeat for all comma separated parts.
|
||||
*/
|
||||
modep = p_guicursor;
|
||||
while (*modep != NUL) {
|
||||
colonp = vim_strchr(modep, ':');
|
||||
if (colonp == NULL)
|
||||
return (char_u *)N_("E545: Missing colon");
|
||||
if (colonp == modep)
|
||||
return (char_u *)N_("E546: Illegal mode");
|
||||
commap = vim_strchr(modep, ',');
|
||||
|
||||
/*
|
||||
* Repeat for all mode's before the colon.
|
||||
* For the 'a' mode, we loop to handle all the modes.
|
||||
*/
|
||||
all_idx = -1;
|
||||
while (modep < colonp || all_idx >= 0) {
|
||||
if (all_idx < 0) {
|
||||
/* Find the mode. */
|
||||
if (modep[1] == '-' || modep[1] == ':')
|
||||
len = 1;
|
||||
else
|
||||
len = 2;
|
||||
if (len == 1 && TOLOWER_ASC(modep[0]) == 'a')
|
||||
all_idx = SHAPE_IDX_COUNT - 1;
|
||||
else {
|
||||
for (idx = 0; idx < SHAPE_IDX_COUNT; ++idx)
|
||||
if (STRNICMP(modep, shape_table[idx].name, len)
|
||||
== 0)
|
||||
break;
|
||||
if (idx == SHAPE_IDX_COUNT
|
||||
|| (shape_table[idx].used_for & what) == 0)
|
||||
return (char_u *)N_("E546: Illegal mode");
|
||||
if (len == 2 && modep[0] == 'v' && modep[1] == 'e')
|
||||
found_ve = TRUE;
|
||||
}
|
||||
modep += len + 1;
|
||||
}
|
||||
|
||||
if (all_idx >= 0)
|
||||
idx = all_idx--;
|
||||
else if (round == 2) {
|
||||
{
|
||||
/* Set the defaults, for the missing parts */
|
||||
shape_table[idx].shape = SHAPE_BLOCK;
|
||||
shape_table[idx].blinkwait = 700L;
|
||||
shape_table[idx].blinkon = 400L;
|
||||
shape_table[idx].blinkoff = 250L;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the part after the colon */
|
||||
for (p = colonp + 1; *p && *p != ','; ) {
|
||||
{
|
||||
/*
|
||||
* First handle the ones with a number argument.
|
||||
*/
|
||||
i = *p;
|
||||
len = 0;
|
||||
if (STRNICMP(p, "ver", 3) == 0)
|
||||
len = 3;
|
||||
else if (STRNICMP(p, "hor", 3) == 0)
|
||||
len = 3;
|
||||
else if (STRNICMP(p, "blinkwait", 9) == 0)
|
||||
len = 9;
|
||||
else if (STRNICMP(p, "blinkon", 7) == 0)
|
||||
len = 7;
|
||||
else if (STRNICMP(p, "blinkoff", 8) == 0)
|
||||
len = 8;
|
||||
if (len != 0) {
|
||||
p += len;
|
||||
if (!VIM_ISDIGIT(*p))
|
||||
return (char_u *)N_("E548: digit expected");
|
||||
n = getdigits(&p);
|
||||
if (len == 3) { /* "ver" or "hor" */
|
||||
if (n == 0)
|
||||
return (char_u *)N_("E549: Illegal percentage");
|
||||
if (round == 2) {
|
||||
if (TOLOWER_ASC(i) == 'v')
|
||||
shape_table[idx].shape = SHAPE_VER;
|
||||
else
|
||||
shape_table[idx].shape = SHAPE_HOR;
|
||||
shape_table[idx].percentage = n;
|
||||
}
|
||||
} else if (round == 2) {
|
||||
if (len == 9)
|
||||
shape_table[idx].blinkwait = n;
|
||||
else if (len == 7)
|
||||
shape_table[idx].blinkon = n;
|
||||
else
|
||||
shape_table[idx].blinkoff = n;
|
||||
}
|
||||
} else if (STRNICMP(p, "block", 5) == 0) {
|
||||
if (round == 2)
|
||||
shape_table[idx].shape = SHAPE_BLOCK;
|
||||
p += 5;
|
||||
} else { /* must be a highlight group name then */
|
||||
endp = vim_strchr(p, '-');
|
||||
if (commap == NULL) { /* last part */
|
||||
if (endp == NULL)
|
||||
endp = p + STRLEN(p); /* find end of part */
|
||||
} else if (endp > commap || endp == NULL)
|
||||
endp = commap;
|
||||
slashp = vim_strchr(p, '/');
|
||||
if (slashp != NULL && slashp < endp) {
|
||||
/* "group/langmap_group" */
|
||||
i = syn_check_group(p, (int)(slashp - p));
|
||||
p = slashp + 1;
|
||||
}
|
||||
if (round == 2) {
|
||||
shape_table[idx].id = syn_check_group(p,
|
||||
(int)(endp - p));
|
||||
shape_table[idx].id_lm = shape_table[idx].id;
|
||||
if (slashp != NULL && slashp < endp)
|
||||
shape_table[idx].id = i;
|
||||
}
|
||||
p = endp;
|
||||
}
|
||||
} /* if (what != SHAPE_MOUSE) */
|
||||
|
||||
if (*p == '-')
|
||||
++p;
|
||||
}
|
||||
}
|
||||
modep = p;
|
||||
if (*modep == ',')
|
||||
++modep;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the 's' flag is not given, use the 'v' cursor for 's' */
|
||||
if (!found_ve) {
|
||||
{
|
||||
shape_table[SHAPE_IDX_VE].shape = shape_table[SHAPE_IDX_V].shape;
|
||||
shape_table[SHAPE_IDX_VE].percentage =
|
||||
shape_table[SHAPE_IDX_V].percentage;
|
||||
shape_table[SHAPE_IDX_VE].blinkwait =
|
||||
shape_table[SHAPE_IDX_V].blinkwait;
|
||||
shape_table[SHAPE_IDX_VE].blinkon =
|
||||
shape_table[SHAPE_IDX_V].blinkon;
|
||||
shape_table[SHAPE_IDX_VE].blinkoff =
|
||||
shape_table[SHAPE_IDX_V].blinkoff;
|
||||
shape_table[SHAPE_IDX_VE].id = shape_table[SHAPE_IDX_V].id;
|
||||
shape_table[SHAPE_IDX_VE].id_lm = shape_table[SHAPE_IDX_V].id_lm;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) \
|
||||
|| defined(FEAT_MOUSESHAPE) || defined(PROTO)
|
||||
/*
|
||||
* Return the index into shape_table[] for the current mode.
|
||||
* When "mouse" is TRUE, consider indexes valid for the mouse pointer.
|
||||
*/
|
||||
int get_shape_idx(int mouse)
|
||||
{
|
||||
if (!mouse && State == SHOWMATCH)
|
||||
return SHAPE_IDX_SM;
|
||||
if (State & VREPLACE_FLAG)
|
||||
return SHAPE_IDX_R;
|
||||
if (State & REPLACE_FLAG)
|
||||
return SHAPE_IDX_R;
|
||||
if (State & INSERT)
|
||||
return SHAPE_IDX_I;
|
||||
if (State & CMDLINE) {
|
||||
if (cmdline_at_end())
|
||||
return SHAPE_IDX_C;
|
||||
if (cmdline_overstrike())
|
||||
return SHAPE_IDX_CR;
|
||||
return SHAPE_IDX_CI;
|
||||
}
|
||||
if (finish_op)
|
||||
return SHAPE_IDX_O;
|
||||
if (VIsual_active) {
|
||||
if (*p_sel == 'e')
|
||||
return SHAPE_IDX_VE;
|
||||
else
|
||||
return SHAPE_IDX_V;
|
||||
}
|
||||
return SHAPE_IDX_N;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURSOR_SHAPE */
|
56
src/cursor_shape.h
Normal file
56
src/cursor_shape.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef NEOVIM_CURSOR_SHAPE_H
|
||||
#define NEOVIM_CURSOR_SHAPE_H
|
||||
|
||||
#ifdef CURSOR_SHAPE
|
||||
/*
|
||||
* struct to store values from 'guicursor' and 'mouseshape'
|
||||
*/
|
||||
/* Indexes in shape_table[] */
|
||||
#define SHAPE_IDX_N 0 /* Normal mode */
|
||||
#define SHAPE_IDX_V 1 /* Visual mode */
|
||||
#define SHAPE_IDX_I 2 /* Insert mode */
|
||||
#define SHAPE_IDX_R 3 /* Replace mode */
|
||||
#define SHAPE_IDX_C 4 /* Command line Normal mode */
|
||||
#define SHAPE_IDX_CI 5 /* Command line Insert mode */
|
||||
#define SHAPE_IDX_CR 6 /* Command line Replace mode */
|
||||
#define SHAPE_IDX_O 7 /* Operator-pending mode */
|
||||
#define SHAPE_IDX_VE 8 /* Visual mode with 'selection' exclusive */
|
||||
#define SHAPE_IDX_CLINE 9 /* On command line */
|
||||
#define SHAPE_IDX_STATUS 10 /* A status line */
|
||||
#define SHAPE_IDX_SDRAG 11 /* dragging a status line */
|
||||
#define SHAPE_IDX_VSEP 12 /* A vertical separator line */
|
||||
#define SHAPE_IDX_VDRAG 13 /* dragging a vertical separator line */
|
||||
#define SHAPE_IDX_MORE 14 /* Hit-return or More */
|
||||
#define SHAPE_IDX_MOREL 15 /* Hit-return or More in last line */
|
||||
#define SHAPE_IDX_SM 16 /* showing matching paren */
|
||||
#define SHAPE_IDX_COUNT 17
|
||||
|
||||
#define SHAPE_BLOCK 0 /* block cursor */
|
||||
#define SHAPE_HOR 1 /* horizontal bar cursor */
|
||||
#define SHAPE_VER 2 /* vertical bar cursor */
|
||||
|
||||
#define MSHAPE_NUMBERED 1000 /* offset for shapes identified by number */
|
||||
#define MSHAPE_HIDE 1 /* hide mouse pointer */
|
||||
|
||||
#define SHAPE_MOUSE 1 /* used for mouse pointer shape */
|
||||
#define SHAPE_CURSOR 2 /* used for text cursor shape */
|
||||
|
||||
typedef struct cursor_entry {
|
||||
int shape; /* one of the SHAPE_ defines */
|
||||
int mshape; /* one of the MSHAPE defines */
|
||||
int percentage; /* percentage of cell for bar */
|
||||
long blinkwait; /* blinking, wait time before blinking starts */
|
||||
long blinkon; /* blinking, on time */
|
||||
long blinkoff; /* blinking, off time */
|
||||
int id; /* highlight group ID */
|
||||
int id_lm; /* highlight group ID for :lmap mode */
|
||||
char *name; /* mode name (fixed) */
|
||||
char used_for; /* SHAPE_MOUSE and/or SHAPE_CURSOR */
|
||||
} cursorentry_T;
|
||||
#endif /* CURSOR_SHAPE */
|
||||
|
||||
char_u *parse_shape_opt(int what);
|
||||
int get_shape_idx(int mouse);
|
||||
void update_mouseshape(int shape_idx);
|
||||
|
||||
#endif /* NEOVIM_CURSOR_SHAPE_H */
|
@ -33,6 +33,7 @@
|
||||
#include "message.h"
|
||||
#include "misc1.h"
|
||||
#include "misc2.h"
|
||||
#include "cursor_shape.h"
|
||||
#include "keymap.h"
|
||||
#include "garray.h"
|
||||
#include "move.h"
|
||||
@ -46,6 +47,7 @@
|
||||
#include "tag.h"
|
||||
#include "term.h"
|
||||
#include "window.h"
|
||||
#include "ui.h"
|
||||
#include "os/os.h"
|
||||
|
||||
/*
|
||||
|
@ -944,11 +944,6 @@ EXTERN int stl_syntax INIT(= 0);
|
||||
EXTERN int no_hlsearch INIT(= FALSE);
|
||||
|
||||
|
||||
#ifdef CURSOR_SHAPE
|
||||
/* the table is in misc2.c, because of initializations */
|
||||
extern cursorentry_T shape_table[SHAPE_IDX_COUNT];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Printer stuff shared between hardcopy.c and machine-specific printing code.
|
||||
*/
|
||||
|
244
src/misc2.c
244
src/misc2.c
@ -1858,250 +1858,6 @@ int illegal_slash(char *name)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CURSOR_SHAPE) || defined(PROTO)
|
||||
|
||||
/*
|
||||
* Handling of cursor and mouse pointer shapes in various modes.
|
||||
*/
|
||||
|
||||
cursorentry_T shape_table[SHAPE_IDX_COUNT] =
|
||||
{
|
||||
/* The values will be filled in from the 'guicursor' and 'mouseshape'
|
||||
* defaults when Vim starts.
|
||||
* Adjust the SHAPE_IDX_ defines when making changes! */
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "n", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "v", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "i", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "r", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "c", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "ci", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "cr", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "o", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 700L, 400L, 250L, 0, 0, "ve", SHAPE_CURSOR+SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "e", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "s", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "sd", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "vs", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "vd", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "m", SHAPE_MOUSE},
|
||||
{0, 0, 0, 0L, 0L, 0L, 0, 0, "ml", SHAPE_MOUSE},
|
||||
{0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR},
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape'
|
||||
* ("what" is SHAPE_MOUSE).
|
||||
* Returns error message for an illegal option, NULL otherwise.
|
||||
*/
|
||||
char_u *parse_shape_opt(int what)
|
||||
{
|
||||
char_u *modep;
|
||||
char_u *colonp;
|
||||
char_u *commap;
|
||||
char_u *slashp;
|
||||
char_u *p, *endp;
|
||||
int idx = 0; /* init for GCC */
|
||||
int all_idx;
|
||||
int len;
|
||||
int i;
|
||||
long n;
|
||||
int found_ve = FALSE; /* found "ve" flag */
|
||||
int round;
|
||||
|
||||
/*
|
||||
* First round: check for errors; second round: do it for real.
|
||||
*/
|
||||
for (round = 1; round <= 2; ++round) {
|
||||
/*
|
||||
* Repeat for all comma separated parts.
|
||||
*/
|
||||
modep = p_guicursor;
|
||||
while (*modep != NUL) {
|
||||
colonp = vim_strchr(modep, ':');
|
||||
if (colonp == NULL)
|
||||
return (char_u *)N_("E545: Missing colon");
|
||||
if (colonp == modep)
|
||||
return (char_u *)N_("E546: Illegal mode");
|
||||
commap = vim_strchr(modep, ',');
|
||||
|
||||
/*
|
||||
* Repeat for all mode's before the colon.
|
||||
* For the 'a' mode, we loop to handle all the modes.
|
||||
*/
|
||||
all_idx = -1;
|
||||
while (modep < colonp || all_idx > = 0) {
|
||||
if (all_idx < 0) {
|
||||
/* Find the mode. */
|
||||
if (modep[1] == '-' || modep[1] == ':')
|
||||
len = 1;
|
||||
else
|
||||
len = 2;
|
||||
if (len == 1 && TOLOWER_ASC(modep[0]) == 'a')
|
||||
all_idx = SHAPE_IDX_COUNT - 1;
|
||||
else {
|
||||
for (idx = 0; idx < SHAPE_IDX_COUNT; ++idx)
|
||||
if (STRNICMP(modep, shape_table[idx].name, len)
|
||||
== 0)
|
||||
break;
|
||||
if (idx == SHAPE_IDX_COUNT
|
||||
|| (shape_table[idx].used_for & what) == 0)
|
||||
return (char_u *)N_("E546: Illegal mode");
|
||||
if (len == 2 && modep[0] == 'v' && modep[1] == 'e')
|
||||
found_ve = TRUE;
|
||||
}
|
||||
modep += len + 1;
|
||||
}
|
||||
|
||||
if (all_idx >= 0)
|
||||
idx = all_idx--;
|
||||
else if (round == 2) {
|
||||
{
|
||||
/* Set the defaults, for the missing parts */
|
||||
shape_table[idx].shape = SHAPE_BLOCK;
|
||||
shape_table[idx].blinkwait = 700L;
|
||||
shape_table[idx].blinkon = 400L;
|
||||
shape_table[idx].blinkoff = 250L;
|
||||
}
|
||||
}
|
||||
|
||||
/* Parse the part after the colon */
|
||||
for (p = colonp + 1; *p && *p != ','; ) {
|
||||
{
|
||||
/*
|
||||
* First handle the ones with a number argument.
|
||||
*/
|
||||
i = *p;
|
||||
len = 0;
|
||||
if (STRNICMP(p, "ver", 3) == 0)
|
||||
len = 3;
|
||||
else if (STRNICMP(p, "hor", 3) == 0)
|
||||
len = 3;
|
||||
else if (STRNICMP(p, "blinkwait", 9) == 0)
|
||||
len = 9;
|
||||
else if (STRNICMP(p, "blinkon", 7) == 0)
|
||||
len = 7;
|
||||
else if (STRNICMP(p, "blinkoff", 8) == 0)
|
||||
len = 8;
|
||||
if (len != 0) {
|
||||
p += len;
|
||||
if (!VIM_ISDIGIT(*p))
|
||||
return (char_u *)N_("E548: digit expected");
|
||||
n = getdigits(&p);
|
||||
if (len == 3) { /* "ver" or "hor" */
|
||||
if (n == 0)
|
||||
return (char_u *)N_("E549: Illegal percentage");
|
||||
if (round == 2) {
|
||||
if (TOLOWER_ASC(i) == 'v')
|
||||
shape_table[idx].shape = SHAPE_VER;
|
||||
else
|
||||
shape_table[idx].shape = SHAPE_HOR;
|
||||
shape_table[idx].percentage = n;
|
||||
}
|
||||
} else if (round == 2) {
|
||||
if (len == 9)
|
||||
shape_table[idx].blinkwait = n;
|
||||
else if (len == 7)
|
||||
shape_table[idx].blinkon = n;
|
||||
else
|
||||
shape_table[idx].blinkoff = n;
|
||||
}
|
||||
} else if (STRNICMP(p, "block", 5) == 0) {
|
||||
if (round == 2)
|
||||
shape_table[idx].shape = SHAPE_BLOCK;
|
||||
p += 5;
|
||||
} else { /* must be a highlight group name then */
|
||||
endp = vim_strchr(p, '-');
|
||||
if (commap == NULL) { /* last part */
|
||||
if (endp == NULL)
|
||||
endp = p + STRLEN(p); /* find end of part */
|
||||
} else if (endp > commap || endp == NULL)
|
||||
endp = commap;
|
||||
slashp = vim_strchr(p, '/');
|
||||
if (slashp != NULL && slashp < endp) {
|
||||
/* "group/langmap_group" */
|
||||
i = syn_check_group(p, (int)(slashp - p));
|
||||
p = slashp + 1;
|
||||
}
|
||||
if (round == 2) {
|
||||
shape_table[idx].id = syn_check_group(p,
|
||||
(int)(endp - p));
|
||||
shape_table[idx].id_lm = shape_table[idx].id;
|
||||
if (slashp != NULL && slashp < endp)
|
||||
shape_table[idx].id = i;
|
||||
}
|
||||
p = endp;
|
||||
}
|
||||
} /* if (what != SHAPE_MOUSE) */
|
||||
|
||||
if (*p == '-')
|
||||
++p;
|
||||
}
|
||||
}
|
||||
modep = p;
|
||||
if (*modep == ',')
|
||||
++modep;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the 's' flag is not given, use the 'v' cursor for 's' */
|
||||
if (!found_ve) {
|
||||
{
|
||||
shape_table[SHAPE_IDX_VE].shape = shape_table[SHAPE_IDX_V].shape;
|
||||
shape_table[SHAPE_IDX_VE].percentage =
|
||||
shape_table[SHAPE_IDX_V].percentage;
|
||||
shape_table[SHAPE_IDX_VE].blinkwait =
|
||||
shape_table[SHAPE_IDX_V].blinkwait;
|
||||
shape_table[SHAPE_IDX_VE].blinkon =
|
||||
shape_table[SHAPE_IDX_V].blinkon;
|
||||
shape_table[SHAPE_IDX_VE].blinkoff =
|
||||
shape_table[SHAPE_IDX_V].blinkoff;
|
||||
shape_table[SHAPE_IDX_VE].id = shape_table[SHAPE_IDX_V].id;
|
||||
shape_table[SHAPE_IDX_VE].id_lm = shape_table[SHAPE_IDX_V].id_lm;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
# if defined(MCH_CURSOR_SHAPE) || defined(FEAT_GUI) \
|
||||
|| defined(FEAT_MOUSESHAPE) || defined(PROTO)
|
||||
/*
|
||||
* Return the index into shape_table[] for the current mode.
|
||||
* When "mouse" is TRUE, consider indexes valid for the mouse pointer.
|
||||
*/
|
||||
int get_shape_idx(int mouse)
|
||||
{
|
||||
if (!mouse && State == SHOWMATCH)
|
||||
return SHAPE_IDX_SM;
|
||||
if (State & VREPLACE_FLAG)
|
||||
return SHAPE_IDX_R;
|
||||
if (State & REPLACE_FLAG)
|
||||
return SHAPE_IDX_R;
|
||||
if (State & INSERT)
|
||||
return SHAPE_IDX_I;
|
||||
if (State & CMDLINE) {
|
||||
if (cmdline_at_end())
|
||||
return SHAPE_IDX_C;
|
||||
if (cmdline_overstrike())
|
||||
return SHAPE_IDX_CR;
|
||||
return SHAPE_IDX_CI;
|
||||
}
|
||||
if (finish_op)
|
||||
return SHAPE_IDX_O;
|
||||
if (VIsual_active) {
|
||||
if (*p_sel == 'e')
|
||||
return SHAPE_IDX_VE;
|
||||
else
|
||||
return SHAPE_IDX_V;
|
||||
}
|
||||
return SHAPE_IDX_N;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* CURSOR_SHAPE */
|
||||
|
||||
/*
|
||||
* Change directory to "new_dir". If FEAT_SEARCHPATH is defined, search
|
||||
* 'cdpath' for relative directory names, otherwise just mch_chdir().
|
||||
|
@ -65,9 +65,6 @@ int after_pathsep(char_u *b, char_u *p);
|
||||
int same_directory(char_u *f1, char_u *f2);
|
||||
int vim_chdirfile(char_u *fname);
|
||||
int illegal_slash(char *name);
|
||||
char_u *parse_shape_opt(int what);
|
||||
int get_shape_idx(int mouse);
|
||||
void update_mouseshape(int shape_idx);
|
||||
int vim_chdir(char_u *new_dir);
|
||||
int get_user_name(char_u *buf, int len);
|
||||
void sort_strings(char_u **files, int count);
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "keymap.h"
|
||||
#include "crypt.h"
|
||||
#include "garray.h"
|
||||
#include "cursor_shape.h"
|
||||
#include "move.h"
|
||||
#include "normal.h"
|
||||
#include "os_unix.h"
|
||||
|
@ -1724,54 +1724,6 @@ struct window_S {
|
||||
qf_info_T *w_llist_ref;
|
||||
};
|
||||
|
||||
#ifdef CURSOR_SHAPE
|
||||
/*
|
||||
* struct to store values from 'guicursor' and 'mouseshape'
|
||||
*/
|
||||
/* Indexes in shape_table[] */
|
||||
#define SHAPE_IDX_N 0 /* Normal mode */
|
||||
#define SHAPE_IDX_V 1 /* Visual mode */
|
||||
#define SHAPE_IDX_I 2 /* Insert mode */
|
||||
#define SHAPE_IDX_R 3 /* Replace mode */
|
||||
#define SHAPE_IDX_C 4 /* Command line Normal mode */
|
||||
#define SHAPE_IDX_CI 5 /* Command line Insert mode */
|
||||
#define SHAPE_IDX_CR 6 /* Command line Replace mode */
|
||||
#define SHAPE_IDX_O 7 /* Operator-pending mode */
|
||||
#define SHAPE_IDX_VE 8 /* Visual mode with 'selection' exclusive */
|
||||
#define SHAPE_IDX_CLINE 9 /* On command line */
|
||||
#define SHAPE_IDX_STATUS 10 /* A status line */
|
||||
#define SHAPE_IDX_SDRAG 11 /* dragging a status line */
|
||||
#define SHAPE_IDX_VSEP 12 /* A vertical separator line */
|
||||
#define SHAPE_IDX_VDRAG 13 /* dragging a vertical separator line */
|
||||
#define SHAPE_IDX_MORE 14 /* Hit-return or More */
|
||||
#define SHAPE_IDX_MOREL 15 /* Hit-return or More in last line */
|
||||
#define SHAPE_IDX_SM 16 /* showing matching paren */
|
||||
#define SHAPE_IDX_COUNT 17
|
||||
|
||||
#define SHAPE_BLOCK 0 /* block cursor */
|
||||
#define SHAPE_HOR 1 /* horizontal bar cursor */
|
||||
#define SHAPE_VER 2 /* vertical bar cursor */
|
||||
|
||||
#define MSHAPE_NUMBERED 1000 /* offset for shapes identified by number */
|
||||
#define MSHAPE_HIDE 1 /* hide mouse pointer */
|
||||
|
||||
#define SHAPE_MOUSE 1 /* used for mouse pointer shape */
|
||||
#define SHAPE_CURSOR 2 /* used for text cursor shape */
|
||||
|
||||
typedef struct cursor_entry {
|
||||
int shape; /* one of the SHAPE_ defines */
|
||||
int mshape; /* one of the MSHAPE defines */
|
||||
int percentage; /* percentage of cell for bar */
|
||||
long blinkwait; /* blinking, wait time before blinking starts */
|
||||
long blinkon; /* blinking, on time */
|
||||
long blinkoff; /* blinking, off time */
|
||||
int id; /* highlight group ID */
|
||||
int id_lm; /* highlight group ID for :lmap mode */
|
||||
char *name; /* mode name (fixed) */
|
||||
char used_for; /* SHAPE_MOUSE and/or SHAPE_CURSOR */
|
||||
} cursorentry_T;
|
||||
#endif /* CURSOR_SHAPE */
|
||||
|
||||
/*
|
||||
* Struct to save values in before executing autocommands for a buffer that is
|
||||
* not the current buffer. Without FEAT_AUTOCMD only "curbuf" is remembered.
|
||||
|
Loading…
Reference in New Issue
Block a user