Skip to content

Commit

Permalink
Fix char -> widechar comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Nov 8, 2020
1 parent 32eb7d3 commit 811fbfb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/chat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,16 +1061,16 @@ bool chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
return false;
}

if (ctx->pastemode && key == '\r') {
key = '\n';
if (ctx->pastemode && key == L'\r') {
key = L'\n';
}

if (self->help->active) {
help_onKey(self, key);
return true;
}

if (ltr || key == '\n') { /* char is printable */
if (ltr || key == L'\n') { /* char is printable */
input_new_char(self, key, x, x2);

if (ctx->line[0] != '/' && !ctx->self_is_typing && statusbar->connection != TOX_CONNECTION_NONE) {
Expand All @@ -1090,7 +1090,7 @@ bool chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)

int input_ret = false;

if (key == '\t' && ctx->len > 1 && ctx->line[0] == '/') { /* TAB key: auto-complete */
if (key == L'\t' && ctx->len > 1 && ctx->line[0] == '/') { /* TAB key: auto-complete */
input_ret = true;
int diff = -1;

Expand Down Expand Up @@ -1128,7 +1128,7 @@ bool chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
sound_notify(self, notif_error, 0, NULL);
}

} else if (key == '\r') {
} else if (key == L'\r') {
input_ret = true;
rm_trailing_spaces_buf(ctx);

Expand Down
8 changes: 4 additions & 4 deletions src/friendlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ static bool friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
return true;
}

if (key == 'h') {
if (key == L'h') {
help_init_menu(self);
return true;
}
Expand All @@ -879,7 +879,7 @@ static bool friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)

/* lock screen and force decision on deletion popup */
if (PendingDelete.active) {
if (key == 'y' || key == 'n') {
if (key == L'y' || key == L'n') {
del_friend_deactivate(m, key);
}

Expand All @@ -891,7 +891,7 @@ static bool friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
}

switch (key) {
case '\r':
case L'\r':
if (blocklist_view) {
break;
}
Expand All @@ -914,7 +914,7 @@ static bool friendlist_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
del_friend_activate(f);
break;

case 'b':
case L'b':
if (!blocklist_view) {
block_friend(m, f);
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/groupchat.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,11 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
return true;
}

if (ctx->pastemode && key == '\r') {
key = '\n';
if (ctx->pastemode && key == L'\r') {
key = L'\n';
}

if (ltr || key == '\n') { /* char is printable */
if (ltr || key == L'\n') { /* char is printable */
input_new_char(self, key, x, x2);
return true;
}
Expand All @@ -517,7 +517,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)

bool input_ret = false;

if (key == '\t') { /* TAB key: auto-completes peer name or command */
if (key == L'\t') { /* TAB key: auto-completes peer name or command */
input_ret = true;

if (ctx->len > 0) {
Expand Down Expand Up @@ -564,7 +564,7 @@ static bool groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
if (groupchats[self->num].side_pos > 0) {
--groupchats[self->num].side_pos;
}
} else if (key == '\r') {
} else if (key == L'\r') {
input_ret = true;
rm_trailing_spaces_buf(ctx);

Expand Down
16 changes: 8 additions & 8 deletions src/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ void help_onKey(ToxWindow *self, wint_t key)
int height;

switch (key) {
case 'x':
case L'x':
case T_KEY_ESC:
help_exit(self);
break;

case 'c':
case L'c':
#ifdef VIDEO
help_init_window(self, 23, 80);
#elif AUDIO
Expand All @@ -372,7 +372,7 @@ void help_onKey(ToxWindow *self, wint_t key)
self->help->type = HELP_CHAT;
break;

case 'g':
case L'g':
height = 22;
#ifdef VIDEO
height += 8;
Expand All @@ -386,30 +386,30 @@ void help_onKey(ToxWindow *self, wint_t key)
self->help->type = HELP_GLOBAL;
break;

case 'r':
case L'r':
help_init_window(self, 6, 80);
self->help->type = HELP_GROUP;
break;

#ifdef PYTHON

case 'p':
case L'p':
help_init_window(self, 4 + num_registered_handlers(), help_max_width());
self->help->type = HELP_PLUGIN;
break;
#endif /* PYTHON */

case 'f':
case L'f':
help_init_window(self, 10, 80);
self->help->type = HELP_CONTACTS;
break;

case 'k':
case L'k':
help_init_window(self, 15, 80);
self->help->type = HELP_KEYS;
break;

case 'm':
case L'm':
help_init_menu(self);
self->help->type = HELP_MENU;
break;
Expand Down

0 comments on commit 811fbfb

Please sign in to comment.