mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 14:53:26 +01:00
couple fixes
This commit is contained in:
parent
c371c37bce
commit
14c9599a30
@ -373,20 +373,16 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
}
|
||||
|
||||
else if (key == KEY_UP) { /* fetches previous item in history */
|
||||
if (ctx->hst_pos >= 0) {
|
||||
fetch_hist_item(ctx->line, &ctx->pos, &ctx->len, ctx->ln_history, ctx->hst_tot,
|
||||
&ctx->hst_pos, LN_HIST_MV_UP);
|
||||
mv_curs_end(self->window, ctx->len, y2, x2);
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == KEY_DOWN) { /* fetches next item in history */
|
||||
if (ctx->hst_pos < ctx->hst_tot) {
|
||||
fetch_hist_item(ctx->line, &ctx->pos, &ctx->len, ctx->ln_history, ctx->hst_tot,
|
||||
&ctx->hst_pos, LN_HIST_MV_DWN);
|
||||
mv_curs_end(self->window, ctx->len, y2, x2);
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == '\t') { /* TAB key: command */
|
||||
if (ctx->len > 1 && ctx->line[0] == '/') {
|
||||
|
@ -301,7 +301,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
|
||||
if (key == 0x107 || key == 0x8 || key == 0x7f) { /* BACKSPACE key: Remove character behind pos */
|
||||
if (ctx->pos > 0) {
|
||||
cur_len = wcwidth(ctx->line[ctx->pos - 1]);
|
||||
cur_len = MAX(1, wcwidth(ctx->line[ctx->pos - 1]));
|
||||
del_char_buf_bck(ctx->line, &ctx->pos, &ctx->len);
|
||||
|
||||
if (x == 0)
|
||||
@ -367,20 +367,16 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
}
|
||||
|
||||
else if (key == KEY_UP) { /* fetches previous item in history */
|
||||
if (ctx->hst_pos >= 0) {
|
||||
fetch_hist_item(ctx->line, &ctx->pos, &ctx->len, ctx->ln_history, ctx->hst_tot,
|
||||
&ctx->hst_pos, LN_HIST_MV_UP);
|
||||
mv_curs_end(self->window, ctx->len, y2, x2);
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == KEY_DOWN) { /* fetches next item in history */
|
||||
if (ctx->hst_pos < ctx->hst_tot) {
|
||||
fetch_hist_item(ctx->line, &ctx->pos, &ctx->len, ctx->ln_history, ctx->hst_tot,
|
||||
&ctx->hst_pos, LN_HIST_MV_DWN);
|
||||
mv_curs_end(self->window, ctx->len, y2, x2);
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == '\t') { /* TAB key: completes peer name */
|
||||
if (ctx->len > 0) {
|
||||
|
@ -166,7 +166,6 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
}
|
||||
|
||||
else if (key == KEY_UP) { /* fetches previous item in history */
|
||||
if (prt->hst_pos >= 0) {
|
||||
wmove(self->window, prt->orig_y, X_OFST);
|
||||
fetch_hist_item(prt->line, &prt->pos, &prt->len, prt->ln_history, prt->hst_tot,
|
||||
&prt->hst_pos, LN_HIST_MV_UP);
|
||||
@ -187,15 +186,12 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == KEY_DOWN) { /* fetches next item in history */
|
||||
if (prt->hst_pos < prt->hst_tot) {
|
||||
wmove(self->window, prt->orig_y, X_OFST);
|
||||
fetch_hist_item(prt->line, &prt->pos, &prt->len, prt->ln_history, prt->hst_tot,
|
||||
&prt->hst_pos, LN_HIST_MV_DWN);
|
||||
}
|
||||
}
|
||||
|
||||
else if (key == '\t') { /* TAB key: completes command */
|
||||
if (prt->len > 1 && prt->line[0] == '/')
|
||||
|
@ -130,7 +130,8 @@ void fetch_hist_item(wchar_t *buf, size_t *pos, size_t *len, wchar_t (*hst)[MAX_
|
||||
beep();
|
||||
}
|
||||
} else {
|
||||
if (++(*hst_pos) == hst_tot) {
|
||||
if (++(*hst_pos) > hst_tot) {
|
||||
--(*hst_pos);
|
||||
discard_buf(buf, pos, len);
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define MAX_STR_SIZE 256
|
||||
#define MAX_CMDNAME_SIZE 64
|
||||
#define KEY_SIZE_BYTES 32
|
||||
#define TOXIC_MAX_NAME_LENGTH 32 /* Must be < TOX_MAX_NAME_LENGTH */
|
||||
#define TOXIC_MAX_NAME_LENGTH 32 /* Must be <= TOX_MAX_NAME_LENGTH */
|
||||
#define N_DEFAULT_WINS 2 /* number of permanent default windows */
|
||||
#define CURS_Y_OFFSET 3 /* y-axis cursor offset for chat contexts */
|
||||
#define CHATBOX_HEIGHT 4
|
||||
|
Loading…
Reference in New Issue
Block a user