From 6b339b7a97692efb53af42650f570242e38ab008 Mon Sep 17 00:00:00 2001 From: Delapouite Date: Wed, 27 Sep 2017 17:26:39 +0200 Subject: [PATCH] Add status info when navigating through jumplist (, ) --- src/context.cc | 15 +++++++++++++-- src/context.hh | 4 ++-- src/normal.cc | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/context.cc b/src/context.cc index 3963254d..e3e20e0c 100644 --- a/src/context.cc +++ b/src/context.cc @@ -2,6 +2,7 @@ #include "alias_registry.hh" #include "client.hh" +#include "face_registry.hh" #include "register_manager.hh" #include "window.hh" @@ -85,26 +86,33 @@ void JumpList::push(SelectionList jump) m_current = m_jumps.size(); } -const SelectionList& JumpList::forward() +const SelectionList& JumpList::forward(Context& context) { if (m_current != m_jumps.size() and m_current + 1 != m_jumps.size()) { SelectionList& res = m_jumps[++m_current]; res.update(); + context.print_status({ format("jumped to #{} ({})", + m_current, m_jumps.size() - 1), + get_face("Information") }); return res; } throw runtime_error("no next jump"); } -const SelectionList& JumpList::backward(const SelectionList& current) +const SelectionList& JumpList::backward(Context& context) { + const SelectionList& current = context.selections(); if (m_current != m_jumps.size() and m_jumps[m_current] != current) { push(current); SelectionList& res = m_jumps[--m_current]; res.update(); + context.print_status({ format("jumped to #{} ({})", + m_current, m_jumps.size() - 1), + get_face("Information") }); return res; } if (m_current != 0) @@ -117,6 +125,9 @@ const SelectionList& JumpList::backward(const SelectionList& current) } SelectionList& res = m_jumps[--m_current]; res.update(); + context.print_status({ format("jumped to #{} ({})", + m_current, m_jumps.size() - 1), + get_face("Information") }); return res; } throw runtime_error("no previous jump"); diff --git a/src/context.hh b/src/context.hh index fb7996f6..6c2a4641 100644 --- a/src/context.hh +++ b/src/context.hh @@ -20,8 +20,8 @@ class AliasRegistry; struct JumpList { void push(SelectionList jump); - const SelectionList& forward(); - const SelectionList& backward(const SelectionList& current); + const SelectionList& forward(Context& context); + const SelectionList& backward(Context& context); void forget_buffer(Buffer& buffer); friend bool operator==(const JumpList& lhs, const JumpList& rhs) diff --git a/src/normal.cc b/src/normal.cc index 0a82d4d4..6f1103ae 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1399,8 +1399,8 @@ template void jump(Context& context, NormalParams) { auto jump = (direction == Forward) ? - context.jump_list().forward() : - context.jump_list().backward(context.selections()); + context.jump_list().forward(context) : + context.jump_list().backward(context); Buffer* oldbuf = &context.buffer(); Buffer& buffer = const_cast(jump.buffer());