Fix wrapping support
This commit is contained in:
parent
0dec1e3a91
commit
d86a612774
|
@ -47,6 +47,8 @@ struct DisplaySetup
|
||||||
DisplayCoord cursor_pos;
|
DisplayCoord cursor_pos;
|
||||||
// Offset of line and columns that must remain visible around cursor
|
// Offset of line and columns that must remain visible around cursor
|
||||||
DisplayCoord scroll_offset;
|
DisplayCoord scroll_offset;
|
||||||
|
// Put full lines in the initial display buffer
|
||||||
|
bool full_lines;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Highlighter
|
struct Highlighter
|
||||||
|
|
|
@ -752,6 +752,7 @@ struct WrapHighlighter : Highlighter
|
||||||
setup.cursor_pos.column += setup.window_pos.column;
|
setup.cursor_pos.column += setup.window_pos.column;
|
||||||
setup.window_pos.column = 0;
|
setup.window_pos.column = 0;
|
||||||
setup.scroll_offset.column = 0;
|
setup.scroll_offset.column = 0;
|
||||||
|
setup.full_lines = true;
|
||||||
|
|
||||||
const LineCount win_height = context.window().dimensions().line;
|
const LineCount win_height = context.window().dimensions().line;
|
||||||
LineCount win_line = 0;
|
LineCount win_line = 0;
|
||||||
|
|
|
@ -120,7 +120,10 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
|
||||||
return m_display_buffer;
|
return m_display_buffer;
|
||||||
|
|
||||||
kak_assert(&buffer() == &context.buffer());
|
kak_assert(&buffer() == &context.buffer());
|
||||||
compute_display_setup(context);
|
const DisplaySetup setup = compute_display_setup(context);
|
||||||
|
|
||||||
|
m_position = setup.window_pos;
|
||||||
|
m_range = setup.window_range;
|
||||||
|
|
||||||
const int tabstop = context.options()["tabstop"].get<int>();
|
const int tabstop = context.options()["tabstop"].get<int>();
|
||||||
for (LineCount line = 0; line < m_range.line; ++line)
|
for (LineCount line = 0; line < m_range.line; ++line)
|
||||||
|
@ -129,7 +132,10 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
|
||||||
if (buffer_line >= buffer().line_count())
|
if (buffer_line >= buffer().line_count())
|
||||||
break;
|
break;
|
||||||
auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column});
|
auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column});
|
||||||
auto end_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column});
|
auto end_byte = setup.full_lines ?
|
||||||
|
buffer()[buffer_line].length() :
|
||||||
|
get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column});
|
||||||
|
|
||||||
lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, {buffer_line, end_byte}} });
|
lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, {buffer_line, end_byte}} });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +177,7 @@ void Window::set_dimensions(DisplayCoord dimensions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::compute_display_setup(const Context& context)
|
DisplaySetup Window::compute_display_setup(const Context& context)
|
||||||
{
|
{
|
||||||
DisplayCoord offset = options()["scrolloff"].get<DisplayCoord>();
|
DisplayCoord offset = options()["scrolloff"].get<DisplayCoord>();
|
||||||
offset.line = std::min(offset.line, (m_dimensions.line + 1) / 2);
|
offset.line = std::min(offset.line, (m_dimensions.line + 1) / 2);
|
||||||
|
@ -191,7 +197,8 @@ void Window::compute_display_setup(const Context& context)
|
||||||
m_dimensions,
|
m_dimensions,
|
||||||
{cursor.line - m_position.line,
|
{cursor.line - m_position.line,
|
||||||
get_column(buffer(), tabstop, cursor) - m_position.column},
|
get_column(buffer(), tabstop, cursor) - m_position.column},
|
||||||
offset
|
offset,
|
||||||
|
false
|
||||||
};
|
};
|
||||||
for (auto pass : { HighlightPass::Move, HighlightPass::Wrap })
|
for (auto pass : { HighlightPass::Move, HighlightPass::Wrap })
|
||||||
m_highlighters.compute_display_setup(context, pass, setup);
|
m_highlighters.compute_display_setup(context, pass, setup);
|
||||||
|
@ -214,8 +221,7 @@ void Window::compute_display_setup(const Context& context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_position = setup.window_pos;
|
return setup;
|
||||||
m_range = setup.window_range;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -53,7 +53,7 @@ private:
|
||||||
Window(const Window&) = delete;
|
Window(const Window&) = delete;
|
||||||
|
|
||||||
void on_option_changed(const Option& option) override;
|
void on_option_changed(const Option& option) override;
|
||||||
void compute_display_setup(const Context& context);
|
DisplaySetup compute_display_setup(const Context& context);
|
||||||
|
|
||||||
void run_hook_in_own_context(StringView hook_name, StringView param,
|
void run_hook_in_own_context(StringView hook_name, StringView param,
|
||||||
String client_name = "");
|
String client_name = "");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user