mirror of
https://github.com/neovim/neovim.git
synced 2025-11-28 13:10:44 +00:00
ops.c: cleanup of get_yank_register
This commit is contained in:
@@ -79,7 +79,7 @@ static struct yankreg {
|
|||||||
} y_regs[NUM_REGISTERS];
|
} y_regs[NUM_REGISTERS];
|
||||||
|
|
||||||
static struct yankreg *y_current; /* ptr to current yankreg */
|
static struct yankreg *y_current; /* ptr to current yankreg */
|
||||||
static int y_append; /* TRUE when appending */
|
static bool y_append; /* true when appending */
|
||||||
static struct yankreg *y_previous = NULL; /* ptr to last written yankreg */
|
static struct yankreg *y_previous = NULL; /* ptr to last written yankreg */
|
||||||
|
|
||||||
static bool clipboard_didwarn_unnamed = false;
|
static bool clipboard_didwarn_unnamed = false;
|
||||||
@@ -773,34 +773,32 @@ typedef enum {
|
|||||||
/// Obtain the location that would be read when pasting `regname`.
|
/// Obtain the location that would be read when pasting `regname`.
|
||||||
void get_yank_register(int regname, int mode)
|
void get_yank_register(int regname, int mode)
|
||||||
{
|
{
|
||||||
int i;
|
y_append = false;
|
||||||
|
|
||||||
if (mode == YREG_PASTE && get_clipboard(regname, &y_current, false)) {
|
if (mode == YREG_PASTE && get_clipboard(regname, &y_current, false)) {
|
||||||
// y_current is set to clipboard contents.
|
// y_current is set to clipboard contents.
|
||||||
return;
|
return;
|
||||||
}
|
} else if (mode != YREG_YANK && (regname == 0 || regname == '"') && y_previous != NULL) {
|
||||||
y_append = FALSE;
|
|
||||||
if ((regname == 0 || regname == '"') && mode != YREG_YANK && y_previous != NULL) {
|
|
||||||
y_current = y_previous;
|
y_current = y_previous;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i = regname;
|
|
||||||
if (VIM_ISDIGIT(i))
|
int i = 0; // when not 0-9, a-z, A-Z or '-'/'+'/'*': use register 0
|
||||||
i -= '0';
|
if (VIM_ISDIGIT(regname))
|
||||||
else if (ASCII_ISLOWER(i))
|
i = regname - '0';
|
||||||
i = CharOrdLow(i) + 10;
|
else if (ASCII_ISLOWER(regname))
|
||||||
else if (ASCII_ISUPPER(i)) {
|
i = CharOrdLow(regname) + 10;
|
||||||
i = CharOrdUp(i) + 10;
|
else if (ASCII_ISUPPER(regname)) {
|
||||||
y_append = TRUE;
|
i = CharOrdUp(regname) + 10;
|
||||||
|
y_append = true;
|
||||||
} else if (regname == '-')
|
} else if (regname == '-')
|
||||||
i = DELETION_REGISTER;
|
i = DELETION_REGISTER;
|
||||||
else if (regname == '*')
|
else if (regname == '*')
|
||||||
i = STAR_REGISTER;
|
i = STAR_REGISTER;
|
||||||
else if (regname == '+')
|
else if (regname == '+')
|
||||||
i = PLUS_REGISTER;
|
i = PLUS_REGISTER;
|
||||||
else /* not 0-9, a-z, A-Z or '-': use register 0 */
|
|
||||||
i = 0;
|
|
||||||
y_current = &(y_regs[i]);
|
y_current = &(y_regs[i]);
|
||||||
|
|
||||||
if (mode == YREG_YANK) {
|
if (mode == YREG_YANK) {
|
||||||
// remember the written register for unnamed paste
|
// remember the written register for unnamed paste
|
||||||
y_previous = y_current;
|
y_previous = y_current;
|
||||||
|
|||||||
Reference in New Issue
Block a user