diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-01-12 17:42:44 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-01-12 17:42:44 +0300 |
commit | 0fbed9a95255c9a6ade511bf3c12286f4450fa90 (patch) | |
tree | 33d506f22df736c1197b4354d9b8be28baf37b3a | |
parent | 03777f5be657dcaa8fe379f2e1a39d1c2db04d00 (diff) | |
download | openrussian-cli-0fbed9a95255c9a6ade511bf3c12286f4450fa90.tar.gz |
support FreeBSD
* Instead of relying on `man -`, we call Groff directly.
* Naturally, we must depend on Groff as well.
* man-db is not available on FreeBSD
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 17 | ||||
-rwxr-xr-x | openrussian.lua | 9 |
3 files changed, 26 insertions, 2 deletions
@@ -47,7 +47,7 @@ install : openrussian openrussian-sqlite3.db \ cp openrussian-completion.bash $(DESTDIR)$(COMPLETIONSDIR)/openrussian mkdir -p $(DESTDIR)$(PREFIX)/man/man1 cp openrussian.1 $(DESTDIR)$(PREFIX)/man/man1 - mandb + mandb || true clean: $(RM) openrussian openrussian-sqlite3.db @@ -36,6 +36,8 @@ Possible future features: * Be tolerant to typing mistakes. * Accented characters are still broken in nroff tables (see https://lists.gnu.org/archive/html/groff/2018-08/msg00000.html). + We could and probably should of translate most vowel-accent combinations to single precomposed codepoints, + but that might cause problems when copying text from the terminal. ## Installation @@ -72,6 +74,21 @@ If it returns lots of errors, you should probably stay with the original databas Otherwise, the error messages might help in fixing/upgrading the script. You are of course welcome to contribute patches. :-) +### FreeBSD + +Build-time dependencies: + + pkg install gmake pkgconf groff lua52 lua52-luasql-sqlite3 lua52-luarocks wget sqlite3 + +Installing [luautf8](https://github.com/starwing/luautf8) using LuaRocks: + + luarocks52 install luautf8 + +Building is straight forward: + + gmake LUA=lua52 LUAC=luac52 + gmake install + ### NixOS `openrussian-cli` is part of the `nixos-unstable` (and soon `nixos-21.05`) channels. diff --git a/openrussian.lua b/openrussian.lua index 961efdc..6ee5628 100755 --- a/openrussian.lua +++ b/openrussian.lua @@ -600,7 +600,14 @@ end -- Open stream only now, after no more messages have to be written to -- stdout/stderr. -out_stream = assert(use_stdout and io.stdout or io.popen("man /dev/stdin", "w")) +if use_stdout then + out_stream = io.stdout +else + local size_stream = io.popen("stty size") + local columns = size_stream and size_stream:read("*a"):match("%d+ (%d+)") or 80 + out_stream = io.popen("nroff -Kutf8 -Tutf8 -t -man -rLL="..columns.."n -rLT="..columns.."n | less -r", "w") +end +assert(out_stream) -- NOTE: The headers and footers shouldn't contain critical information -- since they might not be printed at all. |