Update list of wide characters
[centerim5.git] / cppconsui / Keys.cpp
blob6b3318fbde902e7c73a5193ed4ee56393a1671fe
1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
3 //
4 // This file is part of CenterIM.
5 //
6 // CenterIM is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // CenterIM is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
19 #include "Keys.h"
21 #include "CoreManager.h"
23 #include <string.h>
25 namespace CppConsUI {
27 namespace Keys {
29 bool TermKeyCmp::operator()(const TermKeyKey &a, const TermKeyKey &b) const
31 return termkey_keycmp(COREMANAGER->getTermKeyHandle(), &a, &b) > 0;
34 TermKeyKey refineKey(const TermKeyKey &k)
36 if (k.type != TERMKEY_TYPE_KEYSYM)
37 return k;
39 TermKeyKey res = k;
40 if (res.code.sym == TERMKEY_SYM_TAB) {
41 res.type = TERMKEY_TYPE_UNICODE;
42 strcpy(res.utf8, "\t");
43 res.code.codepoint = UTF8::getUniChar(res.utf8);
45 else if (res.code.sym == TERMKEY_SYM_ENTER) {
46 res.type = TERMKEY_TYPE_UNICODE;
47 strcpy(res.utf8, "\n");
48 res.code.codepoint = UTF8::getUniChar(res.utf8);
50 else if (res.code.sym == TERMKEY_SYM_SPACE) {
51 res.type = TERMKEY_TYPE_UNICODE;
52 strcpy(res.utf8, " ");
53 res.code.codepoint = UTF8::getUniChar(res.utf8);
55 return res;
58 } // namespace Keys
60 } // namespace CppConsUI
62 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: