Skip to main content

Pragtical v3.8.2 Release

· 7 min read
Jefferson Gonzalez
Contributor of Pragtical

Another month, another release accompanied with the usual bug fixes, additional enhancements and CI build system improvements. Salted with a pinch of new features in order to keep the flavor going on!

Views State Support

This release adds support for saving and loading a View state explicitly, allowing to properly load them on subsequent editor launches. This change introduces the following new methods that can be implemented by child Views to enable state restoration on next session load:

---Serialize this view into a persistable state table.
---
---This method is called when the editor is saving workspace/session state.
---The returned table must contain only plain Lua data (no functions,
---userdata, metatables, or cyclic references).
---
---Returning `nil` indicates that this view should NOT be restored when
---reloading the workspace.
---
---@return table? state
function View:get_state()
return nil
end

---Create and initialize a new view instance from a previously saved state.
---
---This function is called when restoring workspace/session state.
---Implementations are responsible for:
--- * creating the view instance
--- * applying any persisted state
---
---If loading the instance failed nil will be returned.
---
---@param state table
---@return core.view? view
function View.from_state(state)
return nil
end

These functionality was implemented on DocView and ImageView.

note

Views that do not provide implementation of these methods will no longer be automatically reloaded on subsequent editor launches.

Another new method is View:get_module() which allows to easily fetch the module associated to the current View child:

---Returns the module path of this view.
---
---This method resolves the Lua module name that loaded the concrete view
---class (for example `"core.view"`).
---
---If the view class cannot be associated with any loaded module, `nil`
---is returned.
---
---@return string? path
function View:get_module() end

Image Loading Improvements

A new function was added to more easily allow opening images on the viewer and text files on the document viewer:

---Opens the given file path in the root view.
---If the given file is a supported image, it will open it in the image viewer;
---otherwise, it will open it as a normal text file.
---@param filename string Path to the file to open
---@return core.imageview|core.docview
function core.open_file(filename) end

This function is now been use on find files plugin and other places that need to load files into the editor.

Also thanks to tacf xpm joins svg as one of the image formats that is allowed to be opened as a text file from within the TreeView.

open in editor

UI Improvements

Thanks to juliardi (the evangelist) a button was added to the toolbar and settings plugins tab to more easily access the plugin manager:

The scale plugin now keeps previous scale factor on editor restart and even on sub-instances launched thru main editor since an internal environment variable is been use for this purpose.

Also, the renderer cache cell size was reduced to improve detection of dirty regions, the code related to this change was documented and re-arranged for clearness and the convenience of future contributors.

Before

#define RENCACHE_CELLS_X 80
#define RENCACHE_CELLS_Y 50
#define RENCACHE_CELL_SIZE 96

before cell size

After

/* These values represent the maximum size that can be tracked by rencache
7680x4320 = 8k resolution, we use a common divisor for the size of regions
that will be dirty checked.
*/
#define RENCACHE_CELL_SIZE 60 /* common divisor of width and height */
#define RENCACHE_CELLS_X (7680 / RENCACHE_CELL_SIZE) /* 128 cells */
#define RENCACHE_CELLS_Y (4320 / RENCACHE_CELL_SIZE) /* 72 cells */

after cell size

Two new variants of monokai were introduced:

  • monokai-pro - thanks to suxragi
  • monokai-varied - forgot who gave me this one, thank you too!

Additional Improvements

More Lua doc comments were added thanks to Amer which allows better LSP code completion when working with the editor source code as better generation of the API reference exposed on the website.

Also, Thanks to our testing Ninja the following bugs where corrected:

  • Wrong scale factor detection on Windows
  • EmptyView widgets not properly positioned when transitions are turned off.

Fixed a documentation bug on DirMonitor thanks to Walkero, also proper cleaning of watched directories on backends like kqueue.

Correction to the context menu sizing on 4K displays thanks also to tacf:

Before

before context menu 1 before context menu 2 before context menu 3

After

after context menu 1 after context menu 2 after context menu 3

On the build/CI system front, now the generated profiler guided optimizations are been really used on clang builds AKA macOS builds, so crossing fingers and hoping that now it works xD. Other optimizations were done to the CI like defaulting to optimization level 3, installation of additional LuaJIT modules and building of LuaJIT in amalgamation mode. Also, sdl and sdl_image were updated both to v3.4.0, finally, the CI Linux AArch64 builds will require glibc version 2.29 since the newer dependency versions introduced a requirement on posix_spawn_file_actions_addchdir_np for this architecture.

Other fixes and improvements on the changes log below, enjoy!

Downloads on GitHub.

Changes Log

New Features

  • Add view state save/load support (#409)

Enhancements

  • Documentation (#396)

  • Open images in viewer from open file operations (#403)

  • core.step: deprioritize only the mousemove event (#407)

  • Add xpm as additional open as text format (#410)

UI Enhancements

  • scale plugin: keep current scale state on restart (#401)

  • Reduce rencache cell size for better dirty detect (#405)

  • add button for opening plugin manager from settings and toolbarview (#408)

  • Made plugin manager button more subtle on settings ui (40b0287e)

Fixes

  • common.dirname: treat leading / as directory name (#400)

  • Reorder current/default scales on get_display_info (#402)

  • EmptyView: re-update childs on size/pos changes (#404)

  • DirMonitor: fix doc comment error (#406)

  • fix: context menu not properly sized (#411)

Build System

  • CI: really use profiler data when compiling with clang (30c734ab)

  • CI: always use optimization level 3 (ac6395f8)

  • Build luajit subproject in amalgamation mode. (#390)

  • LuaJIT subproject: install additional lua modules (#391)

  • Update colors subproject for more monokai variations (#392)

  • Update SDL and SDL_image to v3.4.0 (#413)

  • CI: fix polyfill-glibc on Linux AArch64 (bumps required glibc to v2.29) (ed651cea)