source: trunk/SL/MASKS/hotkeys.cxx

Last change on this file was 19612, checked in by westram, 11 days ago
  • insert module purposes.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
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
17using namespace std;
18
19const char* awt_hotkeys::artificial_hotkey() {
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
44const 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
Note: See TracBrowser for help on using the repository browser.