Debian Codegraph @

src/utils.h

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Copyright (C) 2005 Takuro Ashie
4 * Copyright (C) 2012 CSSlayer
5 *
6 * This program 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, or (at your option)
9 * any later version.
10 *
11 * This program 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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef __FCITX_ANTHY_UTILS_H__
22 #define __FCITX_ANTHY_UTILS_H__
23
24 #include "common.h"
25
26 size_t
27 util_utf8_string_length(const std::string& s);
28
29 std::string
30 util_utf8_string_substr(const std::string& s, size_t start, size_t len);
31
32 bool util_match_key_event (const FcitxHotkey* list,
33 const KeyEvent &key,
34 uint32_t ignore_mask = 0);
35 void util_split_string (std::string &str,
36 std::vector<std::string> &str_list,
37 char *delim,
38 int num);
39 void util_convert_to_wide (std::string &wide,
40 const std::string &str);
41 void util_convert_to_half (std::string &half,
42 const std::string &str);
43 void util_convert_to_katakana (std::string &kata,
44 const std::string &hira,
45 bool half = false);
46
47 bool util_key_is_keypad (const KeyEvent &key);
48 void util_keypad_to_string (std::string &str,
49 const KeyEvent &key);
50 void util_launch_program (const char *command);
51
52
53
54 bool util_surrounding_get_safe_delta(uint from, uint to, int32_t *delta);
55
56 bool util_surrounding_get_anchor_pos_from_selection(
57 const std::string &surrounding_text,
58 const std::string &selected_text,
59 uint cursor_pos,
60 uint *anchor_pos);
61
62 #endif /* __FCITX_ANTHY_UTILS_H__ */