Bugfix to termkey_keycmp - implement sense in correct direction

This commit is contained in:
Paul LeoNerd Evans
2011-04-07 23:31:43 +01:00
parent 0a101ff71e
commit 03371bdd04
2 changed files with 14 additions and 14 deletions

View File

@@ -1148,25 +1148,25 @@ char *termkey_strpkey(TermKey *tk, const char *str, TermKeyKey *key, TermKeyForm
int termkey_keycmp(TermKey *tk, const TermKeyKey *key1, const TermKeyKey *key2)
{
if(key1->type != key2->type)
return key2->type - key1->type;
return key1->type - key2->type;
switch(key1->type) {
case TERMKEY_TYPE_UNICODE:
if(key1->code.codepoint != key2->code.codepoint)
return key2->code.codepoint - key1->code.codepoint;
return key1->code.codepoint - key2->code.codepoint;
case TERMKEY_TYPE_KEYSYM:
if(key1->code.sym != key2->code.sym)
return key2->code.sym - key1->code.sym;
return key1->code.sym - key2->code.sym;
case TERMKEY_TYPE_FUNCTION:
if(key1->code.number != key2->code.number)
return key2->code.number - key1->code.number;
return key1->code.number - key2->code.number;
case TERMKEY_TYPE_MOUSE:
{
int cmp = strncmp(key2->code.mouse, key1->code.mouse, 4);
int cmp = strncmp(key1->code.mouse, key2->code.mouse, 4);
if(cmp != 0)
return cmp;
}
}
return key2->modifiers - key1->modifiers;
return key1->modifiers - key2->modifiers;
}