Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor cleanup

  • Loading branch information...
commit fab96d054536f3cfe8f6329664a49c2f1242d79e 1 parent 5a51d83
Petr Pavlu authored
View
8 cppconsui/ColorScheme.cpp
@@ -26,10 +26,6 @@
* @ingroup cppconsui
*/
-/* Uncomment to enable an experimental feature to lower the number of used
- * colorpairs */
-//#define SAVE_COLOR_PAIRS
-
#include "ColorScheme.h"
#include "gettext.h"
@@ -64,7 +60,11 @@ int ColorScheme::GetColorPair(const char *scheme, const char *widget,
return 0;
}
+#ifdef SAVE_COLOR_PAIRS
int ColorScheme::GetColorPair(Color& c)
+#else
+int ColorScheme::GetColorPair(const Color& c)
+#endif
{
ColorPairs::const_iterator i;
int fg = c.foreground;
View
8 cppconsui/ColorScheme.h
@@ -34,6 +34,10 @@
#include <map>
#include <string>
+/* Uncomment to enable an experimental feature to lower the number of used
+ * colorpairs. */
+//#define SAVE_COLOR_PAIRS
+
#define COLORSCHEME (CppConsUI::ColorScheme::Instance())
namespace CppConsUI
@@ -65,7 +69,11 @@ class ColorScheme
*/
int GetColorPair(const char *scheme, const char *widget,
const char *property);
+#ifdef SAVE_COLOR_PAIRS
int GetColorPair(Color& c);
+#else
+ int GetColorPair(const Color& c);
+#endif
/**
* Sets color pair and Curses attributes for a given scheme, widget,
* property combination.
View
7 src/CenterIM.cpp
@@ -729,7 +729,7 @@ bool CenterIM::SaveColorSchemeConfig()
char *CenterIM::ColorToString(int color)
{
- if (color >= -1 && color < (int)G_N_ELEMENTS(named_colors) - 1)
+ if (color >= -1 && color < static_cast<int>(G_N_ELEMENTS(named_colors) - 1))
return g_strdup(named_colors[color + 1]);
return g_strdup_printf("%d", color);
}
@@ -742,7 +742,7 @@ bool CenterIM::StringToColor(const char *str, int *color)
*color = 0;
// symbolic colors
- for (int i = -1; i < (int)G_N_ELEMENTS(named_colors) - 1; i++)
+ for (int i = -1; i < static_cast<int>(G_N_ELEMENTS(named_colors) - 1); i++)
if (!strcmp(str, named_colors[i + 1])) {
*color = i;
return true;
@@ -864,6 +864,7 @@ void CenterIM::LoadDefaultKeyConfig()
KEYCONFIG->BindKey("centerim", "conversation-number17", "Alt-u");
KEYCONFIG->BindKey("centerim", "conversation-number18", "Alt-i");
KEYCONFIG->BindKey("centerim", "conversation-number19", "Alt-o");
+ KEYCONFIG->BindKey("centerim", "conversation-number20", "Alt-p");
KEYCONFIG->BindKey("buddylist", "contextmenu", "Ctrl-d");
@@ -1012,7 +1013,7 @@ void CenterIM::DeclareBindables()
sigc::mem_fun(this, &CenterIM::ActionFocusNextConversation),
InputProcessor::BINDABLE_OVERRIDE);
char action[] = "conversation-numberXX";
- for (int i = 1; i < 20; i++) {
+ for (int i = 1; i <= 20; i++) {
g_sprintf(action + sizeof(action) - 3, "%d", i);
DeclareBindable("centerim", action, sigc::bind(sigc::mem_fun(this,
&CenterIM::ActionFocusConversation), i),
View
37 src/Conversations.cpp
@@ -49,41 +49,34 @@ void Conversations::FocusActiveConversation()
void Conversations::FocusConversation(int i)
{
- int prev, cur;
- prev = -1;
- cur = NextActiveConversation(prev);
-
- while (cur > prev) {
- if (i == 1) {
- ActivateConversation(cur);
- return;
- }
+ g_assert(i >= 1);
- i--;
- prev = cur;
- cur = NextActiveConversation(cur);
- }
+ if (conversations.empty())
+ return;
+
+ // the external conversation #1 is the internal conversation #0
+ i -= 1;
- // if there is less than i active conversations then active the last one
- if (prev != -1)
- ActivateConversation(prev);
+ int s = static_cast<int>(conversations.size());
+ if (i < s)
+ ActivateConversation(i);
+ else {
+ // if there is less than i active conversations then active the last one
+ ActivateConversation(s - 1);
+ }
}
void Conversations::FocusPrevConversation()
{
int i = PrevActiveConversation(active);
- if (i == -1)
- ActivateConversation(active);
- else
+ if (i != -1)
ActivateConversation(i);
}
void Conversations::FocusNextConversation()
{
int i = NextActiveConversation(active);
- if (i == -1)
- ActivateConversation(active);
- else
+ if (i != -1)
ActivateConversation(i);
}
Please sign in to comment.
Something went wrong with that request. Please try again.