various code style fixes

This commit is contained in:
Maxime Coste 2013-01-04 18:39:13 +01:00
parent b5418c94ca
commit 4b649d386c
12 changed files with 74 additions and 75 deletions

View File

@ -80,8 +80,8 @@ bool is_horizontal_blank(char c)
struct unterminated_string : parse_error
{
unterminated_string(const String& open, const String& close, int nest = 0)
: parse_error{"unterminated string '" + open + "..." + close + "'" +
(nest > 0 ? "(nesting: " + int_to_str(nest) + ")" : "")}
: parse_error{"unterminated string '" + open + "..." + close + "'" +
(nest > 0 ? "(nesting: " + int_to_str(nest) + ")" : "")}
{}
};

View File

@ -279,8 +279,8 @@ void add_highlighter(const CommandParameters& params, Context& context)
Window& window = context.window();
HighlighterGroup& group = parser.has_option("group") ?
get_group(window.highlighters(), parser.option_value("group"))
: window.highlighters();
get_group(window.highlighters(), parser.option_value("group"))
: window.highlighters();
auto& factory = registry[name];
group.append(factory(window, highlighter_params));
@ -294,8 +294,8 @@ void rm_highlighter(const CommandParameters& params, Context& context)
Window& window = context.window();
HighlighterGroup& group = parser.has_option("group") ?
get_group(window.highlighters(), parser.option_value("group"))
: window.highlighters();
get_group(window.highlighters(), parser.option_value("group"))
: window.highlighters();
group.remove(parser[0]);
}
@ -316,8 +316,8 @@ void add_filter(const CommandParameters& params, Context& context)
Editor& editor = context.editor();
FilterGroup& group = parser.has_option("group") ?
get_group(editor.filters(), parser.option_value("group"))
: editor.filters();
get_group(editor.filters(), parser.option_value("group"))
: editor.filters();
auto& factory = registry[name];
group.append(factory(filter_params));
@ -331,8 +331,8 @@ void rm_filter(const CommandParameters& params, Context& context)
Editor& editor = context.editor();
FilterGroup& group = parser.has_option("group") ?
get_group(editor.filters(), parser.option_value("group"))
: editor.filters();
get_group(editor.filters(), parser.option_value("group"))
: editor.filters();
group.remove(parser[0]);
}
@ -371,8 +371,8 @@ EnvVarMap params_to_env_var_map(const CommandParameters& params)
char param_name[] = "param0";
for (size_t i = 0; i < params.size(); ++i)
{
param_name[sizeof(param_name) - 2] = '0' + i;
vars[param_name] = params[i];
param_name[sizeof(param_name) - 2] = '0' + i;
vars[param_name] = params[i];
}
return vars;
}
@ -413,9 +413,9 @@ void define_command(const CommandParameters& params, Context& context)
}
else
{
cmd = [=](const CommandParameters& params, Context& context) {
if (not params.empty())
throw wrong_argument_count();
cmd = [=](const CommandParameters& params, Context& context) {
if (not params.empty())
throw wrong_argument_count();
CommandManager::instance().execute(commands, context);
};
}
@ -479,10 +479,10 @@ class RegisterRestorer
{
public:
RegisterRestorer(char name, const Context& context)
: m_name(name)
: m_name(name)
{
memoryview<String> save = RegisterManager::instance()[name].values(context);
m_save = std::vector<String>(save.begin(), save.end());
memoryview<String> save = RegisterManager::instance()[name].values(context);
m_save = std::vector<String>(save.begin(), save.end());
}
~RegisterRestorer()
@ -497,7 +497,7 @@ class BatchUI : public UserInterface
{
public:
BatchUI(const KeyList& keys)
: m_keys(keys), m_pos(0) {}
: m_keys(keys), m_pos(0) {}
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());
}
Context& keys_context = parser.has_option("client") ?
ClientManager::instance().get_client_context(parser.option_value("client"))
: context;

View File

@ -18,11 +18,11 @@ static boost::regex make_regex_ifp(const String& ex)
boost::regex result;
if (not ex.empty())
{
try
{
result = boost::regex(ex.c_str());
}
catch(boost::regex_error&) {}
try
{
result = boost::regex(ex.c_str());
}
catch(boost::regex_error&) {}
}
return result;
}

View File

@ -117,8 +117,8 @@ struct DisplayAtom
AtomContent content;
DisplayAtom(AtomContent content)
: content(std::move(content)), attribute(Normal),
fg_color(Color::Default), bg_color(Color::Default) {}
: content(std::move(content)), attribute(Normal),
fg_color(Color::Default), bg_color(Color::Default) {}
};
class DisplayLine

View File

@ -486,7 +486,7 @@ IncrementalInserter::~IncrementalInserter()
{
if (m_mode == InsertMode::Append and sel.last().column() > 0)
sel.last() = utf8::previous(sel.last());
sel.avoid_eol();
sel.avoid_eol();
}
m_editor.on_incremental_insertion_end();

View File

@ -54,7 +54,7 @@ void EventManager::handle_next_events()
void EventManager::force_signal(int fd)
{
m_forced.push_back(fd);
m_forced.push_back(fd);
}
}

View File

