Replacing swipl‐win - SWI-Prolog/packages-xpce GitHub Wiki

swipl-win has two implementations: one using the Win32 GDI and one using Qt for MacOS and Linux. The Win32 version is getting outdated and the Qt version is a heavy dependency. This sub-project will replace both by an XPCE on SDL+Cairo based embedded terminal.

Design

This project adds a class terminal_image, similar to text_image that provides the basic terminal emulation as an XPCE subclass of graphical. Outline

  • Use the Windows swipl-win code that implements a two-dimensional terminal with savelines and ANSI escape code handling.
    • Wrap the code into class terminal_image, using XPCE's core infrastructure.
    • Allow a Prolog thread to act as "client"
      • On non-Windows system, use a PTY for the interface. This way we can reuse the editline command line editor. Also shell/0,1 and friends work out-of-the-box.

Tasks

  • Implement terminal_image
    • Basic terminal rendering
    • Map events to terminal actions
    • Implement client interaction using POSIX pseudo terminal (PTY)
    • How to deal with Windows?
    • Implement ANSI terminal handling
      • Basic sequences
      • Bold and underline
      • The 16 ANSI colors
      • 256 color scheme
      • Direct color
  • Implement a Prolog library to create a fully functional terminal
    • Wrap into class epilog
      • Add scrolling
      • Connect to a Prolog thread
      • Add menu
      • Allow multiple terminals (split horizontal/vertical)
      • Proper history handling
      • Deal with thread-local Prolog flags.
  • Allow using Epilog as main console, such that we can use this as "App"/GUI application
    • Add new executable (swipl-win) that starts Epilog
    • Run initialization commands in the Epilog environment.

Bugs/issues

  • Do we need/want shell job control?
  • cls/0 often leads to assertion error
  • Handle \e[<n>@ to insert <n> spaces at the current location. Needed for libedit insert.
  • less quit does not properly clean screen
  • top display top is garbage.
  • Trackpad scrolling seems broken.