degesch: reorder code
This commit is contained in:
parent
3f55693400
commit
0074b1eda9
138
degesch.c
138
degesch.c
|
@ -786,8 +786,6 @@ struct user
|
|||
{
|
||||
REF_COUNTABLE_HEADER
|
||||
|
||||
// TODO: eventually a reference to the server
|
||||
|
||||
char *nickname; ///< Literal nickname
|
||||
// TODO: write code to poll for the away status
|
||||
bool away; ///< User is away
|
||||
|
@ -851,8 +849,6 @@ struct channel
|
|||
{
|
||||
REF_COUNTABLE_HEADER
|
||||
|
||||
// TODO: eventually a reference to the server
|
||||
|
||||
char *name; ///< Channel name
|
||||
char *topic; ///< Channel topic
|
||||
|
||||
|
@ -893,6 +889,69 @@ REF_COUNTABLE_METHODS (channel)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
enum formatter_item_type
|
||||
{
|
||||
FORMATTER_ITEM_TEXT, ///< Text
|
||||
FORMATTER_ITEM_ATTR, ///< Formatting attributes
|
||||
FORMATTER_ITEM_FG_COLOR, ///< Foreground color
|
||||
FORMATTER_ITEM_BG_COLOR, ///< Background color
|
||||
FORMATTER_ITEM_SIMPLE, ///< For mIRC formatting only so far
|
||||
FORMATTER_ITEM_IGNORE_ATTR ///< Un/set attribute ignoration
|
||||
};
|
||||
|
||||
struct formatter_item
|
||||
{
|
||||
LIST_HEADER (struct formatter_item)
|
||||
|
||||
enum formatter_item_type type; ///< Type of this item
|
||||
int color; ///< Color
|
||||
int attribute; ///< Attribute ID
|
||||
char *text; ///< Either text or an attribute string
|
||||
};
|
||||
|
||||
static struct formatter_item *
|
||||
formatter_item_new (void)
|
||||
{
|
||||
struct formatter_item *self = xcalloc (1, sizeof *self);
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
formatter_item_destroy (struct formatter_item *self)
|
||||
{
|
||||
free (self->text);
|
||||
free (self);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
struct formatter
|
||||
{
|
||||
struct app_context *ctx; ///< Application context
|
||||
struct server *s; ///< Server
|
||||
|
||||
struct formatter_item *items; ///< Items
|
||||
struct formatter_item *items_tail; ///< Tail of items
|
||||
};
|
||||
|
||||
static void
|
||||
formatter_init (struct formatter *self,
|
||||
struct app_context *ctx, struct server *s)
|
||||
{
|
||||
memset (self, 0, sizeof *self);
|
||||
self->ctx = ctx;
|
||||
self->s = s;
|
||||
}
|
||||
|
||||
static void
|
||||
formatter_free (struct formatter *self)
|
||||
{
|
||||
LIST_FOR_EACH (struct formatter_item, iter, self->items)
|
||||
formatter_item_destroy (iter);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
enum buffer_line_flags
|
||||
{
|
||||
BUFFER_LINE_STATUS = 1 << 0, ///< Status message
|
||||
|
@ -918,9 +977,6 @@ buffer_line_new (void)
|
|||
return self;
|
||||
}
|
||||
|
||||
// FIXME: see if we can't rearrange the code in some way to get rid of this
|
||||
static void formatter_free (struct formatter *self);
|
||||
|
||||
static void
|
||||
buffer_line_destroy (struct buffer_line *self)
|
||||
{
|
||||
|
@ -1297,9 +1353,12 @@ app_context_free (struct app_context *self)
|
|||
input_free (&self->input);
|
||||
}
|
||||
|
||||
// TODO: see if we can reorder the code to get rid of these
|
||||
static void refresh_prompt (struct app_context *ctx);
|
||||
static char *irc_cut_nickname (const char *prefix);
|
||||
static const char *irc_find_userhost (const char *prefix);
|
||||
static char *irc_to_utf8 (struct app_context *ctx, const char *text);
|
||||
static bool irc_is_this_us (struct server *s, const char *prefix);
|
||||
|
||||
// --- Configuration -----------------------------------------------------------
|
||||
|
||||
|
@ -2002,67 +2061,6 @@ attribute_printer_update (struct attribute_printer *self)
|
|||
// Modifiers:
|
||||
// & free() the string argument after using it
|
||||
|
||||
enum formatter_item_type
|
||||
{
|
||||
FORMATTER_ITEM_TEXT, ///< Text
|
||||
FORMATTER_ITEM_ATTR, ///< Formatting attributes
|
||||
FORMATTER_ITEM_FG_COLOR, ///< Foreground color
|
||||
FORMATTER_ITEM_BG_COLOR, ///< Background color
|
||||
FORMATTER_ITEM_SIMPLE, ///< For mIRC formatting only so far
|
||||
FORMATTER_ITEM_IGNORE_ATTR ///< Un/set attribute ignoration
|
||||
};
|
||||
|
||||
struct formatter_item
|
||||
{
|
||||
LIST_HEADER (struct formatter_item)
|
||||
|
||||
enum formatter_item_type type; ///< Type of this item
|
||||
int color; ///< Color
|
||||
int attribute; ///< Attribute ID
|
||||
char *text; ///< Either text or an attribute string
|
||||
};
|
||||
|
||||
static struct formatter_item *
|
||||
formatter_item_new (void)
|
||||
{
|
||||
struct formatter_item *self = xcalloc (1, sizeof *self);
|
||||
return self;
|
||||
}
|
||||
|
||||
static void
|
||||
formatter_item_destroy (struct formatter_item *self)
|
||||
{
|
||||
free (self->text);
|
||||
free (self);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
struct formatter
|
||||
{
|
||||
struct app_context *ctx; ///< Application context
|
||||
struct server *s; ///< Server
|
||||
|
||||
struct formatter_item *items; ///< Items
|
||||
struct formatter_item *items_tail; ///< Tail of items
|
||||
};
|
||||
|
||||
static void
|
||||
formatter_init (struct formatter *self,
|
||||
struct app_context *ctx, struct server *s)
|
||||
{
|
||||
memset (self, 0, sizeof *self);
|
||||
self->ctx = ctx;
|
||||
self->s = s;
|
||||
}
|
||||
|
||||
static void
|
||||
formatter_free (struct formatter *self)
|
||||
{
|
||||
LIST_FOR_EACH (struct formatter_item, iter, self->items)
|
||||
formatter_item_destroy (iter);
|
||||
}
|
||||
|
||||
static void
|
||||
formatter_add_item (struct formatter *self, struct formatter_item template_)
|
||||
{
|
||||
|
@ -2186,10 +2184,6 @@ formatter_parse_mirc (struct formatter *self, const char *s)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// FIXME: try to reorder the code so that we don't need these
|
||||
static char * irc_to_utf8 (struct app_context *ctx, const char *text);
|
||||
static bool irc_is_this_us (struct server *s, const char *prefix);
|
||||
|
||||
static void
|
||||
formatter_parse_nick (struct formatter *self, char *s)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue