GNU TeXmacsUser manualReferenceAboutEnglish
The graphical user interface ports

1.Introduction

TeXmacs does not talk to a particular toolkit. The kernel only knows the abstract interfaces of

Graphics/Gui/gui.hpp

(the application: main loop, clipboards, fonts, screen size, …), of

Graphics/Gui/widget.hpp

(the widget constructors and the message protocol) and of

Graphics/Renderer/renderer.hpp

(the drawing surface). A port is a directory in

src/src/Plugins/

which implements these interfaces for one toolkit. This chapter is a comparative map of the ports which exist in this source tree and describes the port specific internals which are not covered elsewhere: how each port is selected and built, its event loop, keyboard and input methods, clipboards and printing.

The abstract interfaces themselves are documented in the abstract widget system, which also contains a checklist for porting TeXmacs to another toolkit; the reference port is described in detail in the Qt implementation, and the original toolkit in the graphical user interface (historical Widkit toolkit). The screen renderers of the ports are compared in the renderer implementations, and the operating system layers (which are independent of the graphical port) in platform support. Dialogs written in TeXmacs markup (has-markup-gui?, see the GUI through markup) only use the abstract constructors, so they work in every port.

All file names are relative to

src/src/

unless stated otherwise.

2.Overview

The ports fall into three families. Qt (with its fork

Plugins/Qt6

) and Cocoa map every abstract widget to a native widget of the toolkit. X11, SDL and Qtwk use the toolkit only for windows, events and clipboards and draw all widgets themselves with Widkit (

Plugins/Widkit

), the original widget library of TeXmacs. Vue also draws all widgets itself, but in immediate mode, with the layout library Clay.

Selection.
Exactly one port is compiled in; it is chosen when TeXmacs is configured.
Port Directories configure CMake TEXMACS_GUI Macro
Qt
Plugins/Qt
--with-gui=qt (default) Qt (default), Qt6, Qt5, Qt4 QTTEXMACS
Qt6 fork
Plugins/Qt6
--with-gui=qt --enable-qt-new (default on Android) none QTTEXMACS
Qtwk
Plugins/Qtwk
, Widkit, part of Plugins/Qt
--with-gui=qtwk none QTWKTEXMACS and QTTEXMACS
X11
Plugins/X11
, Widkit
--with-gui=x11 X11 X11TEXMACS
SDL
Plugins/SDL
, Widkit,
Plugins/MuPDF
--with-gui=sdl SDL SDLTEXMACS
Vue
Plugins/Vue
,
Plugins/MuPDF
--with-gui=vue Vue (without the GPU renderer) VUETEXMACS
Cocoa
Plugins/NS
,
Plugins/MacOS
--with-gui=cocoa (or aqua) none AQUATEXMACS

Headless mode (option -headless) is not a port but a run-time mode, implemented by Qt (both directories) and Vue, which make no windows, and by SDL, X11 and Cocoa, which make their windows but never show them, see selecting and building a port.

Run time.
The port can be recognized with gui_version () (exported as gui-version) and with the predicates of
Kernel/Abstractions/basic.cpp

, exported as qt-gui?, x-gui? and vue-gui?. qt-gui? means “implements the widgets and dialogs of Qt”, and x-gui? “has the historical X11 look and feel”. Scheme also defines ns-gui?, qt5-gui?, qt6-or-later-gui?, … from gui-version, in

kernel/boot/abbrevs.scm

.

Port gui_version Predicates which hold Screen renderer Lines
Qt "qt5", "qt6" ("qt4") qt-gui? qt_renderer_rep 25500
Qt6 fork "qt6" qt-gui? qt_renderer_rep 26800
Qtwk "qt5", "qt6" x-gui? qt_renderer_rep 3700 + Widkit
X11 "x11" x-gui? x_drawable_rep 4100 + Widkit
SDL "sdl" x-gui? mupdf_renderer_rep 2500 + Widkit
Vue "vue" vue-gui? mupdf_renderer_rep, gpu_renderer_rep 16600 + Clay
Cocoa "ns" qt-gui?, ns-gui? ns_renderer_rep 12700

