| 1 |
/* |
| 2 |
* Copyright 2016 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import QtMultimedia 5.0 |
| 19 |
import Lomiri.Components 1.3 |
| 20 |
import Lomiri.Components.Popups 1.3 |
| 21 |
|
| 22 |
import keys 1.0 |
| 23 |
import "key_constants.js" as UI |
| 24 |
import "parser.js" as Parser |
| 25 |
|
| 26 |
CharKey { |
| 27 |
|
| 28 |
allowPreeditHandler: true |
| 29 |
preeditHandler: handler |
| 30 |
|
| 31 |
Item { |
| 32 |
id: handler |
| 33 |
|
| 34 |
//Each Hangul represents one syllable. The Hangul are composed of jamo. |
| 35 |
//It need to manipulate preedit until compose one syllable. |
| 36 |
|
| 37 |
function onKeyReleased(keyString, action) { |
| 38 |
// get previous preedit string |
| 39 |
var preedit = maliit_input_method.preedit; |
| 40 |
|
| 41 |
if (Parser.is_hangul(keyString)) { |
| 42 |
// parsing preedit until compose one syllable. |
| 43 |
if (preedit.length > 1) { |
| 44 |
var syllableString = preedit.substring(0,preedit.length - 1); |
| 45 |
var preeditString = preedit[preedit.length - 1]; |
| 46 |
maliit_input_method.preedit = syllableString + Parser.add_jamo(preeditString, keyString); |
| 47 |
} else { |
| 48 |
maliit_input_method.preedit = Parser.add_jamo(preedit, keyString); |
| 49 |
} |
| 50 |
|
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
maliit_input_method.preedit = preedit + keyString; |
| 55 |
event_handler.onKeyReleased("", "commit"); |
| 56 |
} |
| 57 |
} |
| 58 |
} |