Remove implicit conversion from String to DisplayAtom/DisplayLine

This commit is contained in:
Maxime Coste 2018-04-29 20:33:47 +10:00
parent cbb91bcaed
commit 2fa553e728
5 changed files with 15 additions and 16 deletions

View File

@ -37,7 +37,7 @@ public:
DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end)
: m_type(Range), m_buffer(&buffer), m_range{begin, end} {}
DisplayAtom(String str, Face face = Face{})
DisplayAtom(String str, Face face)
: m_type(Text), m_text(std::move(str)), face(face) {}
StringView content() const;
@ -104,7 +104,7 @@ public:
DisplayLine() = default;
DisplayLine(AtomList atoms);
DisplayLine(String str, Face face = Face{})
DisplayLine(String str, Face face)
{ push_back({ std::move(str), face }); }
iterator begin() { return m_atoms.begin(); }

View File

@ -628,7 +628,7 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params)
continue;
if (target_col > 0)
line.push_back({String{' ', target_col}});
line.push_back({String{' ', target_col}, {}});
line.push_back({" ", face});
}
};

View File

@ -179,12 +179,12 @@ InsertCompletion complete_word(const SelectionList& sels,
if (other_buffers && m.buffer)
{
const auto pad_len = longest + 1 - m.candidate().char_length();
menu_entry.push_back(m.candidate().str());
menu_entry.push_back(String{' ', pad_len});
menu_entry.push_back({ m.candidate().str(), {} });
menu_entry.push_back({ String{' ', pad_len}, {} });
menu_entry.push_back({ m.buffer->display_name(), faces["MenuInfo"] });
}
else
menu_entry.push_back(m.candidate().str());
menu_entry.push_back({ m.candidate().str(), {} });
candidates.push_back({m.candidate().str(), "", std::move(menu_entry)});
return true;
@ -226,7 +226,7 @@ InsertCompletion complete_filename(const SelectionList& sels,
{
for (auto& filename : Kakoune::complete_filename(prefix,
options["ignored_files"].get<Regex>()))
candidates.push_back({ filename, "", filename });
candidates.push_back({ filename, "", {filename, {}} });
}
else
{
@ -246,7 +246,7 @@ InsertCompletion complete_filename(const SelectionList& sels,
options["ignored_files"].get<Regex>()))
{
StringView candidate = filename.substr(dir.length());
candidates.push_back({ candidate.str(), "", candidate.str() });
candidates.push_back({ candidate.str(), "", {candidate.str(), {}} });
}
visited_dirs.push_back(std::move(dir));
@ -316,7 +316,7 @@ InsertCompletion complete_option(const SelectionList& sels,
auto& menu = std::get<2>(candidate);
match.menu_entry = not menu.empty() ?
parse_display_line(expand_tabs(menu, tabstop, column), faces)
: DisplayLine{ expand_tabs(menu, tabstop, column) };
: DisplayLine{ expand_tabs(menu, tabstop, column), {} };
matches.push_back(std::move(match));
}
@ -368,7 +368,7 @@ InsertCompletion complete_line(const SelectionList& sels,
{
StringView candidate = line.substr(0_byte, line.length()-1);
candidates.push_back({candidate.str(), "",
expand_tabs(candidate, tabstop, column)});
{expand_tabs(candidate, tabstop, column), {}}});
// perf: it's unlikely the user intends to search among >10 candidates anyway
if (candidates.size() == 100)
break;

View File

@ -382,7 +382,7 @@ void NCursesUI::draw_line(NCursesWin* window, const DisplayLine& line,
}
}
static const DisplayLine empty_line = String(" ");
static const DisplayLine empty_line = { String(" "), {} };
void NCursesUI::draw(const DisplayBuffer& display_buffer,
const Face& default_face,
@ -438,7 +438,7 @@ void NCursesUI::draw_status(const DisplayLine& status_line,
{
DisplayLine trimmed_mode_line = mode_line;
trimmed_mode_line.trim(mode_len + 2 - remaining, remaining - 2);
trimmed_mode_line.insert(trimmed_mode_line.begin(), { "" });
trimmed_mode_line.insert(trimmed_mode_line.begin(), { "", {} });
kak_assert(trimmed_mode_line.length() == remaining - 1);
ColumnCount col = m_dimensions.column - remaining + 1;

View File

@ -290,15 +290,14 @@ Color MsgReader::read<Color>()
template<>
DisplayAtom MsgReader::read<DisplayAtom>()
{
DisplayAtom atom(read<String>());
atom.face = read<Face>();
return atom;
String content = read<String>();
return {std::move(content), read<Face>()};
}
template<>
DisplayLine MsgReader::read<DisplayLine>()
{
return DisplayLine(read_vector<DisplayAtom>());
return {read_vector<DisplayAtom>()};
}
template<>