mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:13:26 +01:00
fix backspace bug, simplify a bit
This commit is contained in:
parent
26ad5a00a3
commit
fb5a9bc043
@ -66,13 +66,11 @@ static void input_backspace(ToxWindow *self, int x, int mx_x)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cur_len = wcwidth(ctx->line[ctx->pos]);
|
int cur_len = ctx->pos > 0 ? wcwidth(ctx->line[ctx->pos - 1]) : 0;
|
||||||
int s_len = wcwidth(ctx->line[ctx->start]);
|
int s_len = ctx->start > 0 ? wcwidth(ctx->line[ctx->start - 1]) : 0;
|
||||||
|
|
||||||
if (ctx->start && (x >= mx_x - cur_len))
|
if (ctx->start && (x >= mx_x - cur_len))
|
||||||
ctx->start = MAX(0, ctx->start - 1 + (s_len - cur_len));
|
ctx->start = MAX(0, ctx->start - 1 + (s_len - cur_len));
|
||||||
else if (ctx->start && (ctx->pos == ctx->len))
|
|
||||||
ctx->start = MAX(0, ctx->start - cur_len);
|
|
||||||
else if (ctx->start)
|
else if (ctx->start)
|
||||||
ctx->start = MAX(0, ctx->start - cur_len);
|
ctx->start = MAX(0, ctx->start - cur_len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user