diff options
author | TheJackiMonster <thejackimonster@gmail.com> | 2022-08-18 14:32:08 +0200 |
---|---|---|
committer | TheJackiMonster <thejackimonster@gmail.com> | 2022-08-18 14:32:08 +0200 |
commit | 82dfd76ff534e362b7bfb3c12b870286a354f80b (patch) | |
tree | 815f344cf92433d2e47242aaa65069bc6213f3d7 /src/ui/account_create_dialog.c | |
parent | 774d4ea84ac0fd216821b6a058555576ab6db6af (diff) | |
download | messenger-cli-82dfd76ff534e362b7bfb3c12b870286a354f80b.tar.gz messenger-cli-82dfd76ff534e362b7bfb3c12b870286a354f80b.zip |
Normalized text input via macro and added lobby-entering dialog
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat (limited to 'src/ui/account_create_dialog.c')
-rw-r--r-- | src/ui/account_create_dialog.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/src/ui/account_create_dialog.c b/src/ui/account_create_dialog.c index 5472bc7..f3c9394 100644 --- a/src/ui/account_create_dialog.c +++ b/src/ui/account_create_dialog.c | |||
@@ -24,12 +24,11 @@ | |||
24 | 24 | ||
25 | #include "account_create_dialog.h" | 25 | #include "account_create_dialog.h" |
26 | 26 | ||
27 | #include <ctype.h> | ||
28 | |||
29 | #include <gnunet/platform.h> | 27 | #include <gnunet/platform.h> |
30 | #include <gnunet/gnunet_chat_lib.h> | 28 | #include <gnunet/gnunet_chat_lib.h> |
31 | #include <gnunet/gnunet_util_lib.h> | 29 | #include <gnunet/gnunet_util_lib.h> |
32 | 30 | ||
31 | #include "text_input.h" | ||
33 | #include "../application.h" | 32 | #include "../application.h" |
34 | #include "../util.h" | 33 | #include "../util.h" |
35 | 34 | ||
@@ -42,69 +41,21 @@ account_create_dialog_event(UI_ACCOUNT_CREATE_DIALOG_Handle *create_dialog, | |||
42 | { | 41 | { |
43 | case 27: | 42 | case 27: |
44 | case KEY_EXIT: | 43 | case KEY_EXIT: |
45 | { | ||
46 | create_dialog->window = NULL; | 44 | create_dialog->window = NULL; |
47 | break; | 45 | break; |
48 | } | ||
49 | case KEY_LEFT: | ||
50 | { | ||
51 | create_dialog->name_pos--; | ||
52 | break; | ||
53 | } | ||
54 | case KEY_RIGHT: | ||
55 | { | ||
56 | create_dialog->name_pos++; | ||
57 | break; | ||
58 | } | ||
59 | case '\n': | 46 | case '\n': |
60 | case KEY_ENTER: | 47 | case KEY_ENTER: |
61 | { | ||
62 | if (create_dialog->name_len > 0) | 48 | if (create_dialog->name_len > 0) |
63 | GNUNET_CHAT_account_create(app->chat.handle, create_dialog->name); | 49 | GNUNET_CHAT_account_create(app->chat.handle, create_dialog->name); |
64 | 50 | ||
65 | create_dialog->name_len = 0; | 51 | create_dialog->name_len = 0; |
66 | create_dialog->window = NULL; | 52 | create_dialog->window = NULL; |
67 | break; | 53 | break; |
68 | } | ||
69 | case KEY_BACKSPACE: | ||
70 | { | ||
71 | if ((create_dialog->name_pos < create_dialog->name_len) && | ||
72 | (create_dialog->name_pos > 0)) | ||
73 | for (int i = create_dialog->name_pos; i < create_dialog->name_len; i++) | ||
74 | create_dialog->name[i - 1] = create_dialog->name[i]; | ||
75 | |||
76 | if ((create_dialog->name_pos > 0) && (create_dialog->name_len > 0)) | ||
77 | { | ||
78 | create_dialog->name_pos--; | ||
79 | create_dialog->name_len--; | ||
80 | } | ||
81 | |||
82 | break; | ||
83 | } | ||
84 | default: | 54 | default: |
85 | { | ||
86 | if (!isprint(key)) | ||
87 | break; | ||
88 | |||
89 | for (int i = create_dialog->name_len - 1; i >= create_dialog->name_pos; i--) | ||
90 | create_dialog->name[i + 1] = create_dialog->name[i]; | ||
91 | |||
92 | create_dialog->name[create_dialog->name_pos++] = (char) key; | ||
93 | create_dialog->name_len++; | ||
94 | break; | 55 | break; |
95 | } | ||
96 | } | 56 | } |
97 | 57 | ||
98 | if (create_dialog->name_len > 255) | 58 | text_input_event(create_dialog->name, key); |
99 | create_dialog->name_len = 255; | ||
100 | |||
101 | create_dialog->name[create_dialog->name_len] = '\0'; | ||
102 | |||
103 | if (create_dialog->name_pos < 0) | ||
104 | create_dialog->name_pos = 0; | ||
105 | |||
106 | if (create_dialog->name_pos > create_dialog->name_len) | ||
107 | create_dialog->name_pos = create_dialog->name_len; | ||
108 | } | 59 | } |
109 | 60 | ||
110 | void | 61 | void |