# `BB.TUI.Panels.Parameters`
[🔗](https://github.com/mcass19/bb_tui/blob/v0.3.0/lib/bb/tui/panels/parameters.ex#L1)

Parameters panel — displays robot parameters grouped by path.

Renders a tab strip in the title when remote bridges have been
discovered. The `Local` tab shows parameters from `state.parameters.list`
(with schema metadata from `state.parameters.metadata`). Bridge tabs
show entries from `state.parameters.remote[bridge_name]`, which the
app populates by calling `BB.Parameter.list_remote/2` whenever the
user switches to that tab.

Pure function — takes state, returns a widget struct.

# `edit_hint`

```elixir
@spec edit_hint(term()) :: String.t()
```

Returns an edit hint suffix indicating how a parameter can be edited.

## Examples

    iex> BB.TUI.Panels.Parameters.edit_hint(42)
    " [h/l]"

    iex> BB.TUI.Panels.Parameters.edit_hint(3.14)
    " [h/l]"

    iex> BB.TUI.Panels.Parameters.edit_hint(true)
    " [enter]"

    iex> BB.TUI.Panels.Parameters.edit_hint(:fast)
    ""

# `format_path`

```elixir
@spec format_path(list()) :: String.t()
```

Formats a parameter path list as a dot-separated string.

## Examples

    iex> BB.TUI.Panels.Parameters.format_path([:controller, :kp])
    "controller.kp"

    iex> BB.TUI.Panels.Parameters.format_path([:speed])
    "speed"

# `format_type`

```elixir
@spec format_type(map() | nil) :: String.t()
```

Formats a parameter's Spark-declared type for the Type column.

Returns `"—"` when no schema metadata is present. Atom types render as
`":float"`; option-tagged types like `{:integer, [min: 0, max: 100]}`
render as their head atom — the bounds belong in the (future) edit
popup, not in a one-line table cell.

## Examples

    iex> BB.TUI.Panels.Parameters.format_type(nil)
    "—"

    iex> BB.TUI.Panels.Parameters.format_type(%{type: nil})
    "—"

    iex> BB.TUI.Panels.Parameters.format_type(%{type: :float})
    ":float"

    iex> BB.TUI.Panels.Parameters.format_type(%{type: {:integer, [min: 0, max: 100]}})
    ":integer"

    iex> BB.TUI.Panels.Parameters.format_type(%{type: {:custom, MyMod, :validate, []}})
    "{:custom, MyMod, :validate, []}"

    iex> BB.TUI.Panels.Parameters.format_type(%{})
    "—"

# `format_value`

```elixir
@spec format_value(term()) :: String.t()
```

Formats a parameter value for display.

## Examples

    iex> BB.TUI.Panels.Parameters.format_value(42)
    "42"

    iex> BB.TUI.Panels.Parameters.format_value(3.14159)
    "3.142"

    iex> BB.TUI.Panels.Parameters.format_value(true)
    "true"

    iex> BB.TUI.Panels.Parameters.format_value(:fast)
    ":fast"

# `render`

```elixir
@spec render(BB.TUI.State.t(), boolean()) :: struct()
```

Renders the parameters panel as a Table widget. Columns depend on the
selected tab: the local tab shows `Parameter | Value | Type`, while a
bridge tab shows `Parameter | Value | Type` populated from the remote
fetch result.

## Examples

    iex> state = %BB.TUI.State{parameters: %BB.TUI.State.Parameters{list: [{[:speed], 100}, {[:controller, :kp], 0.5}]}}
    iex> %ExRatatui.Widgets.Table{header: header} = BB.TUI.Panels.Parameters.render(state, false)
    iex> header
    ["Parameter", "Value", "Type"]

    iex> state = %BB.TUI.State{parameters: %BB.TUI.State.Parameters{list: []}}
    iex> %ExRatatui.Widgets.Table{rows: rows} = BB.TUI.Panels.Parameters.render(state, false)
    iex> rows
    [["No parameters defined", "", ""]]

# `title_line`

```elixir
@spec title_line([atom() | {:bridge, atom()}], non_neg_integer(), non_neg_integer()) ::
  ExRatatui.Text.Line.t()
```

Builds the panel title as a rich `%Line{}` carrying the tab strip.

Single-tab (local-only) state renders as ` Parameters (N) ` with a
bold-cyan count. Multi-tab state renders ` Parameters · Local | mavlink ` etc.,
with the active tab bold-cyan. The `t` shortcut to cycle tabs is
surfaced in the bottom status bar.

## Examples

    iex> %ExRatatui.Text.Line{spans: spans} =
    ...>   BB.TUI.Panels.Parameters.title_line([:local], 0, 5)
    iex> Enum.map_join(spans, "", & &1.content)
    "  5  Parameters (5) "

    iex> %ExRatatui.Text.Line{spans: spans} =
    ...>   BB.TUI.Panels.Parameters.title_line([:local], 0, 0)
    iex> Enum.map_join(spans, "", & &1.content)
    "  5  Parameters "

    iex> %ExRatatui.Text.Line{spans: spans} =
    ...>   BB.TUI.Panels.Parameters.title_line([:local, {:bridge, :mavlink}], 1, 12)
    iex> Enum.map_join(spans, "", & &1.content)
    "  5  Parameters · Local | mavlink (12) "

---

*Consult [api-reference.md](api-reference.md) for complete listing*
