kdesc --typeface from the reflection klammerset; a missing font directory is a row, not an error
Assembled from klammertext-dev daad6273483a. The font-store listing is rendered from ref/ (one table per search directory, in search order, with the styles each typeface holds); the search path is described, not validated, so a KLAMMERTEXT_FONTS directory that does not exist -- the default ~/.klammertext/fonts on a fresh install -- is a row saying so and the command exits 0. A typeface an earlier directory also holds is marked shadowed, with the winning directory, in a column present only when needed. The store's layout convention has one reader, fonts_in_directory(). Six kdesc suite cases pin the listing.
This commit is contained in:
1 parent
c016b3e5f3
commit
f9af1ff869
7 files changed
+188
-103
No files matched your search
+31
-25
@@ -122,31 +122,6 @@ static void klammerset_command(Machine& machine, const strings_t& words)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void font_command(const strings_t& words)
|
||||
{
|
||||
std::string verb = words.empty() ? "list" : words[0];
|
||||
size_t n = words.size() - (words.empty() ? 0 : 1);
|
||||
if (verb == "list" && n == 0) {
|
||||
std::cout << boldblack << "Fonts\n" << black << describe_fonts();
|
||||
} else if (verb == "samples" && n == 1) {
|
||||
std::cout << "Font samples written to "
|
||||
<< write_font_samples(words[1]) << "\n";
|
||||
} else if (verb == "samples" && n == 2) {
|
||||
std::cout << "Font samples written to "
|
||||
<< write_font_samples(words[2], words[1]) << "\n";
|
||||
} else if (verb == "install" && (n == 1 || n == 2)) {
|
||||
std::cout << "Installing fonts from " << words[1] << ":\n"
|
||||
<< install_fonts(words[1], n == 2 ? words[2] : "");
|
||||
} else if (verb == "help") {
|
||||
font_usage();
|
||||
} else {
|
||||
std::cout << "Unrecognized typeface command: --typeface " << join(words, " ")
|
||||
<< "\n\n";
|
||||
font_usage();
|
||||
}
|
||||
}
|
||||
|
||||
// The target for the Klammertext kdesc renders for its own output: the
|
||||
// ansi target (plain text with type styles as escape sequences) when
|
||||
// stdout is a terminal, the txt target otherwise. The COMMAND decides,
|
||||
@@ -166,6 +141,37 @@ static Machine ref_machine()
|
||||
return M;
|
||||
}
|
||||
|
||||
void show_fonts()
|
||||
{
|
||||
Machine M = ref_machine();
|
||||
M.read_string("@klammertext_fonts@");
|
||||
std::cout << "\n" << M.apply(text_target()) << "\n\n";
|
||||
}
|
||||
|
||||
static void font_command(const strings_t& words)
|
||||
{
|
||||
std::string verb = words.empty() ? "list" : words[0];
|
||||
size_t n = words.size() - (words.empty() ? 0 : 1);
|
||||
if (verb == "list" && n == 0) {
|
||||
show_fonts();
|
||||
} else if (verb == "samples" && n == 1) {
|
||||
std::cout << "Font samples written to "
|
||||
<< write_font_samples(words[1]) << "\n";
|
||||
} else if (verb == "samples" && n == 2) {
|
||||
std::cout << "Font samples written to "
|
||||
<< write_font_samples(words[2], words[1]) << "\n";
|
||||
} else if (verb == "install" && (n == 1 || n == 2)) {
|
||||
std::cout << "Installing fonts from " << words[1] << ":\n"
|
||||
<< install_fonts(words[1], n == 2 ? words[2] : "");
|
||||
} else if (verb == "help") {
|
||||
font_usage();
|
||||
} else {
|
||||
std::cout << "Unrecognized typeface command: --typeface " << join(words, " ")
|
||||
<< "\n\n";
|
||||
font_usage();
|
||||
}
|
||||
}
|
||||
|
||||
void show_special_characters()
|
||||
{
|
||||
Machine M = ref_machine();
|
||||
|
||||
Reference in new issue
Block a user