1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Whitespace formatting

This commit is contained in:
James Booth 2014-07-16 22:03:46 +01:00
parent aa8872875f
commit 2cbe7e4ccb

View File

@ -332,7 +332,10 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp,
} }
} }
void win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message, ...) { void
win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp,
int flags, int attrs, const char * const from, const char * const message, ...)
{
va_list arg; va_list arg;
va_start(arg, message); va_start(arg, message);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
@ -340,26 +343,31 @@ void win_save_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, in
win_save_print(window, show_char, tstamp, flags, attrs, from, fmt_msg->str); win_save_print(window, show_char, tstamp, flags, attrs, from, fmt_msg->str);
} }
void
void win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, int attrs, const char * const from, const char * const message) { win_save_print(ProfWin *window, const char show_char, GTimeVal *tstamp,
int flags, int attrs, const char * const from, const char * const message)
{
gchar *date_fmt; gchar *date_fmt;
GDateTime *time; GDateTime *time;
if (tstamp == NULL) { if (tstamp == NULL) {
time = g_date_time_new_now_local(); time = g_date_time_new_now_local();
date_fmt = g_date_time_format(time, "%H:%M:%S"); date_fmt = g_date_time_format(time, "%H:%M:%S");
} } else {
else {
time = g_date_time_new_from_timeval_utc(tstamp); time = g_date_time_new_from_timeval_utc(tstamp);
date_fmt = g_date_time_format(time, "%H:%M:%S"); date_fmt = g_date_time_format(time, "%H:%M:%S");
} }
g_date_time_unref(time); g_date_time_unref(time);
buffer_push(window->buffer, show_char, date_fmt, flags, attrs, from, message); buffer_push(window->buffer, show_char, date_fmt, flags, attrs, from, message);
win_print(window, show_char, date_fmt, flags, attrs, from, message); win_print(window, show_char, date_fmt, flags, attrs, from, message);
g_free(date_fmt); g_free(date_fmt);
} }
void
void win_print(ProfWin *window, const char show_char, const char * const date_fmt, int flags, int attrs, const char * const from, const char * const message) { win_print(ProfWin *window, const char show_char, const char * const date_fmt,
int flags, int attrs, const char * const from, const char * const message)
{
// flags : 1st bit = 0/1 - me/not me // flags : 1st bit = 0/1 - me/not me
// 2nd bit = 0/1 - date/no date // 2nd bit = 0/1 - date/no date
// 3rd bit = 0/1 - eol/no eol // 3rd bit = 0/1 - eol/no eol
@ -367,6 +375,7 @@ void win_print(ProfWin *window, const char show_char, const char * const date_fm
int unattr_me = 0; int unattr_me = 0;
int offset = 0; int offset = 0;
int colour = COLOUR_ME; int colour = COLOUR_ME;
if ((flags & 2) == 0) { if ((flags & 2) == 0) {
wattron(window->win, COLOUR_TIME); wattron(window->win, COLOUR_TIME);
wprintw(window->win, "%s %c ", date_fmt, show_char); wprintw(window->win, "%s %c ", date_fmt, show_char);
@ -377,25 +386,30 @@ void win_print(ProfWin *window, const char show_char, const char * const date_fm
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
colour = COLOUR_THEM; colour = COLOUR_THEM;
} }
if((flags & 8) != 0) { if((flags & 8) != 0) {
colour = 0; colour = 0;
} }
wattron(window->win, colour); wattron(window->win, colour);
if (strncmp(message, "/me ", 4) == 0) { if (strncmp(message, "/me ", 4) == 0) {
wprintw(window->win, "*%s ", from); wprintw(window->win, "*%s ", from);
offset = 4; offset = 4;
unattr_me = 1; unattr_me = 1;
} } else {
else {
wprintw(window->win, "%s: ", from); wprintw(window->win, "%s: ", from);
wattroff(window->win, colour); wattroff(window->win, colour);
} }
} }
wattron(window->win, attrs); wattron(window->win, attrs);
if((flags & 4) == 0)
if ((flags & 4) == 0) {
wprintw(window->win, "%s\n", message+offset); wprintw(window->win, "%s\n", message+offset);
else } else {
wprintw(window->win, "%s", message+offset); wprintw(window->win, "%s", message+offset);
}
wattroff(window->win, attrs); wattroff(window->win, attrs);
if (unattr_me) { if (unattr_me) {
@ -403,10 +417,13 @@ void win_print(ProfWin *window, const char show_char, const char * const date_fm
} }
} }
void win_redraw(ProfWin *window) { void
win_redraw(ProfWin *window)
{
int i, size; int i, size;
werase(window->win); werase(window->win);
size = buffer_size(window->buffer); size = buffer_size(window->buffer);
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
ProfBuffEntry e = buffer_yield_entry(window->buffer, i); ProfBuffEntry e = buffer_yield_entry(window->buffer, i);
win_print(window, e.show_char, e.date_fmt, e.flags, e.attrs, e.from, e.message); win_print(window, e.show_char, e.date_fmt, e.flags, e.attrs, e.from, e.message);