Advertisement
JoshDreamland

Rainbow Tag

Mar 17th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. /// Struct defining a rainbow tag, [rb].
  2. struct rainbowtag: bbcode_tag {
  3.   void init() { }
  4.   string get_replacement(PurpleConversation*, PurpleAccount*, int, string content, string, string) {
  5.     char colors[10] = { '4', '7', '8', '3', '2', '6' };
  6.     string res = "\00304"; int color = 0;
  7.     for (const char* uc = content.c_str(); *uc; ) {
  8.       const char *ucf = uc; uc = g_utf8_next_char(uc);
  9.       res += string(ucf,uc);
  10.       gunichar c = g_utf8_get_char(ucf);
  11.       if (!g_unichar_isspace(c)) {
  12.         res += "\0030", res += colors[++color % 6];
  13.       }
  14.     }
  15.     return res;
  16.   }
  17.   rainbowtag(): bbcode_tag("rb",false) {}
  18. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement