Windows: product names, the editors, WSL; the Linux page's image step

Assembled from development commit c3c40f6c8fca. Since 830b193: on Windows the
products carry Windows names (ktext.exe, klammertext.dll, document.dll,
reflect.dll) and the console's output code page is UTF-8 for a run; the
editor tooling works on Windows (VS Code, Sublime Text, Vim, with the
interpreter's name chosen by platform) and Notepad++ joins it
(doc/edit/notepadpp: a User Defined Language and two Run-menu commands);
a sixth install page, doc/install/windows_wsl_install.md, for Linux
inside WSL; the Windows page opens with the three routes and gains its
editor section, the PowerShell quoting and Path notes; the Linux page
installs OpenImageIO from the python3-openimageio package and verifies
with kdiag --machine; the README lists all six install pages. Linux and
macOS behaviour is unchanged.
This commit is contained in:
ack committed 2026-09-25 18:43:22 +02:00
1 parent 830b19394d
commit ee8bcf5300
33 files changed
+741 -122

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ DEPFILES := $(addsuffix .d,$(BASENAMES))
# Shared library
LIBDIR := ../lib
LIBRARY := $(LIBDIR)/libklammertext.so
LIBRARY := $(LIBDIR)/$(KLAMMERTEXT_LIBFILE)
# Compiler flags for dependency generation
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
+31
View File
@@ -1,7 +1,11 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <fcntl.h>
#include <io.h>
#endif
#include <cstdlib>
#include <tuple>
#include "argv.h"
@@ -39,6 +43,26 @@ void set_verbose_level(int argc, char* argv[])
// byte. The C runtime's text mode would append it to every line.
_setmode(_fileno(stdout), _O_BINARY);
_setmode(_fileno(stderr), _O_BINARY);
// A console decodes what a program writes in the CONSOLE's output code
// page, which on a localized Windows is an OEM page (850 on a German one)
// and never UTF-8, whatever the process's own code page (the manifest
// makes that UTF-8). The commands write UTF-8 -- kdesc --katoms's
// ⟨name⟩, an error report's ⟨katom⟩ -- so a console showed three cp850
// characters per symbol while a file or a pipe received the right bytes
// (which is why no suite saw it; Andy did, 2026-09-25). Switch the
// console to UTF-8 while a command runs, when a stream is a console, and
// put it back at exit: the page belongs to the console, not the process,
// and would outlive it.
static UINT console_output_cp = 0;
static UINT console_output_cp_now = 0;
if (_isatty(_fileno(stdout)) || _isatty(_fileno(stderr))) {
console_output_cp = GetConsoleOutputCP();
if (console_output_cp != 0 && console_output_cp != CP_UTF8) {
SetConsoleOutputCP(CP_UTF8);
console_output_cp_now = GetConsoleOutputCP();
std::atexit([] { SetConsoleOutputCP(console_output_cp); });
}
}
#endif
//command_name = absolute_pathname(argv[0]);
command_name = fs::path(argv[0]).generic_string();
@@ -49,6 +73,13 @@ void set_verbose_level(int argc, char* argv[])
args.opt("v", "'verbosity'", "level", "0", "'verbosity'");
args.parse(argc, argv, false);
verbose_level = args.as_verbosity("v");
#ifdef _WIN32
if (console_output_cp != 0 && console_output_cp != CP_UTF8) {
K::log(1, "Console output code page set to UTF-8 for this run (was "
+ std::to_string(console_output_cp) + ", now "
+ std::to_string(console_output_cp_now) + ")");
}
#endif
}
bool show_usage(int argc, char* argv[])
+1 -1
View File
@@ -320,7 +320,7 @@ std::string Eval::eval_command(katom_iter begin, katom_iter end)
if (!khome.empty()) {
lib_text = string_replace(lib_text, "*KLAMMERTEXT_HOME*", khome);
}
fs::path libpath(lib_text + ".so");
fs::path libpath(lib_text + shared_library_suffix);
// A relative library name not found from the cwd is searched in the
// directories of the files the Machine has read (same rule as the
// Python module path: the library lives next to the file using it).
+6 -3
View File
@@ -72,14 +72,17 @@ size_t count_substrings(const std::string& text, const std::string& substring) {
std::string home_directory()
{
if (const char* home = std::getenv("HOME"); home && *home) {
return home;
}
#ifdef _WIN32
// USERPROFILE first: an MSYS2 shell may set HOME to its own /home/<user>
// (C:\msys64\home\<user>), and a Windows user's ~/.klammertext must be
// the same directory from PowerShell and from that shell.
if (const char* profile = std::getenv("USERPROFILE"); profile && *profile) {
return profile;
}
#endif
if (const char* home = std::getenv("HOME"); home && *home) {
return home;
}
return {};
}
+11 -3
View File
@@ -25,9 +25,17 @@ constexpr char path_list_separator = ';';
#else
constexpr char path_list_separator = ':';
#endif
// The user's home directory as the system names it: HOME, and on Windows
// USERPROFILE when HOME is unset (a plain PowerShell or cmd sets no HOME;
// an MSYS2 shell does). Empty when neither is set.
// The suffix of a shared library loaded at run time (the library a
// "@eval :cpp" names): ".dll" on Windows, ".so" everywhere else -- the same
// choice makefile.env's DSO makes when it builds one.
#ifdef _WIN32
constexpr const char* shared_library_suffix = ".dll";
#else
constexpr const char* shared_library_suffix = ".so";
#endif
// The user's home directory as the system names it: HOME; on Windows
// USERPROFILE first, so the directory is the same from PowerShell (no HOME)
// and from an MSYS2 shell (which may set HOME to its own /home/<user>).
std::string home_directory();
// The first PROGRAM on PATH (split on path_list_separator; on Windows the
// name also tried with ".exe"), or "" when none: what "which" answers, without