1 // -*- mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 /* Unikey Vietnamese Input Method
3 * Copyright (C) 2000-2005 Pham Kim Long
6 * UniKey project: http://unikey.org
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
29 #include "inputproc.h"
32 //This is a shared object among processes, do not put any pointer in it
39 UnikeyOptions options;
40 UkInputProcessor input;
46 UnikeySysInfo sysInfo;
51 #define CTRL_SHIFT_SW 0
54 #define MAX_UK_ENGINE 128
56 enum VnWordForm {vnw_nonVn, vnw_empty, vnw_c, vnw_v, vnw_cv, vnw_vc, vnw_cvc};
58 typedef void (* CheckKeyboardCaseCb)(int *pShiftPressed, int *pCapslockOn);
69 void setCtrlInfo(UkSharedMem *p)
74 void setCheckKbCaseFunc(CheckKeyboardCaseCb pFunc)
76 m_keyCheckFunc = pFunc;
79 bool atWordBeginning();
81 int process(unsigned int keyCode, int & backs, unsigned char *outBuf, int & outSize, UkOutputType & outType);
82 void pass(int keyCode); //just pass through without filtering
85 int processBackspace(int & backs, unsigned char *outBuf, int & outSize, UkOutputType & outType);
87 int restoreKeyStrokes(int & backs, unsigned char *outBuf, int & outSize, UkOutputType & outType);
89 //following methods must be public just to enable the use of pointers to them
90 //they should not be called from outside.
91 int processTone(UkKeyEvent & ev);
92 int processRoof(UkKeyEvent & ev);
93 int processHook(UkKeyEvent & ev);
94 int processAppend(UkKeyEvent & ev);
95 int appendVowel(UkKeyEvent & ev);
96 int appendConsonnant(UkKeyEvent & ev);
97 int processDd(UkKeyEvent & ev);
98 int processMapChar(UkKeyEvent & ev);
99 int processTelexW(UkKeyEvent & ev);
100 int processEscChar(UkKeyEvent & ev);
101 bool lastWordIsNonVn();
104 static bool m_classInit;
105 CheckKeyboardCaseCb m_keyCheckFunc;
106 UkSharedMem *m_pCtrl;
115 //unsigned int m_keyStrokes[MAX_UK_ENGINE];
116 KeyBufEntry m_keyStrokes[MAX_UK_ENGINE];
120 //varables valid in one session
121 unsigned char *m_pOutBuf;
123 bool m_outputWritten;
127 UkOutputType m_outType;
130 //info for word ending at this position
132 int c1Offset, vOffset, c2Offset;
139 //info for current symbol
141 //canonical symbol, after caps, tone are removed
142 //for non-Vn, vnSym == -1
147 WordInfo m_buffer[MAX_UK_ENGINE];
149 int processHookWithUO(UkKeyEvent & ev);
150 int macroMatch(UkKeyEvent & ev);
151 void markChange(int pos);
152 void prepareBuffer(); //make sure we have a least 10 entries available
153 int writeOutput(unsigned char *outBuf, int & outSize);
154 //int getSeqLength(int first, int last);
155 int getSeqSteps(int first, int last);
156 int getTonePosition(VowelSeq vs, bool terminated);
158 int checkEscapeVIQR(UkKeyEvent & ev);
159 int processNoSpellCheck(UkKeyEvent & ev);
160 int processWordEnd(UkKeyEvent & ev);
161 void synchKeyStrokeBuffer();
162 bool lastWordHasVnMark();
165 void SetupUnikeyEngine();