The line counts are those of the C++ and Objective-C sources of the port directories, rounded. Widkit adds 10500 lines, Clay is a single header library of 5100 lines (

Vue/clay.h

), and

Plugins/MacOS

(3600 lines of Objective-C helpers: images, spell checking, the application delegate) is compiled into the Qt ports on macOS and is required by Cocoa.

Many Scheme features test the predicates: the print dialog (use-print-dialog? in

kernel/texmacs/tm-preferences.scm

) and the item “Copy to Image” of the Edit menu need qt-gui? or vue-gui?, Scheme asks for a confirmation before overwriting a file only when x-gui? holds (

texmacs/texmacs/tm-files.scm

, the other ports have native dialogs which ask), and the typographic palettes of the color menus are only offered with vue-gui? (

kernel/gui/menu-define.scm

).

Widget constructors.
widget.hpp

declares 49 constructors (52 counting the overloads of choice_widget and glue_widget). Every port defines all of them, so that the kernel links, but not all definitions are real widgets:

Ports Real Stubs and substitutes
Qt, Qt6 fork 46 ink_widget, empty_widget and wait_widget return a nil widget
X11, SDL, Qtwk (Widkit) 44 printer_widget is a “Cancel” button, tree_view_widget shows “Not implemented”, the two responsive tab widgets are plain tabs, tooltip_window_widget is a popup window
Cocoa 44 ink_widget, empty_widget and wait_widget as in Qt; the two responsive tab widgets are plain tabs
Vue 49 none (the responsive tabs have four presentations, after the preference gui:responsive tab mode)

The three setting widgets (setting_toggle_widget, …) are composed of simpler widgets in Widkit, Cocoa and Vue, which counts as real here. The definitions are in

Qt/qt_widget.cpp

,

Widkit/Basic/widkit_wrapper.cpp

,

NS/ns_widget.mm

and

Vue/vue_widget.cpp

(most of them through the macro VUE_WIDGET).

3.Source files

Graphics/Gui/gui.hpp
,
widget.hpp
,
message.hpp

The interfaces every port implements.

misc/m4/tm_gui.m4

The configure options --with-gui and --enable-qtpipes and the definition of the port macros;

misc/m4/qt.m4

(--enable-qt-new),

misc/m4/sdl3.m4

,

misc/m4/thorvg.m4

and

misc/m4/mupdf.m4

(MuPDF per port) complete it.

CMakeLists.txt
(top level of
src/
)

The cache variable TEXMACS_GUI and the source lists of the ports which CMake builds.

src/makefile.in

The lists of port directories compiled by the make build.

Kernel/Abstractions/basic.cpp

gui_is_qt, gui_is_x and gui_is_vue.

Plugins/Qt/qt_gui.cpp
,
QTMWidget.cpp
,
QTMKeyboardEvent.cpp
,
qt_printer_widget.cpp
,
QTMPrinterSettings.cpp

Main loop, keyboard and input methods, clipboards and printing of the Qt port (the same file names in

Plugins/Qt6

).

Plugins/Qtwk/qtwk_gui.cpp
,
QTWKWindow.cpp
,
qtwk_window.cpp

Main loop, clipboards and windows of Qtwk.

Plugins/X11/x_loop.cpp
,
x_gui.cpp
,
x_window.cpp
,
x_init.cpp

Main loop, keyboard, selections and initialization of the X11 port.

Plugins/SDL/sdl_gui.cpp
,
sdl_window.cpp
,
README.md

Main loop, keyboard, clipboard, windows and test scripts of the SDL port.

Plugins/Widkit/Basic/widkit_wrapper.cpp

The implementation of the abstract widget constructors in terms of Widkit.

Plugins/Vue/vue_gui.cpp
,
vue_widget.cpp
,
vue_gpu.cpp
,
TODO

Windows, event loop, keyboard, clipboard and test driver; the widgets; the GPU renderer; the state of the port. The design notes are in

docs/vue-graphics-stack.md

and

docs/vue-testing.md

.

Plugins/NS/ns_gui.mm
,
TMView.mm
,
ns_widget.mm
,
ns_dialogues.mm

Main loop and clipboard, keyboard and input methods, widget constructors and dialogs of the Cocoa port.

4.Contents of this chapter

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".