github egoist/mygo v0.5.0
MyGo 0.5.0

latest releases: v0.10.0, v0.9.2, v0.9.1...
one month ago

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, Clicked and the On… callbacks are unchanged.

  • Terminal plugin: Options.OnPaste takes transfer.Data, every format the clipboard holds, instead of a string. Read the text with d.Read(transfer.Text), or d.Files() and transfer.PNG to 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 build and mygo generate write typed Go functions (locales.FilesSelected(3)) and a TypeScript module for pages. mygo i18n check and the build check every message in every language.
  • App.Locale, SetLocale (kept for the next launches), OnLocaleChanged, and the user's regional formats in App.Region; mygo dev -lang de runs the app in another language, and the pseudo locales en-XA and ar-XB test layouts before translating.
  • Package i18n formats numbers and dates with CLDR 48.2 for 430 locales, as ICU and Intl do, 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-Hans and locales/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 with richtext.Theme (#329, #332). See examples/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 SortBy and Cmd-click, and column headers take a context menu with HeaderMenu (#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 every TextRange (#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's doCommandBySelector does; its SetText replaces the input's text, as a composer clearing itself after sending (#335, building on #294 by @hwj123hwj).
  • Outline sets how far its levels are indented (#301, @saanuregh); ui.FontFamilies lists the system's fonts (#291, @roelfdiedericks).
  • Theme carries 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 NSDocument and SwiftUI's DocumentGroup: 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). See examples/documents.
  • Launchers, as Spotlight and Raycast: WindowOptions.Panel floats a window above every app (on Wayland with gtk-layer-shell), Shell.FileIcon gets the icons of files and apps, and Shell.InstalledApps and LaunchApp find and open installed apps (#317, #320, #321, #322, #323). See examples/launcher.
  • Cookies reads and changes the webview's cookies (#165), Secrets keeps secrets in the system's credential store (#158), and Network reports whether the computer is online and on a metered connection (#164), @zzstar101.
  • WatchFiles and 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).
  • WebViewAvailable tells whether the system webview is there, before App.Run too, 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.ClipboardRead decides whether programs may read the clipboard: deny (the default), allow, or ask, with OnClipboardRequest or 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

Full Changelog: v0.4.8...v0.5.0

Don't miss a new mygo release

NewReleases is sending notifications on new releases.