various code style fixes
This commit is contained in:
parent
b5418c94ca
commit
4b649d386c
|
@ -80,8 +80,8 @@ bool is_horizontal_blank(char c)
|
||||||
struct unterminated_string : parse_error
|
struct unterminated_string : parse_error
|
||||||
{
|
{
|
||||||
unterminated_string(const String& open, const String& close, int nest = 0)
|
unterminated_string(const String& open, const String& close, int nest = 0)
|
||||||
: parse_error{"unterminated string '" + open + "..." + close + "'" +
|
: parse_error{"unterminated string '" + open + "..." + close + "'" +
|
||||||
(nest > 0 ? "(nesting: " + int_to_str(nest) + ")" : "")}
|
(nest > 0 ? "(nesting: " + int_to_str(nest) + ")" : "")}
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -279,8 +279,8 @@ void add_highlighter(const CommandParameters& params, Context& context)
|
||||||
|
|
||||||
Window& window = context.window();
|
Window& window = context.window();
|
||||||
HighlighterGroup& group = parser.has_option("group") ?
|
HighlighterGroup& group = parser.has_option("group") ?
|
||||||
get_group(window.highlighters(), parser.option_value("group"))
|
get_group(window.highlighters(), parser.option_value("group"))
|
||||||
: window.highlighters();
|
: window.highlighters();
|
||||||
|
|
||||||
auto& factory = registry[name];
|
auto& factory = registry[name];
|
||||||
group.append(factory(window, highlighter_params));
|
group.append(factory(window, highlighter_params));
|
||||||
|
@ -294,8 +294,8 @@ void rm_highlighter(const CommandParameters& params, Context& context)
|
||||||
|
|
||||||
Window& window = context.window();
|
Window& window = context.window();
|
||||||
HighlighterGroup& group = parser.has_option("group") ?
|
HighlighterGroup& group = parser.has_option("group") ?
|
||||||
get_group(window.highlighters(), parser.option_value("group"))
|
get_group(window.highlighters(), parser.option_value("group"))
|
||||||
: window.highlighters();
|
: window.highlighters();
|
||||||
|
|
||||||
group.remove(parser[0]);
|
group.remove(parser[0]);
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,8 @@ void add_filter(const CommandParameters& params, Context& context)
|
||||||
|
|
||||||
Editor& editor = context.editor();
|
Editor& editor = context.editor();
|
||||||
FilterGroup& group = parser.has_option("group") ?
|
FilterGroup& group = parser.has_option("group") ?
|
||||||
get_group(editor.filters(), parser.option_value("group"))
|
get_group(editor.filters(), parser.option_value("group"))
|
||||||
: editor.filters();
|
: editor.filters();
|
||||||
|
|
||||||
auto& factory = registry[name];
|
auto& factory = registry[name];
|
||||||
group.append(factory(filter_params));
|
group.append(factory(filter_params));
|
||||||
|
@ -331,8 +331,8 @@ void rm_filter(const CommandParameters& params, Context& context)
|
||||||
|
|
||||||
Editor& editor = context.editor();
|
Editor& editor = context.editor();
|
||||||
FilterGroup& group = parser.has_option("group") ?
|
FilterGroup& group = parser.has_option("group") ?
|
||||||
get_group(editor.filters(), parser.option_value("group"))
|
get_group(editor.filters(), parser.option_value("group"))
|
||||||
: editor.filters();
|
: editor.filters();
|
||||||
|
|
||||||
group.remove(parser[0]);
|
group.remove(parser[0]);
|
||||||
}
|
}
|
||||||
|
@ -371,8 +371,8 @@ EnvVarMap params_to_env_var_map(const CommandParameters& params)
|
||||||
char param_name[] = "param0";
|
char param_name[] = "param0";
|
||||||
for (size_t i = 0; i < params.size(); ++i)
|
for (size_t i = 0; i < params.size(); ++i)
|
||||||
{
|
{
|
||||||
param_name[sizeof(param_name) - 2] = '0' + i;
|
param_name[sizeof(param_name) - 2] = '0' + i;
|
||||||
vars[param_name] = params[i];
|
vars[param_name] = params[i];
|
||||||
}
|
}
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
@ -413,9 +413,9 @@ void define_command(const CommandParameters& params, Context& context)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmd = [=](const CommandParameters& params, Context& context) {
|
cmd = [=](const CommandParameters& params, Context& context) {
|
||||||
if (not params.empty())
|
if (not params.empty())
|
||||||
throw wrong_argument_count();
|
throw wrong_argument_count();
|
||||||
CommandManager::instance().execute(commands, context);
|
CommandManager::instance().execute(commands, context);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -479,10 +479,10 @@ class RegisterRestorer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RegisterRestorer(char name, const Context& context)
|
RegisterRestorer(char name, const Context& context)
|
||||||
: m_name(name)
|
: m_name(name)
|
||||||
{
|
{
|
||||||
memoryview<String> save = RegisterManager::instance()[name].values(context);
|
memoryview<String> save = RegisterManager::instance()[name].values(context);
|
||||||
m_save = std::vector<String>(save.begin(), save.end());
|
m_save = std::vector<String>(save.begin(), save.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
~RegisterRestorer()
|
~RegisterRestorer()
|
||||||
|
@ -497,7 +497,7 @@ class BatchUI : public UserInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BatchUI(const KeyList& keys)
|
BatchUI(const KeyList& keys)
|
||||||
: m_keys(keys), m_pos(0) {}
|
: m_keys(keys), m_pos(0) {}
|
||||||
|
|
||||||
Key get_key() override
|
Key get_key() override
|
||||||
{
|
{
|
||||||
|
@ -551,7 +551,6 @@ void exec_string(const CommandParameters& params, Context& context)
|
||||||
keys.insert(keys.end(), param_keys.begin(), param_keys.end());
|
keys.insert(keys.end(), param_keys.begin(), param_keys.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Context& keys_context = parser.has_option("client") ?
|
Context& keys_context = parser.has_option("client") ?
|
||||||
ClientManager::instance().get_client_context(parser.option_value("client"))
|
ClientManager::instance().get_client_context(parser.option_value("client"))
|
||||||
: context;
|
: context;
|
||||||
|
|
|
@ -18,11 +18,11 @@ static boost::regex make_regex_ifp(const String& ex)
|
||||||
boost::regex result;
|
boost::regex result;
|
||||||
if (not ex.empty())
|
if (not ex.empty())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result = boost::regex(ex.c_str());
|
result = boost::regex(ex.c_str());
|
||||||
}
|
}
|
||||||
catch(boost::regex_error&) {}
|
catch(boost::regex_error&) {}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,8 @@ struct DisplayAtom
|
||||||
AtomContent content;
|
AtomContent content;
|
||||||
|
|
||||||
DisplayAtom(AtomContent content)
|
DisplayAtom(AtomContent content)
|
||||||
: content(std::move(content)), attribute(Normal),
|
: content(std::move(content)), attribute(Normal),
|
||||||
fg_color(Color::Default), bg_color(Color::Default) {}
|
fg_color(Color::Default), bg_color(Color::Default) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DisplayLine
|
class DisplayLine
|
||||||
|
|
|
@ -486,7 +486,7 @@ IncrementalInserter::~IncrementalInserter()
|
||||||
{
|
{
|
||||||
if (m_mode == InsertMode::Append and sel.last().column() > 0)
|
if (m_mode == InsertMode::Append and sel.last().column() > 0)
|
||||||
sel.last() = utf8::previous(sel.last());
|
sel.last() = utf8::previous(sel.last());
|
||||||
sel.avoid_eol();
|
sel.avoid_eol();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editor.on_incremental_insertion_end();
|
m_editor.on_incremental_insertion_end();
|
||||||
|
|
|
@ -54,7 +54,7 @@ void EventManager::handle_next_events()
|
||||||
|
|
||||||
void EventManager::force_signal(int fd)
|
void EventManager::force_signal(int fd)
|
||||||
{
|
{
|
||||||
m_forced.push_back(fd);
|
m_forced.push_back(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ void preserve_indent(Buffer& buffer, Selection& selection, String& content)
|
||||||
{
|
{
|
||||||
if (content == "\n")
|
if (content == "\n")
|
||||||
{
|
{
|
||||||
BufferIterator line_begin = buffer.iterator_at_line_begin(selection.last() - 1);
|
BufferIterator line_begin = buffer.iterator_at_line_begin(selection.last() - 1);
|
||||||
BufferIterator first_non_white = line_begin;
|
BufferIterator first_non_white = line_begin;
|
||||||
while ((*first_non_white == '\t' or *first_non_white == ' ') and
|
while ((*first_non_white == '\t' or *first_non_white == ' ') and
|
||||||
not first_non_white.is_end())
|
not first_non_white.is_end())
|
||||||
++first_non_white;
|
++first_non_white;
|
||||||
|
|
||||||
content += buffer.string(line_begin, first_non_white);
|
content += buffer.string(line_begin, first_non_white);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,9 +175,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_last_search;
|
String m_last_search;
|
||||||
ColorSpec m_colors;
|
ColorSpec m_colors;
|
||||||
RegexColorizer m_colorizer;
|
RegexColorizer m_colorizer;
|
||||||
};
|
};
|
||||||
|
|
||||||
HighlighterAndId highlight_search_factory(Window& window,
|
HighlighterAndId highlight_search_factory(Window& window,
|
||||||
|
@ -271,10 +271,10 @@ void highlight_selections(Window& window, DisplayBuffer& display_buffer)
|
||||||
|
|
||||||
const BufferIterator& last = sel.last();
|
const BufferIterator& last = sel.last();
|
||||||
highlight_range(display_buffer, last, utf8::next(last), false,
|
highlight_range(display_buffer, last, utf8::next(last), false,
|
||||||
[](DisplayAtom& atom) { atom.attribute |= Attributes::Reverse; atom.attribute &= ~Attributes::Underline; });
|
[](DisplayAtom& atom) { atom.attribute |= Attributes::Reverse;
|
||||||
|
atom.attribute &= ~Attributes::Underline; });
|
||||||
}
|
}
|
||||||
const Selection& back = window.selections().back();
|
const Selection& back = window.selections().back();
|
||||||
const BufferIterator& last = back.last();
|
|
||||||
highlight_range(display_buffer, back.begin(), back.end(), false,
|
highlight_range(display_buffer, back.begin(), back.end(), false,
|
||||||
[](DisplayAtom& atom) { atom.attribute |= Attributes::Bold; });
|
[](DisplayAtom& atom) { atom.attribute |= Attributes::Bold; });
|
||||||
}
|
}
|
||||||
|
|
18
src/main.cc
18
src/main.cc
|
@ -126,8 +126,8 @@ void do_pipe(Context& context)
|
||||||
|
|
||||||
Editor& editor = context.editor();
|
Editor& editor = context.editor();
|
||||||
std::vector<String> strings;
|
std::vector<String> strings;
|
||||||
for (auto& sel : const_cast<const Editor&>(context.editor()).selections())
|
for (auto& sel : context.editor().selections())
|
||||||
strings.push_back(ShellManager::instance().pipe(String(sel.begin(), sel.end()),
|
strings.push_back(ShellManager::instance().pipe({sel.begin(), sel.end()},
|
||||||
cmdline, context, {}, {}));
|
cmdline, context, {}, {}));
|
||||||
editor.insert(strings, InsertMode::Replace);
|
editor.insert(strings, InsertMode::Replace);
|
||||||
}, context);
|
}, context);
|
||||||
|
@ -637,13 +637,13 @@ void register_registers()
|
||||||
register_manager.register_dynamic_register('.', [](const Context& context) { return context.editor().selections_content(); });
|
register_manager.register_dynamic_register('.', [](const Context& context) { return context.editor().selections_content(); });
|
||||||
for (size_t i = 0; i < 10; ++i)
|
for (size_t i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
register_manager.register_dynamic_register('0'+i,
|
register_manager.register_dynamic_register('0'+i,
|
||||||
[i](const Context& context) {
|
[i](const Context& context) {
|
||||||
std::vector<String> result;
|
std::vector<String> result;
|
||||||
for (auto& sel : context.editor().selections())
|
for (auto& sel : context.editor().selections())
|
||||||
result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : "");
|
result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : "");
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,42 +309,42 @@ void RemoteClient::process_next_message()
|
||||||
{
|
{
|
||||||
case RemoteUIMsg::PrintStatus:
|
case RemoteUIMsg::PrintStatus:
|
||||||
{
|
{
|
||||||
auto status = read<String>(m_socket);
|
auto status = read<String>(m_socket);
|
||||||
auto cursor_pos = read<CharCount>(m_socket);
|
auto cursor_pos = read<CharCount>(m_socket);
|
||||||
m_ui->print_status(status, cursor_pos);
|
m_ui->print_status(status, cursor_pos);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RemoteUIMsg::MenuShow:
|
case RemoteUIMsg::MenuShow:
|
||||||
{
|
{
|
||||||
auto choices = read_vector<String>(m_socket);
|
auto choices = read_vector<String>(m_socket);
|
||||||
auto anchor = read<DisplayCoord>(m_socket);
|
auto anchor = read<DisplayCoord>(m_socket);
|
||||||
auto style = read<MenuStyle>(m_socket);
|
auto style = read<MenuStyle>(m_socket);
|
||||||
m_ui->menu_show(choices, anchor, style);
|
m_ui->menu_show(choices, anchor, style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RemoteUIMsg::MenuSelect:
|
case RemoteUIMsg::MenuSelect:
|
||||||
m_ui->menu_select(read<int>(m_socket));
|
m_ui->menu_select(read<int>(m_socket));
|
||||||
break;
|
break;
|
||||||
case RemoteUIMsg::MenuHide:
|
case RemoteUIMsg::MenuHide:
|
||||||
m_ui->menu_hide();
|
m_ui->menu_hide();
|
||||||
break;
|
break;
|
||||||
case RemoteUIMsg::InfoShow:
|
case RemoteUIMsg::InfoShow:
|
||||||
{
|
{
|
||||||
auto choices = read<String>(m_socket);
|
auto choices = read<String>(m_socket);
|
||||||
auto anchor = read<DisplayCoord>(m_socket);
|
auto anchor = read<DisplayCoord>(m_socket);
|
||||||
auto style = read<MenuStyle>(m_socket);
|
auto style = read<MenuStyle>(m_socket);
|
||||||
m_ui->info_show(choices, anchor, style);
|
m_ui->info_show(choices, anchor, style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RemoteUIMsg::InfoHide:
|
case RemoteUIMsg::InfoHide:
|
||||||
m_ui->info_hide();
|
m_ui->info_hide();
|
||||||
break;
|
break;
|
||||||
case RemoteUIMsg::Draw:
|
case RemoteUIMsg::Draw:
|
||||||
{
|
{
|
||||||
DisplayBuffer display_buffer = read<DisplayBuffer>(m_socket);
|
DisplayBuffer display_buffer = read<DisplayBuffer>(m_socket);
|
||||||
String mode_line = read<String>(m_socket);
|
String mode_line = read<String>(m_socket);
|
||||||
m_ui->draw(display_buffer, mode_line);
|
m_ui->draw(display_buffer, mode_line);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct Selection : public Range
|
||||||
{
|
{
|
||||||
Selection(const BufferIterator& first, const BufferIterator& last,
|
Selection(const BufferIterator& first, const BufferIterator& last,
|
||||||
CaptureList captures = {})
|
CaptureList captures = {})
|
||||||
: Range(first, last), m_captures(std::move(captures)) {}
|
: Range(first, last), m_captures(std::move(captures)) {}
|
||||||
|
|
||||||
void avoid_eol();
|
void avoid_eol();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ class StronglyTypedInteger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit constexpr StronglyTypedInteger(ValueType value)
|
explicit constexpr StronglyTypedInteger(ValueType value)
|
||||||
: m_value(value) {}
|
: m_value(value) {}
|
||||||
|
|
||||||
constexpr RealType operator+(const RealType& other) const
|
constexpr RealType operator+(const RealType& other) const
|
||||||
{ return RealType(m_value + other.m_value); }
|
{ return RealType(m_value + other.m_value); }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user