colors demo

This commit is contained in:
anon 2023-08-03 15:55:04 +02:00
parent add94130bd
commit 62c0a8f26f
3 changed files with 29 additions and 19 deletions

View File

@ -1,21 +1,27 @@
#ifndef IRCCOLOR_H_
#define IRC_COLOR_WHITE "\x03\x00"
#define IRC_COLOR_BLACK "\x03\x01"
#define IRC_COLOR_BLUE "\x03\x02"
#define IRC_COLOR_GREEN "\x03\x03"
#define IRC_COLOR_RED "\x03\x04"
#define IRC_COLOR_BROWN "\x03\x05"
#define IRC_COLOR_PURPLE "\x03\x06"
#define IRC_COLOR_ORANGE "\x03\x07"
#define IRC_COLOR_YELLOW "\x03\x08"
#define IRC_COLOR_LIGHT_GREEN "\x03\x09"
#define IRC_COLOR_TEAL "\x03\x10"
#define IRC_COLOR_LIGHT_CYAN "\x03\x11"
#define IRC_COLOR_LIGHT_BLUE "\x03\x12"
#define IRC_COLOR_PINK "\x03\x13"
#define IRC_COLOR_GREY "\x03\x14"
#define IRC_COLOR_LIGHT_GREY "\x03\x15"
// Formatting macros
#define IRC_FORMAT_BOLD "[B]"
#define IRC_FORMAT_ITALIC "[I]"
#define IRC_FORMAT_UNDERLINE "[U]"
// Color macros
#define IRC_COLOR_BLACK "[COLOR=BLACK]"
#define IRC_COLOR_DARKBLUE "[COLOR=DARKBLUE]"
#define IRC_COLOR_DARKGREEN "[COLOR=DARKGREEN]"
#define IRC_COLOR_RED "[COLOR=RED]"
#define IRC_COLOR_BROWN "[COLOR=BROWN]"
#define IRC_COLOR_PURPLE "[COLOR=PURPLE]"
#define IRC_COLOR_OLIVE "[COLOR=OLIVE]"
#define IRC_COLOR_YELLOW "[COLOR=YELLOW]"
#define IRC_COLOR_GREEN "[COLOR=GREEN]"
#define IRC_COLOR_TEAL "[COLOR=TEAL]"
#define IRC_COLOR_CYAN "[COLOR=CYAN]"
#define IRC_COLOR_BLUE "[COLOR=BLUE]"
#define IRC_COLOR_MAGENTA "[COLOR=MAGENTA]"
#define IRC_COLOR_DARKGRAY "[COLOR=DARKGRAY]"
#define IRC_COLOR_LIGHTGRAY "[COLOR=LIGHTGRAY]"
#define IRC_COLOR_TERMINATE "[/COLOR]"
#define IRCCOLOR_H_
#endif

View File

@ -68,11 +68,11 @@ remind(char * who)
desc = strdup(desc);
repo = (char *) sqlite3_column_text(remind_stmt, 3);
repo = strdup(repo);
asprintf(&r, IRC_COLOR_RED "%s: " IRC_COLOR_YELLOW "%s (@%s)", title, desc, repo);
asprintf(&r, IRC_COLOR_RED "%s: " IRC_COLOR_YELLOW "%s" IRC_COLOR_GREEN " (@" IRC_COLOR_BLUE "%s" IRC_COLOR_GREEN ")" IRC_COLOR_TERMINATE, title, desc, repo);
}
else
{
r = strdup("No current assignment.");
r = strdup(IRC_COLOR_RED "No current assignment." IRC_COLOR_TERMINATE);
}
return r;
}

View File

@ -29,6 +29,7 @@
#include "parse.h"
#include "api.h"
#include "error.h"
#include "irccolors.h"
#define PREFIX_COMMAND_CHAR '!'
@ -59,6 +60,7 @@ ircmsg(const char* fmt,
{
va_list args;
char * fmtdmsg;
char * swp;
va_start(args, fmt);
if(vasprintf(&fmtdmsg, fmt, args) == -1)
@ -68,7 +70,9 @@ ircmsg(const char* fmt,
const char* delim = "\n";
char* data = strtok(fmtdmsg, delim);
do{
IRCMSG(data);
swp = irc_color_convert_to_mirc(data);
IRCMSG(swp);
free(swp);
}while((data = strtok(NULL, delim), data));
free(fmtdmsg);