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