get rid of Character

This commit is contained in:
Maxime Coste 2012-10-08 19:33:53 +02:00
parent 194bf6ac98
commit c7272e427d
6 changed files with 18 additions and 17 deletions

View File

@ -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(), ',');

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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

View File

@ -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};

View File

@ -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