ARB
hotkeys.cxx
Go to the documentation of this file.
1 // ==================================================================== //
2 // //
3 // File : hotkeys.cxx //
4 // Purpose : auto-generated mnemonics for user masks //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in August 2001 //
7 // Copyright Department of Microbiology (Technical University Munich) //
8 // //
9 // Visit our web site at: http://www.arb-home.de/ //
10 // //
11 // ==================================================================== //
12 
13 #include "hotkeys.hxx"
14 #include <cctype>
15 
16 
17 using namespace std;
18 
20  if (artificial <= '9') {
21  current[0] = artificial++;
22  }
23  else {
24  int i;
25  for (i = 25; i >= 0; --i) {
26  if (!used[i]) {
27  current[0] = 'a'+i;
28  used[i] = true;
29  break;
30  }
31  if (!USED[i]) {
32  current[0] = 'A'+i;
33  USED[i] = true;
34  break;
35  }
36  }
37 
38  if (i == 26) current[0] = 0;
39  }
40 
41  return current;
42 }
43 
44 const char* awt_hotkeys::hotkey(const string& label) {
45  if (label.length()) {
46  for (string::const_iterator ch = label.begin(); ch != label.end(); ++ch) {
47  if (islower(*ch)) {
48  if (!used[*ch-'a']) {
49  used[*ch-'a'] = true;
50  current[0] = *ch;
51  return current;
52  }
53  }
54  else if (isupper(*ch)) {
55  if (!USED[*ch-'A']) {
56  USED[*ch-'A'] = true;
57  current[0] = *ch;
58  return current;
59  }
60  }
61  }
62  }
63  return artificial_hotkey();
64 }
65 
66 
67 
68 
STL namespace.
const char * hotkey(const std::string &label)
Definition: hotkeys.cxx:44
const char * artificial_hotkey()
Definition: hotkeys.cxx:19
const char * label