- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
static inline gboolean is_alt(const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 'a' || string[1] == 'A') &&
(string[2] == 'l' || string[2] == 'L') &&
(string[3] == 't' || string[3] == 'T') &&
(string[4] == '>'));
}
static inline gboolean is_ctl (const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 'c' || string[1] == 'C') &&
(string[2] == 't' || string[2] == 'T') &&
(string[3] == 'l' || string[3] == 'L') &&
(string[4] == '>'));
}
static inline gboolean is_modx(const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 'm' || string[1] == 'M') &&
(string[2] == 'o' || string[2] == 'O') &&
(string[3] == 'd' || string[3] == 'D') &&
(string[4] >= '1' && string[4] <= '5') &&
(string[5] == '>'));
}
static inline gboolean is_ctrl(const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 'c' || string[1] == 'C') &&
(string[2] == 't' || string[2] == 'T') &&
(string[3] == 'r' || string[3] == 'R') &&
(string[4] == 'l' || string[4] == 'L') &&
(string[5] == '>'));
}
static inline gboolean is_shft (const gchar* string)
{
return ((string[0] == '<') &&
(string[1] == 's' || string[1] == 'S') &&
(string[2] == 'h' || string[2] == 'H') &&
(string[3] == 'f' || string[3] == 'F') &&
(string[4] == 't' || string[4] == 'T') &&
(string[5] == '>'));
}
// ... (ещё 100500 подобных функций)
// ... а тем временем где-то ниже:
if (len >= 9 && is_release (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_RELEASE_MASK;
}
else if (len >= 9 && is_control (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 9 && is_primary (accelerator))
{
accelerator += 9;
len -= 9;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
else if (len >= 7 && is_shift (accelerator))
{
accelerator += 7;
len -= 7;
mods |= EGG_VIRTUAL_SHIFT_MASK;
}
else if (len >= 6 && is_shft (accelerator))
{
accelerator += 6;
len -= 6;
mods |= EGG_VIRTUAL_SHIFT_MASK;
}
else if (len >= 6 && is_ctrl (accelerator))
{
accelerator += 6;
len -= 6;
mods |= EGG_VIRTUAL_CONTROL_MASK;
}
// ... и так далее. код целиком сюда просто не влезет.
шедевр. что сравнение строк, что цепочка if-else. все хороши.
полной версией можно насладиться тут:
https://github.com/mate-desktop/mate-control-center/blob/master/capplets/keybindings/eggaccelerators.c
rat4 06.01.2012 15:22 # +1
http://git.gnome.org/browse/gnome-control-center/tree/capplets/keybindings/eggaccelerators.c?h=gnome-2-32
guest 06.01.2012 15:26 # −8
TheHamstertamer 06.01.2012 19:19 # 0
angry C nerd 06.01.2012 15:27 # 0
rat4 06.01.2012 15:34 # 0
angry C nerd 06.01.2012 15:39 # 0
guest 06.01.2012 15:25 # −10
guest 06.01.2012 15:27 # −10
guest 06.01.2012 16:01 # −7
eth0 06.01.2012 19:03 # +6
Lure Of Chaos 06.01.2012 23:06 # +3
Dummy00001 07.01.2012 01:01 # 0
rat4 07.01.2012 09:44 # 0
Dummy00001 07.01.2012 17:10 # 0
guest8 09.04.2019 12:27 # −999