Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/screen.c @ 1381:40095d413da9
Fix compilation on OpenBSD
This patch fixes compilation on some BSD systems.
Thanks to "undet" for the suggestion regarding DATA_DIR.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 02 Dec 2007 10:36:42 +0100 |
parents | a0deb5124ebf |
children | 1447c5296977 |
comparison
equal
deleted
inserted
replaced
1380:605f9e1f9f76 | 1381:40095d413da9 |
---|---|
241 return -1; | 241 return -1; |
242 } | 242 } |
243 | 243 |
244 static int get_user_color(const char *color) | 244 static int get_user_color(const char *color) |
245 { | 245 { |
246 bool isbright = false; | 246 bool isbright = FALSE; |
247 int cl; | 247 int cl; |
248 if (!strncmp(color, "bright", 6)) { | 248 if (!strncmp(color, "bright", 6)) { |
249 isbright = true; | 249 isbright = TRUE; |
250 color += 6; | 250 color += 6; |
251 } | 251 } |
252 cl = color_to_color_fg(FindColorInternal(color)); | 252 cl = color_to_color_fg(FindColorInternal(color)); |
253 if (cl < 0) | 253 if (cl < 0) |
254 return cl; | 254 return cl; |
302 // If color is "-", the color is marked as automaticly assigned and is | 302 // If color is "-", the color is marked as automaticly assigned and is |
303 // not used if the room is in the "preset" mode | 303 // not used if the room is in the "preset" mode |
304 void scr_MucNickColor(const char *nick, const char *color) | 304 void scr_MucNickColor(const char *nick, const char *color) |
305 { | 305 { |
306 char *snick, *mnick; | 306 char *snick, *mnick; |
307 bool need_update = false; | 307 bool need_update = FALSE; |
308 snick = g_strdup_printf("<%s>", nick); | 308 snick = g_strdup_printf("<%s>", nick); |
309 mnick = g_strdup_printf("*%s ", nick); | 309 mnick = g_strdup_printf("*%s ", nick); |
310 if (!strcmp(color, "-")) {//Remove the color | 310 if (!strcmp(color, "-")) {//Remove the color |
311 if (nickcolors) { | 311 if (nickcolors) { |
312 nickcolor *nc = g_hash_table_lookup(nickcolors, snick); | 312 nickcolor *nc = g_hash_table_lookup(nickcolors, snick); |
313 if (nc) {//Have this nick already | 313 if (nc) {//Have this nick already |
314 nc->manual = false; | 314 nc->manual = FALSE; |
315 nc = g_hash_table_lookup(nickcolors, mnick); | 315 nc = g_hash_table_lookup(nickcolors, mnick); |
316 assert(nc);//Must have both at the same time | 316 assert(nc);//Must have both at the same time |
317 nc->manual = false; | 317 nc->manual = FALSE; |
318 }// Else -> no color saved, nothing to delete | 318 }// Else -> no color saved, nothing to delete |
319 } | 319 } |
320 g_free(snick);//They are not saved in the hash | 320 g_free(snick);//They are not saved in the hash |
321 g_free(mnick); | 321 g_free(mnick); |
322 need_update = true; | 322 need_update = TRUE; |
323 } else if (!strcmp(color, "!")) { | 323 } else if (!strcmp(color, "!")) { |
324 if (nickcolors) { | 324 if (nickcolors) { |
325 g_free(g_hash_table_lookup(nickcolors, snick)); | 325 g_free(g_hash_table_lookup(nickcolors, snick)); |
326 g_hash_table_remove(nickcolors, snick); | 326 g_hash_table_remove(nickcolors, snick); |
327 g_hash_table_remove(nickcolors, mnick); | 327 g_hash_table_remove(nickcolors, mnick); |
328 } | 328 } |
329 g_free(snick);//They are not saved in the hash | 329 g_free(snick);//They are not saved in the hash |
330 g_free(mnick); | 330 g_free(mnick); |
331 need_update = true; | 331 need_update = TRUE; |
332 } else { | 332 } else { |
333 int cl = get_user_color(color); | 333 int cl = get_user_color(color); |
334 if (cl < 0) { | 334 if (cl < 0) { |
335 scr_LogPrint(LPRINT_NORMAL, "No such color name"); | 335 scr_LogPrint(LPRINT_NORMAL, "No such color name"); |
336 g_free(snick); | 336 g_free(snick); |
337 g_free(mnick); | 337 g_free(mnick); |
338 } else { | 338 } else { |
339 nickcolor *nc = g_new(nickcolor, 1); | 339 nickcolor *nc = g_new(nickcolor, 1); |
340 ensure_string_htable(&nickcolors, NULL); | 340 ensure_string_htable(&nickcolors, NULL); |
341 nc->manual = true; | 341 nc->manual = TRUE; |
342 nc->color = cl; | 342 nc->color = cl; |
343 //Free the struct, if any there already | 343 //Free the struct, if any there already |
344 g_free(g_hash_table_lookup(nickcolors, mnick)); | 344 g_free(g_hash_table_lookup(nickcolors, mnick)); |
345 //Save the new ones | 345 //Save the new ones |
346 g_hash_table_replace(nickcolors, mnick, nc); | 346 g_hash_table_replace(nickcolors, mnick, nc); |
347 g_hash_table_replace(nickcolors, snick, nc); | 347 g_hash_table_replace(nickcolors, snick, nc); |
348 need_update = true; | 348 need_update = TRUE; |
349 } | 349 } |
350 } | 350 } |
351 if (need_update && chatmode && | 351 if (need_update && chatmode && |
352 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM)) | 352 (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_ROOM)) |
353 scr_UpdateBuddyWindow(); | 353 scr_UpdateBuddyWindow(); |
1082 !g_hash_table_lookup(nickcolors, line->text))) { | 1082 !g_hash_table_lookup(nickcolors, line->text))) { |
1083 ensure_string_htable(&nickcolors, NULL); | 1083 ensure_string_htable(&nickcolors, NULL); |
1084 char *snick = g_strdup(line->text), *mnick = g_strdup(line->text); | 1084 char *snick = g_strdup(line->text), *mnick = g_strdup(line->text); |
1085 nickcolor *nc = g_new(nickcolor, 1); | 1085 nickcolor *nc = g_new(nickcolor, 1); |
1086 nc->color = nickcols[random() % nickcolcount]; | 1086 nc->color = nickcols[random() % nickcolcount]; |
1087 nc->manual = false; | 1087 nc->manual = FALSE; |
1088 *snick = '<'; | 1088 *snick = '<'; |
1089 snick[strlen(snick)-1] = '>'; | 1089 snick[strlen(snick)-1] = '>'; |
1090 *mnick = '*'; | 1090 *mnick = '*'; |
1091 mnick[strlen(mnick)-1] = ' '; | 1091 mnick[strlen(mnick)-1] = ' '; |
1092 // Insert them | 1092 // Insert them |
2088 if (newbuddy == current_buddy) return; | 2088 if (newbuddy == current_buddy) return; |
2089 | 2089 |
2090 // We're moving to another buddy. We're thus inactive wrt current_buddy. | 2090 // We're moving to another buddy. We're thus inactive wrt current_buddy. |
2091 set_chatstate(0); | 2091 set_chatstate(0); |
2092 // We don't want the chatstate to be changed again right now. | 2092 // We don't want the chatstate to be changed again right now. |
2093 lock_chatstate = true; | 2093 lock_chatstate = TRUE; |
2094 | 2094 |
2095 prev_st = buddy_getstatus(BUDDATA(current_buddy), NULL); | 2095 prev_st = buddy_getstatus(BUDDATA(current_buddy), NULL); |
2096 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); | 2096 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE); |
2097 if (chatmode) | 2097 if (chatmode) |
2098 alternate_buddy = current_buddy; | 2098 alternate_buddy = current_buddy; |
3705 void process_key(keycode kcode) | 3705 void process_key(keycode kcode) |
3706 { | 3706 { |
3707 int key = kcode.value; | 3707 int key = kcode.value; |
3708 int display_char = FALSE; | 3708 int display_char = FALSE; |
3709 | 3709 |
3710 lock_chatstate = false; | 3710 lock_chatstate = FALSE; |
3711 | 3711 |
3712 switch (kcode.mcode) { | 3712 switch (kcode.mcode) { |
3713 case 0: | 3713 case 0: |
3714 break; | 3714 break; |
3715 case MKEY_EQUIV: | 3715 case MKEY_EQUIV: |