-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui_edits.h
More file actions
142 lines (118 loc) · 3.13 KB
/
ui_edits.h
File metadata and controls
142 lines (118 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* edits */
static uint8_t edit_name_data[128], edit_status_data[128], edit_addid_data[TOX_FRIEND_ADDRESS_SIZE * 2], edit_addmsg_data[1024], edit_msg_data[1024];
static void edit_name_onenter(void)
{
uint8_t *data = edit_name_data;
uint16_t length = edit_name.length;
if(!length) {
return;
}
memcpy(self.name, data, length);
self.name_length = length;
tox_postmessage(TOX_SETNAME, length, 0, self.name);//!
}
static void edit_status_onenter(void)
{
uint8_t *data = edit_status_data;
uint16_t length = edit_status.length;
if(!length) {
return;
}
void *p = realloc(self.statusmsg, length);
if(!p) {
return;
}
self.statusmsg = p;
memcpy(self.statusmsg, data, length);
self.statusmsg_length = length;
tox_postmessage(TOX_SETSTATUSMSG, length, 0, self.statusmsg);//!
}
static void edit_msg_onenter(void)
{
uint16_t length = edit_msg.length;
if(length == 0) {
return;
}
if(sitem->item == ITEM_FRIEND) {
FRIEND *f = sitem->data;
MESSAGE *msg = malloc(length + sizeof(MESSAGE));
msg->flags = 1;
msg->length = length;
memcpy(msg->msg, edit_msg_data, length);
/*uint16_t *data = malloc(length + 8);
data[0] = 0;
data[1] = length;
memcpy((void*)data + 4, edit_msg_data, length);*/
friend_addmessage(f, msg);
//
void *d = malloc(length);
memcpy(d, edit_msg_data, length);
tox_postmessage(TOX_SENDMESSAGE, (f - friend), length, d);
} else {
GROUPCHAT *g = sitem->data;
void *d = malloc(length);
memcpy(d, edit_msg_data, length);
tox_postmessage(TOX_SENDMESSAGEGROUP, (g - group), length, d);
}
edit_msg.length = 0;
}
EDIT edit_name = {
.panel = {
.type = PANEL_EDIT,
.x = 5 * SCALE,
.y = SCALE * 14,
.height = SCALE * 12,
.width = -SCROLL_WIDTH - 5 * SCALE
},
.maxlength = 128,
.data = edit_name_data,
.onenter = edit_name_onenter,
},
edit_status = {
.panel = {
.type = PANEL_EDIT,
.x = 5 * SCALE,
.y = SCALE * 38,
.height = SCALE * 12,
.width = -SCROLL_WIDTH - 5 * SCALE
},
.maxlength = 128,
.data = edit_status_data,
.onenter = edit_status_onenter,
},
edit_addid = {
.panel = {
.type = PANEL_EDIT,
.x = 5 * SCALE,
.y = SCALE * 14,
.height = SCALE * 12,
.width = -SCROLL_WIDTH - 5 * SCALE
},
.maxlength = sizeof(edit_addid_data),
.data = edit_addid_data,
},
edit_addmsg = {
.panel = {
.type = PANEL_EDIT,
.x = 5 * SCALE,
.y = SCALE * 38,
.height = SCALE * 42,
.width = -SCROLL_WIDTH - 5 * SCALE
},
.multiline = 1,
.maxlength = sizeof(edit_addmsg_data),
.data = edit_addmsg_data,
},
edit_msg = {
.panel = {
.type = PANEL_EDIT,
.x = 5 * SCALE,
.y = -47 * SCALE,
.height = 42 * SCALE,
.width = - 5 * SCALE
},
.multiline = 1,
.maxlength = sizeof(edit_msg_data),
.data = edit_msg_data,
.onenter = edit_msg_onenter,
};