Diffstat (limited to 'inputmethods/dasher/AlphIO.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dasher/AlphIO.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/inputmethods/dasher/AlphIO.cpp b/inputmethods/dasher/AlphIO.cpp index 41b1b23..96ca14a 100644 --- a/inputmethods/dasher/AlphIO.cpp +++ b/inputmethods/dasher/AlphIO.cpp | |||
@@ -1,83 +1,85 @@ | |||
1 | // AlphIO.cpp | 1 | // AlphIO.cpp |
2 | // | 2 | // |
3 | ///////////////////////////////////////////////////////////////////////////// | 3 | ///////////////////////////////////////////////////////////////////////////// |
4 | // | 4 | // |
5 | // Copyright (c) 2002 Iain Murray | 5 | // Copyright (c) 2002 Iain Murray |
6 | // | 6 | // |
7 | ///////////////////////////////////////////////////////////////////////////// | 7 | ///////////////////////////////////////////////////////////////////////////// |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | #include "AlphIO.h" | 11 | #include "AlphIO.h" |
12 | 12 | ||
13 | using namespace Dasher; | 13 | using namespace Dasher; |
14 | using namespace std; | 14 | using namespace std; |
15 | 15 | ||
16 | CAlphIO::CAlphIO(string SystemLocation, string UserLocation) | 16 | CAlphIO::CAlphIO(string SystemLocation, string UserLocation) |
17 | : SystemLocation(SystemLocation), UserLocation(UserLocation), | 17 | : BlankInfo(), |
18 | BlankInfo(), CData("") | 18 | SystemLocation(SystemLocation), |
19 | UserLocation(UserLocation), | ||
20 | CData("") | ||
19 | { | 21 | { |
20 | CreateDefault(); | 22 | CreateDefault(); |
21 | } | 23 | } |
22 | 24 | ||
23 | 25 | ||
24 | void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const | 26 | void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const |
25 | { | 27 | { |
26 | AlphabetList->clear(); | 28 | AlphabetList->clear(); |
27 | 29 | ||
28 | typedef std::map<std::string, AlphInfo>::const_iterator CI; | 30 | typedef std::map<std::string, AlphInfo>::const_iterator CI; |
29 | CI End = Alphabets.end(); | 31 | CI End = Alphabets.end(); |
30 | 32 | ||
31 | for (CI Cur=Alphabets.begin(); Cur!=End; Cur++) | 33 | for (CI Cur=Alphabets.begin(); Cur!=End; Cur++) |
32 | AlphabetList->push_back( (*Cur).second.AlphID); | 34 | AlphabetList->push_back( (*Cur).second.AlphID); |
33 | } | 35 | } |
34 | 36 | ||
35 | 37 | ||
36 | const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID) | 38 | const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID) |
37 | { | 39 | { |
38 | if (AlphID=="") | 40 | if (AlphID=="") |
39 | return Alphabets["Default"]; | 41 | return Alphabets["Default"]; |
40 | else { | 42 | else { |
41 | AlphInfo& CurInfo = Alphabets[AlphID]; | 43 | // AlphInfo& CurInfo = Alphabets[AlphID]; |
42 | Alphabets[AlphID].AlphID = AlphID; // Ensure consistency | 44 | Alphabets[AlphID].AlphID = AlphID; // Ensure consistency |
43 | return Alphabets[AlphID]; | 45 | return Alphabets[AlphID]; |
44 | } | 46 | } |
45 | } | 47 | } |
46 | 48 | ||
47 | 49 | ||
48 | void CAlphIO::SetInfo(const AlphInfo& NewInfo) | 50 | void CAlphIO::SetInfo(const AlphInfo& NewInfo) |
49 | { | 51 | { |
50 | Alphabets[NewInfo.AlphID] = NewInfo; | 52 | Alphabets[NewInfo.AlphID] = NewInfo; |
51 | } | 53 | } |
52 | 54 | ||
53 | 55 | ||
54 | void CAlphIO::Delete(const std::string& AlphID) | 56 | void CAlphIO::Delete(const std::string& AlphID) |
55 | { | 57 | { |
56 | if (Alphabets.find(AlphID)!=Alphabets.end()) { | 58 | if (Alphabets.find(AlphID)!=Alphabets.end()) { |
57 | Alphabets.erase(AlphID); | 59 | Alphabets.erase(AlphID); |
58 | } | 60 | } |
59 | } | 61 | } |
60 | 62 | ||
61 | 63 | ||
62 | void CAlphIO::CreateDefault() | 64 | void CAlphIO::CreateDefault() |
63 | { | 65 | { |
64 | // TODO I appreciate these strings should probably be in a resource file. | 66 | // TODO I appreciate these strings should probably be in a resource file. |
65 | // Not urgent though as this is not intended to be used. It's just a | 67 | // Not urgent though as this is not intended to be used. It's just a |
66 | // last ditch effort in case file I/O totally fails. | 68 | // last ditch effort in case file I/O totally fails. |
67 | AlphInfo& Default = Alphabets["Default"]; | 69 | AlphInfo& Default = Alphabets["Default"]; |
68 | Default.AlphID = "Default"; | 70 | Default.AlphID = "Default"; |
69 | Default.Type = Opts::Western; | 71 | Default.Type = Opts::Western; |
70 | Default.Mutable = false; | 72 | Default.Mutable = false; |
71 | Default.Orientation = Opts::LeftToRight; | 73 | Default.Orientation = Opts::LeftToRight; |
72 | Default.SpaceCharacter.Display = "_"; | 74 | Default.SpaceCharacter.Display = "_"; |
73 | Default.SpaceCharacter.Text = " "; | 75 | Default.SpaceCharacter.Text = " "; |
74 | Default.TrainingFile = "training_english_GB.txt"; | 76 | Default.TrainingFile = "training_english_GB.txt"; |
75 | string Chars = "abcdefghijklmnopqrstuvwxyz"; | 77 | string Chars = "abcdefghijklmnopqrstuvwxyz"; |
76 | Default.Groups.resize(1); | 78 | Default.Groups.resize(1); |
77 | Default.Groups[0].Description = "Lower case Latin letters"; | 79 | Default.Groups[0].Description = "Lower case Latin letters"; |
78 | Default.Groups[0].Characters.resize(Chars.size()); | 80 | Default.Groups[0].Characters.resize(Chars.size()); |
79 | for (unsigned int i=0; i<Chars.size(); i++) { | 81 | for (unsigned int i=0; i<Chars.size(); i++) { |
80 | Default.Groups[0].Characters[i].Text = Chars[i]; | 82 | Default.Groups[0].Characters[i].Text = Chars[i]; |
81 | Default.Groups[0].Characters[i].Display = Chars[i]; | 83 | Default.Groups[0].Characters[i].Display = Chars[i]; |
82 | } | 84 | } |
83 | } | 85 | } |