From f73831668980e13c637570bf9827061558132e1f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 19 Sep 2014 13:45:11 +0100 Subject: [PATCH] small refactor in highlighters --- src/highlighters.cc | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index 30214c2f..310ab223 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -163,27 +163,22 @@ auto apply_face = [](const Face& face) using FacesSpec = std::vector; -struct Fill -{ - Fill(String facespec) : m_facespec(facespec) {} - - void operator()(const Context& context, HighlightFlags flags, - DisplayBuffer& display_buffer) - { - auto range = display_buffer.range(); - highlight_range(display_buffer, range.first, range.second, true, - apply_face(get_face(m_facespec))); - } - - String m_facespec; -}; - HighlighterAndId fill_factory(HighlighterParameters params) { if (params.size() != 1) throw runtime_error("wrong parameter count"); - get_face(params[0]); // validate param - return HighlighterAndId("fill_" + params[0], Fill(params[0])); + + const String& facespec = params[0]; + get_face(facespec); // validate param + + auto fill = [facespec](const Context& context, HighlightFlags flags, + DisplayBuffer& display_buffer) + { + auto range = display_buffer.range(); + highlight_range(display_buffer, range.first, range.second, true, + apply_face(get_face(facespec))); + }; + return HighlighterAndId("fill_" + params[0], fill); } template