1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-26 04:52:53 +03:00

Filters: code cleanup

This commit is contained in:
Maxime Coste 2011-11-09 14:06:05 +00:00
parent 9f66354948
commit 55c092eed9
3 changed files with 9 additions and 14 deletions

View File

@ -1,6 +1,8 @@
#include "filters.hh" #include "filters.hh"
#include "display_buffer.hh"
#include "filter_registry.hh" #include "filter_registry.hh"
#include <boost/regex.hpp>
namespace Kakoune namespace Kakoune
{ {
@ -149,6 +151,7 @@ void register_filters()
{ {
FilterRegistry& registry = FilterRegistry::instance(); FilterRegistry& registry = FilterRegistry::instance();
registry.register_factory("expand_tabs", SimpleFilterFactory<expand_tabulations>("expand_tabs"));
registry.register_factory("line_numbers", SimpleFilterFactory<show_line_numbers>("line_numbers")); registry.register_factory("line_numbers", SimpleFilterFactory<show_line_numbers>("line_numbers"));
registry.register_factory("hlcpp", SimpleFilterFactory<colorize_cplusplus>("hlcpp")); registry.register_factory("hlcpp", SimpleFilterFactory<colorize_cplusplus>("hlcpp"));
} }

View File

@ -1,20 +1,9 @@
#ifndef filters_hh_INCLUDED #ifndef filters_hh_INCLUDED
#define filters_hh_INCLUDED #define filters_hh_INCLUDED
#include <boost/regex.hpp>
#include "display_buffer.hh"
namespace Kakoune namespace Kakoune
{ {
void colorize_regex(DisplayBuffer& display_buffer,
const boost::regex& ex, Color color);
void colorize_cplusplus(DisplayBuffer& display_buffer);
void colorize_cplusplus(DisplayBuffer& display_buffer);
void expand_tabulations(DisplayBuffer& display_buffer);
void show_line_numbers(DisplayBuffer& display_buffer);
void register_filters(); void register_filters();
} }

View File

@ -1,7 +1,7 @@
#include "window.hh" #include "window.hh"
#include "assert.hh" #include "assert.hh"
#include "filters.hh" #include "filter_registry.hh"
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
@ -114,8 +114,11 @@ Window::Window(Buffer& buffer)
m_current_inserter(nullptr) m_current_inserter(nullptr)
{ {
m_selections.push_back(Selection(buffer.begin(), buffer.begin())); m_selections.push_back(Selection(buffer.begin(), buffer.begin()));
m_filters.push_back(FilterAndId("show_tabs", expand_tabulations));
m_filters.push_back(FilterAndId("show_selection", HighlightSelections(*this))); FilterRegistry& registry = FilterRegistry::instance();
add_filter(registry.get_filter("expand_tabs", FilterParameters()));
add_filter(FilterAndId("show_selections", HighlightSelections(*this)));
add_filter(registry.get_filter("hlcpp", FilterParameters()));
} }
void Window::check_invariant() const void Window::check_invariant() const