@@ -117,7 +117,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
|
||||
cons_show("");
|
||||
win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]);
|
||||
win_print(console, THEME_HELP_HEADER, "-", "");
|
||||
int i;
|
||||
size_t i;
|
||||
for (i = 0; i < strlen(cmd) - 1; i++) {
|
||||
win_append(console, THEME_HELP_HEADER, "-");
|
||||
}
|
||||
@@ -131,7 +131,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
|
||||
win_println(console, THEME_HELP_HEADER, "-", "Description");
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", help->desc);
|
||||
|
||||
int maxlen = 0;
|
||||
size_t maxlen = 0;
|
||||
for (i = 0; help->args[i][0] != NULL; i++) {
|
||||
if (strlen(help->args[i][0]) > maxlen)
|
||||
maxlen = strlen(help->args[i][0]);
|
||||
@@ -448,7 +448,7 @@ cons_show_wins(gboolean unread)
|
||||
|
||||
GSList* curr = window_strings;
|
||||
while (curr) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") != NULL) {
|
||||
win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data);
|
||||
} else {
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", curr->data);
|
||||
@@ -469,7 +469,7 @@ cons_show_wins_attention(void)
|
||||
|
||||
GSList* curr = window_strings;
|
||||
while (curr) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") != NULL) {
|
||||
win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data);
|
||||
} else {
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", curr->data);
|
||||
@@ -823,7 +823,7 @@ cons_show_qrcode(const char* const text)
|
||||
static const size_t ZOOM_SIZE = 10;
|
||||
QRcode* qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||
|
||||
int width = (qrcode->width * ZOOM_SIZE);
|
||||
size_t width = (qrcode->width * ZOOM_SIZE);
|
||||
unsigned char* data = qrcode->data;
|
||||
|
||||
ProfWin* console = wins_get_console();
|
||||
@@ -835,7 +835,7 @@ cons_show_qrcode(const char* const text)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||
for (size_t i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||
strcat(pad, "\u2588\u2588");
|
||||
}
|
||||
|
||||
@@ -2760,7 +2760,7 @@ cons_show_bookmarks_ignore(gchar** list, gsize len)
|
||||
cons_show("");
|
||||
cons_show("Ignored bookmarks:");
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
win_print(console, THEME_DEFAULT, "-", " %s", list[i]);
|
||||
win_newline(console);
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ _inp_write(char* line, int offset)
|
||||
if (line[i] == '\n') {
|
||||
c = retc;
|
||||
ch_len = wctomb(retc, L'\u23ce'); /* return symbol */
|
||||
if (ch_len == -1) { /* not representable */
|
||||
if (ch_len == (size_t)-1) { /* not representable */
|
||||
retc[0] = '\\';
|
||||
ch_len = 1;
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge
|
||||
}
|
||||
trigger_section[i] = '\0';
|
||||
|
||||
if (first_trigger_pos + first_trigger_len < strlen(message)) {
|
||||
if (first_trigger_pos + first_trigger_len < (int)strlen(message)) {
|
||||
win_append_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section);
|
||||
_mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers);
|
||||
} else {
|
||||
|
||||
@@ -71,24 +71,24 @@ typedef struct _status_bar_t
|
||||
char* prompt;
|
||||
char* fulljid;
|
||||
GHashTable* tabs;
|
||||
int current_tab;
|
||||
guint current_tab;
|
||||
} StatusBar;
|
||||
|
||||
static GTimeZone* tz;
|
||||
static StatusBar* statusbar;
|
||||
static WINDOW* statusbar_win;
|
||||
|
||||
void _get_range_bounds(int* start, int* end, gboolean is_static);
|
||||
static int _status_bar_draw_time(int pos);
|
||||
static int _status_bar_draw_maintext(int pos);
|
||||
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
|
||||
static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static);
|
||||
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets);
|
||||
static int _status_bar_draw_tabs(int pos);
|
||||
void _get_range_bounds(guint* start, guint* end, gboolean is_static);
|
||||
static guint _status_bar_draw_time(guint pos);
|
||||
static guint _status_bar_draw_maintext(guint pos);
|
||||
static guint _status_bar_draw_bracket(gboolean current, guint pos, const char* ch);
|
||||
static guint _status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static);
|
||||
static guint _status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets);
|
||||
static guint _status_bar_draw_tabs(guint pos);
|
||||
static void _destroy_tab(StatusBarTab* tab);
|
||||
static int _tabs_width(int start, int end);
|
||||
static unsigned int _count_digits(int number);
|
||||
static unsigned int _count_digits_in_range(int start, int end);
|
||||
static guint _tabs_width(guint start, guint end);
|
||||
static guint _count_digits(guint number);
|
||||
static guint _count_digits_in_range(guint start, guint end);
|
||||
static char* _display_name(StatusBarTab* tab);
|
||||
static gboolean _tabmode_is_actlist(void);
|
||||
|
||||
@@ -161,7 +161,7 @@ status_bar_set_all_inactive(void)
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_current(int i)
|
||||
status_bar_current(guint i)
|
||||
{
|
||||
if (i == 0) {
|
||||
statusbar->current_tab = 10;
|
||||
@@ -288,7 +288,7 @@ status_bar_draw(void)
|
||||
werase(statusbar_win);
|
||||
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
|
||||
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int pos = 1;
|
||||
|
||||
pos = _status_bar_draw_time(pos);
|
||||
@@ -300,24 +300,22 @@ status_bar_draw(void)
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tabs(int pos)
|
||||
static guint
|
||||
_status_bar_draw_tabs(guint pos)
|
||||
{
|
||||
auto_gchar gchar* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
|
||||
|
||||
if (g_strcmp0(tabmode, "actlist") != 0) {
|
||||
int start, end;
|
||||
guint start, end;
|
||||
gboolean is_static = g_strcmp0(tabmode, "dynamic") != 0;
|
||||
_get_range_bounds(&start, &end, is_static);
|
||||
|
||||
pos = getmaxx(stdscr) - _tabs_width(start, end);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
// if the result of the calc is negative we take 0
|
||||
pos = MAX(0, (getmaxx(stdscr) - (int)_tabs_width(start, end)));
|
||||
|
||||
pos = _status_bar_draw_extended_tabs(pos, TRUE, start, end, is_static);
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
pos = _status_bar_draw_tab(tab, pos, i, TRUE);
|
||||
@@ -365,9 +363,9 @@ _status_bar_draw_tabs(int pos)
|
||||
static gboolean
|
||||
_has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, int display_tabs_end)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int tabs_count = g_hash_table_size(statusbar->tabs);
|
||||
if (tabs_count <= max_tabs) {
|
||||
if ((guint)tabs_count <= max_tabs) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -384,10 +382,10 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
|
||||
static guint
|
||||
_status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
if (max_tabs == 0) {
|
||||
return pos;
|
||||
}
|
||||
@@ -426,8 +424,8 @@ _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gbo
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets)
|
||||
static guint
|
||||
_status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets)
|
||||
{
|
||||
gboolean is_current = num == statusbar->current_tab;
|
||||
|
||||
@@ -475,8 +473,8 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brack
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
static guint
|
||||
_status_bar_draw_bracket(gboolean current, guint pos, const char* ch)
|
||||
{
|
||||
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
|
||||
wattron(statusbar_win, bracket_attrs);
|
||||
@@ -491,8 +489,8 @@ _status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_time(int pos)
|
||||
static guint
|
||||
_status_bar_draw_time(guint pos)
|
||||
{
|
||||
auto_gchar gchar* time_pref = prefs_get_string(PREF_TIME_STATUSBAR);
|
||||
if (g_strcmp0(time_pref, "off") == 0) {
|
||||
@@ -536,8 +534,8 @@ _tabmode_is_actlist(void)
|
||||
return g_strcmp0(tabmode, "actlist") == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_maintext(int pos)
|
||||
static guint
|
||||
_status_bar_draw_maintext(guint pos)
|
||||
{
|
||||
const char* maintext = NULL;
|
||||
auto_jid Jid* jidp = NULL;
|
||||
@@ -597,20 +595,20 @@ _destroy_tab(StatusBarTab* tab)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_tabs_width(int start, int end)
|
||||
static guint
|
||||
_tabs_width(guint start, guint end)
|
||||
{
|
||||
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
guint opened_tabs = g_hash_table_size(statusbar->tabs);
|
||||
|
||||
int width = start < 2 ? 1 : 4;
|
||||
width += end > opened_tabs - 1 ? 0 : 3;
|
||||
|
||||
if (show_name && show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -627,7 +625,7 @@ _tabs_width(int start, int end)
|
||||
}
|
||||
|
||||
if (show_name && !show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -698,7 +696,7 @@ _display_name(StatusBarTab* tab)
|
||||
}
|
||||
|
||||
void
|
||||
_get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
_get_range_bounds(guint* start, guint* end, gboolean is_static)
|
||||
{
|
||||
int current_tab = statusbar->current_tab;
|
||||
gint display_range = prefs_get_statusbartabs();
|
||||
@@ -721,12 +719,10 @@ _get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
}
|
||||
|
||||
// Counts amount of digits in a number
|
||||
static unsigned int
|
||||
_count_digits(int number)
|
||||
static guint
|
||||
_count_digits(guint number)
|
||||
{
|
||||
unsigned int digits_count = 0;
|
||||
if (number < 0)
|
||||
number = -number;
|
||||
guint digits_count = 0;
|
||||
|
||||
do {
|
||||
number /= 10;
|
||||
@@ -738,12 +734,11 @@ _count_digits(int number)
|
||||
|
||||
// Counts the total number of digits in a range of numbers, inclusive.
|
||||
// Example: _count_digits_in_range(2, 3) returns 2, _count_digits_in_range(2, 922) returns 2657
|
||||
static unsigned int
|
||||
_count_digits_in_range(int start, int end)
|
||||
static guint
|
||||
_count_digits_in_range(guint start, guint end)
|
||||
{
|
||||
int total_digits = 0;
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
guint total_digits = 0;
|
||||
for (guint i = start; i <= end; i++) {
|
||||
total_digits += _count_digits(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,6 @@ void status_bar_set_prompt(const char* const prompt);
|
||||
void status_bar_clear_prompt(void);
|
||||
void status_bar_set_fulljid(const char* const fulljid);
|
||||
void status_bar_clear_fulljid(void);
|
||||
void status_bar_current(int i);
|
||||
void status_bar_current(guint i);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1871,7 +1871,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
curr_ch++;
|
||||
continue;
|
||||
}
|
||||
int offset = 0;
|
||||
size_t offset = 0;
|
||||
while (offset < ch_len) {
|
||||
word[wordi++] = curr_ch[offset++];
|
||||
}
|
||||
@@ -1880,9 +1880,9 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
word[wordi] = '\0';
|
||||
wordlen = utf8_display_len(word);
|
||||
|
||||
int curx = getcurx(win);
|
||||
size_t curx = (size_t)getcurx(win);
|
||||
int cury;
|
||||
int maxx = getmaxx(win);
|
||||
size_t maxx = getmaxx(win);
|
||||
|
||||
// wrap required
|
||||
if (curx + wordlen > maxx) {
|
||||
@@ -1892,7 +1892,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
if (wordlen > linelen) {
|
||||
gchar* word_ch = g_utf8_offset_to_pointer(word, 0);
|
||||
while (*word_ch != '\0') {
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
@@ -1913,7 +1913,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
// newline and print word
|
||||
} else {
|
||||
waddch(win, '\n');
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
@@ -1928,7 +1928,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
|
||||
// no wrap required
|
||||
} else {
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user