78 Commits
Author SHA1 Message Date
p 5b8335654f Bump version, update NEWS
Arch Linux AUR Success
OpenBSD 7.8 Success
Alpine 3.24 Success
2026-07-31 02:23:48 +02:00
p 2a0ce32bdd CMakeLists.txt: rename option to match README.adoc 2026-07-31 02:13:38 +02:00
p 13e1b220ff Miscellaneous fixes
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-31 01:55:17 +02:00
p 8827d1d473 xF: render formatting
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-30 23:29:07 +02:00
p 70fa559752 xF: finish the frontend using liberty-xui
This has long been the missing piece in our frontend collection.

After including the termo library in a recent rewrite, we've kind of
received an option to use liberty-xui, the terminal/X11/AppKit library
spawned off from nncmpp.

The frontend for the most part resembles xP, with some missing
xC features on top.

We do not care about text layouting or X11 text selection,
seeing as that requires rather extensive changes,
and I'm not planning to use this frontend other than for testing.
General formatting support will arrive in a following commit.

It should build for macOS as well with minor changes,
but we already have xM in our collection, so this is not finished.

Bump liberty.
2026-07-30 23:23:32 +02:00
p bcfbd40003 xC/xP: implement session resumption
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
Mobile clients pretty much need this, because they keep interrupting
their connections to the relay.
2026-07-28 18:28:19 +02:00
p 38188632e0 xP: fix inverted condition 2026-07-28 18:28:19 +02:00
p 682f3de097 xD/xS: fix KICKs in quiet channels
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-21 17:33:31 +02:00
p 5295733629 xD/xS: NICK without USER would block nicks forever 2026-07-21 17:33:31 +02:00
p 49e76b49de xS: fix multiple old porting errors 2026-07-21 17:33:31 +02:00
p 60a14b6683 xW: acknowledge a harmless possible underflow 2026-07-21 16:36:08 +02:00
p d2a3719b78 xA/xT/xW: handle server rename events better 2026-07-21 16:36:08 +02:00
p d453b64d3f xA: make reset items also reset inverse text 2026-07-21 16:36:08 +02:00
p 09c3980c50 xA: show relay error messages rather than crash 2026-07-21 16:36:08 +02:00
p ed6ad5981a xC: transcode input editor output back
Alpine 3.24 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-21 15:38:47 +02:00
p 6c749be5f7 xC: parse RPL_CHANNELMODEIS properly
The mode processor used to start with the channel name,
but it must start past it.
2026-07-21 15:38:47 +02:00
p 8f21138f26 xC: more precise capability whitelisting
It could theoretically match on more entries than intended.
2026-07-21 15:38:47 +02:00
p 542f2bca6b xC: validate server TLS certificate hostname
I haven't actually checked if this takes effect.
2026-07-21 15:38:47 +02:00
p b9097f40f6 xA: bump Fyne to 2.8.0
Alpine 3.23 Scripts failed
Arch Linux AUR Success
OpenBSD 7.8 Success
Alpine 3.24 Success
Now supporting strike-through formatting.

Overall, this frontend is much more usable now.
2026-07-20 07:49:50 +02:00
p 4102e3c02c xC: fix the integration test
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-20 03:03:31 +02:00
p 474a5973a3 xC: don't crash on non-terminal output 2026-07-20 02:43:24 +02:00
p a65389ec62 xC: show the prompt even with empty configuration
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-20 02:27:06 +02:00
p 0c256943fd xC: fix a segmentation fault on startup
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
A last-minute "harmless" change turns out to have side-effects.
2026-07-20 02:17:36 +02:00
p da2c8de56f Bump liberty 2026-07-20 01:58:16 +02:00
p eb02e8eee6 Try to fix OpenBSD build
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-20 01:52:56 +02:00
p 24c8108f35 Fix some compiler warnings 2026-07-20 01:50:33 +02:00
p 67d044a426 xC: nuke Readline and libedit
Arch Linux AUR Success
Alpine 3.23 Success
OpenBSD 7.8 Scripts failed
Replace them with a custom frontend making use of the termo library.
It's a bit rough at the edges, yet thoroughly functional.

The original libraries have carried us far, but they've become more
trouble than what they're worth:

 - It's much easier to make this change than to keep fixing
   both frontends.  That has become particularly difficult as of late.

 - It's also a much smaller undertaking than rewriting the client
   in more radical ways, such as:
    - Going for headless operation (also note that we currently lack
      a terminal relay client).
    - Rewriting the entire user interface to use curses.

 - Abandoning GNU Readline clears up licencing.

 - The old interface code was full of odd hacks and wild adapters.
   While this commit adds some fresh ugly areas, in sum it's a cleanup.

 - Purging the dependencies simplifies an eventual automated rewrite
   in another language.

Some freshly invalidated issues:

 - Readline 8.3 has reworked history, and our method of circumventing
   a memory leak in history handling stopped working reliably.
   Very tough to trace.

 - Editline could block waiting on input.

 - Editline refresh.c revision 1.61 seems to have completely broken
   the prompt hiding mechanism, with no obvious means of circumventing.
2026-07-20 00:46:08 +02:00
p e52501a1df prime.lua: prevent DoS on infinity
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-07-16 23:35:07 +02:00
p f57e8c59d6 xC: document the Lua API, bump liberty
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
asciiman.awk has needed a minor change, and it's forced us into
writing the document in a certain way, but it remains strong.

Looking at the API more closely makes one realise how lacking it is,
but the async functionality is still cool.
2026-07-15 05:47:12 +02:00
p 5ba2c825a1 xC: fix Lua 5.5 build
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
Everything appears to work, not inspecting this in depth.
2026-03-28 03:50:44 +01:00
p d11bd2c54e xT: produce an Android icon
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-01-26 18:31:16 +01:00
p c68e1f9d49 Bump version
Alpine 3.23 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2026-01-10 13:02:14 +01:00
p 253bfb530b xA: bump dependencies 2026-01-10 12:48:42 +01:00
p 6c38c3a526 xP: improve the activity indicator
Also adjust the Makefile to reflect resource embedding.
2026-01-10 12:43:53 +01:00
p 45b1b16c77 xC: fix libedit start from empty configuration 2026-01-10 12:43:23 +01:00
p 2728f9d1eb xT: clean up Windows and Mac deployment
Alpine 3.22 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2025-12-26 21:07:33 +01:00
p 77aaf87860 xC: hackfix Readline 8.3
Alpine 3.22 Success
Arch Linux AUR Success
OpenBSD 7.8 Success
2025-11-19 11:03:55 +01:00
p 57261fb13a xA: bump Fyne and other dependencies
Alpine 3.21 Scripts failed
Arch Linux AUR Success
OpenBSD 7.8 Success
2025-11-03 17:58:32 +01:00
p 5c41eab9d7 xA: add a Makefile rule for Android 2025-11-03 17:58:32 +01:00
p 99c95edd57 Update .gitignore for newer Qt Creator 2025-11-03 17:58:31 +01:00
p 7d90142f0f xP: fix alternative browsers on iOS
As a rule, they use the same stupid and broken WebKit.
2025-11-03 17:58:08 +01:00
p 71e1a744c5 xP: embed web resources, tame browser caching
Alpine 3.21 Success
Arch Linux AUR Success
OpenBSD 7.6 Success
2025-07-09 22:15:13 +02:00
p 80af5c22d6 Add an xC relay protocol analyzer
Alpine 3.21 Success
Arch Linux AUR Success
OpenBSD 7.6 Success
2025-05-15 14:14:53 +02:00
p 7ba17a0161 Make the relay acknowledge all received commands
Alpine 3.21 Success
Arch Linux AUR Success
OpenBSD 7.6 Success
To that effect, bump liberty and the xC relay protocol version.
Relay events have been reordered to improve forward compatibility.

Also prevent use-after-free when serialization fails.

xP now slightly throttles activity notifications,
and indicates when there are unacknowledged commands.
2025-05-10 12:08:51 +02:00
p 4cf8c394b9 xA: bump Fyne to 2.6.0
Arch Linux AUR Success
OpenBSD 7.6 Success
Alpine 3.21 Success
Alpine 3.20 Abandoned
Not much has actually changed.
2025-04-26 15:04:49 +02:00
p e225306419 CMakeLists.txt: actually name an option 2025-01-12 11:02:41 +01:00
p 858734384b xC: regard more characters as highlight delimiters
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
Almost 10 years of a poor decision.
2025-01-08 06:40:53 +01:00
p 278a7f95a9 Port the integration test from expect to wdye 2025-01-08 06:40:52 +01:00
p a8575ab875 Bump version, update NEWS
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
A few annoying bugs have been fixed.
2024-12-19 03:15:34 +01:00
p 081525f5be Update README.adoc 2024-12-19 03:08:14 +01:00
p 6ac2ac5511 xT: improve MSYS2 build
The static Qt 6 package is unusable.
2024-12-19 03:08:13 +01:00
p f6483489c2 xC: fix crash with too many topic formatting items
Arch Linux AUR Success
OpenBSD 7.5 Success
Alpine 3.20 Success
Manually constructed formatters have no sentinel value.

This is a one-line change in relay_prepare_channel_buffer_update(),
however the whole block of "Relay output" code has been moved down,
resolving one TODO and rendering two function prototypes unnecessary.
2024-12-18 11:48:17 +01:00
p ed5ac1815b xT: figure out basic packaging
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-12-17 06:34:45 +01:00
p 509cb9f4dd xC: fix newer Readline, allow stdin streaming
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
Also update NEWS.
2024-12-17 03:31:00 +01:00
p b3684c4d9f Bump liberty
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-12-16 09:37:29 +01:00
p 918c589c65 Add a Qt Widgets frontend to xC
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
This is very much a work in progress, though functional.

Qt Widgets are basically non-working on Android,
though Qt Quick requires a radically different approach.
2024-12-15 06:57:28 +01:00
p 21095a11d6 xM: fix build regression
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-11-26 13:10:05 +01:00
p a22baa4b55 xA: prevent sound playback GC
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
The beep sound could be cut short.
2024-11-14 16:48:44 +01:00
p b3e545e0bb xP: bump copyright years
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-11-14 16:27:56 +01:00
p cd76702ab2 xA/xW: dehighlight current buffer appropriately 2024-11-14 16:14:54 +01:00
p 977b073b58 xA: enforce internal icon from the start 2024-11-14 16:14:49 +01:00
p 46be4836df xW: print the separator line at the end of buffer 2024-11-14 13:50:51 +01:00
p 05a41b2629 xA/xM/xW: refresh renamed buffers correctly
Rendering takes the current buffer into account,
so change its value before using it, not afterwards.

