Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/screen.c @ 2007:6c02ccb14c1c
Added an option to remove the extra space before items in the roster.
author | Simon Jacquin <simon@jacquin.me> |
---|---|
date | Fri, 27 Jan 2012 21:07:56 +0100 |
parents | 555e342556e7 |
children | 0d5ece2324c6 |
comparison
equal
deleted
inserted
replaced
2004:aa7e03c35488 | 2007:6c02ccb14c1c |
---|---|
125 | 125 |
126 static int roster_hidden; | 126 static int roster_hidden; |
127 static int chatmode; | 127 static int chatmode; |
128 static int multimode; | 128 static int multimode; |
129 static char *multiline, *multimode_subj; | 129 static char *multiline, *multimode_subj; |
130 static int no_space_before_items; | |
130 | 131 |
131 static bool Curses; | 132 static bool Curses; |
132 static bool log_win_on_top; | 133 static bool log_win_on_top; |
133 static bool roster_win_on_right; | 134 static bool roster_win_on_right; |
134 static guint autoaway_source = 0; | 135 static guint autoaway_source = 0; |
1542 int requested_size; | 1543 int requested_size; |
1543 gchar *ver, *message; | 1544 gchar *ver, *message; |
1544 int chat_y_pos, chatstatus_y_pos, log_y_pos; | 1545 int chat_y_pos, chatstatus_y_pos, log_y_pos; |
1545 int roster_x_pos, chat_x_pos; | 1546 int roster_x_pos, chat_x_pos; |
1546 | 1547 |
1548 no_space_before_items = settings_opt_get_int("no_space_before_items"); | |
1549 | |
1547 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; | 1550 Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; |
1548 requested_size = settings_opt_get_int("log_win_height"); | 1551 requested_size = settings_opt_get_int("log_win_height"); |
1549 if (requested_size > 0) { | 1552 if (requested_size > 0) { |
1550 if (maxY > requested_size + 3) | 1553 if (maxY > requested_size + 3) |
1551 Log_Win_Height = requested_size + 2; | 1554 Log_Win_Height = requested_size + 2; |
1941 int rOffset; | 1944 int rOffset; |
1942 int cursor_backup; | 1945 int cursor_backup; |
1943 char status, pending; | 1946 char status, pending; |
1944 enum imstatus currentstatus = xmpp_getstatus(); | 1947 enum imstatus currentstatus = xmpp_getstatus(); |
1945 int x_pos; | 1948 int x_pos; |
1949 char *space; | |
1950 int prefix_length; | |
1946 | 1951 |
1947 // We can reset update_roster | 1952 // We can reset update_roster |
1948 update_roster = FALSE; | 1953 update_roster = FALSE; |
1949 | 1954 |
1950 getmaxyx(rosterWnd, maxy, maxx); | 1955 getmaxyx(rosterWnd, maxy, maxx); |
1996 | 2001 |
1997 if (roster_win_on_right) | 2002 if (roster_win_on_right) |
1998 x_pos = 1; // 1 char offset (vertical line) | 2003 x_pos = 1; // 1 char offset (vertical line) |
1999 else | 2004 else |
2000 x_pos = 0; | 2005 x_pos = 0; |
2006 | |
2007 space = g_new0(char, 2); | |
2008 if (no_space_before_items) { | |
2009 space[0] = '\0'; | |
2010 prefix_length = 6; | |
2011 } else { | |
2012 prefix_length = 7; | |
2013 } | |
2001 | 2014 |
2002 name = g_new0(char, 4*Roster_Width); | 2015 name = g_new0(char, 4*Roster_Width); |
2003 rline = g_new0(char, 4*Roster_Width+1); | 2016 rline = g_new0(char, 4*Roster_Width+1); |
2004 | 2017 |
2005 buddy = buddylist; | 2018 buddy = buddylist; |
2087 } | 2100 } |
2088 wattrset(rosterWnd, color); | 2101 wattrset(rosterWnd, color); |
2089 } | 2102 } |
2090 } | 2103 } |
2091 | 2104 |
2092 if (Roster_Width > 7) | 2105 if (Roster_Width > prefix_length) |
2093 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); | 2106 g_utf8_strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-prefix_length); |
2094 else | 2107 else |
2095 name[0] = 0; | 2108 name[0] = 0; |
2096 | 2109 |
2097 if (pending == '#') { | 2110 if (pending == '#') { |
2098 // Attention sign? | 2111 // Attention sign? |
2104 if (isgrp) { | 2117 if (isgrp) { |
2105 if (ishid) { | 2118 if (ishid) { |
2106 int group_count = 0; | 2119 int group_count = 0; |
2107 foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered, | 2120 foreach_group_member(BUDDATA(buddy), increment_if_buddy_not_filtered, |
2108 &group_count); | 2121 &group_count); |
2109 snprintf(rline, 4*Roster_Width, " %c+++ %s (%i)", pending, name, | 2122 snprintf(rline, 4*Roster_Width, "%s%c+++ %s (%i)", space, pending, name, |
2110 group_count); | 2123 group_count); |
2111 /* Do not display the item count if there isn't enough space */ | 2124 /* Do not display the item count if there isn't enough space */ |
2112 if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width) | 2125 if (g_utf8_strlen(rline, 4*Roster_Width) >= Roster_Width) |
2113 snprintf(rline, 4*Roster_Width, " %c+++ %s", pending, name); | 2126 snprintf(rline, 4*Roster_Width, "%s%c+++ %s", space, pending, name); |
2114 } | 2127 } |
2115 else | 2128 else |
2116 snprintf(rline, 4*Roster_Width, " %c--- %s", pending, name); | 2129 snprintf(rline, 4*Roster_Width, "%s%c--- %s", space, pending, name); |
2117 } else if (isspe) { | 2130 } else if (isspe) { |
2118 snprintf(rline, 4*Roster_Width, " %c%s", pending, name); | 2131 snprintf(rline, 4*Roster_Width, "%s%c%s", space, pending, name); |
2119 } else { | 2132 } else { |
2120 char sepleft = '['; | 2133 char sepleft = '['; |
2121 char sepright = ']'; | 2134 char sepright = ']'; |
2122 if (btype & ROSTER_TYPE_USER) { | 2135 if (btype & ROSTER_TYPE_USER) { |
2123 guint subtype = buddy_getsubscription(BUDDATA(buddy)); | 2136 guint subtype = buddy_getsubscription(BUDDATA(buddy)); |
2126 if (!(subtype & sub_from)) { | 2139 if (!(subtype & sub_from)) { |
2127 sepleft = '{'; | 2140 sepleft = '{'; |
2128 sepright = '}'; | 2141 sepright = '}'; |
2129 } | 2142 } |
2130 } | 2143 } |
2131 | |
2132 snprintf(rline, 4*Roster_Width, | 2144 snprintf(rline, 4*Roster_Width, |
2133 " %c%c%c%c %s", pending, sepleft, status, sepright, name); | 2145 "%s%c%c%c%c %s", space, pending, sepleft, status, sepright, name); |
2134 } | 2146 } |
2135 | 2147 |
2136 rline_locale = from_utf8(rline); | 2148 rline_locale = from_utf8(rline); |
2137 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); | 2149 mvwprintw(rosterWnd, i, x_pos, "%s", rline_locale); |
2138 g_free(rline_locale); | 2150 g_free(rline_locale); |
2139 i++; | 2151 i++; |
2140 } | 2152 } |
2141 | 2153 |
2154 g_free(space); | |
2142 g_free(rline); | 2155 g_free(rline); |
2143 g_free(name); | 2156 g_free(name); |
2144 top_panel(inputPanel); | 2157 top_panel(inputPanel); |
2145 update_panels(); | 2158 update_panels(); |
2146 curs_set(cursor_backup); | 2159 curs_set(cursor_backup); |