summaryrefslogtreecommitdiff
path: root/inputmethods/dasher/Alphabet.h
Unidiff
Diffstat (limited to 'inputmethods/dasher/Alphabet.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/Alphabet.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/inputmethods/dasher/Alphabet.h b/inputmethods/dasher/Alphabet.h
new file mode 100644
index 0000000..5f0f9a5
--- a/dev/null
+++ b/inputmethods/dasher/Alphabet.h
@@ -0,0 +1,83 @@
1// Alphabet.h
2//
3/////////////////////////////////////////////////////////////////////////////
4// Alphabet.h
5//
6/////////////////////////////////////////////////////////////////////////////
7//
8// Copyright (c) 2001-2002 David Ward
9//
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __DASHER_ALPHABET_H__
13#define __DASHER_ALPHABET_H__
14
15
16#include "DasherTypes.h"
17
18#include "MSVC_Unannoy.h"
19#include <map>
20#include <vector>
21#include "AlphabetMap.h"
22
23
24namespace Dasher {class CAlphabet;}
25class Dasher::CAlphabet
26{
27public:
28 CAlphabet();
29 ~CAlphabet() {}
30
31 int GetNumberSymbols() const { return m_Characters.size();} // return size of alphabet
32
33 Opts::ScreenOrientations GetOrientation() {return m_Orientation;}
34 Opts::AlphabetTypes GetType() {return m_DefaultEncoding;}
35 std::string& GetTrainingFile() {return m_TrainingFile;}
36
37 symbol GetSpaceSymbol() {return m_SpaceSymbol;}
38 const std::string& GetDisplayText(symbol i) const {return m_Display[i];} // return display string for i'th symbol
39 const std::string& GetText(symbol i) const {return m_Characters[i];} // return string for i'th symbol
40 const std::string& GetColour(symbol i) const {return m_Colours[i];} // return the colour for i'th symbol
41 int GetTextColour(symbol i); // return the foreground colour for i'th symbol
42 const std::string& GetForeground(symbol i) const {return m_Foreground[i];} // return the foreground colour for i'th symbol
43 int get_group(symbol i) const {return m_Group[i];} // return group membership of i'th symbol
44
45 // Fills Symbols with the symbols corresponding to Input. {{{ Note that this
46 // is not necessarily reversible by repeated use of GetText. Some text
47 // may not be recognised and so discarded. If IsMore is true then Input
48 // is truncated to any final characters that were not used due to ambiguous
49 // continuation. If IsMore is false Input is assumed to be all the available
50 // text and so a symbol will be returned for a final "a" even if "ae" is
51 // defined as its own symbol. }}}
52 void GetSymbols(std::vector<symbol>* Symbols, std::string* Input, bool IsMore);
53
54 void dump() const; // diagnostic
55
56protected:
57 // Add the characters that can appear in Nodes
58 void AddChar(const std::string NewCharacter, const std::string Display, const std::string Colour, const std::string Foreground); // add single char to the alphabet
59 void StartNewGroup();
60
61 // Alphabet language parameters
62 void SetSpaceSymbol() {m_SpaceSymbol=m_Characters.size()-1;} // We can set the space symbol to be the last character added
63 void SetSpaceSymbol(symbol SpaceSymbol) {m_SpaceSymbol=SpaceSymbol;} // ...or any desired symbol.
64 void SetOrientation(Opts::ScreenOrientations Orientation) {m_Orientation=Orientation;}
65 void SetLanguage(Opts::AlphabetTypes Group) {m_DefaultEncoding=Group;}
66 void SetTrainingFile(std::string TrainingFile) {m_TrainingFile=TrainingFile;}
67private:
68 Opts::AlphabetTypes m_DefaultEncoding;
69 Opts::ScreenOrientations m_Orientation;
70 symbol m_SpaceSymbol;
71 std::string m_TrainingFile;
72
73 std::vector<std::string> m_Characters; // stores the characters
74 std::vector<std::string> m_Display; // stores how the characters are visually represented in the Dasher nodes
75 std::vector<std::string> m_Colours; // stores the colour of the characters
76 std::vector<std::string> m_Foreground; // stores the colour of the character foreground
77 std::vector<int> m_Group; // stores the group indicators - e.g. caps, numbers, punctuation
78 int m_Groups; // number of groups
79 alphabet_map TextMap;
80};
81
82
83#endif // ifndef __DASHER_ALPHABET_H__