The order happened to not matter on at least Windows,
because we just queue a message.
2024-11-14 11:41:09 +01:00
p a62ed5bbac xA/xM: refresh buffer list on dehighlight 2024-11-14 11:41:08 +01:00
p 9c9776bacd xA: make the log effectively read-only
Arch Linux AUR Success
OpenBSD 7.5 Success
Alpine 3.20 Success
2024-11-13 10:29:11 +01:00
p 086b879ab8 xA: add a "generate" target to the Makefile
So that Fyne tools can be run without building the default binary.
2024-11-12 17:11:23 +01:00
p 214c349869 xA: limit buffer length
Arch Linux AUR Success
OpenBSD 7.5 Success
Alpine 3.20 Success
2024-11-12 16:19:53 +01:00
p 3d975c9437 xA: downgrade Go version requirement
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
We need 1.22 for the "for" loop variable scope change.
2024-11-12 13:53:55 +01:00
p fce8fd40cc Bump xP dependencies
Alpine 3.20 Scripts failed
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-11-12 12:59:33 +01:00
p 3597ab9420 Update README.adoc 2024-11-12 12:41:09 +01:00
p 1635a730e8 Add a Fyne frontend for xC
Alpine 3.20 Scripts failed
Arch Linux AUR Scripts failed
OpenBSD 7.5 Success
It is fairly mediocre all around, but also generally usable,
natively covering mobile platforms.
2024-11-12 12:02:10 +01:00
p a64b1152a1 Bump liberty 2024-11-11 21:42:28 +01:00
p a011b57ce2 Bump liberty
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-11-07 11:07:36 +01:00
p b1ee295345 xP: update variable name 2024-11-04 07:40:14 +01:00
p 872f2d7c59 Fix calloc argument order
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-08-08 09:13:25 +02:00
p f15d887dcd Bump liberty
Alpine 3.20 Success
Arch Linux AUR Success
OpenBSD 7.5 Success
2024-08-08 09:02:25 +02:00
p 841bc00c51 xP: cleanup
I had forgotten about the auto-redraw system.
2024-07-28 13:42:28 +02:00
p 8afe4f8aad Improve wording in the last NEWS entry 2024-07-28 13:26:24 +02:00
51 changed files with 10205 additions and 2559 deletions
+1
View File
@@ -2,6 +2,7 @@
/build
# Qt Creator files
/.qtcreator
/CMakeLists.txt.user*
/xK.config
/xK.files
+3
View File
@@ -1,3 +1,6 @@
[submodule "liberty"]
path = liberty
url = https://git.janouch.name/p/liberty.git
[submodule "termo"]
path = termo
url = https://git.janouch.name/p/termo.git
+84 -43
View File
@@ -9,9 +9,7 @@ project (xK VERSION "${project_version}"
DESCRIPTION "IRC daemon, bot, TUI client and its web frontend" LANGUAGES C)
# Options
option (WANT_READLINE "Use GNU Readline for the UI (better)" ON)
option (WANT_LIBEDIT "Use BSD libedit for the UI" OFF)
option (WANT_XF "Build xF" OFF)
option (WITH_XF "Build the xF frontend" OFF)
# Moar warnings
set (CMAKE_C_STANDARD 99)
@@ -72,6 +70,8 @@ endif ()
# -lrt is only for glibc < 2.17
# -liconv may or may not be a part of libc
# -lm may or may not be a part of libc
find_path (iconv_INCLUDE_DIRS iconv.h)
include_directories (${iconv_INCLUDE_DIRS})
foreach (extra iconv rt m)
find_library (extra_lib_${extra} ${extra})
if (extra_lib_${extra})
@@ -88,13 +88,32 @@ CHECK_C_SOURCE_RUNS ("#include <iconv.h>
== (iconv_t) -1; }" ICONV_ACCEPTS_TRANSLIT)
# Dependencies for xC
pkg_check_modules (libffi REQUIRED libffi)
list (APPEND xC_libraries ${libffi_LIBRARIES})
include_directories (${libffi_INCLUDE_DIRS})
link_directories (${libffi_LIBRARY_DIRS})
find_package (Termo QUIET NO_MODULE)
option (USE_SYSTEM_TERMO
"Don't compile our own termo library, use the system one" "${Termo_FOUND}")
if (USE_SYSTEM_TERMO)
if (NOT Termo_FOUND)
message (FATAL_ERROR "System termo library not found")
endif ()
else ()
# We don't want the library to install, but EXCLUDE_FROM_ALL ignores tests
add_subdirectory (termo EXCLUDE_FROM_ALL)
file (WRITE ${PROJECT_BINARY_DIR}/CTestCustom.cmake
"execute_process (COMMAND ${CMAKE_COMMAND} --build termo)")
# We don't have many good choices; this is a relatively clean approach
# (other possibilities: setting a variable in the parent scope, using
# a cache variable, writing a special config file with build paths in it
# and including it here, or setting a custom property on the targets)
get_directory_property (Termo_INCLUDE_DIRS
DIRECTORY termo INCLUDE_DIRECTORIES)
set (Termo_LIBRARIES termo-static)
endif ()
list (APPEND xC_libraries ${Termo_LIBRARIES})
# XXX: other Lua versions may be acceptable, don't know yet
pkg_search_module (lua lua53 lua5.3 lua-5.3 lua54 lua5.4 lua-5.4 lua>=5.3)
pkg_search_module (lua
lua53 lua5.3 lua-5.3 lua54 lua5.4 lua-5.4 lua55 lua5.5 lua-5.5 lua>=5.3)
option (WITH_LUA "Enable support for Lua plugins" ${lua_FOUND})
if (WITH_LUA)
@@ -119,32 +138,8 @@ else ()
message (SEND_ERROR "Curses not found")
endif ()
if ((WANT_READLINE AND WANT_LIBEDIT) OR (NOT WANT_READLINE AND NOT WANT_LIBEDIT))
message (SEND_ERROR "You have to choose either GNU Readline or libedit")
elseif (WANT_READLINE)
pkg_check_modules (readline readline)
# OpenBSD's default readline is too old
if ("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD")
include_directories (${OPENBSD_LOCALBASE}/include/ereadline)
list (APPEND xC_libraries ereadline)
elseif (readline_FOUND)
list (APPEND xC_libraries ${readline_LIBRARIES})
include_directories (${readline_INCLUDE_DIRS})
link_directories (${readline_LIBRARY_DIRS})
else ()
list (APPEND xC_libraries readline)
endif ()
elseif (WANT_LIBEDIT)
pkg_check_modules (libedit REQUIRED libedit)
list (APPEND xC_libraries ${libedit_LIBRARIES})
include_directories (${libedit_INCLUDE_DIRS})
endif ()
# Generate a configuration file
set (HAVE_READLINE "${WANT_READLINE}")
set (HAVE_EDITLINE "${WANT_LIBEDIT}")
set (HAVE_LUA "${WITH_LUA}")
set (HAVE_LUA "${WITH_LUA}")
include (GNUInstallDirs)
set (project_config ${PROJECT_BINARY_DIR}/config.h)
@@ -176,24 +171,42 @@ add_custom_command (OUTPUT xC-proto.c
add_custom_target (xC-proto DEPENDS ${PROJECT_BINARY_DIR}/xC-proto.c)
# Build
set (project_binaries xB xC xD)
foreach (name xB xC xD)
add_executable (${name} ${name}.c ${project_config})
target_link_libraries (${name} ${project_libraries})
target_link_libraries (${name} PRIVATE ${project_libraries})
add_threads (${name})
endforeach ()
add_dependencies (xD replies)
add_dependencies (xC replies xC-proto)
target_link_libraries (xC ${xC_libraries})
target_link_libraries (xC PRIVATE ${xC_libraries})
target_include_directories (xC PRIVATE ${Termo_INCLUDE_DIRS})
if (WANT_XF)
pkg_check_modules (x11 REQUIRED x11 xrender xft fontconfig)
include_directories (${x11_INCLUDE_DIRS})
link_directories (${x11_LIBRARY_DIRS})
if (WITH_XF)
list (APPEND project_binaries xF)
find_package (Unistring REQUIRED)
pkg_check_modules (x11 x11 xrender xft fontconfig libpng)
option (WITH_X11 "Build xF with X11 support" "${x11_FOUND}")
if (WITH_X11 AND NOT x11_FOUND)
message (FATAL_ERROR "Some X11 libraries were not found")
endif ()
add_executable (xF xF.c ${project_config})
add_dependencies (xF xC-proto)
target_link_libraries (xF ${x11_LIBRARIES} ${project_libraries})
target_include_directories (xF PRIVATE
${Unistring_INCLUDE_DIRS} ${Termo_INCLUDE_DIRS})
target_link_libraries (xF PRIVATE
${Unistring_LIBRARIES} ${Termo_LIBRARIES}
${ncursesw_LIBRARIES} ${project_libraries})
if (WITH_X11)
target_compile_definitions (xF PRIVATE WITH_X11)
target_include_directories (xF PRIVATE ${x11_INCLUDE_DIRS})
target_link_directories (xF PRIVATE ${x11_LIBRARY_DIRS})
target_link_libraries (xF PRIVATE ${x11_LIBRARIES})
endif ()
add_threads (xF)
endif ()
@@ -202,7 +215,10 @@ include (CTest)
if (BUILD_TESTING)
add_executable (test-xC $<TARGET_PROPERTY:xC,SOURCES>)
set_target_properties (test-xC PROPERTIES COMPILE_DEFINITIONS TESTING)
target_link_libraries (test-xC $<TARGET_PROPERTY:xC,LINK_LIBRARIES>)
target_include_directories (test-xC
PUBLIC $<TARGET_PROPERTY:xC,INCLUDE_DIRECTORIES>)
target_link_libraries (test-xC
PUBLIC $<TARGET_PROPERTY:xC,LINK_LIBRARIES>)
add_threads (test-xC)
add_dependencies (test-xC replies)
@@ -210,6 +226,11 @@ if (BUILD_TESTING)
add_test (NAME custom-static-analysis
COMMAND ${PROJECT_SOURCE_DIR}/test-static)
endif ()
option (BUILD_TESTING_WDYE "Build the integration test" OFF)
if (BUILD_TESTING_WDYE)
add_subdirectory (liberty/tools/wdye)
add_test (NAME integration COMMAND wdye "${PROJECT_SOURCE_DIR}/test.lua")
endif ()
# Various clang-based diagnostics, loads of fake positives and spam
file (GLOB clang_tidy_sources *.c)
@@ -226,13 +247,33 @@ add_custom_target (clang-tidy
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# Installation
install (TARGETS xB xC xD DESTINATION ${CMAKE_INSTALL_BINDIR})
install (TARGETS ${project_binaries} DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install (DIRECTORY plugins/xB/
DESTINATION ${CMAKE_INSTALL_DATADIR}/xB/plugins USE_SOURCE_PERMISSIONS)
install (DIRECTORY plugins/xC/
DESTINATION ${CMAKE_INSTALL_DATADIR}/xC/plugins)
# Rasterize and install SVG icons
if (WITH_XF AND WITH_X11)
include (IconUtils)
set (icon_base ${PROJECT_BINARY_DIR}/icons)
set (icon_png_list)
foreach (icon_size 16 32 48)
icon_to_png (xF ${PROJECT_SOURCE_DIR}/xF.svg
${icon_size} ${icon_base} icon_png)
list (APPEND icon_png_list ${icon_png})
endforeach ()
add_custom_target (icons ALL DEPENDS ${icon_png_list})
install (FILES xF.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install (DIRECTORY ${icon_base}
DESTINATION ${CMAKE_INSTALL_DATADIR})
endif ()
# Generate documentation from text markup
find_program (ASCIIDOCTOR_EXECUTABLE asciidoctor)
find_program (A2X_EXECUTABLE a2x)
@@ -241,7 +282,7 @@ if (NOT ASCIIDOCTOR_EXECUTABLE AND NOT A2X_EXECUTABLE)
"falling back to a substandard manual page generator")
endif ()
foreach (page xB xC xD)
foreach (page ${project_binaries})
set (page_output "${PROJECT_BINARY_DIR}/${page}.1")
list (APPEND project_MAN_PAGES "${page_output}")
if (ASCIIDOCTOR_EXECUTABLE)
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2014 - 2024, Přemysl Eric Janouch <p@janouch.name>
Copyright (c) 2014 - 2026, Přemysl Eric Janouch <p@janouch.name>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
+60 -1
View File
@@ -1,3 +1,62 @@
2.3.0 (2026-07-31) "Clean"
* xC: nuked broken Readline and editline support, added a custom interface
* xC: added a /bindings command
* xC: relay sessions can now be resumed after a dropped connection (adjustable
with general.relay_resume_timeout and general.relay_resume_log_limit);
dead links are detected with periodic pings
* xC: server TLS certificate hostnames are now properly verified
* xC: added support for Lua 5.5
* xP: added a button to reconnect and resume the session if possible;
page reloads start a new session as before
* prime.lua: prevented a DoS opportunity on excessively large numbers
* Added a terminal/X11 frontend for xC called xF
* Bumped relay protocol version
* Various bugfixes
2.2.0 (2026-01-10) "Just Doing the Needful"
* xC: added more characters as nickname delimiters,
so that @nick works as a highlight
* xC: fixed libedit crash with empty configuration, hackfixed Readline >= 8.3
* xC: prevented rare crashes in relay code
* xP: added a network lag indicator to the user interface
* xP: started embedding the necessary web resources,
and making sure that the files have unique paths after change,
so that stale copies are not cached by browsers indefinitely
* Bumped relay protocol version
2.1.0 (2024-12-19) "Bunnyrific"
* xC: fixed a crash when the channel topic had too many formatting items
* xC: fixed keyboard EOF behaviour with Readline >= 8.0
* xC: made it possible to stream commands into the binary
* xM/xW: various bugfixes
* Added a Fyne frontend for xC called xA
* Added a Qt Widgets frontend for xC called xT
2.0.0 (2024-07-28) "Perfect Is the Enemy of Good"
* xD: now using SHA-256 for client certificate fingerprints
@@ -16,7 +75,7 @@
* xC: replaced behaviour.save_on_quit with general.autosave
* xC: the server *.command configuration option now supports multiple lines
* xC: the servers.*.command configuration option now supports multiple lines
* xC: improved pager integration capabilities
+34 -38
View File
@@ -2,17 +2,18 @@ xK
==
'xK' (chat kit) is an IRC software suite consisting of a daemon, bot, notifier,
terminal client, and web/Windows/macOS frontends for the client. It's all
you're ever going to need for chatting, so long as you can make do with slightly
minimalist software.
terminal client, and web/Windows/macOS/Linux/FreeBSD/Android/iOS frontends
for the client. It's all you're ever going to need for chatting, so long as
you can make do with slightly minimalist software.
They're all lean on dependencies, and offer a maximally permissive licence.
xC
--
The IRC client, and the core of 'xK'. It is largely defined by building on top
of GNU Readline or BSD Editline that have been hacked to death. Its interface
should feel somewhat familiar for weechat or irssi users.
The IRC client, and the core of 'xK'. Its interface should feel somewhat
familiar for weechat or irssi users. Currently the terminal interface
experience deserves some polishing, because we've just got rid of
Readline/Editline dependencies, which kept breaking in exciting ways.
image::xC.webp[align="center"]
@@ -33,6 +34,11 @@ including link:xC.adoc#_key_bindings[keyboard shortcuts].
image::xP.webp[align="center"]
xA, xF, xT, xW, xM
------------------
Fyne, terminal/X11, Qt Widgets, Win32, Cocoa frontends for 'xC'.
Using them is not recommended.
xD
--
The IRC daemon. It is designed for use as a regular user application rather
@@ -81,16 +87,17 @@ or as a https://git.janouch.name/p/nixexprs[Nix derivation].
Building
--------
Build-only dependencies: CMake, pkg-config, awk, liberty (included),
asciidoctor or asciidoc (recommended but optional) +
asciidoctor or asciidoc (recommended but optional), rsvg-convert (for 'xF') +
Common runtime dependencies: openssl +
Additionally for 'xC': curses, libffi, readline >= 6.0 or libedit >= 2013-07-12,
lua >= 5.3 (optional) +
Additionally for 'xC': curses, lua >= 5.3 (optional), termo (included) +
Additionally for 'xF': ncursesw, libunistring, termo (included),
x11 + xft + libpng (X11)
$ git clone --recursive https://git.janouch.name/p/xK.git
$ mkdir xK/build
$ cd xK/build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWANT_READLINE=ON -DWANT_LIBEDIT=OFF -DWITH_LUA=ON
-DWITH_LUA=ON -DWITH_XF=OFF
$ make
To install the application, you can do either the usual:
@@ -131,17 +138,29 @@ The precondition for running 'xC' frontends is enabling its relay interface:
/set general.relay_bind = "127.0.0.1:9000"
To build the web server, you'll need to install the Go compiler, and run `make`
from the _xP_ directory. Then start it from the _public_ subdirectory,
and navigate to the adress you gave it as its first argument--in the following
example, that would be http://localhost:8080[]:
To build the web server, install the Go compiler, and run `make`
from the _xP_ directory. Then start the resulting binary, and navigate to
the adress you give it as its first argument--in the following example,
that would be http://localhost:8080[]:
$ ../xP 127.0.0.1:8080 127.0.0.1:9000
$ ./xP 127.0.0.1:8080 127.0.0.1:9000
For remote use, it's recommended to put 'xP' behind a reverse proxy, with TLS,
and some form of HTTP authentication. Pass the external URL of the WebSocket
endpoint as the third command line argument in this case.
xA
~~
The Fyne frontend supports all of Linux, FreeBSD, Windows, macOS, Android, and
iOS natively, albeit somewhat poorly. Only use `fyne` or `fyne-cross` after
running `make generate` first.
xT
~~
The Qt Widgets frontend is a separate CMake subproject. It generally supports
all desktop operating systems, Android is technically usable. To avoid having
to specify the relay address each time you run it, pass it on the command line.
xW
~~
The Win32 frontend is a separate CMake subproject that should be compiled
@@ -174,26 +193,6 @@ in the required form, use:
$ openssl x509 -in public.pem -outform DER | sha256sum
Custom Key Bindings in xC
-------------------------
The default and preferred frontend used in 'xC' is GNU Readline. This means
that you can change your bindings by editing '~/.inputrc'. For example:
....
# Preload with system-wide settings
$include /etc/inputrc
# Make M-left and M-right reorder buffers
$if xC
"\e\e[C": move-buffer-right
"\e\e[D": move-buffer-left
$endif
....
Consult the source code and the GNU Readline manual for a list of available
functions. Also refer to the latter for the exact syntax of this file.
Beware that you can easily break the program if you're not careful.
How do I make xC look like the screenshot?
------------------------------------------
With the defaults, 'xC' doesn't look too fancy because I don't want to have
@@ -238,6 +237,3 @@ License
-------
This software is released under the terms of the 0BSD license, the text of which
is included within the package along with the list of authors.
Note that 'xC' becomes GPL-licensed when you link it against GNU Readline,
but that is not a concern of this source package. The licenses are compatible.
+30
View File
@@ -110,6 +110,11 @@ tokenize_host_port (char *address, const char **port)
// --- To be moved to liberty --------------------------------------------------
#define LIST_FOR_EACH_REVERSED(type, iter, tail) \
for (type *iter = (tail), *prev; \
(iter && (prev = iter->prev)) || iter; \
iter = prev)
// FIXME: in xssl_get_error() we rely on error reasons never being NULL (i.e.,
// all loaded), which isn't very robust.
// TODO: check all places where this is used and see if we couldn't gain better
@@ -134,6 +139,31 @@ xerr_describe_error (void)
return reason;
}
static bool
str_append_c_utf8 (struct str *s, uint32_t ucs4)
{
if (ucs4 < 0x80)
str_append_c (s, ucs4);
else if (ucs4 < 0x7FF)
str_append_data (s, (char[]) {
0xc0 | (ucs4 >> 6),
0x80 | (ucs4 & 0x3f) }, 2);
else if (ucs4 < 0xFFFF)
str_append_data (s, (char[]) {
0xe0 | (ucs4 >> 12),
0x80 | ((ucs4 >> 6) & 0x3f),
0x80 | (ucs4 & 0x3f) }, 3);
else if (ucs4 < 0x10FFFF)
str_append_data (s, (char[]) {
0xf0 | (ucs4 >> 18),
0x80 | ((ucs4 >> 12) & 0x3f),
0x80 | ((ucs4 >> 6) & 0x3f),
0x80 | (ucs4 & 0x3f) }, 4);
else
return false;
return true;
}
static struct str
str_from_cstr (const char *cstr)
{
-2
View File
@@ -6,8 +6,6 @@
// We use the XDG Base Directory Specification, but may be installed anywhere.
#define PROJECT_DATADIR "${CMAKE_INSTALL_FULL_DATADIR}"
#cmakedefine HAVE_READLINE
#cmakedefine HAVE_EDITLINE
#cmakedefine HAVE_LUA
#cmakedefine01 ICONV_ACCEPTS_TRANSLIT
+1 -1
Submodule liberty updated: f04cc2c61e...12063aecde
+2 -1
View File
@@ -1,7 +1,7 @@
--
-- prime.lua: highlight prime numbers in messages
--
-- Copyright (c) 2020, Přemysl Eric Janouch <p@janouch.name>
-- Copyright (c) 2020, 2026 Přemysl Eric Janouch <p@janouch.name>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted.
@@ -34,6 +34,7 @@ xC.setup_config {
-- The prime test is actually very fast, so there is no DoS concern
local do_intercolour = function (text)
return tostring (text:gsub ("%f[%w_]%d+", function (n)
if tonumber (n) > math.maxinteger then return nil end
if tonumber (n) < smallest then return nil end
for i = 2, n ^ (1 / 2) do if (n % i) == 0 then return nil end end
return highlight .. n .. highlight
Submodule
+1
Submodule termo added at a8f3f6eca3
-52
View File
@@ -1,52 +0,0 @@
#!/usr/bin/expect -f
# Very basic end-to-end testing for CI
set tempdir [exec mktemp -d]
set ::env(XDG_CONFIG_HOME) $tempdir
# Run the daemon to test against
system ./xD --write-default-cfg
spawn ./xD -d
# 10 seconds is a bit too much
set timeout 5
spawn ./xC
# Fuck this Tcl shit, I want the exit code
expect_after {
eof {
puts ""
puts "Child exited prematurely"
exit 1
}
}
# Connect to the daemon
send "/server add localhost\n"
expect "]"
send "/set servers.localhost.addresses = \"localhost\"\n"
expect "Option changed"
send "/disconnect\n"
expect "]"
send "/connect\n"
expect "Welcome to"
# Try some chatting
send "/join #test\n"
expect "has joined"
send "Hello\n"
expect "Hello"
# Attributes
send "\x1bmbBold text! \x1bmc0,5And colors.\n"
expect "]"
# Try basic commands
send "/set\n"
expect "]"
send "/help\n"
expect "]"
# Quit
send "/quit\n"
expect "Shutting down"
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/env wdye
-- Very basic end-to-end testing for CI
function exec (...)
local p = wdye.spawn(...)
local out = wdye.expect(p:eof {function (p) return p[0] end})
if not out then
error "exec() timeout"
end
local status = p:wait()
if status ~= 0 then
io.write(out, "\n")
error("exit status " .. status)
end
return out:gsub("%s+$", "")
end
local temp = exec {"mktemp", "-d"}
local atexit = {}
setmetatable(atexit, {__gc = function () exec {"rm", "-rf", "--", temp} end})
local env = {XDG_CONFIG_HOME=temp, TERM="xterm"}
exec {"./xD", "--write-default-cfg", environ=env}
-- Run the daemon to test against (assuming the default port 6667)
local xD = wdye.spawn {"./xD", "-d", environ=env}
local xC = wdye.spawn {"./xC", environ=env}
function send (...) xC:send(...) end
function expect (string)
wdye.expect(xC:exact {string},
wdye.timeout {5, function (p) error "xC timeout" end},
xC:eof {function (p) error "xC exited prematurely" end})
end
expect "]"
-- Connect to the daemon
send "/server add localhost\n"
expect "]"
send "/set servers.localhost.addresses = \"localhost\"\n"
expect "Option changed"
send "/disconnect\n"
expect "]"
send "/connect\n"
expect "Welcome to"
-- Try some chatting
send "/join #test\n"
expect "has joined"
send "Hello\n"
expect "Hello"
-- Attributes
send "\x1bmbBold text! \x1bmc0,5And colors.\n"
expect "]"
-- Try basic commands
send "/set\n"
expect "]"
send "/help\n"
expect "]"
-- Quit
send "/quit\n"
expect "Shutting down"
local s1 = xC:wait()
assert(s1 == 0, "xC exited abnormally: " .. s1)
-- Send SIGINT (^C)
xD:send "\003"
local s2 = xD:wait()
assert(s2 == 0, "xD exited abnormally: " .. s2)
+6
View File
@@ -0,0 +1,6 @@
/xA
/xA.apk
/proto.go
/FyneApp.toml
/*.png
/beep.raw
+42
View File
@@ -0,0 +1,42 @@
.POSIX:
.SUFFIXES:
.SUFFIXES: .png .svg
AWK = env LC_ALL=C awk
tools = ../liberty/tools
generated = FyneApp.toml xA.png xA-highlighted.png beep.raw proto.go
outputs = xA $(generated)
all: $(outputs)
generate: $(generated)
FyneApp.toml: ../xK-version
printf "\
[Details]\n\
Icon = 'xA.png'\n\
Name = 'xA'\n\
ID = 'name.janouch.xA'\n\
Version = '$$(cat ../xK-version)'\n\
Build = 1\n\
\n\
[Migrations]\n\
# This is temporary, for Fyne 2.8\n\
fyneDo = true\n\
\n\
[LinuxAndBSD]\n\
GenericName = 'IRC Client'\n\
Categories = ['Network', 'Chat', 'IRCClient']\n" > $@
.svg.png:
rsvg-convert --output=$@ -- $<
beep.raw:
sox -Dr 44100 -c 1 -e signed-integer -b 16 -L -n $@ \
synth 0.1 0 25 triangle 800 vol 0.5 fade t 0 -0 0.005 pad 0 0.05
proto.go: $(tools)/lxdrgen.awk $(tools)/lxdrgen-go.awk ../xC.lxdr
$(AWK) -f $(tools)/lxdrgen.awk -f $(tools)/lxdrgen-go.awk \
-v PrefixCamel=Relay ../xC.lxdr > $@
xA: xA.go ../xK-version $(generated)
go build -ldflags "-X 'main.projectVersion=$$(cat ../xK-version)'" -o $@ \
-gcflags=all="-N -l"
xA.apk: $(generated)
fyne package -os android
clean:
rm -f $(outputs)
+47
View File
@@ -0,0 +1,47 @@
module janouch.name/xK/xA
go 1.26
require (
fyne.io/fyne/v2 v2.8.0
github.com/ebitengine/oto/v3 v3.4.0
)
require (
fyne.io/systray v1.12.2 // indirect
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/FyshOS/fancyfs v0.0.1 // indirect
github.com/anthonynsimon/bild v0.16.1 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ebitengine/purego v0.10.1 // indirect
github.com/fredbi/uri v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/fyne-io/gl-js v0.2.1-0.20260315212741-029c47fd27e8 // indirect
github.com/fyne-io/glfw-js v0.4.0 // indirect
github.com/fyne-io/image v0.1.1 // indirect
github.com/fyne-io/oksvg v0.2.0 // indirect
github.com/go-gl/gl v0.0.0-20260331235117-4566fea9a276 // indirect
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260707082822-2a407d02d01a // indirect
github.com/go-text/render v0.2.1 // indirect
github.com/go-text/typesetting v0.3.4 // indirect
github.com/godbus/dbus/v5 v5.2.2 // indirect
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
github.com/hack-pad/safejs v0.1.1 // indirect
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade // indirect
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/nicksnyder/go-i18n/v2 v2.6.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rymdport/portal v0.4.2 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.11.1 // indirect
github.com/yuin/goldmark v1.8.4 // indirect
golang.org/x/image v0.44.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+93
View File
@@ -0,0 +1,93 @@
fyne.io/fyne/v2 v2.8.0 h1:KNUdIk1eKsXSPy/wU6MdiR1hppAPvyzbjPbtJ8h6EUQ=
fyne.io/fyne/v2 v2.8.0/go.mod h1:tLJK7CVtUBOnMiSDR+J88t/quiGuEhwGs09tIVM1RXg=
fyne.io/systray v1.12.2 h1:Y8DZxgLHsVQt6rY9Zrkkg+j67S7vv/1F2viOWKPpVeA=
fyne.io/systray v1.12.2/go.mod h1:RVwqP9nYMo7h5zViCBHri2FgjXF7H2cub7MAq4NSoLs=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/FyshOS/fancyfs v0.0.1 h1:kgvm7VvwOMLkYTqSflplp62SlMVWQ2uAoHw9CXwXHYg=
github.com/FyshOS/fancyfs v0.0.1/go.mod h1:S5SHVz/5R72iCXOxCqdcyTPSlg3JxNd0gaHyGBSrY8A=
github.com/anthonynsimon/bild v0.16.1 h1:ECqtLkQ15kqfHdRtzUfNvQniJtHNpzdVU/7feMYAm0o=
github.com/anthonynsimon/bild v0.16.1/go.mod h1:hYAxurnswTQ9dexoiK922MepdXLC1lBzG35n6ypk//g=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/oto/v3 v3.4.0 h1:br0PgASsEWaoWn38b2Goe7m1GKFYfNgnsjSd5Gg+/bQ=
github.com/ebitengine/oto/v3 v3.4.0/go.mod h1:IOleLVD0m+CMak3mRVwsYY8vTctQgOM0iiL6S7Ar7eI=
github.com/ebitengine/purego v0.10.1 h1:dewVBCBT2GaMu1SrNTYxQhgQBethzfhiwvZiLGP/qyY=
github.com/ebitengine/purego v0.10.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
github.com/fredbi/uri v1.1.1 h1:xZHJC08GZNIUhbP5ImTHnt5Ya0T8FI2VAwI/37kh2Ko=
github.com/fredbi/uri v1.1.1/go.mod h1:4+DZQ5zBjEwQCDmXW5JdIjz0PUA+yJbvtBv+u+adr5o=
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/fyne-io/gl-js v0.2.1-0.20260315212741-029c47fd27e8 h1:0kdPD/GEntpWmZEK5Zu/xE6Tr37jYCVDf9QP8lA/QK8=
github.com/fyne-io/gl-js v0.2.1-0.20260315212741-029c47fd27e8/go.mod h1:ZcepK8vmOYLu96JoxbCKJy2ybr+g1pTnaBDdl7c3ajI=
github.com/fyne-io/glfw-js v0.4.0 h1:I9hREBeFyI10cNIqbMKYb1PRidyPDgwob8o2la9SfQo=
github.com/fyne-io/glfw-js v0.4.0/go.mod h1:SDchsFZh4n7nVuBoiowOhOgIBdz+qUQVeC1w9fe2yVU=
github.com/fyne-io/image v0.1.1 h1:WH0z4H7qfvNUw5l4p3bC1q70sa5+YWVt6HCj7y4VNyA=
github.com/fyne-io/image v0.1.1/go.mod h1:xrfYBh6yspc+KjkgdZU/ifUC9sPA5Iv7WYUBzQKK7JM=
github.com/fyne-io/oksvg v0.2.0 h1:mxcGU2dx6nwjJsSA9PCYZDuoAcsZ/OuJlvg/Q9Njfo8=
github.com/fyne-io/oksvg v0.2.0/go.mod h1:dJ9oEkPiWhnTFNCmRgEze+YNprJF7YRbpjgpWS4kzoI=
github.com/go-gl/gl v0.0.0-20260331235117-4566fea9a276 h1:IO5P06Pcj9K04d+l4nrf3c2U56+dAotIFG6u4P1wAHI=
github.com/go-gl/gl v0.0.0-20260331235117-4566fea9a276/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260707082822-2a407d02d01a h1:HWK0MBggT/T6YH7VffE10xBIhqeTq8JzIUPJXrRy87g=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260707082822-2a407d02d01a/go.mod h1:T5Dn0JwIJOX1euPZ/iT4tq6nFYtmukjcYa7937HuYK8=
github.com/go-text/render v0.2.1 h1:qwHhxqGUjjg4L0XyJWj7M7bpY75NZM+kBpv2Yfw5mcg=
github.com/go-text/render v0.2.1/go.mod h1:HCCAq8MUlm/WRcXshBb4K/n+IkjeXQ1c2Ba+yICSm0A=
github.com/go-text/typesetting v0.3.4 h1:YYurUOtEb9kGSOz4uE3k4OpBGsp1dDL8+fjCeaFamAU=
github.com/go-text/typesetting v0.3.4/go.mod h1:4qZCQphq4KSgGTAeI0uMEkVbROgfah8BuyF5LRYr7XY=
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3 h1:drBZzMgdYPbmyXqOto4YhhJGrFIQCX94FpR4MzTCsos=
github.com/go-text/typesetting-utils v0.0.0-20260223113751-2d88ac90dae3/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o=
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y=
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
github.com/hack-pad/go-indexeddb v0.3.2 h1:DTqeJJYc1usa45Q5r52t01KhvlSN02+Oq+tQbSBI91A=
github.com/hack-pad/go-indexeddb v0.3.2/go.mod h1:QvfTevpDVlkfomY498LhstjwbPW6QC4VC/lxYb0Kom0=
github.com/hack-pad/safejs v0.1.1 h1:d5qPO0iQ7h2oVtpzGnLExE+Wn9AtytxIfltcS2b9KD8=
github.com/hack-pad/safejs v0.1.1/go.mod h1:HdS+bKF1NrE72VoXZeWzxFOVQVUSqZJAG0xNCnb+Tio=
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade h1:FmusiCI1wHw+XQbvL9M+1r/C3SPqKrmBaIOYwVfQoDE=
github.com/jeandeaual/go-locale v0.0.0-20250612000132-0ef82f21eade/go.mod h1:ZDXo8KHryOWSIqnsb/CiDq7hQUYryCgdVnxbj8tDG7o=
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25 h1:YLvr1eE6cdCqjOe972w/cYF+FjW34v27+9Vo5106B4M=
github.com/jsummers/gobmp v0.0.0-20230614200233-a9de23ed2e25/go.mod h1:kLgvv7o6UM+0QSf0QjAse3wReFDsb9qbZJdfexWlrQw=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=
github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/nicksnyder/go-i18n/v2 v2.6.1 h1:JDEJraFsQE17Dut9HFDHzCoAWGEQJom5s0TRd17NIEQ=
github.com/nicksnyder/go-i18n/v2 v2.6.1/go.mod h1:Vee0/9RD3Quc/NmwEjzzD7VTZ+Ir7QbXocrkhOzmUKA=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rymdport/portal v0.4.2 h1:7jKRSemwlTyVHHrTGgQg7gmNPJs88xkbKcIL3NlcmSU=
github.com/rymdport/portal v0.4.2/go.mod h1:kFF4jslnJ8pD5uCi17brj/ODlfIidOxlgUDTO5ncnC4=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c h1:km8GpoQut05eY3GiYWEedbTT0qnSxrCjsVbb7yKY1KE=
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c/go.mod h1:cNQ3dwVJtS5Hmnjxy6AgTPd0Inb3pW05ftPSX7NZO7Q=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef h1:Ch6Q+AZUxDBCVqdkI8FSpFyZDtCVBc2VmejdNrm5rRQ=
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef/go.mod h1:nXTWP6+gD5+LUJ8krVhhoeHjvHTutPxMYl5SvkcnJNE=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/yuin/goldmark v1.8.4 h1:oat/nd3U6NeQqFEL3xpEJq7d7c86NI+DbSNGAs4xnjA=
github.com/yuin/goldmark v1.8.4/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/image v0.44.0 h1:+tDekMZED9+LrtB3G5xzRggpVh9CARjZqROla3R3R+I=
golang.org/x/image v0.44.0/go.mod h1:V8K3KE9KKKE+pLpQDOeN18w9oacNSvy1tDOirTu4xtY=
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" width="512" height="512" viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="background" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="#ffaa00" offset="0" />
<stop stop-color="#ffffff" offset="1" />
</linearGradient>
<clipPath id="clip">
<rect x="0" y="0" width="1" height="1" />
</clipPath>
</defs>
<rect x="0" y="0" width="512" height="512" fill="url(#background)" />
<g transform="translate(64, 64) scale(384)" stroke-linecap="square">
<g clip-path="url(#clip)">
<path stroke="#ff0000" stroke-width="0.125"
d="M 0.25,1.1 0.65,-0.1 M 0.75,1.1 0.35,-0.1 M 0.225,0.75 0.775,0.75" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 781 B

+1666
View File
File diff suppressed because it is too large Load Diff
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" width="512" height="512" viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="background" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="#ffaa00" offset="0" />
<stop stop-color="#ff0000" offset="1" />
</linearGradient>
<clipPath id="clip">
<rect x="0" y="0" width="1" height="1" />
</clipPath>
</defs>
<rect x="0" y="0" width="512" height="512" fill="url(#background)" />
<g transform="translate(64, 64) scale(384)" stroke-linecap="square">
<g clip-path="url(#clip)">
<path stroke="#ffffff" stroke-width="0.125"
d="M 0.25,1.1 0.65,-0.1 M 0.75,1.1 0.35,-0.1 M 0.225,0.75 0.775,0.75" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 781 B

+1 -1
View File
@@ -630,7 +630,7 @@ recovery_handler (int signum, siginfo_t *info, void *context)
const char *signal_name = NULL, *reason = NULL;
translate_signal_info (signum, &signal_name, info->si_code, &reason);
char buf[128], numbuf[8];
char buf[128], numbuf[16];
if (!signal_name)
{
snprintf (numbuf, sizeof numbuf, "%d", signum);
+217 -15
View File
@@ -39,10 +39,9 @@ This feature may be used to preview server MOTD files.
Key bindings
------------
Most key bindings are inherited from the frontend in use, which is either GNU
Readline or BSD editline. A few of them, however, are special to the IRC client
or assume a different function. This is a list of all local overrides and
their respective function names:
The basic key bindings are inspired by GNU Readline. On top of that, there are
some which are special to the IRC client or assume a different function.
This is a list of all local specialties and their respective function names:
*M-p*::
Go up in history for this buffer (normally mapped to *C-p*).
@@ -83,13 +82,220 @@ their respective function names:
Should there be any issues with the display, this will clear the terminal
screen and redraw all information.
Additionally, *C-w* and *C-u* in editline behave the same as they would in
Readline or the "vi" command mode, even though the "emacs" mode is enabled
by default.
Custom bindings
---------------
Edit the configuration file manually. For example, to make buffer reordering
functions accessible:
Bindings can be customized in your _.inputrc_ or _.editrc_ file. Both libraries
support conditional execution based on the program name. Beware that it is easy
to make breaking changes.
....
bindings = {
"M-Left" = "move-buffer-left"
"M-Right" = "move-buffer-right"
}
....
You may bind any function you see in the */bindings* listing, though beware that
you can easily break the program if you're not careful.
Lua plugin API
--------------
The API closely reflects the internal structure of the client.
For code examples, please consult preinstalled plugins.
All references to internal objects are weak, and may become invalid.
Methods named like __:get_PROPERTY__ can also be accessed as __.PROPERTY__.
As a rule, properties are read-only, and strings are encoded in UTF-8.
*xC.buffers* ({Buffer, ...})::
All buffers in order.
*xC.current_buffer* (Buffer)::
The active buffer.
*xC.global_buffer* (Buffer)::
The global buffer.
*xC.servers* ({[string = Server, ...]})::
Configured servers, indexed by their name.
*xC.get_screen_size*() -> integer, integer::
Return the number of terminal lines and columns.
*xC.hook_completion*(_callback_[, _priority_]) -> Hook::
Register a generator _callback_ for Tab completions: +
Hook, {buffer, line, words, location}, string -> {[string, ...]}?
+
* *buffer* (Buffer): Where the completion occurs.
+
* *line* (string): The whole input line.
+
* *words* ({[string, ...]}): The input line split into words.
+
* *location* (integer): Which word is being completed, zero-based.
*xC.hook_input*(_callback_[, _priority_]) -> Hook::
Register a filter _callback_ for user-typed input: +
Hook, Buffer, string -> string?
*xC.hook_irc*(_callback_[, _priority_]) -> Hook::
Register a filter _callback_ for incoming raw IRC messages: +
Hook, Server, string -> string?
*xC.hook_prompt*(_callback_[, _priority_]) -> Hook::
Register a generator _callback_ for the TUI input line prompt: +
Hook -> string?
+
So as to not break the display, escape any terminal control sequences
by enclosing them between \x01 and \x02.
*xC.measure*(_string_) -> integer::
Determine the width of a _string_ in terms of terminal cells.
*xC.parse*(_message_) -> {tags, prefix, command, params}::
Parse a raw IRC _message_ into its components:
+
* *tags* ({[string = string, ...]})
+
* *prefix* (string?)
+
* *command* (string?)
+
* *params* ({[string, ...]})
*xC.setup_config*(_options_)::
Declare persistent plugin configuration under _plugins.NAME_, with the name
derived from the script's basename without any extensions.
The _options_ index configuration items by name, as further tables with:
+
* *type* (string): The configuration type of the value: one of _null_,
_object_, _boolean_, _integer_, _string_, __string_array__.
+
* *comment* (string?): The description of the value.
+
* *default* (string?): The default value, expressed in terms of
the configuration language. Items with a default may not become _null_.
+
* *on_change* (function?): Called when the value is initialized,
first read, or later changed.
+
* *validate* (function?): Called to validate values after they pass a type
check, returning _true_ if a change should be allowed.
Async Library
~~~~~~~~~~~~~
Within this concurency model, use Lua's *coroutine.yield* like *await*.
*xC.async.dial*(_host_, _service_) -> WaitChannel::
Connect to the server at _host_, port _service_. Make sure
to set the appropriate callbacks on the returned Connection object.
*xC.async.go*(_fn_, ...) -> Task::
Run _fn_ as a coroutine. These coroutines may only yield WaitChannels.
When yielding multiple wait channel values, the operation will return
the index of the completed channel, followed by all its return values packed
into a single table.
*xC.async.timer_ms*(_milliseconds_) -> WaitChannel::
Resume the calling task after the given number of _milliseconds_.
Buffer
~~~~~~
*.channel* (Channel?)::
The associated channel, if any.
*.hide_unimportant* (boolean)::
Whether unimportant messages are hidden in the user interface.
*.highlighted* (boolean)::
Whether we've been highlighted since last seeing the buffer.
*.name* (string)::
The full name of the buffer.
*.new_messages_count* (integer)::
The number of new messages since last seeing the buffer.
*.new_unimportant_count* (integer)::
How many of those messages are unimportant.
*.server* (Server?)::
The associated server, if any.
*.user* (User?)::
The associated user, if any.
*:execute*(_input_)::
Process a line of _input_ within the buffer, as if the user typed it in.
*:log*(_message_)::
Log a status _message_.
Channel
~~~~~~~
*.left_manually* (boolean)::
Whether we've left the channel manually, not to rejoin on reconnect.
*.name* (string)::
The channel's literal name, which may not be in UTF-8.
*.no_param_modes* (string)::
Active no-parameter channel modes.
*.param_modes* ({[string = string, ...]})::
Active parametrized channel modes.
*.topic* (string)::
The channel topic, which may not be in UTF-8.
This string includes any in-line formatting.
*.users_len* (integer)::
The number of users on the channel.
*:get_users*() -> {[{prefixes = string, user = User}, ...]}::
Return all users on the channel, together with their prefixes.
Connection
~~~~~~~~~~
*.on_data*(_data_)::
Called whenever _data_ is received from the server.
*.on_eof*()::
Called when the connection is closed by the server.
*.on_error*(_error_)::
Called when the connection sees an _error_.
*:close*()::
Close the connection.
*:send*(_data_)::
Send a string to the server.
Hook
~~~~
*:unhook*()::
Forget about the hook.
Server
~~~~~~
*.autoaway_active* (boolean)::
Whether we've currently automatically marked ourselves away.
*.buffer* (Buffer)::
The server's buffer.
*.cap_echo_message* (boolean)::
Whether the echo-message capability is active.
*.irc_user_host* (string)::
Our own user's user@host as we know it, used for message splitting.
*.manual_disconnect* (boolean)::
A flag to avoid reconnecting automatically after a manual disconnect request
causes a connection interrupt.
*.name* (string)::
The name of the server.
*.reconnect_attempt* (integer)::
Attempt counter while establishing a connection.
//*.state* (integer)::
// The connection state as an integer constant. Overriden.
*.user* (User?)::
Our own user, once we're registered.
*.user_mode* (string)::
Our own user's modes.
*:get_state*() -> string::
The connection state: one of _disconnected_, _connecting_, _connected_,
_registered_, _closing_, _half-closed_.
*:send*(_message_)::
Send an IRC message verbatim, after appending newline characters.
Task
~~~~
*:cancel*()::
Cancel the task, interrupting any *yield*.
User
~~~~
*.away* (boolean)::
Whether the user is marked away.
*.nickname* (string)::
The user's literal nickname, which may not be in UTF-8.
*:get_channels*() -> {[Channel, ...]}::
Return all channels the user shares with us.
Environment
-----------
@@ -113,10 +319,6 @@ _/usr/local/share/xC/plugins/_::
_/usr/share/xC/plugins/_::
Plugins are searched for in these directories, in order.
Bugs
----
The editline (libedit) frontend may exhibit some unexpected behaviour.
Reporting bugs
--------------
Use https://git.janouch.name/p/xK to report bugs, request features,
@@ -124,4 +326,4 @@ or submit pull requests.
See also
--------
*less*(1), *readline*(3) or *editline*(7)
*less*(1), *xF*(1)
+1940 -2064
View File
File diff suppressed because it is too large Load Diff
+40 -31
View File
@@ -1,7 +1,8 @@
// Backwards-compatible protocol version.
const VERSION = 1;
const VERSION = 3;
// From the frontend to the relay.
// All commands receive either an Event.RESPONSE, or an Event.ERROR.
struct CommandMessage {
// The command sequence number will be repeated in responses
// in the respective fields.
@@ -12,16 +13,20 @@ struct CommandMessage {
BUFFER_ACTIVATE,
BUFFER_INPUT,
BUFFER_TOGGLE_UNIMPORTANT,
PING_RESPONSE,
PING,
PING_RESPONSE,
BUFFER_COMPLETE,
BUFFER_LOG,
} command) {
// If the version check succeeds, the client will receive
// an initial stream of SERVER_UPDATE, BUFFER_UPDATE, BUFFER_STATS,
// BUFFER_LINE, and finally a BUFFER_ACTIVATE message.
// When a session is resumed, the RESPONSE is preceded by an event log
// replay starting at event_seq.
case HELLO:
u32 version;
// Empty to start a new session, otherwise the session to resume.
u8 session_id<>;
// The event_seq to continue from;
// a new session is started when that point is no longer available.
u32 event_seq;
case ACTIVE:
void;
case BUFFER_ACTIVATE:
@@ -32,13 +37,10 @@ struct CommandMessage {
// XXX: Perhaps this should rather be handled through a /buffer command.
case BUFFER_TOGGLE_UNIMPORTANT:
string buffer_name;
case PING_RESPONSE:
u32 event_seq;
// Only these commands may produce Event.RESPONSE, as below,
// but any command may produce an error.
case PING:
void;
case PING_RESPONSE:
u32 event_seq;
case BUFFER_COMPLETE:
string buffer_name;
string text;
@@ -52,6 +54,9 @@ struct CommandMessage {
struct EventMessage {
u32 event_seq;
union EventData switch (enum Event {
ERROR,
RESPONSE,
PING,
BUFFER_LINE,
BUFFER_UPDATE,
@@ -64,12 +69,34 @@ struct EventMessage {
SERVER_UPDATE,
SERVER_RENAME,
SERVER_REMOVE,
ERROR,
RESPONSE,
} event) {
// Restriction: command_seq strictly follows the sequence received
// by the relay, across both of these replies.
case ERROR:
u32 command_seq;
string error;
case RESPONSE:
u32 command_seq;
union ResponseData switch (Command command) {
case HELLO:
// The session to present on the next connection. If it differs
// from the command, the session is new, and a full resync follows:
// an initial stream of SERVER_UPDATE, BUFFER_UPDATE, BUFFER_STATS,
// BUFFER_LINE, and finally a BUFFER_ACTIVATE message.
u8 session_id<>;
case BUFFER_COMPLETE:
u32 start;
string completions<>;
case BUFFER_LOG:
// UTF-8, but not guaranteed.
u8 log<>;
default:
// Reception acknowledged.
void;
} data;
case PING:
void;
case BUFFER_LINE:
string buffer_name;
// Whether the line should also be displayed in the active buffer.
@@ -188,23 +215,5 @@ struct EventMessage {
string new;
case SERVER_REMOVE:
string server_name;
// Restriction: command_seq strictly follows the sequence received
// by the relay, across both of these replies.
case ERROR:
u32 command_seq;
string error;
case RESPONSE:
u32 command_seq;
union ResponseData switch (Command command) {
case PING:
void;
case BUFFER_COMPLETE:
u32 start;
string completions<>;
case BUFFER_LOG:
// UTF-8, but not guaranteed.
u8 log<>;
} data;
} data;
};
+11
View File
@@ -887,7 +887,14 @@ static void
client_unregister (struct client *c, const char *reason)
{
if (!c->registered)
{
if (c->nickname)
{
str_map_set (&c->ctx->users, c->nickname, NULL);
cstr_set (&c->nickname, NULL);
}
return;
}
char *message = xstrdup_printf (":%s!%s@%s QUIT :%s",
c->nickname, c->username, c->hostname, reason);
@@ -2630,7 +2637,11 @@ irc_try_kick (struct client *c, const char *channel_name, const char *nick,
if (!(chan->modes & IRC_CHAN_MODE_QUIET))
irc_channel_multicast (chan, message, NULL);
else
{
client_send (c, "%s", message);
if (c != client)
client_send (client, "%s", message);
}
free (message);
channel_remove_user (chan, user);
+39
View File
@@ -0,0 +1,39 @@
xF(1)
=====
:doctype: manpage
:manmanual: xK Manual
:mansource: xK {release-version}
Name
----
xF - Terminal/X11 frontend for xC
Synopsis
--------
*xF* [_OPTION_]... RELAY-ADDRESS
Description
-----------
*xF* is an example frontend for the relay interface of the *xC* IRC client.
It normally runs in the terminal, and can also use a graphical interface
when built with support for one.
Options
-------
*-g*, *--gui*::
Use the graphical interface even when running from a terminal.
*-h*, *--help*::
Display a help message and exit.
*-V*, *--version*::
Output version information and exit.
Reporting bugs
--------------
Use https://git.janouch.name/p/xK to report bugs, request features,
or submit pull requests.
See also
--------
*xC*(1)
+3201 -79
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
2.0.0
2.3.0
+3
View File
@@ -3,6 +3,9 @@
// Copyright (c) 2023, Přemysl Eric Janouch <p@janouch.name>
// SPDX-License-Identifier: 0BSD
//
// As an odd regression, AppKit may be necessary for JIT linking.
import AppKit
// NSGraphicsContext mostly just weirdly wraps over Quartz,
// so we do it all in Quartz directly.
import CoreGraphics
+9 -4
View File
@@ -173,8 +173,11 @@ class RelayRPC {
func send(data: RelayCommandData, callback: Callback? = nil) {
self.commandSeq += 1
let m = RelayCommandMessage(commandSeq: self.commandSeq, data: data)
if let callback = callback {
self.commandCallbacks[m.commandSeq] = callback
self.commandCallbacks[m.commandSeq] = callback ?? { error, data in
if data == nil {
NSSound.beep()
Logger().warning("\(error)")
}
}
var w = RelayWriter()
@@ -694,7 +697,8 @@ func refreshBuffer(b: Buffer) {
// --- Event processing --------------------------------------------------------
relayRPC.onConnected = {
let hello = RelayCommandDataHello(version: UInt32(relayVersion))
let hello = RelayCommandDataHello(
version: UInt32(relayVersion), sessionId: [], eventSeq: 0)
relayRPC.send(data: hello)
}
@@ -842,11 +846,11 @@ relayRPC.onEvent = { message in
b.bufferName = data.new
refreshBufferList()
if b.bufferName == relayBufferCurrent {
relayBufferCurrent = data.new
refreshStatus()
}
refreshBufferList()
if b.bufferName == relayBufferLast {
relayBufferLast = data.new
}
@@ -1203,6 +1207,7 @@ class WindowDelegate: NSObject, NSWindowDelegate {
b.highlighted = false
refreshIcon()
refreshBufferList()
}
// Buffer indexes rotated to start after the current buffer.
+5 -5
View File
@@ -247,16 +247,16 @@ func main() {
flag.PrintDefaults()
}
flag.Parse()
if flag.NArg() < 1 {
flag.Usage()
os.Exit(2)
}
if *version {
fmt.Printf("%s %s\n", projectName, projectVersion)
return
}
if flag.NArg() < 1 {
flag.Usage()
os.Exit(2)
}
text, err := io.ReadAll(os.Stdin)
if err != nil {
log.Fatalln(err)
+1 -1
View File
@@ -6,7 +6,7 @@ tools = ../liberty/tools
outputs = xP proto.go public/proto.js public/mithril.js
all: $(outputs) public/ircfmt.woff2
xP: xP.go proto.go
xP: xP.go proto.go public/proto.js public/mithril.js public/xP.css public/xP.js
go build -o $@
proto.go: $(tools)/lxdrgen.awk $(tools)/lxdrgen-go.awk ../xC.lxdr
$(AWK) -f $(tools)/lxdrgen.awk -f $(tools)/lxdrgen-go.awk \
+3 -6
View File
@@ -1,10 +1,7 @@
module janouch.name/xK/xP
go 1.18
go 1.22
require nhooyr.io/websocket v1.8.7
toolchain go1.23.2
require (
github.com/klauspost/compress v1.15.9 // indirect
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
)
require nhooyr.io/websocket v1.8.17
+2 -62
View File
@@ -1,62 +1,2 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
nhooyr.io/websocket v1.8.17 h1:KEVeLJkUywCKVsnLIDlD/5gtayKp8VoCkksHCGGfT9Y=
nhooyr.io/websocket v1.8.17/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
+4 -1
View File
@@ -66,8 +66,11 @@ body {
bottom: -1px;
background: #ccc;
}
.invisible {
visibility: hidden;
}
.toolbar {
.toolbar, .title div {
display: flex;
align-items: baseline;
margin-right: -.3em;
+125 -41
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2022 - 2023, Přemysl Eric Janouch <p@janouch.name>
// Copyright (c) 2022 - 2026, Přemysl Eric Janouch <p@janouch.name>
// SPDX-License-Identifier: 0BSD
import * as Relay from './proto.js'
@@ -9,14 +9,40 @@ class RelayRPC extends EventTarget {
super()
this.url = url
this.commandSeq = 0
this.promised = {}
// Session to resume after a lost connection, and our progress in it.
this.sessionId = ''
this.lastEventSeq = 0
this.connecting = false
}
// FIXME: The m.redraws are contamination for properties
// that should have an event: this.connecting, this.busy
// When we can't resume our session, a 'reset' event will ask for the model
// to be reinitialized.
connect() {
// We can't close the connection immediately, as that queues a task.
if (this.connecting)
return
this.connecting = true
m.redraw()
// We can't reopen the socket immediately, as closing queues a task.
if (this.ws === undefined)
this._connect()
else {
this.ws.addEventListener('close',
() => this._connect(), {once: true})
this.ws.close()
}
}
_connect() {
if (this.ws !== undefined)
throw "Already connecting or connected"
return new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
let ws = this.ws = new WebSocket(this.url)
ws.onopen = event => {
this._initialize()
@@ -27,6 +53,20 @@ class RelayRPC extends EventTarget {
this.ws = undefined
reject()
}
}).then(() => {
return this.send({
command: 'Hello',
version: Relay.version,
sessionId: this.sessionId,
// Continue right after the last event we have processed.
eventSeq: this.sessionId ? (this.lastEventSeq + 1) >>> 0 : 0,
})
}).catch(error => {
// Failures manifest as a closed connection.
console.error(error)
}).finally(() => {
this.connecting = false
m.redraw()
})
}
@@ -42,8 +82,6 @@ class RelayRPC extends EventTarget {
this.ws.onclose = event => {
let message = "Connection closed: " +
event.reason + " (" + event.code + ")"
for (const seq in this.promised)
this.promised[seq].reject(message)
this.ws = undefined
this.dispatchEvent(new CustomEvent('close', {
@@ -52,8 +90,6 @@ class RelayRPC extends EventTarget {
// Now connect() can be called again.
}
this.promised = {}
}
_process(data) {
@@ -66,19 +102,25 @@ class RelayRPC extends EventTarget {
}
_processOne(message) {
this.lastEventSeq = message.eventSeq
let e = message.data
let p
switch (e.event) {
case Relay.Event.Error:
if (this.promised[e.commandSeq] !== undefined)
this.promised[e.commandSeq].reject(e.error)
else
if ((p = this.promised[e.commandSeq]) === undefined)
console.error(`Unawaited error: ${e.error}`)
else if (p !== true)
p.reject(e.error)
break
case Relay.Event.Response:
if (this.promised[e.commandSeq] !== undefined)
this.promised[e.commandSeq].resolve(e.data)
else
if (e.data.command === Relay.Command.Hello)
this._adoptSession(base64Encode(e.data.sessionId), e.commandSeq)
if ((p = this.promised[e.commandSeq]) === undefined)
console.error("Unawaited response")
else if (p !== true)
p.resolve(e.data)
break
default:
e.eventSeq = message.eventSeq
@@ -89,12 +131,37 @@ class RelayRPC extends EventTarget {
delete this.promised[e.commandSeq]
for (const seq in this.promised) {
// We don't particularly care about wraparound issues.
if (seq >= e.commandSeq)
continue
this.promised[seq].reject("No response")
delete this.promised[seq]
if (seq < e.commandSeq)
this._abandon(seq, "No response")
}
m.redraw()
}
_adoptSession(sessionId, seq) {
if (sessionId === this.sessionId)
return
// Nothing else can be answered from within the new session.
for (const pending in this.promised)
if (pending != seq)
this._abandon(pending, "Session lost")
this.sessionId = sessionId
this.dispatchEvent(new CustomEvent('reset'))
}
// Stop waiting for a reply that is never going to arrive.
_abandon(seq, message) {
const p = this.promised[seq]
if (p !== true)
p.reject(message)
delete this.promised[seq]
}
get busy() {
for (const seq in this.promised)
return true
return false
}
send(params) {
@@ -110,6 +177,9 @@ class RelayRPC extends EventTarget {
this.ws.send(JSON.stringify({commandSeq: seq, data: params}))
this.promised[seq] = true
m.redraw()
// Automagically detect if we want a result.
let data = undefined
const promise = new Promise(
@@ -127,6 +197,8 @@ class RelayRPC extends EventTarget {
function utf8Encode(s) { return new TextEncoder().encode(s) }
function utf8Decode(s) { return new TextDecoder().decode(s) }
function base64Encode(bytes) { return btoa(String.fromCharCode(...bytes)) }
function hasShortcutModifiers(event) {
return (event.altKey || event.escapePrefix) &&
!event.metaKey && !event.ctrlKey
@@ -191,6 +263,27 @@ let bufferAutoscroll = true
let servers = new Map()
rpc.addEventListener('reset', event => {
buffers.clear()
bufferLast = undefined
bufferCurrent = undefined
bufferLog = undefined
bufferAutoscroll = true
servers.clear()
})
let lastActive = undefined
function notifyActive() {
// Reduce unnecessary traffic.
const now = Date.now()
if (lastActive === undefined || (now - lastActive >= 5000)) {
lastActive = now
rpc.send({command: 'Active'})
}
}
function bufferResetStats(b) {
b.newMessages = 0
b.newUnimportantMessages = 0
@@ -237,23 +330,7 @@ function bufferToggleLog() {
})
}
let connecting = true
rpc.connect().then(result => {
buffers.clear()
bufferLast = undefined
bufferCurrent = undefined
bufferLog = undefined
bufferAutoscroll = true
servers.clear()
rpc.send({command: 'Hello', version: Relay.version})
connecting = false
m.redraw()
}).catch(error => {
connecting = false
m.redraw()
})
rpc.connect()
rpc.addEventListener('close', event => {
m.redraw()
@@ -695,10 +772,8 @@ let Buffer = {
dom.scrollTop + dom.clientHeight + 1 >= dom.scrollHeight
let b = buffers.get(bufferCurrent)
if (b !== undefined && b.highlighted && !bufferAutoscroll) {
if (b !== undefined && b.highlighted && !bufferAutoscroll)
b.highlighted = false
m.redraw()
}
}}, lines)
},
}
@@ -1000,7 +1075,7 @@ let Input = {
onKeyDown: event => {
// TODO: And perhaps on other actions, too.
rpc.send({command: 'Active'})
notifyActive()
let b = buffers.get(bufferCurrent)
if (b === undefined || event.isComposing)
@@ -1095,7 +1170,7 @@ let Input = {
let Main = {
view: vnode => {
let overlay = undefined
if (connecting)
if (rpc.connecting)
overlay = m('.overlay', {}, "Connecting...")
else if (rpc.ws === undefined)
overlay = m('.overlay', {}, [
@@ -1105,7 +1180,16 @@ let Main = {
return m('.xP', {}, [
overlay,
m('.title', {}, [m('b', {}, `xP`), m(Topic)]),
m('.title', {}, [
m('div', [
// Midline Horizontal Ellipsis, No-Break Space
m('span', {class: rpc.busy ? undefined : 'invisible'},
`\u22EF\u00A0`),
m('b', {}, `xP`),
m('button', {onclick: () => rpc.connect()}, '⟳'),
]),
m(Topic),
]),
m('.middle', {}, [m(BufferList), m(BufferContainer)]),
m(Status),
m('.input', {}, [m(Prompt), m(Input)]),
+73 -20
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2022, Přemysl Eric Janouch <p@janouch.name>
// Copyright (c) 2022 - 2025, Přemysl Eric Janouch <p@janouch.name>
// SPDX-License-Identifier: 0BSD
package main
@@ -6,12 +6,16 @@ package main
import (
"bufio"
"context"
"crypto/sha1"
"embed"
"encoding/binary"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"html/template"
"io"
"io/fs"
"log"
"net"
"net/http"
@@ -23,7 +27,12 @@ import (
)
var (
debug = flag.Bool("debug", false, "enable debug output")
debug = flag.Bool("debug", false, "enable debug output")
webRoot = flag.String("webroot", "", "override bundled web resources")
//go:embed public/*
webResources embed.FS
webResourcesHash string
addressBind string
addressConnect string
@@ -75,12 +84,12 @@ func relayMakeReceiver(ctx context.Context, conn net.Conn) <-chan []byte {
go func() {
defer close(p)
for {
j := relayReadFrame(r)
if j == nil {
b := relayReadFrame(r)
if b == nil {
return
}
select {
case p <- j:
case p <- b:
case <-ctx.Done():
return
}
@@ -145,14 +154,13 @@ func clientWriteError(ctx context.Context, ws *websocket.Conn, err error) bool {
b, ok := (&RelayEventMessage{
EventSeq: 0,
Data: RelayEventData{
Interface: RelayEventDataError{
Event: RelayEventError,
Variant: &RelayEventDataError{
CommandSeq: 0,
Error: err.Error(),
},
},
}).AppendTo(nil)
if ok {
if !ok {
log.Println("Event serialization failed")
return false
}
@@ -168,9 +176,11 @@ func handleWS(w http.ResponseWriter, r *http.Request) {
}
// AppleWebKit can be broken with compression.
if agent := r.UserAgent(); strings.Contains(agent, " Version/") &&
(strings.HasPrefix(agent, "Mozilla/5.0 (Macintosh; ") ||
strings.HasPrefix(agent, "Mozilla/5.0 (iPhone; ")) {
// It would be more reliable to check for 'ApplePaySession' in window in JS,
// and have us disable compression based on a query parameter.
if agent := r.UserAgent(); (strings.Contains(agent, " Version/") &&
strings.HasPrefix(agent, "Mozilla/5.0 (Macintosh; ")) ||
strings.HasPrefix(agent, "Mozilla/5.0 (iPhone; ") {
opts.CompressionMode = websocket.CompressionDisabled
}
@@ -241,21 +251,20 @@ func handleWS(w http.ResponseWriter, r *http.Request) {
// -----------------------------------------------------------------------------
var staticHandler = http.FileServer(http.Dir("."))
var page = template.Must(template.New("/").Parse(`<!DOCTYPE html>
<html>
<head>
<title>xP</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="{{ .Root }}/">
<link rel="stylesheet" href="xP.css" />
</head>
<body>
<script src="mithril.js">
</script>
<script>
let proxy = '{{ . }}'
let proxy = '{{ .Proxy }}'
</script>
<script type="module" src="xP.js">
</script>
@@ -263,20 +272,49 @@ var page = template.Must(template.New("/").Parse(`<!DOCTYPE html>
</html>`))
func handleDefault(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
staticHandler.ServeHTTP(w, r)
return
}
wsURI := addressWS
if wsURI == "" {
wsURI = fmt.Sprintf("ws://%s/ws", r.Host)
}
if err := page.Execute(w, wsURI); err != nil {
args := struct {
Root string
Proxy string
}{
Root: webResourcesHash,
Proxy: wsURI,
}
if err := page.Execute(w, &args); err != nil {
log.Println("Template execution failed: " + err.Error())
}
}
func hashFS(root fs.FS) []byte {
hasher := sha1.New()
callback := func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
// Note that this can be fooled.
fmt.Fprintln(hasher, path)
if !d.IsDir() {
file, err := root.Open(path)
if err != nil {
return err
}
defer file.Close()
io.Copy(hasher, file)
}
return nil
}
if err := fs.WalkDir(root, ".", callback); err != nil {
log.Fatalln(err)
}
return hasher.Sum(nil)
}
func main() {
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(),
@@ -295,6 +333,21 @@ func main() {
addressWS = flag.Arg(2)
}
subResources, err := fs.Sub(webResources, "public")
if err != nil {
log.Fatalln(err)
}
if *webRoot != "" {
subResources = os.DirFS(*webRoot)
}
// The simplest way of ensuring that web browsers don't use
// stale cached copies of our files.
webResourcesHash = hex.EncodeToString(hashFS(subResources))
http.Handle("/"+webResourcesHash+"/",
http.StripPrefix("/"+webResourcesHash+"/",
http.FileServerFS(subResources)))
http.Handle("/ws", http.HandlerFunc(handleWS))
http.Handle("/", http.HandlerFunc(handleDefault))
+2
View File
@@ -0,0 +1,2 @@
/xR
/proto.go
+17
View File
@@ -0,0 +1,17 @@
.POSIX:
AWK = env LC_ALL=C awk
tools = ../liberty/tools
generated = proto.go
outputs = xR $(generated)
all: $(outputs)
generate: $(generated)
proto.go: $(tools)/lxdrgen.awk $(tools)/lxdrgen-go.awk ../xC.lxdr
$(AWK) -f $(tools)/lxdrgen.awk -f $(tools)/lxdrgen-go.awk \
-v PrefixCamel=Relay ../xC.lxdr > $@
xR: xR.go ../xK-version $(generated)
go build -ldflags "-X 'main.projectVersion=$$(cat ../xK-version)'" -o $@ \
-gcflags=all="-N -l"
clean:
rm -f $(outputs)
+5
View File
@@ -0,0 +1,5 @@
module janouch.name/xK/xR
go 1.23.0
toolchain go1.24.0
+41
View File
@@ -0,0 +1,41 @@
xR(1)
=====
:doctype: manpage
:manmanual: xK Manual
:mansource: xK {release-version}
Name
----
xR - xC relay protocol analyzer
Synopsis
--------
*xR* [_OPTION_]... RELAY-ADDRESS...
Description
-----------
*xR* connects to an *xC* relay and prints all incoming events one per line
in JSON format. The JSON objects have two additional fields:
when::
The time of reception (or sending) as a nanosecond precision
RFC 3339 UTC timestamp.
raw::
The incoming event (or outgoing command) in raw binary form.
Options
-------
*-debug*::
Print any outgoing commands as well, which may help in debugging any issues.
*-version*::
Output version information and exit.
Reporting bugs
--------------
Use https://git.janouch.name/p/xK to report bugs, request features,
or submit pull requests.
See also
--------
*xC*(1)
+134
View File
@@ -0,0 +1,134 @@
// Copyright (c) 2025, Přemysl Eric Janouch <p@janouch.name>
// SPDX-License-Identifier: 0BSD
package main
import (
"encoding/binary"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"log"
"net"
"os"
"time"
)
var (
debug = flag.Bool("debug", false, "enable debug output")
version = flag.Bool("version", false, "show version and exit")
projectName = "xR"
projectVersion = "?"
)
func now() string {
return time.Now().UTC().Format(time.RFC3339Nano)
}
func relayReadFrame(r io.Reader) bool {
var length uint32
if err := binary.Read(
r, binary.BigEndian, &length); errors.Is(err, io.EOF) {
return false
} else if err != nil {
log.Fatalln("Event receive failed: " + err.Error())
}
b := make([]byte, length)
if _, err := io.ReadFull(r, b); errors.Is(err, io.EOF) {
return false
} else if err != nil {
log.Fatalln("Event receive failed: " + err.Error())
}
m := struct {
When string `json:"when"`
Binary []byte `json:"raw"`
RelayEventMessage
}{
When: now(),
Binary: b,
}
if after, ok := m.RelayEventMessage.ConsumeFrom(b); !ok {
log.Println("Event deserialization failed")
} else if len(after) != 0 {
log.Println("Event deserialization failed: trailing data")
return true
}
j, err := json.Marshal(m)
if err != nil {
log.Fatalln("Event marshalling failed: " + err.Error())
}
fmt.Printf("%s\n", j)
return true
}
func run(addressConnect string) {
conn, err := net.Dial("tcp", addressConnect)
if err != nil {
log.Println("Connection failed: " + err.Error())
return
}
defer conn.Close()
// We can only support this one protocol version
// that proto.go has been generated for.
m := RelayCommandMessage{CommandSeq: 0, Data: RelayCommandData{
Variant: &RelayCommandDataHello{Version: RelayVersion},
}}
b, ok := m.AppendTo(make([]byte, 4))
if !ok {
log.Fatalln("Command serialization failed")
}
binary.BigEndian.PutUint32(b[:4], uint32(len(b)-4))
if _, err := conn.Write(b); err != nil {
log.Fatalln("Command send failed: " + err.Error())
}
// You can differentiate the direction by the presence
// of .data.command or .data.event.
if *debug {
j, err := json.Marshal(struct {
When string `json:"when"`
Binary []byte `json:"raw"`
RelayCommandMessage
}{
When: now(),
Binary: b,
RelayCommandMessage: m,
})
if err != nil {
log.Fatalln("Command marshalling failed: " + err.Error())
}
fmt.Printf("%s\n", j)
}
for relayReadFrame(conn) {
}
}
func main() {
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(),
"Usage: %s [OPTION...] CONNECT\n\n", os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
if *version {
fmt.Printf("%s %s (relay protocol version %d)\n",
projectName, projectVersion, RelayVersion)
return
}
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
// TODO(p): This program should be able to run as a filter as well.
run(flag.Arg(0))
}
+1 -1
View File
@@ -5,7 +5,7 @@ AWK = env LC_ALL=C awk
outputs = xS xS-replies.go xS.1
all: $(outputs)
xS: xS.go ../xK-version xS-replies.go
xS: xS.go xS-replies.go ../xK-version
go build -ldflags "-X 'main.projectVersion=$$(cat ../xK-version)'" -o $@
xS-replies.go: xS-gen-replies.awk xS-replies
$(AWK) -f xS-gen-replies.awk xS-replies > $@
+20 -10
View File
@@ -910,6 +910,10 @@ func (c *client) nicknameOrStar() string {
func (c *client) unregister(reason string) {
if !c.registered {
if c.nickname != "" {
delete(users, ircToCanon(c.nickname))
c.nickname = ""
}
return
}
@@ -1126,7 +1130,9 @@ func (c *client) sendLUSERS() {
nChannels := 0
for _, ch := range channels {
if 0 != ch.modes&ircChanModeSecret {
if 0 == ch.modes&ircChanModeSecret {
nChannels++
} else if _, present := ch.userModes[c]; present {
nChannels++
}
}
@@ -1440,7 +1446,7 @@ func ircHandleUSER(msg *message, c *client) {
c.realname = realname
c.mode = 0
if m, err := strconv.ParseUint(mode, 10, 32); err != nil {
if m, err := strconv.ParseUint(mode, 10, 32); err == nil {
if 0 != m&4 {
c.mode |= ircUserModeRxWallops
}
@@ -1494,7 +1500,7 @@ func ircHandleLUSERS(msg *message, c *client) {
func ircHandleMOTD(msg *message, c *client) {
if len(msg.params) > 0 && !ircIsThisMe(msg.params[0]) {
c.sendReply(ERR_NOSUCHSERVER, msg.params[1])
c.sendReply(ERR_NOSUCHSERVER, msg.params[0])
return
}
c.sendMOTD()
@@ -1868,9 +1874,9 @@ func (mp *modeProcessor) step(modeChar byte) bool {
case 'b':
mp.doList(&mp.ch.banList, RPL_BANLIST, RPL_ENDOFBANLIST)
case 'e':
mp.doList(&mp.ch.banList, RPL_EXCEPTLIST, RPL_ENDOFEXCEPTLIST)
mp.doList(&mp.ch.exceptionList, RPL_EXCEPTLIST, RPL_ENDOFEXCEPTLIST)
case 'I':
mp.doList(&mp.ch.banList, RPL_INVITELIST, RPL_ENDOFINVITELIST)
mp.doList(&mp.ch.inviteList, RPL_INVITELIST, RPL_ENDOFINVITELIST)
case 'k':
mp.doKey()
@@ -2373,7 +2379,7 @@ func ircHandleTOPIC(msg *message, c *client) {
}
ch.topic = msg.params[1]
ch.topicWho = fmt.Sprintf("%s@%s@%s", c.nickname, c.username, c.hostname)
ch.topicWho = fmt.Sprintf("%s!%s@%s", c.nickname, c.username, c.hostname)
ch.topicTime = time.Now()
message := fmt.Sprintf(":%s!%s@%s TOPIC %s :%s",
@@ -2397,7 +2403,7 @@ func ircTryPart(c *client, channelName string, reason string) {
return
}
message := fmt.Sprintf(":%s@%s@%s PART %s :%s",
message := fmt.Sprintf(":%s!%s@%s PART %s :%s",
c.nickname, c.username, c.hostname, channelName, reason)
if 0 == ch.modes&ircChanModeQuiet {
ircChannelMulticast(ch, message, nil)
@@ -2454,12 +2460,15 @@ func ircTryKick(c *client, channelName, nick, reason string) {
return
}
message := fmt.Sprintf(":%s@%s@%s KICK %s %s :%s",
message := fmt.Sprintf(":%s!%s@%s KICK %s %s :%s",
c.nickname, c.username, c.hostname, channelName, nick, reason)
if 0 == ch.modes&ircChanModeQuiet {
ircChannelMulticast(ch, message, nil)
} else {
c.send(message)
if c != client {
client.send(message)
}
}
delete(ch.userModes, client)
@@ -2485,7 +2494,7 @@ func ircHandleKICK(msg *message, c *client) {
ircTryKick(c, targetChannels[0], targetUsers[i], reason)
}
} else {
for i := 0; i < len(channels) && i < len(targetUsers); i++ {
for i := 0; i < len(targetChannels) && i < len(targetUsers); i++ {
ircTryKick(c, targetChannels[i], targetUsers[i], reason)
}
}
@@ -2560,7 +2569,7 @@ func ircTryJoin(c *client, channelName, key string) {
}
_, invitedByChanop := c.invites[ircToCanon(channelName)]
if 0 != ch.modes&ircChanModeInviteOnly && c.inMaskList(ch.inviteList) &&
if 0 != ch.modes&ircChanModeInviteOnly && !c.inMaskList(ch.inviteList) &&
!invitedByChanop {
c.sendReply(ERR_INVITEONLYCHAN, channelName)
return
@@ -3113,6 +3122,7 @@ func processOneEvent() {
capVersion: 301,
opened: time.Now(),
lastActive: time.Now(),
invites: map[string]bool{},
// TODO: Make this configurable and more fine-grained.
antiflood: newFloodDetector(10*time.Second, 20),
}
+191
View File
@@ -0,0 +1,191 @@
# As per Qt 6.8 documentation, at least 3.16 is necessary
# CMake 3.21 has RUNTIME_DEPENDENCY_SET.
cmake_minimum_required (VERSION 3.21.1)
file (READ ../xK-version project_version)
configure_file (../xK-version xK-version.tag COPYONLY)
string (STRIP "${project_version}" project_version)
# This is an entirely separate CMake project.
project (xT VERSION "${project_version}"
DESCRIPTION "Qt frontend for xC" LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
find_package (Qt6 REQUIRED COMPONENTS Widgets Network Multimedia)
qt_standard_project_setup ()
add_compile_options ("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options ("$<$<CXX_COMPILER_ID:GNU>:-Wall;-Wextra>")
add_compile_options ("$<$<CXX_COMPILER_ID:Clang>:-Wall;-Wextra>")
set (project_config "${PROJECT_BINARY_DIR}/config.h")
configure_file ("${PROJECT_SOURCE_DIR}/config.h.in" "${project_config}")
include_directories ("${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
# Produce a beep sample
find_program (sox_EXECUTABLE sox REQUIRED)
set (beep "${PROJECT_BINARY_DIR}/beep.wav")
add_custom_command (OUTPUT "${beep}"
COMMAND ${sox_EXECUTABLE} -b 16 -Dr 44100 -n "${beep}"
synth 0.1 0 25 triangle 800 vol 0.5 fade t 0 -0 0.005 pad 0 0.05
COMMENT "Generating a beep sample" VERBATIM)
set_property (SOURCE "${beep}" APPEND PROPERTY QT_RESOURCE_ALIAS beep.wav)
# Rasterize SVG icons
set (root "${PROJECT_SOURCE_DIR}/..")
set (CMAKE_MODULE_PATH "${root}/liberty/cmake")
include (IconUtils)
# It might generally be better to use QtSvg, though it is an extra dependency.
# The icon_to_png macro is not intended to be used like this.
foreach (icon xT xT-highlighted)
icon_to_png (${icon} "${PROJECT_SOURCE_DIR}/${icon}.svg"
48 "${PROJECT_BINARY_DIR}/resources" icon_png)
set_property (SOURCE "${icon_png}"
APPEND PROPERTY QT_RESOURCE_ALIAS "${icon}.png")
list (APPEND icon_rsrc_list "${icon_png}")
endforeach ()
function (android_mipmap_icon svg density size output_dir output)
set (_mipmap_dir "${output_dir}/res/mipmap-${density}")
set (_png "${_mipmap_dir}/ic_launcher.png")
set (${output} "${_png}" PARENT_SCOPE)
find_program (rsvg_convert_EXECUTABLE rsvg-convert REQUIRED)
add_custom_command (OUTPUT "${_png}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${_mipmap_dir}"
COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png}"
"--width=${size}" "--height=${size}" -- "${svg}"
DEPENDS "${svg}"
COMMENT "Generating Android ${density} application icon" VERBATIM)
endfunction ()
if (ANDROID)
set (android_base "${PROJECT_BINARY_DIR}/android")
set (android_icon_list)
foreach (density_size
ldpi:36 mdpi:48 hdpi:72 xhdpi:96 xxhdpi:144 xxxhdpi:192)
string (REPLACE ":" ";" density_size "${density_size}")
android_mipmap_icon ("${PROJECT_SOURCE_DIR}/xT.svg"
${density_size} "${android_base}" android_icon)
list (APPEND android_icon_list "${android_icon}")
endforeach ()
add_custom_target (android-icons ALL DEPENDS ${android_icon_list})
elseif (APPLE)
set (MACOSX_BUNDLE_ICON_FILE xT.icns)
icon_to_icns ("${PROJECT_SOURCE_DIR}/xT.svg"
"${MACOSX_BUNDLE_ICON_FILE}" icon_icns)
else ()
# The largest size is mainly for an appropriately sized Windows icon
set (icon_base "${PROJECT_BINARY_DIR}/icons")
set (icon_png_list)
foreach (icon_size 16 32 48 256)
icon_to_png (xT "${PROJECT_SOURCE_DIR}/xT.svg"
${icon_size} "${icon_base}" icon_png)
list (APPEND icon_png_list "${icon_png}")
endforeach ()
add_custom_target (icons ALL DEPENDS ${icon_png_list})
if (WIN32)
list (REMOVE_ITEM icon_png_list "${icon_png}")
set (icon_ico "${PROJECT_BINARY_DIR}/xT.ico")
icon_for_win32 ("${icon_ico}" "${icon_png_list}" "${icon_png}")
set (resource_file "${PROJECT_BINARY_DIR}/xT.rc")
list (APPEND project_sources "${resource_file}")
# Qt specifically looks up IDI_ICON1 and nothing else.
add_custom_command (OUTPUT "${resource_file}"
COMMAND ${CMAKE_COMMAND} -E echo "IDI_ICON1 ICON \"xT.ico\""
> ${resource_file} VERBATIM)
set_property (SOURCE "${resource_file}"
APPEND PROPERTY OBJECT_DEPENDS ${icon_ico})
endif ()
endif ()
# Build the main executable and link it
find_program (awk_EXECUTABLE awk REQUIRED)
add_custom_command (OUTPUT xC-proto.cpp
COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${awk_EXECUTABLE}
-f ${root}/liberty/tools/lxdrgen.awk
-f ${root}/liberty/tools/lxdrgen-cpp.awk
-v PrefixCamel=Relay
${root}/xC.lxdr > xC-proto.cpp
DEPENDS
${root}/liberty/tools/lxdrgen.awk
${root}/liberty/tools/lxdrgen-cpp.awk
${root}/xC.lxdr
COMMENT "Generating xC relay protocol code" VERBATIM)
add_custom_target (xC-proto DEPENDS ${PROJECT_BINARY_DIR}/xC-proto.cpp)
list (APPEND project_sources "${root}/liberty/tools/lxdrgen-cpp-qt.cpp")
qt_add_executable (xT
xT.cpp ${project_config} ${project_sources} "${icon_icns}")
add_dependencies (xT xC-proto)
qt_add_resources (xT "rsrc" PREFIX / FILES "${beep}" ${icon_rsrc_list})
target_link_libraries (xT PRIVATE Qt6::Widgets Qt6::Network Qt6::Multimedia)
set_target_properties (xT PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER name.janouch.xT
QT_ANDROID_APP_NAME xT
QT_ANDROID_APP_ICON "@mipmap/ic_launcher"
QT_ANDROID_PACKAGE_NAME name.janouch.xT
QT_ANDROID_PACKAGE_SOURCE_DIR "${android_base}")
if (ANDROID)
add_dependencies (xT android-icons)
endif ()
# https://stackoverflow.com/questions/79079161 and resolved in Qt Creator 16.
set (QT_QML_GENERATE_QMLLS_INI ON)
# The files to be installed
include (GNUInstallDirs)
if (ANDROID)
install (TARGETS xT DESTINATION .)
elseif (APPLE OR WIN32)
install (TARGETS xT
RUNTIME_DEPENDENCY_SET dependencies_xT
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (WIN32)
install (RUNTIME_DEPENDENCY_SET dependencies_xT DIRECTORIES $ENV{PATH}
PRE_EXCLUDE_REGEXES "api-ms-win-.*"
POST_EXCLUDE_REGEXES ".*[/\\]system32[/\\].*")
endif ()
qt_generate_deploy_app_script (TARGET xT OUTPUT_SCRIPT deploy_xT)
install (SCRIPT "${deploy_xT}")
# At least with Homebrew Qt, you will get QTBUG-127075,
# which can be circumvented by running macdeployqt twice.
if (APPLE)
install (SCRIPT "${deploy_xT}")
endif ()
else ()
install (TARGETS xT DESTINATION ${CMAKE_INSTALL_BINDIR})
install (FILES ../LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
install (FILES xT.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install (DIRECTORY ${icon_base}
DESTINATION ${CMAKE_INSTALL_DATADIR})
install (FILES xT.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
endif ()
# CPack
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE")
set (CPACK_GENERATOR "TGZ;ZIP")
set (CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${PROJECT_VERSION}")
set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
set (CPACK_SOURCE_IGNORE_FILES "/build;/CMakeLists.txt.user")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
include (CPack)
+7
View File
@@ -0,0 +1,7 @@
#ifndef CONFIG_H
#define CONFIG_H
#define PROJECT_NAME "${PROJECT_NAME}"
#define PROJECT_VERSION "${project_version}"
#endif // ! CONFIG_H
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" width="48" height="48" viewBox="0 0 48 48"
xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="green-x">
<stop stop-color="hsl(66, 100%, 80%)" offset="0" />
<stop stop-color="hsl(66, 100%, 50%)" offset="1" />
</radialGradient>
<radialGradient id="orange">
<stop stop-color="hsl(36, 100%, 60%)" offset="0" />
<stop stop-color="hsl(23, 100%, 60%)" offset="1" />
</radialGradient>
<filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">
<feDropShadow dx="0" dy="0" stdDeviation="0.05"
flood-color="rgba(0, 0, 0, .5)" />
</filter>
</defs>
<!-- XXX: librsvg screws up shadows on rotated objects. -->
<g filter="url(#shadow)" transform="translate(24 3) scale(16)">
<path fill="url(#orange)" stroke="hsl(36, 100%, 20%)" stroke-width="0.1"
d="M-.8 0 H.8 V.5 H.25 V2.625 H-.25 V.5 H-.8 Z" />
</g>
<g filter="url(#shadow)" transform="translate(24 28) rotate(-45) scale(16)">
<path fill="url(#green-x)" stroke="hsl(66, 100%, 20%)" stroke-width="0.1"
d="M-.25 -1 H.25 V-.25 H1 V.25 H.25 V1 H-.25 V.25 H-1 V-.25 H-.25 Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+1737
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=xT
GenericName=IRC Client
Icon=xT
Exec=xT
StartupNotify=false
Categories=Network;Chat;IRCClient;
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg version="1.1" width="48" height="48" viewBox="0 0 48 48"
xmlns="http://www.w3.org/2000/svg">
<defs>
<radialGradient id="grey-x">
<stop stop-color="hsl(66, 0%, 90%)" offset="0" />
<stop stop-color="hsl(66, 0%, 80%)" offset="1" />
</radialGradient>
<radialGradient id="orange">
<stop stop-color="hsl(36, 100%, 60%)" offset="0" />
<stop stop-color="hsl(23, 100%, 60%)" offset="1" />
</radialGradient>
<filter id="shadow" x="-50%" y="-50%" width="200%" height="200%">
<feDropShadow dx="0" dy="0" stdDeviation="0.05"
flood-color="rgba(0, 0, 0, .5)" />
</filter>
</defs>
<!-- XXX: librsvg screws up shadows on rotated objects. -->
<g filter="url(#shadow)" transform="translate(24 28) rotate(-45) scale(16)">
<path fill="url(#grey-x)" stroke="hsl(66, 0%, 30%)" stroke-width="0.1"
d="M-.25 -1 H.25 V-.25 H1 V.25 H.25 V1 H-.25 V.25 H-1 V-.25 H-.25 Z" />
</g>
<g filter="url(#shadow)" transform="translate(24 3) scale(16)">
<path fill="url(#orange)" stroke="hsl(36, 100%, 20%)" stroke-width="0.1"
d="M-.8 0 H.8 V.5 H.25 V2.625 H-.25 V.5 H-.8 Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+118 -78
View File
@@ -1,7 +1,7 @@
/*
* xW.cpp: Win32 frontend for xC
*
* Copyright (c) 2023, Přemysl Eric Janouch <p@janouch.name>
* Copyright (c) 2023 - 2024, Přemysl Eric Janouch <p@janouch.name>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
@@ -221,6 +221,14 @@ relay_try_write(std::wstring &error)
return true;
}
static void
on_relay_generic_response(
std::wstring error, const Relay::ResponseData *response)
{
if (!response)
show_error_message(error.c_str());
}
static void
relay_send(Relay::CommandData *data, Callback callback = {})
{
@@ -232,6 +240,8 @@ relay_send(Relay::CommandData *data, Callback callback = {})
if (callback)
g.command_callbacks[m.command_seq] = std::move(callback);
else
g.command_callbacks[m.command_seq] = on_relay_generic_response;
uint32_t len = htonl(w.data.size());
uint8_t *prefix = reinterpret_cast<uint8_t *>(&len);
@@ -255,73 +265,6 @@ buffer_by_name(const std::wstring &name)
return nullptr;
}
static void
buffer_activate(const std::wstring &name)
{
auto activate = new Relay::CommandData_BufferActivate();
activate->buffer_name = name;
relay_send(activate);
}
static void
buffer_toggle_unimportant(const std::wstring &name)
{
auto toggle = new Relay::CommandData_BufferToggleUnimportant();
toggle->buffer_name = name;
relay_send(toggle);
}
// --- Current buffer ----------------------------------------------------------
static void
buffer_toggle_log(
const std::wstring &error, const Relay::ResponseData_BufferLog *response)
{
if (!response) {
show_error_message(error.c_str());
return;
}
std::wstring log;
if (!LibertyXDR::utf8_to_wstring(
response->log.data(), response->log.size(), log)) {
show_error_message(L"Invalid encoding.");
return;
}
std::wstring filtered;
for (auto wch : log) {
if (wch == L'\n')
filtered += L"\r\n";
else
filtered += wch;
}
SetWindowText(g.hwndBufferLog, filtered.c_str());
ShowWindow(g.hwndBuffer, SW_HIDE);
ShowWindow(g.hwndBufferLog, SW_SHOW);
}
static void
buffer_toggle_log()
{
if (IsWindowVisible(g.hwndBufferLog)) {
ShowWindow(g.hwndBufferLog, SW_HIDE);
ShowWindow(g.hwndBuffer, SW_SHOW);
SetWindowText(g.hwndBufferLog, L"");
return;
}
auto log = new Relay::CommandData_BufferLog();
log->buffer_name = g.buffer_current;
relay_send(log, [name = g.buffer_current](auto error, auto response) {
if (g.buffer_current != name)
return;
buffer_toggle_log(error,
dynamic_cast<const Relay::ResponseData_BufferLog *>(response));
});
}
static bool
buffer_at_bottom()
{
@@ -354,6 +297,7 @@ refresh_icon()
if (b.highlighted)
icon = g.hiconHighlighted;
// XXX: This may not change the taskbar icon.
SendMessage(g.hwndMain, WM_SETICON, ICON_SMALL, (LPARAM) icon);
SendMessage(g.hwndMain, WM_SETICON, ICON_BIG, (LPARAM) icon);
}
@@ -430,6 +374,88 @@ refresh_status()
SetWindowText(g.hwndStatus, status.c_str());
}
static void
recheck_highlighted()
{
// Corresponds to the logic toggling the bool on.
auto b = buffer_by_name(g.buffer_current);
if (b && b->highlighted && buffer_at_bottom() &&
!IsIconic(g.hwndMain) && !IsWindowVisible(g.hwndBufferLog)) {
b->highlighted = false;
refresh_icon();
refresh_buffer_list();
}
}
// --- Buffer actions ----------------------------------------------------------
static void
buffer_activate(const std::wstring &name)
{
auto activate = new Relay::CommandData_BufferActivate();
activate->buffer_name = name;
relay_send(activate);
}
static void
buffer_toggle_unimportant(const std::wstring &name)
{
auto toggle = new Relay::CommandData_BufferToggleUnimportant();
toggle->buffer_name = name;
relay_send(toggle);
}
static void
buffer_toggle_log(
const std::wstring &error, const Relay::ResponseData_BufferLog *response)
{
if (!response) {
show_error_message(error.c_str());
return;
}
std::wstring log;
if (!LibertyXDR::utf8_to_wstring(
response->log.data(), response->log.size(), log)) {
show_error_message(L"Invalid encoding.");
return;
}
std::wstring filtered;
for (auto wch : log) {
if (wch == L'\n')
filtered += L"\r\n";
else
filtered += wch;
}
SetWindowText(g.hwndBufferLog, filtered.c_str());
ShowWindow(g.hwndBuffer, SW_HIDE);
ShowWindow(g.hwndBufferLog, SW_SHOW);
}
static void
buffer_toggle_log()
{
if (IsWindowVisible(g.hwndBufferLog)) {
ShowWindow(g.hwndBufferLog, SW_HIDE);
ShowWindow(g.hwndBuffer, SW_SHOW);
SetWindowText(g.hwndBufferLog, L"");
recheck_highlighted();
return;
}
auto log = new Relay::CommandData_BufferLog();
log->buffer_name = g.buffer_current;
relay_send(log, [name = g.buffer_current](auto error, auto response) {
if (g.buffer_current != name)
return;
buffer_toggle_log(error,
dynamic_cast<const Relay::ResponseData_BufferLog *>(response));
});
}
// --- Rich Edit formatting ----------------------------------------------------
static COLORREF
@@ -695,7 +721,7 @@ buffer_print_line(std::vector<BufferLine>::const_iterator begin,
static void
buffer_print_separator()
{
bool sameline = !GetWindowTextLength(g.hwndBuffer);
bool sameline = !buffer_reset_selection();
CHARFORMAT2 format = default_charformat();
format.dwEffects &= ~CFE_AUTOCOLOR;
@@ -715,7 +741,7 @@ refresh_buffer(const Buffer &b)
// PFM_BORDER is not implemented, at most we can try to construct
// an OLE object the width of the screen and see how it clips
// (this is a lot of code).
size_t i = 0, mark_before = b.lines.size() -
int64_t i = 0, mark_before = int64_t(b.lines.size()) -
b.new_messages - b.new_unimportant_messages;
for (auto line = b.lines.begin(); line != b.lines.end(); ++line) {
if (i == mark_before)
@@ -728,6 +754,7 @@ refresh_buffer(const Buffer &b)
buffer_print_and_watch_trailing_date_changes();
buffer_scroll_to_bottom();
// We will get a scroll event, so no need to recheck_highlighted() here.
SendMessage(g.hwndBuffer, WM_SETREDRAW, (WPARAM) TRUE, 0);
InvalidateRect(g.hwndBuffer, NULL, TRUE);
@@ -749,8 +776,9 @@ relay_process_buffer_line(Buffer &b, Relay::EventData_BufferLine &m)
// Retained mode is complicated.
bool display = (!m.is_unimportant || !bc->hide_unimportant) &&
(b.buffer_name == g.buffer_current || m.leak_to_active);
// XXX: It would be great if it didn't autoscroll when focused.
bool to_bottom = display &&
buffer_at_bottom();
(buffer_at_bottom() || GetFocus() == g.hwndBuffer);
bool visible = display &&
to_bottom &&
!IsIconic(g.hwndMain) &&
@@ -914,11 +942,11 @@ relay_process_message(const Relay::EventMessage &m)
b->buffer_name = data.new_;
refresh_buffer_list();
if (data.buffer_name == g.buffer_current) {
g.buffer_current = data.new_;
refresh_status();
}
refresh_buffer_list();
if (data.buffer_name == g.buffer_last)
g.buffer_last = data.new_;
break;
@@ -1029,6 +1057,9 @@ relay_process_message(const Relay::EventMessage &m)
auto &data = dynamic_cast<Relay::EventData_ServerRename &>(*m.data);
g.servers.insert_or_assign(data.new_, g.servers.at(data.server_name));
g.servers.erase(data.server_name);
for (auto &b : g.buffers)
if (b.server_name == data.server_name)
b.server_name = data.new_;
break;
}
case Relay::Event::SERVER_REMOVE:
@@ -1465,6 +1496,7 @@ richedit_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
{
// Dragging the scrollbar doesn't result in EN_VSCROLL.
LRESULT lResult = DefSubclassProc(hWnd, uMsg, wParam, lParam);
recheck_highlighted();
refresh_status();
return lResult;
}
@@ -1522,8 +1554,12 @@ process_resize(UINT w, UINT h)
MoveWindow(g.hwndBufferList, 3, top, 150, h - top - bottom, FALSE);
MoveWindow(g.hwndBuffer, 156, top, w - 159, h - top - bottom, FALSE);
MoveWindow(g.hwndBufferLog, 156, top, w - 159, h - top - bottom, FALSE);
if (to_bottom)
if (to_bottom) {
buffer_scroll_to_bottom();
} else {
recheck_highlighted();
refresh_status();
}
InvalidateRect(g.hwndMain, NULL, TRUE);
}
@@ -1685,8 +1721,10 @@ window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case WM_SYSCOMMAND:
{
// We're not deiconified yet, so duplicate recheck_highlighted().
auto b = buffer_by_name(g.buffer_current);
if (b && wParam == SC_RESTORE) {
if (wParam == SC_RESTORE && b && b->highlighted && buffer_at_bottom() &&
!IsWindowVisible(g.hwndBufferLog)) {
b->highlighted = false;
refresh_icon();
}
@@ -1694,13 +1732,15 @@ window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_COMMAND:
if (!lParam)
if (!lParam) {
process_accelerator(LOWORD(wParam));
else if (lParam == (LPARAM) g.hwndBufferList)
} else if (lParam == (LPARAM) g.hwndBufferList) {
process_bufferlist_notification(HIWORD(wParam));
else if (lParam == (LPARAM) g.hwndBuffer &&
HIWORD(wParam) == EN_VSCROLL)
} else if (lParam == (LPARAM) g.hwndBuffer &&
HIWORD(wParam) == EN_VSCROLL) {
recheck_highlighted();
refresh_status();
}
return 0;
case WM_NOTIFY:
switch (((LPNMHDR) lParam)->code) {