A run of Unicode code points now needs one pair of carets, not one pair
each: ^9053 53EF 9053^ renders the characters adjacently, and a single
character inside such a run stands for itself. An invalid code point is
an error naming the position that wrote it, rather than an apology
rendered into the finished document; noncharacters are refused alongside
surrogates; and a code point that lands on a Klammertext special is safe
through the re-reads that assemble a document. The character tables now
produce the precomposed form, so a diacritic written as ^a" and one typed
directly are the same text to a search or a copy-paste.
"kdesc -u" describes how to write a Unicode character, with tables of
glyphs beside the codes that produce them. It is new and not yet
complete: it predates the sequence form and the typeface klammer below.
A typeface and a style are no longer both called "font". A typeface is a
family resolved by name; a style code is the one letter naming a type
style. So @document takes :serif_typeface and its siblings, a table takes
:style, captions take :caption_style and :caption_size, the uniform scale
is :text_scale, and the command is "kdesc --typeface". This renames
arguments a document may already use; an old name is a located error
rather than a silent omission.
@typeface sets a passage in another typeface for the length of that
passage:
@typeface Noto Sans Egyptian Hieroglyphs | ^132AA 133CF^ :scale 1.5 @
Writing the klammer is the whole declaration -- the document resolves the
typeface, embeds it in what it produces, and carries its license along.
Two typefaces for scripts no text font covers now ship with Klammertext:
Noto Sans Egyptian Hieroglyphs and Noto Sans Cuneiform. Every typeface in
the distribution now carries its license file.
(from dev 61e598698891)
68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
#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(const fs::path& filename, int line, int chr);
|
|
// "No location": for errors with no document position -- command-line
|
|
// argument errors, lookups made on the command's behalf. NOT the same
|
|
// as Locator(): the default constructor captures the C++ CALL SITE via
|
|
// std::source_location (and a defaulted Locator parameter captures the
|
|
// CALLER), which is what leaked "argv.cpp, line 597" into user-facing
|
|
// errors (found by the error gallery, 2026-08-22). Locator() is for
|
|
// logging; errors either carry a real document location or this.
|
|
static Locator none() { return Locator(fs::path{}, -1, -1); }
|
|
// The inverse of str(): "[<file>:<line>.<column>]" back to a Locator.
|
|
// A klammer implementation receives its position as the STATE value
|
|
// K_loc, which is that string; without this it can only pass a
|
|
// default-constructed Locator, which captures the C++ source location
|
|
// and prints a file no user can act on. Anything unparseable gives
|
|
// none() -- a missing location beats a wrong one.
|
|
static Locator from_string(const std::string& s);
|
|
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) + " ";
|
|
}
|
|
|