MyGo 0.5.0 lets apps speak their users' languages, makes native UI take a control's input as its constructor returns, as Dear ImGui and egui do, and adds documents, a rich text editor, Markdown for streaming replies, timelines and launchers.
Breaking changes
-
Native UI input timing (#359). A control now writes the user's edit through the pointer it binds before its constructor returns, so the next statement reads the new value, a local copy too:
chosen := app.language ui.RadioGroup(c, func() { /* ui.Radio(c, &chosen, tag, name) … */ }) if chosen != app.language { app.setLanguage(chosen) } // sees the click
Input follows the options of the frame the user acted on. If the app sets
.ReadOnly(true)or.Disabled(true)in the same build that applies an edit, the edit now goes through, because the control was editable when the user typed; before, it was dropped. A control already shown read-only or disabled still ignores input. To throw input away while busy, check the condition where you use the value (if !app.saving { app.draft = draft }).Changed,Submitted,Clickedand theOn…callbacks are unchanged. -
Terminal plugin:
Options.OnPastetakestransfer.Data, every format the clipboard holds, instead of a string. Read the text withd.Read(transfer.Text), ord.Files()andtransfer.PNGto upload them for a remote program (#335).
Languages
Apps say their messages in the language of the people who use them (#338, #339, #340). See Languages.
- Catalogs of ICU messages, a JSON file per language in ARB form, from which
mygo dev,mygo buildandmygo generatewrite typed Go functions (locales.FilesSelected(3)) and a TypeScript module for pages.mygo i18n checkand the build check every message in every language. App.Locale,SetLocale(kept for the next launches),OnLocaleChanged, and the user's regional formats inApp.Region;mygo dev -lang deruns the app in another language, and the pseudo localesen-XAandar-XBtest layouts before translating.- Package
i18nformats numbers and dates with CLDR 48.2 for 430 locales, as ICU andIntldo, with plural rules, skeletons and the names of months, days and languages. - MyGo's own strings (controls, menus, dialogs, the editors) say the app's language. English is always linked; Simplified and Traditional Chinese are packages,
locales/zh-Hansandlocales/zh-Hant, that the generated code imports for the languages an app ships. - Right-to-left layout in native UI, pages and GTK's widgets, for Arabic and Hebrew.
Native UI
ui/richtext: a rich text editor on a document model of attributed text, with typing attributes, commands, grouped undo and inline objects; it copies and pastes HTML, Markdown and RTF (as TextEdit, Pages and WordPad copy it) and is themeable withrichtext.Theme(#329, #332). Seeexamples/notes.ui/markdown: Markdown built for streaming AI replies, which heals an unfinished tail and fades text in as it arrives (#330).Timeline: several tweens on one playhead, placed as GSAP places them (AfterPrevious,WithPrevious,AtLabel,AtTime), with seeking and labels (#327, @zzstar101).- Tables sort by several columns with
SortByand Cmd-click, and column headers take a context menu withHeaderMenu(#312, #308, @saanuregh). - The code editor takes a modal editing mode, as Vim's (#306),
LineBackgrounds(#307), highlighters hear of edits before a line is laid out (#297), and long texts are styled without walking everyTextRange(#305), @saanuregh. Diff viewers run commands and report the caret of their active side (#303, @zucchiniEvader). - Text inputs take
OnTextKey, which sees every key that types no text (Enter, Up, Tab, Escape, Cmd+Enter) as AppKit'sdoCommandBySelectordoes; itsSetTextreplaces the input's text, as a composer clearing itself after sending (#335, building on #294 by @hwj123hwj). Outlinesets how far its levels are indented (#301, @saanuregh);ui.FontFamilieslists the system's fonts (#291, @roelfdiedericks).Themecarries the desktop's accent color and accessibility settings: reduced motion, reduced transparency, increased contrast, text scale (#163, @zzstar101).- macOS slants text whose font has no italic face, as CJK fonts (#295, @Jerryx333).
- Drawing skips work later opaque fills cover, draws large shadows and border rings around their empty interiors, and Metal draws opaque cores without blending, with identical pixels (#353, @StringNick). Metal keeps three drawables, so the main thread waits less for a frame (#241, @StringNick).
- In browsers, the touch keyboard stays up when a text input is tapped in iOS Safari (#334). The fragment shader links in ANGLE's Direct3D 11 backend (#318, @hu-ja-ja).
Apps and windows
- Documents for document-based apps, as
NSDocumentand SwiftUI'sDocumentGroup: the File menu, a window per file, autosave in place, recovery after a crash, asking to save before closing and quitting, and files changed by other apps (#328). Seeexamples/documents. - Launchers, as Spotlight and Raycast:
WindowOptions.Panelfloats a window above every app (on Wayland with gtk-layer-shell),Shell.FileIcongets the icons of files and apps, andShell.InstalledAppsandLaunchAppfind and open installed apps (#317, #320, #321, #322, #323). Seeexamples/launcher. Cookiesreads and changes the webview's cookies (#165),Secretskeeps secrets in the system's credential store (#158), andNetworkreports whether the computer is online and on a metered connection (#164), @zzstar101.WatchFilesand the watch plugin follow changes to files, with FSEvents on macOS, one stream per tree (#171 by @zzstar101, #354).- Recent documents with the Open Recent menu, and the Windows jump list's tasks (#170, @zzstar101).
WebViewAvailabletells whether the system webview is there, beforeApp.Runtoo, so an app can open a window of native UI where it is missing (#319, @ufec).- Pages read the custom schemes they fetch (#35), and the menus of Windows windows draw in the dark appearance (#30), @Sutsikii.
- On macOS, a window that cannot go full screen shows over other apps' full screen when it is visible on all workspaces (#310, @ACAne0320).
Terminal plugin
Options.ClipboardReaddecides whether programs may read the clipboard: deny (the default), allow, or ask, withOnClipboardRequestor the terminal's own prompt (#355).- Programs that read the clipboard take pasted images (OSC 5522) (#293), the owner zooms by the wheel with
OnZoom(#292), and the terminal copies on select and takes Windows Terminal's keys (#290), @roelfdiedericks.
Smaller apps
What every app reaches no longer calls features it does not use (#356, and two commits before it). An app that binds nothing no longer links the TypeScript generator and go/parser, messages link the formatting of dates only when an app formats dates, and CLDR's data comes in two parts. examples/counter-native is 9.0 MB on macOS, down from 11.1 MB in 0.4.8 (8.5 MB on Linux and Windows, down from 10.5 and 10.6 MB), and the architecture guide now has rules that keep it there.
Fixes
- Delta updates include the stapled ticket whole, so they apply to apps installed from a notarized disk image (#302, @jizhi0v0).
- macOS icons leave out the 16 and 32 pixel entries, which Finder, Spotlight and Get Info drew as noise (#315).
New Contributors
- @zzstar101 made their first contribution in #158
- @jizhi0v0 made their first contribution in #302
- @zucchiniEvader made their first contribution in #303
- @ACAne0320 made their first contribution in #310
- @hu-ja-ja made their first contribution in #318
- @Jerryx333 made their first contribution in #295
Full Changelog: v0.4.8...v0.5.0