Initial commit: Klammertext source distribution
Curated source subset assembled by klammertext-dev's doc/make_dist.sh: the Klammermachine (mac), the Standard Klammer Set (sks), the commands (com), editor plugins and install guides (doc), a test subset (tst), and lib/bin placeholders. Builds with 'make -C com'. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
52
mac/locator.h
Normal file
52
mac/locator.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
// #include <filesystem>
|
||||
#include <source_location>
|
||||
#include <map>
|
||||
|
||||
#include "file.h"
|
||||
|
||||
inline std::string klammertext_home_var = "KLAMMERTEXT_HOME";
|
||||
|
||||
class Locator
|
||||
{
|
||||
public:
|
||||
explicit Locator(const std::source_location location =
|
||||
std::source_location::current())
|
||||
// std::source_location::file_name() can return nullptr on some
|
||||
// toolchains (e.g. Homebrew GCC on macOS); guard against
|
||||
// fs::path(nullptr) -> strlen(NULL).
|
||||
: m_filename(location.file_name()
|
||||
? fs::absolute(location.file_name()) : fs::path{})
|
||||
, m_line(int(location.line()))
|
||||
, m_chr(int(location.column()))
|
||||
{};
|
||||
Locator(fs::path filename, int line, int chr);
|
||||
std::string str(bool relative = false) const;
|
||||
std::string desc(bool relative = false) const;
|
||||
std::string abbrev(bool include_chr=true) const;
|
||||
|
||||
std::string m_filename {};
|
||||
int m_line;
|
||||
int m_chr;
|
||||
//std::string m_desc {};
|
||||
};
|
||||
|
||||
std::ostream &nformat(std::ostream &os);
|
||||
|
||||
std::string locator_range(
|
||||
const Locator& start_loc, const Locator& end_loc,
|
||||
std::map<std::string, std::string>& relpath);
|
||||
|
||||
Locator current_locator(
|
||||
const std::source_location location = std::source_location::current());
|
||||
|
||||
std::string locator_summary(std::vector<Locator> locators);
|
||||
|
||||
inline
|
||||
std::string showloc(Locator loc=Locator()) {
|
||||
return loc.abbrev(false) + " ";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user