Move hiliteMatches into a separate header
This is mostly so that we don't #include <regex> everywhere (which adds quite a bit of compilation time).
This commit is contained in:
parent
684e679e07
commit
f05e1f6fbb
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <regex>
|
|
||||||
#include "ansicolor.hh"
|
#include "ansicolor.hh"
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,15 +154,4 @@ inline hintformat hintfmt(std::string plain_string)
|
||||||
return hintfmt("%s", normaltxt(plain_string));
|
return hintfmt("%s", normaltxt(plain_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Highlight all the given matches in the given string `s` by wrapping
|
|
||||||
them between `prefix` and `postfix`.
|
|
||||||
|
|
||||||
If some matches overlap, then their union will be wrapped rather
|
|
||||||
than the individual matches. */
|
|
||||||
std::string hiliteMatches(
|
|
||||||
std::string_view s,
|
|
||||||
std::vector<std::smatch> matches,
|
|
||||||
std::string_view prefix,
|
|
||||||
std::string_view postfix);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "fmt.hh"
|
#include "hilite.hh"
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
20
src/libutil/hilite.hh
Normal file
20
src/libutil/hilite.hh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace nix {
|
||||||
|
|
||||||
|
/* Highlight all the given matches in the given string `s` by wrapping
|
||||||
|
them between `prefix` and `postfix`.
|
||||||
|
|
||||||
|
If some matches overlap, then their union will be wrapped rather
|
||||||
|
than the individual matches. */
|
||||||
|
std::string hiliteMatches(
|
||||||
|
std::string_view s,
|
||||||
|
std::vector<std::smatch> matches,
|
||||||
|
std::string_view prefix,
|
||||||
|
std::string_view postfix);
|
||||||
|
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
#include "shared.hh"
|
#include "shared.hh"
|
||||||
#include "eval-cache.hh"
|
#include "eval-cache.hh"
|
||||||
#include "attr-path.hh"
|
#include "attr-path.hh"
|
||||||
#include "fmt.hh"
|
#include "hilite.hh"
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
Loading…
Reference in a new issue