get rid of Character
This commit is contained in:
parent
194bf6ac98
commit
c7272e427d
|
@ -42,7 +42,7 @@ void ColorRegistry::register_alias(const String& name, const String& colordesc,
|
||||||
throw runtime_error("alias '" + name + "' already defined");
|
throw runtime_error("alias '" + name + "' already defined");
|
||||||
|
|
||||||
if (std::find_if(name.begin(), name.end(),
|
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");
|
throw runtime_error("alias names are limited to alpha numeric words");
|
||||||
|
|
||||||
auto it = std::find(colordesc.begin(), colordesc.end(), ',');
|
auto it = std::find(colordesc.begin(), colordesc.end(), ',');
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
using TokenList = std::vector<Token>;
|
using TokenList = std::vector<Token>;
|
||||||
using TokenPosList = std::vector<std::pair<CharCount, CharCount>>;
|
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';
|
return c == ';' or c == '\n';
|
||||||
}
|
}
|
||||||
|
@ -124,17 +124,17 @@ TokenList parse(const String& line,
|
||||||
if (type_name == "opt")
|
if (type_name == "opt")
|
||||||
type = Token::Type::OptionExpand;
|
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;
|
token_start = ++pos;
|
||||||
|
|
||||||
auto delim_it = matching_delimiters.find(opening_delimiter);
|
auto delim_it = matching_delimiters.find(opening_delimiter);
|
||||||
if (delim_it != matching_delimiters.end())
|
if (delim_it != matching_delimiters.end())
|
||||||
{
|
{
|
||||||
Character closing_delimiter = delim_it->second;
|
char closing_delimiter = delim_it->second;
|
||||||
int level = 0;
|
int level = 0;
|
||||||
while (pos != length)
|
while (pos != length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ Key canonicalize_ifn(Key key)
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unordered_map<String, Character> keynamemap = {
|
static std::unordered_map<String, utf8::Codepoint> keynamemap = {
|
||||||
{ "ret", '\r' },
|
{ "ret", '\r' },
|
||||||
{ "space", ' ' },
|
{ "space", ' ' },
|
||||||
{ "esc", Key::Escape }
|
{ "esc", Key::Escape }
|
||||||
|
@ -53,7 +53,7 @@ KeyList parse_keys(const String& str)
|
||||||
}
|
}
|
||||||
if (keyname.length() == 1)
|
if (keyname.length() == 1)
|
||||||
{
|
{
|
||||||
result.push_back(Key{ modifier, keyname[0] });
|
result.push_back(Key{ modifier, utf8::Codepoint(keyname[0]) });
|
||||||
pos = end_pos;
|
pos = end_pos;
|
||||||
continue;
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
12
src/keys.hh
12
src/keys.hh
|
@ -2,6 +2,7 @@
|
||||||
#define keys_hh_INCLUDED
|
#define keys_hh_INCLUDED
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "utf8.hh"
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
|
@ -16,9 +17,10 @@ struct Key
|
||||||
Alt = 2,
|
Alt = 2,
|
||||||
ControlAlt = 3
|
ControlAlt = 3
|
||||||
};
|
};
|
||||||
enum NamedKey : Character
|
enum NamedKey : utf8::Codepoint
|
||||||
{
|
{
|
||||||
Backspace = 256,
|
// use UTF-16 surrogate pairs range
|
||||||
|
Backspace = 0xD800,
|
||||||
Escape,
|
Escape,
|
||||||
Up,
|
Up,
|
||||||
Down,
|
Down,
|
||||||
|
@ -30,12 +32,12 @@ struct Key
|
||||||
};
|
};
|
||||||
|
|
||||||
Modifiers modifiers;
|
Modifiers modifiers;
|
||||||
Character key;
|
utf8::Codepoint key;
|
||||||
|
|
||||||
constexpr Key(Modifiers modifiers, Character key)
|
constexpr Key(Modifiers modifiers, utf8::Codepoint key)
|
||||||
: modifiers(modifiers), key(key) {}
|
: modifiers(modifiers), key(key) {}
|
||||||
|
|
||||||
constexpr Key(Character key)
|
constexpr Key(utf8::Codepoint key)
|
||||||
: modifiers(Modifiers::None), key(key) {}
|
: modifiers(Modifiers::None), key(key) {}
|
||||||
|
|
||||||
constexpr bool operator==(const Key& other) const
|
constexpr bool operator==(const Key& other) const
|
||||||
|
|
|
@ -182,7 +182,7 @@ void NCursesUI::draw_window(Window& window)
|
||||||
|
|
||||||
Key NCursesUI::get_key()
|
Key NCursesUI::get_key()
|
||||||
{
|
{
|
||||||
const int c = getch();
|
const utf8::Codepoint c = getch();
|
||||||
|
|
||||||
if (c > 0 and c < 27)
|
if (c > 0 and c < 27)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ Key NCursesUI::get_key()
|
||||||
else if (c == 27)
|
else if (c == 27)
|
||||||
{
|
{
|
||||||
timeout(0);
|
timeout(0);
|
||||||
const int new_c = getch();
|
const utf8::Codepoint new_c = getch();
|
||||||
timeout(-1);
|
timeout(-1);
|
||||||
if (new_c != ERR)
|
if (new_c != ERR)
|
||||||
return {Key::Modifiers::Alt, new_c};
|
return {Key::Modifiers::Alt, new_c};
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef int32_t Character;
|
|
||||||
typedef boost::regex Regex;
|
typedef boost::regex Regex;
|
||||||
|
|
||||||
class String
|
class String
|
||||||
|
@ -84,7 +83,7 @@ String int_to_str(int value);
|
||||||
int str_to_int(const String& str);
|
int str_to_int(const String& str);
|
||||||
std::vector<String> split(const String& str, char separator);
|
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
|
return (c >= '0' and c <= '9') or
|
||||||
(c >= 'a' and c <= 'z') or
|
(c >= 'a' and c <= 'z') or
|
||||||
|
|
Loading…
Reference in New Issue
Block a user