1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-22 21:33:02 +01:00

astyle --options=tools/astylerc -r ./*.{c,h}

This commit is contained in:
irungentoo 2013-08-20 19:37:05 -04:00
parent 05fd02767f
commit 43d0d7a1c0
4 changed files with 30 additions and 24 deletions

2
chat.c
View File

@ -123,7 +123,7 @@ static void chat_onStatusChange(ToxWindow *self, int num, uint8_t *status, uint1
status[len - 1] = '\0'; status[len - 1] = '\0';
fix_name(status); fix_name(status);
wattron(ctx->history, COLOR_PAIR(3)); wattron(ctx->history, COLOR_PAIR(3));
wprintw(ctx->history, "* Your partner changed status to '%s'\n", status); wprintw(ctx->history, "* Your partner changed status to '%s'\n", status);
wattroff(ctx->history, COLOR_PAIR(3)); wattroff(ctx->history, COLOR_PAIR(3));

4
main.c
View File

@ -93,7 +93,7 @@ static Messenger *init_tox()
int init_connection(Messenger *m) int init_connection(Messenger *m)
{ {
FILE *fp = NULL; FILE *fp = NULL;
if (DHT_isconnected(m->dht)) if (DHT_isconnected(m->dht))
return 0; return 0;
@ -297,7 +297,7 @@ int main(int argc, char *argv[])
strcpy(DATA_FILE, user_config_dir); strcpy(DATA_FILE, user_config_dir);
strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, CONFIGDIR);
strcat(DATA_FILE, "data"); strcat(DATA_FILE, "data");
SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
strcpy(SRVLIST_FILE, user_config_dir); strcpy(SRVLIST_FILE, user_config_dir);
strcat(SRVLIST_FILE, CONFIGDIR); strcat(SRVLIST_FILE, CONFIGDIR);

View File

@ -365,7 +365,9 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd)
cmd[i] = '\0'; cmd[i] = '\0';
int j = i; int j = i;
while (++j < MAX_STR_SIZE && isspace(cmd[j])); while (++j < MAX_STR_SIZE && isspace(cmd[j]));
i = j - 1; i = j - 1;
numargs++; numargs++;

View File

@ -88,23 +88,25 @@ int add_window(Messenger *m, ToxWindow w)
{ {
if (LINES < 2) if (LINES < 2)
return -1; return -1;
int i; int i;
for(i = 0; i < MAX_WINDOWS_NUM; i++) {
if (windows[i].window) for (i = 0; i < MAX_WINDOWS_NUM; i++) {
if (windows[i].window)
continue; continue;
w.window = newwin(LINES - 2, COLS, 0, 0); w.window = newwin(LINES - 2, COLS, 0, 0);
if (w.window == NULL) if (w.window == NULL)
return -1; return -1;
windows[i] = w; windows[i] = w;
w.onInit(&w, m); w.onInit(&w, m);
active_window = windows+i; active_window = windows + i;
return i; return i;
} }
return -1; return -1;
} }
@ -113,8 +115,10 @@ void del_window(ToxWindow *w)
{ {
active_window = windows; // Go to prompt screen active_window = windows; // Go to prompt screen
delwin(w->window); delwin(w->window);
if (w->x) if (w->x)
free(w->x); free(w->x);
w->window = NULL; w->window = NULL;
memset(w, 0, sizeof(ToxWindow)); memset(w, 0, sizeof(ToxWindow));
clear(); clear();
@ -124,19 +128,19 @@ void del_window(ToxWindow *w)
/* Shows next window when tab or back-tab is pressed */ /* Shows next window when tab or back-tab is pressed */
void set_next_window(int ch) void set_next_window(int ch)
{ {
ToxWindow *end = windows+MAX_WINDOWS_NUM-1; ToxWindow *end = windows + MAX_WINDOWS_NUM - 1;
ToxWindow *inf = active_window; ToxWindow *inf = active_window;
while(true) {
while (true) {
if (ch == '\t') { if (ch == '\t') {
if (++active_window > end) if (++active_window > end)
active_window = windows; active_window = windows;
} else } else if (--active_window < windows)
if (--active_window < windows) active_window = end;
active_window = end;
if (active_window->window) if (active_window->window)
return; return;
if (active_window == inf) { // infinite loop check if (active_window == inf) { // infinite loop check
endwin(); endwin();
exit(2); exit(2);
@ -148,14 +152,14 @@ void set_active_window(int index)
{ {
if (index < 0 || index >= MAX_WINDOWS_NUM) if (index < 0 || index >= MAX_WINDOWS_NUM)
return; return;
active_window = windows+index; active_window = windows + index;
} }
ToxWindow *init_windows() ToxWindow *init_windows()
{ {
int n_prompt = add_window(m, new_prompt()); int n_prompt = add_window(m, new_prompt());
if (n_prompt == -1 if (n_prompt == -1
|| add_window(m, new_friendlist()) == -1 || add_window(m, new_friendlist()) == -1
|| add_window(m, new_dhtstatus()) == -1) { || add_window(m, new_dhtstatus()) == -1) {
@ -166,7 +170,7 @@ ToxWindow *init_windows()
prompt = &windows[n_prompt]; prompt = &windows[n_prompt];
active_window = prompt; active_window = prompt;
return prompt; return prompt;
} }
@ -189,7 +193,7 @@ static void draw_bar()
for (i = 0; i < (MAX_WINDOWS_NUM); ++i) { for (i = 0; i < (MAX_WINDOWS_NUM); ++i) {
if (windows[i].window) { if (windows[i].window) {
if (windows+i == active_window) if (windows + i == active_window)
attron(A_BOLD); attron(A_BOLD);
odd = (odd + 1) % blinkrate; odd = (odd + 1) % blinkrate;
@ -197,13 +201,13 @@ static void draw_bar()
if (windows[i].blink && (odd < (blinkrate / 2))) if (windows[i].blink && (odd < (blinkrate / 2)))
attron(COLOR_PAIR(3)); attron(COLOR_PAIR(3));
clrtoeol(); clrtoeol();
printw(" %s", windows[i].title); printw(" %s", windows[i].title);
if (windows[i].blink && (odd < (blinkrate / 2))) if (windows[i].blink && (odd < (blinkrate / 2)))
attroff(COLOR_PAIR(3)); attroff(COLOR_PAIR(3));
if (windows+i == active_window) { if (windows + i == active_window) {
attroff(A_BOLD); attroff(A_BOLD);
} }
} }