diff options
Diffstat (limited to 'src/ui/account_create.c')
-rw-r--r-- | src/ui/account_create.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/ui/account_create.c b/src/ui/account_create.c deleted file mode 100644 index 947317d..0000000 --- a/src/ui/account_create.c +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2022 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | /* | ||
21 | * @author Tobias Frisch | ||
22 | * @file ui/account_create.c | ||
23 | */ | ||
24 | |||
25 | #include "account_create.h" | ||
26 | |||
27 | #include <ctype.h> | ||
28 | |||
29 | #include <gnunet/platform.h> | ||
30 | #include <gnunet/gnunet_chat_lib.h> | ||
31 | #include <gnunet/gnunet_util_lib.h> | ||
32 | |||
33 | #include "../application.h" | ||
34 | #include "../util.h" | ||
35 | |||
36 | void | ||
37 | account_create_event(UI_ACCOUNT_CREATE_Handle *create, | ||
38 | struct MESSENGER_Application *app, | ||
39 | int key) | ||
40 | { | ||
41 | switch (key) | ||
42 | { | ||
43 | case 27: | ||
44 | case KEY_EXIT: | ||
45 | { | ||
46 | create->window = NULL; | ||
47 | break; | ||
48 | } | ||
49 | case KEY_LEFT: | ||
50 | { | ||
51 | create->name_pos--; | ||
52 | break; | ||
53 | } | ||
54 | case KEY_RIGHT: | ||
55 | { | ||
56 | create->name_pos++; | ||
57 | break; | ||
58 | } | ||
59 | case '\n': | ||
60 | case KEY_ENTER: | ||
61 | { | ||
62 | if (create->name_len > 0) | ||
63 | GNUNET_CHAT_account_create(app->chat.handle, create->name); | ||
64 | |||
65 | create->name_len = 0; | ||
66 | create->window = NULL; | ||
67 | break; | ||
68 | } | ||
69 | case KEY_BACKSPACE: | ||
70 | { | ||
71 | if ((create->name_pos < create->name_len) && | ||
72 | (create->name_pos > 0)) | ||
73 | for (int i = create->name_pos; i < create->name_len; i++) | ||
74 | create->name[i - 1] = create->name[i]; | ||
75 | |||
76 | if ((create->name_pos > 0) && (create->name_len > 0)) | ||
77 | { | ||
78 | create->name_pos--; | ||
79 | create->name_len--; | ||
80 | } | ||
81 | |||
82 | break; | ||
83 | } | ||
84 | default: | ||
85 | { | ||
86 | if (!isalnum(key)) | ||
87 | break; | ||
88 | |||
89 | for (int i = create->name_len - 1; i >= create->name_pos; i--) | ||
90 | create->name[i + 1] = create->name[i]; | ||
91 | |||
92 | create->name[create->name_pos++] = (char) key; | ||
93 | create->name_len++; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | if (create->name_len > 255) | ||
99 | create->name_len = 255; | ||
100 | |||
101 | create->name[create->name_len] = '\0'; | ||
102 | |||
103 | if (create->name_pos < 0) | ||
104 | create->name_pos = 0; | ||
105 | |||
106 | if (create->name_pos > create->name_len) | ||
107 | create->name_pos = create->name_len; | ||
108 | } | ||
109 | |||
110 | void | ||
111 | account_create_print(UI_ACCOUNT_CREATE_Handle *create, | ||
112 | UNUSED struct MESSENGER_Application *app) | ||
113 | { | ||
114 | if (!(create->window)) | ||
115 | return; | ||
116 | |||
117 | werase(create->window); | ||
118 | wmove(create->window, 0, 0); | ||
119 | |||
120 | wprintw(create->window, "%s", create->name); | ||
121 | wmove(create->window, 0, create->name_pos); | ||
122 | } | ||