summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-09 16:00:22 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-09 16:00:22 +0100
commitd86a61277490644da752c17865693297d44680aa (patch)
tree3733cbf0ac37474d6d75699510c30e5904dc6c2f /src
parent0dec1e3a91ffeaa82989c452089488c4e53130ef (diff)
Fix wrapping support
Diffstat (limited to 'src')
-rw-r--r--src/highlighter.hh2
-rw-r--r--src/highlighters.cc1
-rw-r--r--src/window.cc18
-rw-r--r--src/window.hh2
4 files changed, 16 insertions, 7 deletions
diff --git a/src/highlighter.hh b/src/highlighter.hh
index f6159df6..0b804a8d 100644
--- a/src/highlighter.hh
+++ b/src/highlighter.hh
@@ -47,6 +47,8 @@ struct DisplaySetup
DisplayCoord cursor_pos;
// Offset of line and columns that must remain visible around cursor
DisplayCoord scroll_offset;
+ // Put full lines in the initial display buffer
+ bool full_lines;
};
struct Highlighter
diff --git a/src/highlighters.cc b/src/highlighters.cc
index daa83158..49cd425f 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -752,6 +752,7 @@ struct WrapHighlighter : Highlighter
setup.cursor_pos.column += setup.window_pos.column;
setup.window_pos.column = 0;
setup.scroll_offset.column = 0;
+ setup.full_lines = true;
const LineCount win_height = context.window().dimensions().line;
LineCount win_line = 0;
diff --git a/src/window.cc b/src/window.cc
index 26cf3021..5b75c147 100644
--- a/src/window.cc
+++ b/src/window.cc
@@ -120,7 +120,10 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
return m_display_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>();
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())
break;
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}} });
}
@@ -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>();
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,
{cursor.line - m_position.line,
get_column(buffer(), tabstop, cursor) - m_position.column},
- offset
+ offset,
+ false
};
for (auto pass : { HighlightPass::Move, HighlightPass::Wrap })
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;
- m_range = setup.window_range;
+ return setup;
}
namespace
diff --git a/src/window.hh b/src/window.hh
index 2bd78356..1c217dce 100644
--- a/src/window.hh
+++ b/src/window.hh
@@ -53,7 +53,7 @@ private:
Window(const Window&) = delete;
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,
String client_name = "");