1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-12 23:33:03 +01:00

beep when it should beep

This commit is contained in:
Jfreegman 2013-12-15 20:52:10 -05:00
parent dfb5b16e7d
commit d04f5fa102
4 changed files with 54 additions and 5 deletions

View File

@ -314,24 +314,32 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y-1, x2 - cur_len);
else
wmove(self->window, y, x - cur_len);
} else {
beep();
}
}
else if (key == KEY_DC) { /* DEL key: Remove character at pos */
if (ctx->pos != ctx->len)
del_char_buf_frnt(ctx->line, &ctx->pos, &ctx->len);
else
beep();
}
else if (key == T_KEY_DISCARD) { /* CTRL-U: Delete entire line behind pos */
if (ctx->pos > 0) {
discard_buf(ctx->line, &ctx->pos, &ctx->len);
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
} else {
beep();
}
}
else if (key == T_KEY_KILL) { /* CTRL-K: Delete entire line in front of pos */
if (ctx->pos != ctx->len)
kill_buf(ctx->line, &ctx->pos, &ctx->len);
else
beep();
}
else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */
@ -357,6 +365,8 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y-1, x2 - cur_len);
else
wmove(self->window, y, x - cur_len);
} else {
beep();
}
}
@ -369,6 +379,8 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y+1, 0);
else
wmove(self->window, y, x + cur_len);
} else {
beep();
}
}
@ -396,7 +408,11 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key)
} else {
wmove(self->window, y, x+diff);
}
} else {
beep();
}
} else {
beep();
}
}

View File

@ -308,24 +308,32 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y-1, x2 - cur_len);
else
wmove(self->window, y, x - cur_len);
} else {
beep();
}
}
else if (key == KEY_DC) { /* DEL key: Remove character at pos */
if (ctx->pos != ctx->len)
del_char_buf_frnt(ctx->line, &ctx->pos, &ctx->len);
else
beep();
}
else if (key == T_KEY_DISCARD) { /* CTRL-U: Delete entire line behind pos */
if (ctx->pos > 0) {
discard_buf(ctx->line, &ctx->pos, &ctx->len);
wmove(self->window, y2 - CURS_Y_OFFSET, 0);
} else {
beep();
}
}
else if (key == T_KEY_KILL) { /* CTRL-K: Delete entire line in front of pos */
if (ctx->pos != ctx->len)
kill_buf(ctx->line, &ctx->pos, &ctx->len);
else
beep();
}
else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */
@ -351,6 +359,8 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y-1, x2 - cur_len);
else
wmove(self->window, y, x - cur_len);
} else {
beep();
}
}
@ -363,6 +373,8 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, y+1, 0);
else
wmove(self->window, y, x + cur_len);
} else {
beep();
}
}
@ -395,7 +407,11 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
} else {
wmove(self->window, y, x+diff);
}
} else {
beep();
}
} else {
beep();
}
}

View File

@ -119,16 +119,21 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
/* BACKSPACE key: Remove one character from line */
if (key == 0x107 || key == 0x8 || key == 0x7f) {
if (prt->pos > 0)
if (prt->pos > 0) {
del_char_buf_bck(prt->line, &prt->pos, &prt->len);
wmove(self->window, y, x-1); /* not necessary but fixes a display glitch */
prt->scroll = false;
} else {
beep();
}
}
else if (key == KEY_DC) { /* DEL key: Remove character at pos */
if (prt->pos != prt->len) {
del_char_buf_frnt(prt->line, &prt->pos, &prt->len);
prt->scroll = false;
} else {
beep();
}
}
@ -137,12 +142,16 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
wmove(self->window, prt->orig_y, X_OFST);
wclrtobot(self->window);
discard_buf(prt->line, &prt->pos, &prt->len);
} else {
beep();
}
}
else if (key == T_KEY_KILL) { /* CTRL-K: Delete entire line in front of pos */
if (prt->len != prt->pos)
kill_buf(prt->line, &prt->pos, &prt->len);
else
beep();
}
else if (key == KEY_HOME) { /* HOME key: Move cursor to beginning of line */
@ -158,11 +167,15 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
else if (key == KEY_LEFT) {
if (prt->pos > 0)
--prt->pos;
else
beep();
}
else if (key == KEY_RIGHT) {
if (prt->pos < prt->len)
++prt->pos;
else
beep();
}
else if (key == KEY_UP) { /* fetches previous item in history */
@ -194,9 +207,13 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key)
}
else if (key == '\t') { /* TAB key: completes command */
if (prt->len > 1 && prt->line[0] == '/')
complete_line(prt->line, &prt->pos, &prt->len, glob_cmd_list, AC_NUM_GLOB_COMMANDS,
MAX_CMDNAME_SIZE);
if (prt->len > 1 && prt->line[0] == '/') {
if (complete_line(prt->line, &prt->pos, &prt->len, glob_cmd_list, AC_NUM_GLOB_COMMANDS,
MAX_CMDNAME_SIZE) == -1)
beep();
} else {
beep();
}
}
else

View File

@ -132,7 +132,7 @@ void fetch_hist_item(wchar_t *buf, size_t *pos, size_t *len, wchar_t (*hst)[MAX_
} else {
if (++(*hst_pos) > hst_tot) {
--(*hst_pos);
discard_buf(buf, pos, len);
beep();
return;
}
}