avoid literal eol in status lines, replace them with another symbol
This commit is contained in:
parent
24234dffa3
commit
1709886873
|
@ -96,7 +96,7 @@ bool Client::process_pending_inputs()
|
||||||
catch (Kakoune::runtime_error& error)
|
catch (Kakoune::runtime_error& error)
|
||||||
{
|
{
|
||||||
write_to_debug_buffer(format("Error: {}", error.what()));
|
write_to_debug_buffer(format("Error: {}", error.what()));
|
||||||
context().print_status({ error.what().str(), get_face("Error") });
|
context().print_status({ fix_atom_text(error.what().str()), get_face("Error") });
|
||||||
context().hooks().run_hook("RuntimeError", error.what(), context());
|
context().hooks().run_hook("RuntimeError", error.what(), context());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ Client* ClientManager::create_client(std::unique_ptr<UserInterface>&& ui, int pi
|
||||||
}
|
}
|
||||||
catch (Kakoune::runtime_error& error)
|
catch (Kakoune::runtime_error& error)
|
||||||
{
|
{
|
||||||
client->context().print_status({ error.what().str(), get_face("Error") });
|
client->context().print_status({ fix_atom_text(error.what().str()), get_face("Error") });
|
||||||
client->context().hooks().run_hook("RuntimeError", error.what(),
|
client->context().hooks().run_hook("RuntimeError", error.what(),
|
||||||
client->context());
|
client->context());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1101,7 +1101,7 @@ const CommandDesc echo_cmd = {
|
||||||
CommandCompleter{},
|
CommandCompleter{},
|
||||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||||
{
|
{
|
||||||
String message = join(parser, ' ', false);
|
String message = fix_atom_text(join(parser, ' ', false));
|
||||||
if (parser.get_switch("debug"))
|
if (parser.get_switch("debug"))
|
||||||
write_to_debug_buffer(message);
|
write_to_debug_buffer(message);
|
||||||
else if (parser.get_switch("markup"))
|
else if (parser.get_switch("markup"))
|
||||||
|
|
|
@ -303,4 +303,22 @@ DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLin
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fix_atom_text(StringView str)
|
||||||
|
{
|
||||||
|
String res;
|
||||||
|
auto pos = str.begin();
|
||||||
|
for (auto it = str.begin(), end = str.end(); it != end; ++it)
|
||||||
|
{
|
||||||
|
char c = *it;
|
||||||
|
if (c == '\n' or c == '\r')
|
||||||
|
{
|
||||||
|
res += StringView{pos, it};
|
||||||
|
res += c == '\n' ? "" : "␍";
|
||||||
|
pos = it+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res += StringView{pos, str.end()};
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ private:
|
||||||
AtomList m_atoms;
|
AtomList m_atoms;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
String fix_atom_text(StringView str);
|
||||||
DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLine>& builtins = {});
|
DisplayLine parse_display_line(StringView line, const HashMap<String, DisplayLine>& builtins = {});
|
||||||
|
|
||||||
class DisplayBuffer : public UseMemoryDomain<MemoryDomain::Display>
|
class DisplayBuffer : public UseMemoryDomain<MemoryDomain::Display>
|
||||||
|
|
|
@ -500,23 +500,6 @@ public:
|
||||||
|
|
||||||
DisplayLine build_display_line(ColumnCount in_width)
|
DisplayLine build_display_line(ColumnCount in_width)
|
||||||
{
|
{
|
||||||
auto cleanup = [](StringView str) {
|
|
||||||
String res;
|
|
||||||
auto pos = str.begin();
|
|
||||||
for (auto it = str.begin(), end = str.end(); it != end; ++it)
|
|
||||||
{
|
|
||||||
char c = *it;
|
|
||||||
if (c == '\n' or c == '\r')
|
|
||||||
{
|
|
||||||
res += StringView{pos, it};
|
|
||||||
res += c == '\n' ? "" : "␍";
|
|
||||||
pos = it+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res += StringView{pos, str.end()};
|
|
||||||
return res;
|
|
||||||
};
|
|
||||||
|
|
||||||
CharCount width = (int)in_width; // Todo: proper handling of char/column
|
CharCount width = (int)in_width; // Todo: proper handling of char/column
|
||||||
kak_assert(m_cursor_pos <= m_line.char_length());
|
kak_assert(m_cursor_pos <= m_line.char_length());
|
||||||
if (m_cursor_pos < m_display_pos)
|
if (m_cursor_pos < m_display_pos)
|
||||||
|
@ -525,12 +508,12 @@ public:
|
||||||
m_display_pos = m_cursor_pos + 1 - width;
|
m_display_pos = m_cursor_pos + 1 - width;
|
||||||
|
|
||||||
if (m_cursor_pos == m_line.char_length())
|
if (m_cursor_pos == m_line.char_length())
|
||||||
return DisplayLine{{ { cleanup(m_line.substr(m_display_pos, width-1)), get_face("StatusLine") },
|
return DisplayLine{{ { fix_atom_text(m_line.substr(m_display_pos, width-1)), get_face("StatusLine") },
|
||||||
{ " "_str, get_face("StatusCursor")} } };
|
{ " "_str, get_face("StatusCursor")} } };
|
||||||
else
|
else
|
||||||
return DisplayLine({ { cleanup(m_line.substr(m_display_pos, m_cursor_pos - m_display_pos)), get_face("StatusLine") },
|
return DisplayLine({ { fix_atom_text(m_line.substr(m_display_pos, m_cursor_pos - m_display_pos)), get_face("StatusLine") },
|
||||||
{ cleanup(m_line.substr(m_cursor_pos,1)), get_face("StatusCursor") },
|
{ fix_atom_text(m_line.substr(m_cursor_pos,1)), get_face("StatusCursor") },
|
||||||
{ cleanup(m_line.substr(m_cursor_pos+1, width - m_cursor_pos + m_display_pos - 1)), get_face("StatusLine") } });
|
{ fix_atom_text(m_line.substr(m_cursor_pos+1, width - m_cursor_pos + m_display_pos - 1)), get_face("StatusLine") } });
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
CharCount m_cursor_pos = 0;
|
CharCount m_cursor_pos = 0;
|
||||||
|
|
|
@ -842,7 +842,7 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
|
||||||
const char reg = to_lower(params.reg ? params.reg : '/');
|
const char reg = to_lower(params.reg ? params.reg : '/');
|
||||||
|
|
||||||
context.print_status({
|
context.print_status({
|
||||||
format("register '{}' set to '{}'", reg, patterns[sels.main_index()]),
|
format("register '{}' set to '{}'", reg, fix_atom_text(patterns[sels.main_index()])),
|
||||||
get_face("Information") });
|
get_face("Information") });
|
||||||
|
|
||||||
RegisterManager::instance()[reg].set(context, patterns);
|
RegisterManager::instance()[reg].set(context, patterns);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user