summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2012-10-08 19:33:53 +0200
committerMaxime Coste <frrrwww@gmail.com>2012-10-08 19:33:53 +0200
commitc7272e427dab6dde9fb87e7e4890eac9447f2736 (patch)
treed22d1fe076394d990a527c2bdee0ee55bc8acfdf /src
parent194bf6ac98c70e7e1fbc99c9a12906b0ebb07ee4 (diff)
get rid of Character
Diffstat (limited to 'src')
-rw-r--r--src/color_registry.cc2
-rw-r--r--src/command_manager.cc8
-rw-r--r--src/keys.cc6
-rw-r--r--src/keys.hh12
-rw-r--r--src/ncurses.cc4
-rw-r--r--src/string.hh3
6 files changed, 18 insertions, 17 deletions
diff --git a/src/color_registry.cc b/src/color_registry.cc
index 1d1b3235..360e08f4 100644
--- a/src/color_registry.cc
+++ b/src/color_registry.cc
@@ -42,7 +42,7 @@ void ColorRegistry::register_alias(const String& name, const String& colordesc,
throw runtime_error("alias '" + name + "' already defined");
if (std::find_if(name.begin(), name.end(),
- [](Character c) { return not isalnum(c); }) != name.end())
+ [](char c) { return not isalnum(c); }) != name.end())
throw runtime_error("alias names are limited to alpha numeric words");
auto it = std::find(colordesc.begin(), colordesc.end(), ',');
diff --git a/src/command_manager.cc b/src/command_manager.cc
index df23ca6e..b21921da 100644
--- a/src/command_manager.cc
+++ b/src/command_manager.cc
@@ -63,7 +63,7 @@ private:
using TokenList = std::vector<Token>;
using TokenPosList = std::vector<std::pair<CharCount, CharCount>>;
-bool is_command_separator(Character c)
+bool is_command_separator(char c)
{
return c == ';' or c == '\n';
}
@@ -124,17 +124,17 @@ TokenList parse(const String& line,
if (type_name == "opt")
type = Token::Type::OptionExpand;
- static const std::unordered_map<Character, Character> matching_delimiters = {
+ static const std::unordered_map<char, char> matching_delimiters = {
{ '(', ')' }, { '[', ']' }, { '{', '}' }, { '<', '>' }
};
- Character opening_delimiter = line[pos];
+ char opening_delimiter = line[pos];
token_start = ++pos;
auto delim_it = matching_delimiters.find(opening_delimiter);
if (delim_it != matching_delimiters.end())
{
- Character closing_delimiter = delim_it->second;
+ char closing_delimiter = delim_it->second;
int level = 0;
while (pos != length)
{
diff --git a/src/keys.cc b/src/keys.cc
index b79c1940..696b704e 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -16,7 +16,7 @@ Key canonicalize_ifn(Key key)
return key;
}
-static std::unordered_map<String, Character> keynamemap = {
+static std::unordered_map<String, utf8::Codepoint> keynamemap = {
{ "ret", '\r' },
{ "space", ' ' },
{ "esc", Key::Escape }
@@ -53,7 +53,7 @@ KeyList parse_keys(const String& str)
}
if (keyname.length() == 1)
{
- result.push_back(Key{ modifier, keyname[0] });
+ result.push_back(Key{ modifier, utf8::Codepoint(keyname[0]) });
pos = end_pos;
continue;
}
@@ -67,7 +67,7 @@ KeyList parse_keys(const String& str)
}
}
}
- result.push_back({Key::Modifiers::None, str[pos]});
+ result.push_back({Key::Modifiers::None, utf8::Codepoint(str[pos])});
}
return result;
}
diff --git a/src/keys.hh b/src/keys.hh
index 788a25bd..8355397f 100644
--- a/src/keys.hh
+++ b/src/keys.hh
@@ -2,6 +2,7 @@
#define keys_hh_INCLUDED
#include <vector>
+#include "utf8.hh"
#include "string.hh"
namespace Kakoune
@@ -16,9 +17,10 @@ struct Key
Alt = 2,
ControlAlt = 3
};
- enum NamedKey : Character
+ enum NamedKey : utf8::Codepoint
{
- Backspace = 256,
+ // use UTF-16 surrogate pairs range
+ Backspace = 0xD800,
Escape,
Up,
Down,
@@ -30,12 +32,12 @@ struct Key
};
Modifiers modifiers;
- Character key;
+ utf8::Codepoint key;
- constexpr Key(Modifiers modifiers, Character key)
+ constexpr Key(Modifiers modifiers, utf8::Codepoint key)
: modifiers(modifiers), key(key) {}
- constexpr Key(Character key)
+ constexpr Key(utf8::Codepoint key)
: modifiers(Modifiers::None), key(key) {}
constexpr bool operator==(const Key& other) const
diff --git a/src/ncurses.cc b/src/ncurses.cc
index a012fc67..9a916086 100644
--- a/src/ncurses.cc
+++ b/src/ncurses.cc
@@ -182,7 +182,7 @@ void NCursesUI::draw_window(Window& window)
Key NCursesUI::get_key()
{
- const int c = getch();
+ const utf8::Codepoint c = getch();
if (c > 0 and c < 27)
{
@@ -191,7 +191,7 @@ Key NCursesUI::get_key()
else if (c == 27)
{
timeout(0);
- const int new_c = getch();
+ const utf8::Codepoint new_c = getch();
timeout(-1);
if (new_c != ERR)
return {Key::Modifiers::Alt, new_c};
diff --git a/src/string.hh b/src/string.hh
index 31af1986..ad3a7b5f 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -11,7 +11,6 @@
namespace Kakoune
{
-typedef int32_t Character;
typedef boost::regex Regex;
class String
@@ -84,7 +83,7 @@ String int_to_str(int value);
int str_to_int(const String& str);
std::vector<String> split(const String& str, char separator);
-inline bool is_word(Character c)
+inline bool is_word(char c)
{
return (c >= '0' and c <= '9') or
(c >= 'a' and c <= 'z') or