orders

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package orders renders the orders pane, a fixed five-column table with a dim header, the data rows windowed by the scroll offset, and the selected row reverse-highlighted. It has two tabs, selected by Key.Closed:

  • Open (symbol, side, price, qty, filled): the live cancel targets. There is no status column: this tab only ever lists OPEN orders (a small fixed status set), so the steady-state status carried little that the filled column didn't already show, and dropping it buys width for the columns that matter on a narrow terminal. The one status worth surfacing — a cancel in flight — is shown by graying that row out (parallel Data.Canceling), the same "style the row, don't spend a column" approach FlashID uses for a just-accepted order.
  • Closed (symbol, side, price, filled/qty, status): the terminal orders observed this session, read-only. Here the status column IS the point — it is where a rejected (expired) or canceled order becomes visible at all — and filled/qty makes a partial fill's returned remainder legible.

It is a pure view component — Model.View is a function of its explicit Key and Data, owns no shared state, and caches its render via uikit.Memo keyed on Key. The parent builds the table rows and bumps RowsRev whenever it rebuilds them (including when the canceling set changes), so the Key alone decides a cache hit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TitleTab

func TitleTab(innerX int, closed bool) (toClosed, ok bool)

TitleTab maps innerX — a click's cell offset into the pane's title line — to the tab it selects. ok is false off the two tab segments (the "orders:" prefix, the separator, and the trailing scope/count are all inert; a click on the active segment is a valid, idempotent selection). Widths are measured off the localized, PLAIN labels (the color styling does not change cell width), so the hit ranges track the rendered title in every locale.

Types

type Data

type Data struct {
	Rows      [][]string
	OrderIDs  []int64
	Canceling []bool
}

Data is what the component renders on a cache miss: the parent-built table projection (one []string of cell text per order, in column order), the parallel order IDs, and a parallel per-row "cancel in flight" flag (rendered as a grayed-out row instead of a status column). Canceling may be nil or shorter than Rows — a missing entry reads as false. RowsRev in the Key stands in for "did these rows change", and the parent bumps it when the canceling set changes too.

type Key

type Key struct {
	RowsRev  uint64
	Cursor   int
	Scroll   int
	AllPairs bool
	Focused  bool
	Loading  bool
	Count    int
	Symbol   string
	FlashID  int64 // a just-accepted order's id: its row renders highlighted (0 = none)
	// Closed selects the closed tab: its column set, its title, and no
	// loading hint (the closed set is session-observed, never "loading").
	Closed bool
	W, H   int
	Style  uikit.StyleID
}

Key is the comparable cache key: equal Keys render identically. RowsRev is the parent's monotonic stamp for the projected rows (it bumps on order events AND on cancel-in-flight changes, so the component never keys on the raw order revision); Cursor is the selected (cancel-target) row; Scroll is the window offset; AllPairs selects the all-pairs scope for the title; Focused selects the border color and footer label color; Loading shows the title's loading hint; Count is the order total for the title/footer; Symbol is the per-pair scope label; W and H are the OUTER panel size; Style is the palette identity.

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is the orders component. The zero value is ready to use.

func New

func New() *Model

New returns an orders component.

func (*Model) View

func (m *Model) View(k Key, d Data) string

View renders the full bordered pane for k/d, reusing the cached render when k is unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL