navml-library
navml's widget library outside windows and menus -- Control, Cluster, StaticText, Label, Button, InputLine, HexLine, CheckBoxes, RadioButtons, ScrollBar, ListViewer, Modal, Dialog, Field, Spacer, Time
SKILL.md.claude/skills/navml-library/SKILL.md
GitHubThe widget library: dialogs, controls, layouts, history
None of it was designed: DOS Navigator's Colors dialog names the widgets and their states, tools/palconv.py
transcribed all 144 slots into every theme, and the Dialogs group is the specification. navigator/styles/navigator.nss
binds the components to the $dialog-* variables. Windows, the desktop and menus are the navml-windows-menus skill.
The components
First tier (
navml/widgets/dialog/):Control,Cluster,StaticText,Label,Button,InputLine,HexLine,CheckBoxes,RadioButtons,ScrollBar,ListViewer,Modal,Dialog,Field; plusSpacerandTimerat the top.Timerpaints nothing and emitsTimerEventeveryintervalms; Navigator'sClock(navigator/widgets/shell/clock/,HH:MM, blinking colon, Timer slot[1]) is built on it.Modalis the framed, fixed, centred window (bound geometry,modal = True) andDialogderives from it.Dialog.buttonshasok,yes-no-cancel, ...;Dialog.valid()(Valid(cmOK)) keeps a dialog up over a value it cannot read. F7 Mkdir was the first dialog wired into the application.ButtonemitsClickEvent; mouse and Space both go through onepress(). Clicks act on release.Button.command(Turbo Vision'sTButtoncarried one): when set,press()asks for that command from the button throughapp.run_command(command, start=self), exactly as its key would, throughenables(). No click is emitted then. Writecommand: NewGamein markup instead of anon_<id>_clickthat callsself.on_new_game(...). The button is not greyed while its command is disabled;press()returns False.A
Button's tooltip is the keys that press it (press_keys(): the dialog's Default key on the default button, its Cancel key on itscancel, Alt+letter), read off the key tables; its owntooltipgoes in front.CheckBoxes/RadioButtons(Cluster) taketooltips:, one an item in step withitems(translated like it); an empty or missing one falls back to the cluster's owntooltip. Write one only where the caption does not say it (Remove source files, Sticky),""elsewhere; a test keeps every list in step with itsitems.A
ListViewerrow's tooltip is its wholerow_textwhile cut (row_tooltip,cut_text); a subclass with its ownrender_roworrender_itemsgets none unless it overridesrow_tooltip(TraceListdoes) ortooltip_at(UnicodeGrid, per cell). An input line's likewise, plus its own or its field'stooltip.A
TabViewtakestooltips:, one a page (what the page holds), shown on its tab only -- never a page's owntooltip, which would show over its every blank. A cut left-column caption shows whole; the arrows say their way.A
ListViewertakestooltips:too, one an item, before the cut-text fallback (Colors' items, Savers' lists).A standalone
Label(not in aField) shows its linked control'stooltip; its own wins.A
ProgressBarsays what it rounds: exact done/total/left and the percent to one decimal, unless it has its own.CalendarViewspells a day out (weekday,date_format, ISO week, days from today), names a weekday column, and keys its arrows and names;ColorSelectornames a colour (Light blue (light_blue)).A focusable widget that paints several things gives
tooltip_anchor()for Shift+F11 (ListViewer,Cluster,TabView,CalendarView,ColorSelectordo); a framedWindow's title says it whole where cut, and what a double click and a drag do.Button.flat(a departure:TButtonalways had its shadow) drops the shadow, so the face is the whole rectangle and the button may be one row tall; pressed, it does not move. For a small button beside a line, as the Character Table's filter X.Arrows walk buttons (a departure:
TButtonignored them). Left/Up to the previous, Right/Down to the next, no wrap. The group is the unbroken run of buttons around the focused one in the dialog's tab order (Button._row), not a container -- most dialogs place buttons byx/y-- so keep a button row together in tree order, and any other control between buttons splits the run.Clusterlays out in columns asTClusterdid.enable_mask(a bit an item, all by default) isTCluster.EnableMask: a cleared item is greyed (::item:disabledetc.), passed over by the arrows and Home/End, and taken by neither a click nor its letter (item_enabled); Create archive greys types and levels with it. Tri-stateCheckBoxes:mixeddraws[?],tristatelets a bit cycle back to it.Marks come from
navkit.glyphs.marks(look, tier): five three-cell strings (check off/on/mixed, radio off/on), picked bymark_index()(CheckBoxes0-2,RadioButtons3-4).lookis a style property:dos([X](•)),brackets([✓](●)),boxes(☐ ☑ ⊟/○ ◉centred, Font Awesome icons at the Nerd tier),ascii, orauto(the default) forApplication.marks--dosin navkit,[appearance] marksin Navigator. Every mark is three cells in every look and tier: captions sit atx + 4and_column_xsteps bywidest + 6.ListViewerhooks:capacity,index_at,render_items, overridable_follow_cursor;framed = Falsedrops the frame; it claims only a bare Enter.Held buttons repeat (
Application.hold_mouse,navkit-widgets-input):ScrollBar: an arrow or the track steps on every tick while the pointer is over the part pressed (part_at,TScrollBar's extent grown by a cell). So paging stops when the thumb reaches the pointer.ListViewer(TListViewer): a held left button drags the cursor to the row under the pointer. Above or below the rows (beside them with columns), everyedge_ticks-th tick (4,MouseAutosToSkip) moves it on one row, or one column.- Opting out:
follows_drag = Falseturns this off, as the panel does while drag-and-drop is on.edge_delaysets the first tick.
StaticText.linksmarks thehttp(s)://runs it paints (OSC 8, seenavkit-terminal).OptionStrip(navml/widgets/option_strip/, Python only, not DN's): a window's options in a row, each anOptionItem(command, label, lit=None). Lit is the command'schecks(orlit()), greyed itsenables, both asked oftarget(the widget whose options they are) throughnavkit.commandswhile painting -- any reactive write repaints, as forKeyBar. A left press on an enabled item runscommands.run(app, command, target); every press is the strip's. Each item is drawn[label], a cell apart, and nothing between: on a frame the border shows through (═[⌶]═[§]═).spans/used_widthare computed from the labels' display width; bindwidth: self.used_widthand give itroom-- items that would pass it drop from the last. Partitemwith:checked/:disabled. Actions do not belong on it: those stay on menus and keys.ProgressBar(navml/widgets/progress_bar/):value/total/percent, as wide as placed,█▒from navkit'sGAUGES.Spinner(navml/widgets/spinner/): one cell turning through navkit'sSPINNERSeveryintervalms while mounted (call_every, asTimer);framecounts up. Navigator'sWriteWinputs one beside its message.Toast(navml/widgets/toast/, not Turbo Vision's):textin a one-row frame titledtitle, never focused, gone afterseconds(TOAST_SECONDS, 5;call_laterarmed inmounted()) or a left press;natural_widthis how wide it would be,goneis called once it is off the tree. Whoever adds it places it: Navigator'sShell.toast(text, title=, seconds=)adds it first and then binds its geometry (bound beforeadd, the dock layout gives it the whole band), at the desktop's bottom right, newer ones lower (_Toasts).navml/background.py'sBackground: a widget's slow read on a pool of threads, answered on the loop with anOutcomeand the application woken to paint it; with no application running it answers on the spot. One pool per kind of read.TreeView.probe_in_backgroundandFileDialog.read_directoryuse it.TreeViewwithload_in_background/probe_in_backgroundnever reads on the loop from a key: Space/+/- and[+]asknode_has_children(a probe still out answers yes), Right and/open the branch and finish inwhen_loaded(node, then)(the cursor goes in, or the search scope lands on the first child, once the read is in; a/into a branch read empty is taken back; a cursor or search moved on meanwhile is left be).locate()still reads at once.MaskedLine/MaskedField: digits typed into fixed places; Left/Right, Home/End, Backspace/Delete blank a digit; a base-8MaskedFieldtakes 0-7 only.DateField/TimeFieldare masked lines with aCalendar(TVDEMO'sTCalendarViewwith a cursor; month/year picked from lists by click,M/Y, or Tab) or aTimePickerdropped by▐↓▌or Alt+Down; Up/Down step by the place under the caret, PgUp/PgDn by ten times that, carrying. The droppedCalendarspells the cursor's day under the weeks in its button'sdate_format(CalendarView.date_format; empty, no row -- Navigator's Calendar window binds it to Country support's), so it isSPELLED_HEIGHTtall. A 12-hour time is%Iand%p: the mask'sAis a place for thea/pofam/pm(then a literalm), set bya/ptyped anywhere, turned over by Up/Down on it, refusing digits. Spell and read such a time withspell_time/read_time(masked_line), neverstrftime/strptime, whose%pis the C locale's word; theTimeButtondoes, and drops a 12-hourTimePicker(twelve): the hour 1-12, anam/pmcolumn last that Up/Down turn over andA/Pset,valuesstill 24-hour, five columns wider (width_for(seconds, twelve)).CalendarViewis the month without the drop-down:CalendarisCalendarView+DropDownwithinset = 1(its frame) andpicked()choosing; the view alone (inset = 0) answersFalsefor keys it does not use, so Esc reaches its window. Styles nameCalendarView, which matches both. Utilities > Calendar (CalendarWindow, TVDEMO'sTCalendarWindow, a departure: DN 1.51 had no calendar) is one in a window. Other calendars arenavml/calendars.py(Julian with both Easters as itsnote(), Hebrew, tabular Islamic, Persian by the 33-year rule, Indian national/Śaka, Ethiopian, Coptic; Reingold & Dershowitz's arithmetic ondate.toordinal(), no tables), and the Chinese lunisolar one, which has no formula: its months arenavml/chinese_data.py, generated bytools/chinese_calendar.pyfrom the Hong Kong Observatory's 1901-2100 tables (2069's file lacks 30 December, which the tool checks is harmless). It knows lunar years 1901-2099 only:span()says which days a calendar knows,to_daterefuses others, and the view'scalendaris the Gregorian on a day outside it, so the month still shows and paging back in returns to it. Its leap month repeats a number (number(year, month)→(6, True); namesMonth 6,Leap 6, zh 闰六月 by the{month}placeholder), a year on keeps the month by number, andnote()names the year in the sexagenary cycle (pinyin with tones, so 戊 Wù and 午 Wǔ are separate keys) with the Spring Festival on New Year's day. Checked once by hand against lunardate's and LunarCalendar's tables: each differs from HKO in three years, never the same ones. Umm al-Qura (UmmAlQura, a subclass of the tabularIslamicwith its month names) is the same shape:navml/ummalqura_data.py, month starts 1356-1500 AH generated bytools/umm_al_qura.pyfrom R. H. van Gent'sislamcalendar_dat.js(hijri-converter's MIT table is the same data, which it matched in all 1741 boundaries). Sha'ban 1364 has 28 days in the published pre-1392 table; it is kept,KNOWNin the tool. Arabic'sautois it, not the tabular one, which differs on two days in three. Japanese eras, Thai (BE) and ROC (Minguo) areGregoriansubclasses that only write the year otherwise:year_text(day, short=)(an era can change mid-month, so the title asks the cursor's day),year_label(year)for the year list (Reiwa 1 (2019); the list chooses by index, not by parsing), andtitle(day, room), which falls back to the short form (R1,2569,115,-1) where the long one does not fit -- the width test measurestitle(). Japanese starts in 1873 (span), the gannen is written 1. Bengali is Bangladesh's 2019 revision, kept proleptically. Korean and Vietnamese areChinesesubclasses with anotherdatamodule (andnew_year(),animals()-- Vietnam's Buffalo and Cat). No open official table exists, sotools/lunisolar.pycomputes them: Meeus' new moons, his low-precision Sun (0.01°), Espenak-Meeus ΔT, R&D's month rules, reckoned in each country's standard time of the day (Korea UTC+9, +8:30 in 1908-11 and 1954-61; Vietnam China's until 1968, UTC+7 after, its pre-1967 years copied from the HKO table). It verifies itself first: reckoned in Beijing's time (Beijing mean time UTC+7:45:40 before 1929) it must give HKO's months, and does in 196 of 199 years -- 1906, 1917, 1922 each have an event within ten minutes of midnight. Known dates it reproduces: Tết 1968 (29 Jan), 1985 (21 Jan, a month before China), 2007; Seollal 1997, 2027 (a day after China). Events within ten minutes of local midnight are printed as where a published calendar could differ by a day. Nepali (Bikram Sambat,82%).navml/nepali_data.py,tools/bikram_sambat.py): no formula is official and no table of the almanac's own is open. 1975-2083 BS are where two of three MIT packages' tables agree (read from their PyPI wheels as data; after 2083 one repeats its rows of 85 years before, another guesses); 2084-2156 are computed by the rule that gives 99.5% of the agreed month starts: the Sūrya Siddhānta sun (R&D), its ingress in UTC+5:30, Karka's before 05:33 to the day before and Makara's from 17:00 to the day after (the dharmaśāstra rule for the solstitial saṅkrāntis). The modern sun with any ayanamsa fits far worse (note()marks a computed year. Badíʿ (Baháʼí,navml/badi_data.py,tools/badi.py): 20 months in year order, Ayyám-i-Há the 19th (4 or 5 days,naw_ruz(y+1) - naw_ruz(y) - 361), ʿAláʼ the 20th. Naw-Rúz 21 March before 172 BE; 172-221 BE are the World Centre's table (Badíʿ dates 172 to 221 BE, transcribed into the tool'sOFFICIAL, its Ayyám-i-Há column agreeing); 222-257 are computed (Meeus ch. 27 equinox, NOAA sunset at Ṭihrán) by a method that gives 49 of the 50 published -- 2026 is the equinox within half a minute of sunset, beyond a minute-accurate theory; any computed year that close is printed. Wikipedia's "183 BE begins 20 March 2026" is wrong; the table says the 21st. The English caption has no hotkey: every letter of it is taken in that menu. Diyanet, MABIMS Indonesia, MABIMS Malaysia areTabledIslamicsubclasses (asUmmAlQuranow is: adatamodule withFIRST_YEAR,FIRST_MONTH,MONTH_STARTS,PUBLISHED_LAST;note()marks computed months).tools/hijri_criteria.pywrites them: van Gent's published months, then each crescent rule computed withtools/moon.py(Meeus ch. 47 Moon, self-tested: its conjunctions within 1.2 min of ch. 49's, 1900-2100), the rule verified on the published months first. Found by fitting: Malaysia = altitude 2 and elongation 3 degrees, or age 8 h alone, topocentric, anywhere in Malaysia -- 260 of 260; Indonesia the same over its territory (real places, Sabang to Merauke, not a box -- a box's ocean corners were the misses) but the age with the altitude, 196 of 203 (its others were rulings, not the rule); Diyanet the 2016 Istanbul congress rule (5/8 anywhere before 0h UT, else the Americas' mainland -- its west coast, not a box -- if the conjunction came before Wellington's fajr), 137 of 140 since 2016. From 1443 AH both MABIMS are Neo-MABIMS (3/6.4), which no open table can verify. Burmese is Yan Naing Aye's algorithm (ceMmDateTime, MIT, ported with its notice): era constants and the published full-moon and watat exceptions, thenm2jarithmetic; checked by portingj2mtoo (the independent closed form) -- the two agree on every day 1900-2100 (his JS could not be run here). A year runs from 1 Tagu; the year number officially changes at New Year's Day (Thingyan), whichnote()marks. Tibetan (Phugpa) is R&D's arithmetic: a leap month precedes the month of its number (tibetan-from-fixedtakes month0 + 1 past day 30, the year + 1 past month 12 -- leaving that out put Losar 2019 a month late), day numbers skip and double, soCalendarSystem.day_label()(default: the place in the month) gives the number the grid prints. Checked against Losar 2019-2026. Both English captions have no hotkey: every letter is taken. Chhankitek (Khmer, Thai, Lao lunar) is ThyrithSor'smomentkh(MIT, ported with its notice): the year's aharkun/avoman/bodithey decide a doubled Asadh (Pathamasadh, Tutiyasadh) or a 30-day Jesth; the months are stepped from 1 Boss 1900 by each month's own Buddhist Era (getMaybeBEYear). Cross-checked with momentkh's own conversion (year jumps, month steps, its overflow fix) transcribed: 0 days apart 1900-2100. A year here runs from 1 Pisakh, numbered by the BE it enters at Visakha Bochea. In a doubled-Asadh year Thailand and Laos keep Magha Puja and Vesak a month later than Cambodia (2023: 4 May against 3 June), sonote()names both. Afghan Solar Hijri is the Persian with the zodiac months. The view'ssystemputs the grid in one, and paging goes through it:add_months/add_years(a year on keeps the month by name, so Hebrew Adar ↔ Adar II),month_days,month_names(year)in year order (Hebrew Tishri is 1).daystays adate, so the row under the weeks spells it Gregorian bydate_formatwhatever the grid is in -- unlesslabelnames a calendar, whosespell()it is then (spelled(); the Gregorian again on a day that calendar does not hold; itsnote()joins the tooltip's) -- and the drop-down, which writes astrftimeline, stays Gregorian. A month name plus a blank and four digits must fit 17 cells between the arrows, in every catalogue (CJK counts two a character;tests/test_calendars.pychecks each language). A calendar'scaption()carries a menu hotkey andname()isplain(caption()), which also drops a trailing(~X~). To add one: subclassCalendarSystem(caption,from_fixed,to_fixed,days_in_month,month_names,months_in_yearif not 12), put it inSYSTEMS, add its key toCountryData.CALENDARS. Chinese and Umm al-Qura need tables; that's the next round. The window's Calendar system submenu (one radio-tickedSetCalendarSystem(key)perSYSTEMSentry, built in__init__, answered by the window) isCalendarWindow's, and so is Calendar view (SetCalendarView(view),CountryData.VIEWS:only,gregorian_grid,selected_gridthe default,both), which sets each view'ssystemandlabelby binding;bothshows a second view,other, the Gregorian to the right of the calendar's, the window widening fromWIDTHtoWIDE(size(), an effect refits it; the Shell and a restored desktop size it bysize(), not the constants) and two effects keeping the views on one day. Commands go toview(), the one with the keys.onlyandbothspell nothing under the weeks (unspelled():date_formatandlabelleft empty), and the window's views arecompact: only the weeks the month has (rows(), at leastLEAST_WEEKS), the spelled row right under them, so the window's height (size(): frame, two rows,rows(), the spelled row, a blank, the button) follows the month as it pages, its top edge kept. The drop-down keeps six weeks.C(SwapCalendars, the window's key table and Calendar menu) tradesgregorian_gridandselected_grid, and inonlyflips the window'sswapped(the Gregorian alone); refused (refusal(), greyed) inbothor with the Gregorian chosen. Its key-bar hint (key_hints()) names the calendarCwould show.CalendarView.key_hints()puts PgUp/PgDn, Ctrl+PgUp/PgDn and M/Y on the bar as three paired hints (PgUp/Dn Month,^PgUp/Dn Year-- Ctrl as a caret and the sharedPgsaid once, here alone;M/Y Choose) andT Today, read from the current bindings, then the window'sCwithtr("Gregorian"), a short word apart from the menus'~G~regorian. Measured tight (all items, one blank each) every catalogue fits 80 columns with F1 and F10; Latvian exactly, Russian and Latvian with short captions (Выбор,Григор.,Izvēle,Mēn.) -- keep them short. Its paging and picking are commands in a key table (navml/widgets/dialog/commands.py:PreviousMonthPgUp,NextMonthPgDn,PreviousYear/NextYearCtrl+PgUp/PgDn,ChooseMonthM,ChooseYearY,GoToTodayT, each letter with Shift too), Key bindings' Calendar section, so both the drop-down and the window have them; the arrows, Home/End, Enter and Tab mean something per section and stayon_key's. Off an application no key table is consulted, so a test driving the view byon_keyemits these instead. The window shows them on itsCalendar bar menu and its right-click menu (a click on a day moves there first), and hands them on to the view when the button holds the keyboard (CalendarWindow._month); the menu's statickey:s are for that case.HexLine(navml/widgets/dialog/hex_line/, Python alone) is DN'sTHexLine(DIALOGS.PAS): the bytes of theInputLineit islinked to (what.entry), in itsencoding, as hex pairs, edited as hex with DN's keys only (0-9/A-Fhigh nibble then low, Left/Right a nibble, Backspace/Del a byte, Up is Shift+Tab, other letters swallowed). It keeps its owndata, since a hex edit can make bytes that are no text in the encoding: the linked line shows them decoded (U+FFFDfor what will not), and typing there makesdatathe text's bytes again (a character the encoding cannot say gives none). The two cursors follow each other; it does not mirror. Styled asInputLine. The viewer's Find box has one.ChoiceFieldis aChoiceLine(anInputLinenever typed into: every key but Tab/Shift+Tab/Esc/Alt+letter/ Up/Down drops its list, Enter included; Up/Down step between the dialog's lines) overHistory.choices, a fixed list that records nothing and that typing quick-searches by the panel's rule.Every
InputLineselects with a drag or double click (a finished selection is the primary selection) and takes Ctrl+Ins (copy; the whole line with no selection), Shift+Del, Shift+Ins, Ctrl+C (only with a selection), Ctrl+V; middle click pastes the primary selection. A paste walks the focus path whenApplication.on_pastedeclines it.FileDialog.raw, a test for a name line to hand back as typed (a place the dialog cannot list -- a URL), and recorded in the history as typed;FileDialog(unlisted=PLACE)lists nothing, shows PLACE and answers every name as typed, for a caller on another drive (Shift+F4) -- set norawover it.password: Truepaints every character as*and copies nothing -- not to the clipboard, not to the primary selection (aField's line isfield.entry: setfield.entry.passwordfrom the Python half).A modal never says its keys in its frame. The keys a dialog takes that no control shows go to the key bar through
key_hints()(navkit'sWidgethook, asked from the focus out):TabView's Ctrl-PgUp/PgDn Tabs, the history dialogs' list keys, the Attributes grid's R W X,PopupMenu(hints=)andSubMenu.hintsfor a popup's.FileDialog(navml/widgets/dialog/file_dialog/, DN'sTFileDialogfromDNSTDDLG.PAS, every rectangleTFileDialog.Init's):FileDialog(title=, label=, history_id=, directory=, wildcard="*", hidden=, ok_text=)(ok_text"~O~pen"is DN'sfdOpenButton),execute()answering a full path or None. OK isValid(cmFileOpen)(valid()): a wildcard or a directory re-lists and stays up, a name in an existing directory closes, anything else says Invalid drive or directory./Invalid file name. An effect stands forcmFileFocused: the focused list fills the name line (a directory asdir/+ wildcard) andFileInfoPane. Left/Right move between controls outside the name line; Tab skips an empty Files list; Enter or a double click in a list is OK; the history records the full path.FileList(dialog/file_list/,TFileListandTDirectoryListin one) types to search asTSortedListBoxdid;scan()is navml's own directory reader (navml may not import Navigator's). Departures: no drives, no 8.3 completion,*for*.*. StyledFileInfoPaneinnavigator.nss(the Information pane, [61]).ColorSelectorandColorDisplay(navml/widgets/dialog/color_selector/, Python alone): TV'sTColorSelector--coloran index intoCOLORS(the attribute byte's sixteen, by name),-1for none, swatches of blanks on the colour with TV's◘mark (*on ASCII), arrows wrapping asTColorSelector.HandleEventdid; no event, the owner followscolor-- andTColorDisplay,textrepeated insample(aStyle).GroupBox(navml/widgets/dialog/group_box/): Turbo Vision'sofFramedview with aTLabelon its frame line -- a single frame (the sheet'sborder),titletwo cells in on the top edge with a blank either side (~A~in::shortcut), children placed inside in its own coordinates (the frame is the outer row and column). It never takes the keyboard. System Information's four boxes are the first users.TabView(navml/widgets/dialog/tab_view/, Python alone, aLayout): pages behind a row of tabs -- not Turbo Vision's, which had none. Every child is a page, its tab captioned by the page'stitle.TabPage(navml/widgets/dialog/tab_page/, markup alone): a page that is nothing but atitle, for pages laid out inline in the dialog's own document -- their ids stay the dialog's (Alt+E'sAttrDialog). A page of its own component (Settings' pages) needs none.- The look. Each tab is a box drawn in the sheet's
border,┌───┐over│ Caption │. The tabs stand on a baseline across the whole width, closed off by┴feet. The current tab is double (╔═╗,║) with its foot open (╜ ╙), so it stands raised and joins the page under it. - One row, scrolled. When the tabs do not fit, a
←at the left edge and a→at the right appear (arrows,tab_view.ARROWS, not the scrollbar's triangles;^v<>below Unicode), each only while a tab is hidden that way (can_scroll()). A click on one, or on top a notch of the wheel anywhere over the tabs, moves the row a tab along (scroll()) without changing the current tab. Down the left a notch of the wheel over the column chooses the tab above or below instead, stopping at the ends. The row never ends short with tabs hidden before it (_start()). An effect inmounted()(_reveal) movesfirstto bring the current tab into view however it became current. - Pages.
strip_rowsis 2 and a page's row 0 is the baseline, as a dialog's is its frame, so a former dialog's layout fromy: 1carries over unchanged. Pages that are notcurrentare hidden, which takes them out of the paint, the tab order and the Alt+letter walk.select(index)hides them and focuses the new page's first control in the same call. - Keys. The strip takes the keyboard, last:
focus_lastputs it after the dialog's own buttons inDialog.focusable, so a dialog still opens on the page's first control, Tab past Cancel reaches the strip, and the next Tab goes into the page (on_select_next, takingSelectNextonly while the strip has the keyboard, so the key stays rebindable; Shift+Tab from the page's first control comes back). While it has the keyboard, Left/Right and Up/Down (either side) step through the tabs, stopping at the ends, and Home/End go to them;select()then leaves the keyboard on the strip. Its current caption is drawnTabView:focused::selected(a focused button's colour). From anywhere on a page Ctrl+PgDn/Ctrl+PgUp (and Ctrl+Tab/Ctrl+Shift+Tab) areNextTab/PreviousTabin its key table ([tab_view]), wrapping round, and so are plain PgDn/PgUp -- reached only where the control with the keyboard does not take them first (a list pages, aMaskedLinesteps by 10). AListViewer,MaskedLineorMaskedFieldwithpage_keys: Falsegives them way (the arrows still move it); every list and number field on Settings' pages says so.ListViewerleaves Ctrl+PgDn to them as it already did Ctrl+PgUp. Each page remembers its control that last had the keyboard (_remember, an effect onapp.focusedthat only records into a plain dict): Ctrl+PgDn/PgUp or a click back to a page returns there if it can still take it, else to the page's first control (enter_page); so does Tab from the strip. A click on a tab selects it and moves the keyboard to its page: its top, its caption or its foot on the baseline (in_strip). The baseline is the page's row 0, but a page leaves it empty, so the click falls out to theTabView. - Down the left (
side: "left"). A tab a row in acolumn(the longest caption plus 3, at mostMAX_COLUMN20; a longer caption is cut withglyphs.ellipsis), an unbroken│rule beside it the whole height, and the pages to its right. The current tab has a►before it and the selected caption colour. More tabs than rows scroll between↑and↓in the column's top and bottom rows. Withjoins_frametheTabViewspans its parent's frame rows: the rule meets the frame in that frame's tees (joins(parent.border):╤and╧on a double frame), the tabs and pages keep to the rows between, and clicks on the frame rows, or right of the column, fall through to what is behind (the dialog's title and buttons). - Simple (
side: "simple"). The row on top without the boxes: each tab is_size()=caption, caption + 2 cells, in::tab, the current one in its own::currentpart (no mark: a button's background,TabView:focused::currenta focused button's, so it stands out from the dialog's), over a single rule the whole width (_baseline(), shared with the boxed strip). The rule is the page's first row (plan()puts pages aty1), as the boxed strip's baseline is, so it costs two rows where that costs three. It scrolls, wheels and clicks as on top (←/→at the row's ends, on row 0); withjoins_framethe rule meets the frame in╟/╢. joins_frameon top spans the frame's columns instead: the baseline meets the frame in╟and╢, the rows above it leave the frame's bars alone, and the tabs, arrows and pages keep to the columns between. The samefirst,scroll(),_revealand wheel serve both sides: a tab's size along the strip is its width on top and one row on the left (_sizes(),_length()).- Parts.
tab,selected(a selected label's colour) andarrow(the frame icons').
Navigator's Settings is the first user.
History
navml/history.py's HistoryStore/HISTORY is DOS Navigator's HistList: per-id lists, newest first, limit each (DN's 20; Navigator sets it from interface.history_size, default 50),
pinned entries kept (HistoryStore.limit). The History button drops a HistoryList, which Field(history_id=...) places after its line.
Del in a HistoryList forgets the entry under the cursor (HistoryList.forget -> HistoryStore.remove; a
departure, asked for, as Alt+F8's list does), the cursor staying on the row that moves up and the list closing with
its last entry; a choices list and a CompletionList (no button) ignore it.
Ids in use: "mkdir", "select", "command", ... Slots [53-56]. The lists persist: they are rows of the history
table (navml/models/history_entry/, DN's rules in its .py half's remember()), written as each change is made
(see navkit-database). Tests get an empty :memory: database each.
Four rules from building dialogs (each found by running something)
- A handler starts a dialog; it does not wait for one.
await dialog.execute(app)insideon_keymounts it and never paints it:_main_loopawaits_handlebefore rendering and is the queue's only consumer. Useself.spawn(self._work())and return.Dialog.executeraises rather than hanging. - A dialog's geometry must be bound, not assigned.
add()lays a child out into its parent andComponent.layoutsteps around a side only when it carries a binding, so a literal size becomes full-screen the momentoverlay()adds it. Route the size through a declared property the base binds from. - A derived component's own children land after its base's (
super().__init__()is the generated constructor's first line);Dialog.focusable()moves its buttons to the end, or every derived dialog opens with focus on OK, andDialog.activate_shortcut()asks them last, orCancel takes Alt+C from Comparecontents (TV gave a shared letter to the control inserted first, and resources inserted buttons last). - Effects belong in
mounted(), not__init__, for any widget that can be removed and put back -- every widget in a dialog.remove()disposes a subtree's effects.
Layouts
HorizontalLayout, VerticalLayout, GridLayout, DockLayout, StackLayout (navml/widgets/layout/), on a
Python-only Layout that paints nothing, replaced every container's placement arithmetic. A child asks for room with
style hints the layout reads off the child -- basis, grow (default 1, so silent siblings share evenly), dock
-- so a style: block or a sheet rule says it. A layout re-arranges from an effect on its own size, its children's
visible and hints, so a child's geometry is navigated and its markup says nothing about it. Field is
Field(HorizontalLayout), Shell is Shell(DockLayout), Manager's panels sit in an id'd HorizontalLayout, and
Dialog's buttons in a ButtonRow. All conversions paint cmp-identically on a pty.
- A layout can answer for a child that says nothing:
LinearLayout.hints(child)returns(basis, grow), by default the child's own style hints. Override it rather than writing hints onto every child. ButtonRow(navml/widgets/dialog/button_row/, Python only) is aHorizontalLayoutwithspacing2,justify: "center"andheight2. Every child takesbutton_width(11, DN's usual) andgrow0. A child's ownstyle:basiswins.button_width: 0sizes eachButtonby its caption plusBUTTON_CHROME(5). A hidden button gives up its slot, so the rest stay centred.- A dialog that needs other buttons declares its own
ButtonRowunderanchors: left: 0 / right: 0 / bottom: 2and saysbuttons: "none", rather than hand-placing x values. Where DN's columns are not exactly centred, keep them:justify: "start"withanchors: left: Xat the first button's column, and DN'sspacing/button_width(Overwrite query, the UU boxes). buttons: "none"is Dialog's "no row of mine":rowis boundvisible: root.buttons != "none", soself.row.visible = Falsein a Python half now raises (a value over a binding). The message shows only whilepromptis non-empty: an empty one paints nothing, so a dialog of controls needs no line hiding it.- Geometry outside a layout is better said with an
anchors:block (navml-markup) than withparent.width - Karithmetic.
The About dialog
≡ > About is DN's MessageBoxAbout (navigator/widgets/about_dialog/): Dialog with buttons: "ok" and message
centred. Its facts are never written twice: navigator/lib/utilities/about.py's project_info() reads pyproject.toml's
[project] in a checkout and the installed METADATA otherwise. The README screenshot shows it open, so a version bump
makes tools/screenshot.py --check stale (regenerate it with the bump; no test checks that scene). The home page is an OSC 8 hyperlink.
Read when
| Reference | Read when |
|---|---|
reference/widget-library.md |
button drawing, disabled/inert, shortcuts, rows-are-not-widgets, the dialog rules in full, what came from Panel, where colours live, Timer |
reference/layouts.md |
layout hints and rules |
reference/history.md |
HistoryStore, HistoryList, History.choices |
reference/from-textual.md |
what the library takes from Textual |