1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 09:16:45 +02:00

added /me actions to toxic

This commit is contained in:
Jfreegman
2013-08-08 15:01:33 -04:00
parent 90b4f9b98c
commit 30377630ee
4 changed files with 79 additions and 15 deletions

26
main.c
View File

@ -44,8 +44,9 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
wprintw(prompt->window, "%02x", public_key[i] & 0xff);
}
wprintw(prompt->window, "\n");
wprintw(prompt->window, "Use \"accept %d\" to accept it.\n", n);
wprintw(prompt->window, "\nWith the message: %s\n", data);
wprintw(prompt->window, "\nUse \"accept %d\" to accept it.\n", n);
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
if (windows[i].onFriendRequest != NULL)
windows[i].onFriendRequest(&windows[i], public_key, data, length);
@ -54,7 +55,6 @@ void on_request(uint8_t *public_key, uint8_t *data, uint16_t length)
void on_message(int friendnumber, uint8_t *string, uint16_t length)
{
wprintw(prompt->window, "\n(message) %d: %s\n", friendnumber, string);
int i;
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
if (windows[i].onMessage != NULL)
@ -62,6 +62,15 @@ void on_message(int friendnumber, uint8_t *string, uint16_t length)
}
}
void on_action(int friendnumber, uint8_t *string, uint16_t length)
{
int i;
for (i = 0; i < MAX_WINDOW_SLOTS; ++i) {
if (windows[i].onAction != NULL)
windows[i].onAction(&windows[i], friendnumber, string, length);
}
}
void on_nickchange(int friendnumber, uint8_t *string, uint16_t length)
{
wprintw(prompt->window, "\n(nickchange) %d: %s!\n", friendnumber, string);
@ -117,6 +126,7 @@ static void init_tox()
m_callback_friendmessage(on_message);
m_callback_namechange(on_nickchange);
m_callback_statusmessage(on_statuschange);
m_callback_action(on_action);
}
void init_window_status()
@ -272,13 +282,13 @@ static void draw_bar()
attron(A_BOLD);
odd = (odd+1) % blinkrate;
if (windows[i].blink && (odd < (blinkrate/2))) {
if (windows[i].blink && (odd < (blinkrate/2)))
attron(COLOR_PAIR(3));
}
printw(" %s", windows[i].title);
if (windows[i].blink && (odd < (blinkrate/2))) {
if (windows[i].blink && (odd < (blinkrate/2)))
attroff(COLOR_PAIR(3));
}
if (i == active_window) {
attroff(A_BOLD);
}
@ -308,7 +318,6 @@ void set_active_window(int ch)
i = (i + 1) % max;
if (f_inf++ > max) { // infinite loop check
endwin();
clear();
exit(2);
}
}
@ -323,7 +332,6 @@ void set_active_window(int ch)
if (--i < 0) i = max;
if (f_inf++ > max) {
endwin();
clear();
exit(2);
}
}