| 1 | // -*- coding:unix; mode:c++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- |
| 2 | /*------------------------------------------------------------------------------ |
| 3 | UniKey - Open-source Vietnamese Keyboard |
| 4 | Copyright (C) 2000-2005 Pham Kim Long |
| 5 | Contact: |
| 6 | [email protected] |
| 7 | http://unikey.org |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or |
| 10 | modify it under the terms of the GNU General Public License |
| 11 | as published by the Free Software Foundation; either version 2 |
| 12 | of the License, or (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software |
| 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | --------------------------------------------------------------------------------*/ |
| 23 | |
| 24 | #ifndef __UNIKEY_H |
| 25 | #define __UNIKEY_H |
| 26 | |
| 27 | #include "keycons.h" |
| 28 | |
| 29 | /*---------------------------------------------------- |
| 30 | Initialization steps: |
| 31 | 1. UnikeySetup: This will initialized Unikey module, |
| 32 | with default options, input method = TELEX, output format = UTF-8 |
| 33 | 2. If you want a different settings: |
| 34 | + Call UnikeySetInputMethod to change input method |
| 35 | + Call UnikeySetOutputVIQR/UTF8 to chang output format |
| 36 | + Call UnikeySetOptions to change extra options |
| 37 | |
| 38 | Key event handling: |
| 39 | |
| 40 | - Call UnikeyFilter when a key event occurs, examine results in |
| 41 | + UnikeyBackspaces: number of backspaces that need to be sent |
| 42 | + UnikeyBufChars: number of chars in buffer that need to be sent |
| 43 | + UnikeyAnsiBuf: buffer containing output characters. |
| 44 | + UnikeyUniBuf: not used |
| 45 | |
| 46 | You should also call UnikeySetCapsState() before calling UnikeyFilter. |
| 47 | |
| 48 | To make this module portable across platforms, UnikeyFilter should not |
| 49 | be called on special keys: Enter, Tab, movement keys, delete, backspace... |
| 50 | |
| 51 | - Special events: |
| 52 | + Call UnikeyResetBuf to reset the engine's state in situations such as: |
| 53 | focus lost, movement keys: arrow keys, pgup, pgdown.... |
| 54 | + If a backspace is received, call UnikeyBackspacePress, |
| 55 | then examine the result: |
| 56 | UnikeyBackspaces is the number of backspaces actually required to |
| 57 | remove one character. |
| 58 | |
| 59 | Clean up: |
| 60 | - When the Engine is no longer needed, call UnikeyCleanup |
| 61 | ------------------------------------------------------*/ |
| 62 | |
| 63 | #if defined(__cplusplus) |
| 64 | extern "C" { |
| 65 | #endif |
| 66 | extern unsigned char UnikeyBuf[]; |
| 67 | extern int UnikeyBackspaces; |
| 68 | extern int UnikeyBufChars; |
| 69 | extern UkOutputType UnikeyOutput; |
| 70 | |
| 71 | void UnikeySetup(); // always call this first |
| 72 | void UnikeyCleanup(); // call this when unloading unikey module |
| 73 | |
| 74 | // call this to reset Unikey's state when focus, context is changed or |
| 75 | // some control key is pressed |
| 76 | void UnikeyResetBuf(); |
| 77 | |
| 78 | // main handler, call every time a character input is received |
| 79 | void UnikeyFilter(unsigned int ch); |
| 80 | void UnikeyPutChar(unsigned int ch); // put new char without filtering |
| 81 | |
| 82 | // call this before UnikeyFilter for correctly processing some TELEX shortcuts |
| 83 | void UnikeySetCapsState(int shiftPressed, int CapsLockOn); |
| 84 | |
| 85 | // call this when backspace is pressed |
| 86 | void UnikeyBackspacePress(); |
| 87 | |
| 88 | // call this to restore to original key strokes |
| 89 | void UnikeyRestoreKeyStrokes(); |
| 90 | |
| 91 | //set extra options |
| 92 | void UnikeySetOptions(UnikeyOptions *pOpt); |
| 93 | void CreateDefaultUnikeyOptions(UnikeyOptions *pOpt); |
| 94 | |
| 95 | void UnikeyGetOptions(UnikeyOptions *pOpt); |
| 96 | |
| 97 | // set input method |
| 98 | // im: TELEX_INPUT, VNI_INPUT, VIQR_INPUT, VIQR_STAR_INPUT |
| 99 | void UnikeySetInputMethod(UkInputMethod im); |
| 100 | // set output format |
| 101 | // void UnikeySetOutputVIQR(); |
| 102 | // void UnikeySetOutputUTF8(); |
| 103 | int UnikeySetOutputCharset(int charset); |
| 104 | |
| 105 | int UnikeyLoadMacroTable(const char *fileName); |
| 106 | int UnikeyLoadUserKeyMap(const char *fileName); |
| 107 | |
| 108 | //call this to enable typing vietnamese even in a non-vn sequence |
| 109 | //e.g: GD&DDT,QDDND... |
| 110 | //The engine will return to normal mode when a word-break occurs. |
| 111 | void UnikeySetSingleMode(); |
| 112 | |
| 113 | bool UnikeyAtWordBeginning(); |
| 114 | #if defined(__cplusplus) |
| 115 | } |
| 116 | #endif |
| 117 | |
| 118 | #endif |