@ -10,13 +10,13 @@ void preserve_indent(Buffer& buffer, Selection& selection, String& content)
{
if (content == "\n")
{
BufferIterator line_begin = buffer.iterator_at_line_begin(selection.last() - 1);
BufferIterator first_non_white = line_begin;
while ((*first_non_white == '\t' or *first_non_white == ' ') and
not first_non_white.is_end())
++first_non_white;
BufferIterator line_begin = buffer.iterator_at_line_begin(selection.last() - 1);
BufferIterator first_non_white = line_begin;
while ((*first_non_white == '\t' or *first_non_white == ' ') and
not first_non_white.is_end())
++first_non_white;
content += buffer.string(line_begin, first_non_white);
content += buffer.string(line_begin, first_non_white);
}
}

View File

@ -175,9 +175,9 @@ public:
}
private:
String m_last_search;
ColorSpec m_colors;
RegexColorizer m_colorizer;
String m_last_search;
ColorSpec m_colors;
RegexColorizer m_colorizer;
};
HighlighterAndId highlight_search_factory(Window& window,
@ -271,10 +271,10 @@ void highlight_selections(Window& window, DisplayBuffer& display_buffer)
const BufferIterator& last = sel.last();
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 BufferIterator& last = back.last();
highlight_range(display_buffer, back.begin(), back.end(), false,
[](DisplayAtom& atom) { atom.attribute |= Attributes::Bold; });
}

View File

@ -126,8 +126,8 @@ void do_pipe(Context& context)
Editor& editor = context.editor();
std::vector<String> strings;
for (auto& sel : const_cast<const Editor&>(context.editor()).selections())
strings.push_back(ShellManager::instance().pipe(String(sel.begin(), sel.end()),
for (auto& sel : context.editor().selections())
strings.push_back(ShellManager::instance().pipe({sel.begin(), sel.end()},
cmdline, context, {}, {}));
editor.insert(strings, InsertMode::Replace);
}, context);
@ -637,13 +637,13 @@ void register_registers()
register_manager.register_dynamic_register('.', [](const Context& context) { return context.editor().selections_content(); });
for (size_t i = 0; i < 10; ++i)
{
register_manager.register_dynamic_register('0'+i,
[i](const Context& context) {
std::vector<String> result;
for (auto& sel : context.editor().selections())
result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : "");
return result;
});
register_manager.register_dynamic_register('0'+i,
[i](const Context& context) {
std::vector<String> result;
for (auto& sel : context.editor().selections())
result.emplace_back(i < sel.captures().size() ? sel.captures()[i] : "");
return result;
});
}
}

View File

@ -309,42 +309,42 @@ void RemoteClient::process_next_message()
{
case RemoteUIMsg::PrintStatus:
{
auto status = read<String>(m_socket);
auto cursor_pos = read<CharCount>(m_socket);
m_ui->print_status(status, cursor_pos);
break;
auto status = read<String>(m_socket);
auto cursor_pos = read<CharCount>(m_socket);
m_ui->print_status(status, cursor_pos);
break;
}
case RemoteUIMsg::MenuShow:
{
auto choices = read_vector<String>(m_socket);
auto anchor = read<DisplayCoord>(m_socket);
auto style = read<MenuStyle>(m_socket);
m_ui->menu_show(choices, anchor, style);
break;
auto choices = read_vector<String>(m_socket);
auto anchor = read<DisplayCoord>(m_socket);
auto style = read<MenuStyle>(m_socket);
m_ui->menu_show(choices, anchor, style);
break;
}
case RemoteUIMsg::MenuSelect:
m_ui->menu_select(read<int>(m_socket));
break;
m_ui->menu_select(read<int>(m_socket));
break;
case RemoteUIMsg::MenuHide:
m_ui->menu_hide();
break;
m_ui->menu_hide();
break;
case RemoteUIMsg::InfoShow:
{
auto choices = read<String>(m_socket);
auto anchor = read<DisplayCoord>(m_socket);
auto style = read<MenuStyle>(m_socket);
m_ui->info_show(choices, anchor, style);
break;
auto choices = read<String>(m_socket);
auto anchor = read<DisplayCoord>(m_socket);
auto style = read<MenuStyle>(m_socket);
m_ui->info_show(choices, anchor, style);
break;
}
case RemoteUIMsg::InfoHide:
m_ui->info_hide();
break;
m_ui->info_hide();
break;
case RemoteUIMsg::Draw:
{
DisplayBuffer display_buffer = read<DisplayBuffer>(m_socket);
String mode_line = read<String>(m_socket);
m_ui->draw(display_buffer, mode_line);
break;
DisplayBuffer display_buffer = read<DisplayBuffer>(m_socket);
String mode_line = read<String>(m_socket);
m_ui->draw(display_buffer, mode_line);
break;
}
}
}

View File

@ -50,7 +50,7 @@ struct Selection : public Range
{
Selection(const BufferIterator& first, const BufferIterator& last,
CaptureList captures = {})
: Range(first, last), m_captures(std::move(captures)) {}
: Range(first, last), m_captures(std::move(captures)) {}
void avoid_eol();

View File

@ -9,7 +9,7 @@ class StronglyTypedInteger
{
public:
explicit constexpr StronglyTypedInteger(ValueType value)
: m_value(value) {}
: m_value(value) {}
constexpr RealType operator+(const RealType& other) const
{ return RealType(m_value + other.m_value); }