Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
> Patch versions are not included due to maintenance cost considerations.
> More detailed version tracking may be described as the project matures.

## [0.17.0] - Unreleased

### Added

- Added `Document::child_count(row_index)` to JSON and YAML for querying immediate container sizes independently of folding; empty containers return `Some(0)`, closing rows return their opening container's count, and non-container rows return `None`
- Added optional child-count annotations for collapsed and empty JSON and YAML containers, such as `[…] (3 items)` and `{…} (2 keys)`, controlled by `show_child_count` and `child_count_style`

### Changed

- Added `child_count` to `ContainerNode::Open`; direct constructors and exhaustive patterns must account for the new field
- Extended JSON and YAML `Config` with child-count settings, disabled by default; existing serialized configurations retain the previous display, and pretty-printed exports omit annotations
- Updated `promkit-widgets` to `v0.10.0`

## [0.16.0] - 2026-09-07

### Added

- Added `Document::row_index_for_path` and `Document::move_to_path` to JSON and YAML for navigating jq-style paths, including object keys, array indices, quoted string keys, and YAML non-string scalar keys
- Added zero-based document indexes to path navigation for JSON Lines and YAML document streams; moving to a path expands folded ancestors while preserving unrelated folding state
- Added `Document::selected_path()` to retrieve the selected row's document index and jq-style path

### Changed

- Improved selected-path lookup with compact per-row parent and array-index metadata
- Updated workspace dependencies, `promkit-core` to `v0.6.1`, and `promkit-widgets` to `v0.9.0`

## [0.15.0] - 2026-08-16

### Added

- Added `WidgetLayout::height_policy` with `HeightPolicy::OrderedContent`, `FairContent`, and `FairFill` for content-based allocation, equal-share limits, and padded fill areas
- Added configurable text overflow through `text::config::OverflowMode`, supporting wrapping by default or truncation with an ellipsis
- Added terminal regression scenarios for renderer height allocation

### Changed

- Replaced the mutating `PrefixSearch::search` API with `PrefixSearch::query`, which returns an independently selectable `PrefixSearchResult` snapshot
- Changed prefix-search widget state from `State::prefix_search` to `State::result`, moving candidate selection and navigation to the result snapshot
- Extracted renderer height allocation into a dedicated module; fair-content panes stay within their equal share without redistributing unused rows
- Updated `promkit-core` to `v0.6.0` and `promkit-widgets` to `v0.8.0`

### Removed

- Removed the status widget and its `status` Cargo feature from `promkit` and `promkit-widgets`

## [0.14.0] - 2026-07-28

### Added
Expand Down Expand Up @@ -158,7 +203,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

For versions prior to 0.10.0, please refer to the git history or GitHub releases.

[Unreleased]: https://github.com/ynqa/promkit/compare/v0.13.0...HEAD
[Unreleased]: https://github.com/ynqa/promkit/compare/v0.16.0...HEAD
[0.17.0]: https://github.com/ynqa/promkit/compare/v0.16.0...HEAD
[0.16.0]: https://github.com/ynqa/promkit/releases/tag/v0.16.0
[0.15.0]: https://github.com/ynqa/promkit/releases/tag/v0.15.0
[0.14.0]: https://github.com/ynqa/promkit/releases/tag/v0.14.0
[0.13.0]: https://github.com/ynqa/promkit/releases/tag/v0.13.0
[0.12.0]: https://github.com/ynqa/promkit/releases/tag/v0.12.0
[0.11.0]: https://github.com/ynqa/promkit/releases/tag/v0.11.0
Expand Down
2 changes: 1 addition & 1 deletion Concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ Applications select the capabilities and widgets they need through Cargo
features. The runtime is independent from the widget set:

```toml
promkit = { version = "0.16.0", features = [
promkit = { version = "0.17.0", features = [
"runtime",
"validate",
"prefixsearch",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Put the package in your `Cargo.toml`.

```toml
[dependencies]
promkit = { version = "0.16.0", features = ["runtime", "texteditor"] }
promkit = { version = "0.17.0", features = ["runtime", "texteditor"] }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8a6248f.

```

## Features
Expand Down
5 changes: 5 additions & 0 deletions examples/json/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ impl JsonViewer {
overflow_mode: OverflowMode::Wrap,
lines: None,
show_line_numbers: true,
show_child_count: true,
child_count_style: ContentStyle {
foreground_color: Some(Color::DarkGrey),
..Default::default()
},
},
},
}
Expand Down
5 changes: 5 additions & 0 deletions examples/yaml/src/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ impl YamlViewer {
overflow_mode: OverflowMode::Wrap,
lines: None,
show_line_numbers: true,
show_child_count: true,
child_count_style: ContentStyle {
foreground_color: Some(Color::DarkGrey),
..Default::default()
},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion promkit-widgets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "promkit-widgets"
version = "0.9.0"
version = "0.10.0"
edition = "2024"
authors = ["ynqa <un.pensiero.vano@gmail.com>"]
description = "Widgets for promkit"
Expand Down
41 changes: 39 additions & 2 deletions promkit-widgets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ using the `promkit` runtime can enable them through the main crate:

```toml
[dependencies]
promkit = { version = "0.16.0", features = ["runtime", "texteditor"] }
promkit = { version = "0.17.0", features = ["runtime", "texteditor"] }
```

The widget states can also be used directly:

```toml
[dependencies]
promkit-widgets = { version = "0.9", features = ["json", "yaml"] }
promkit-widgets = { version = "0.10", features = ["json", "yaml"] }
```

`promkit` re-exports this crate as `promkit::widgets`, while
Expand All @@ -44,6 +44,43 @@ promkit-widgets = { version = "0.9", features = ["json", "yaml"] }
| `serde` | Serde support for widget configuration |
| `all` | All features above |

## JSON and YAML child counts

JSON and YAML documents retain the number of immediate array/sequence elements
or object/mapping entries, independently of folding. Query a container with
`Document::child_count(row_index)`, using a zero-based index into `Document::rows()`.
Empty containers return `Some(0)`; closing rows return the opening container's
count. Scalars, YAML document separators, and invalid indices return `None`.

Enable annotations through the widget configuration:

```rust
use promkit_widgets::json::{Config, Document, State};

let mut state = State {
document: Document::from_str(r#"{"items": [1, 2, 3]}"#)?,
config: Config {
show_child_count: true,
..Default::default()
},
};
assert_eq!(state.document.child_count(1), Some(3));
state.document.toggle_at(1);
// The items row now displays: "items": […] (3 items)
```

The same APIs are available under `promkit_widgets::yaml`. Annotations appear
beside collapsed or empty containers, for example `{…} (2 keys)` and `[] (0 items)`.
`show_child_count` defaults to `false`; `child_count_style` controls annotation
styling. Changing these settings does not fold or expand containers. Existing
`toggle()` / `toggle_at()` operations control folding. Pretty-printed data exports
do not include annotations.

When constructing `ContainerNode::Open` directly, supply its new `child_count`
field. Existing exhaustive `Open` patterns must include the field or `..`.
For `Config` struct literals, use `..Default::default()` or supply the new fields;
stored Serde configurations without these fields keep the default display.

## Responsibilities

Widgets manage state and project it into renderable content. They intentionally
Expand Down
15 changes: 15 additions & 0 deletions promkit-widgets/benches/structured/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ fn benchmark_fixture(c: &mut Criterion, path: &Path) {
});
});

state.document.set_nodes_visibility(true);
for show_child_count in [false, true] {
state.config.show_child_count = show_child_count;
let label = if show_child_count {
"counts_visible"
} else {
"counts_hidden"
};
group.bench_function(format!("collapsed_viewport_projection/{label}"), |b| {
b.iter(|| {
black_box(state.create_graphemes_in_viewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT))
});
});
}

group.finish();
}

Expand Down
15 changes: 15 additions & 0 deletions promkit-widgets/benches/structured/yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ fn benchmark_fixture(c: &mut Criterion, path: &Path) {
});
});

state.document.set_nodes_visibility(true);
for show_child_count in [false, true] {
state.config.show_child_count = show_child_count;
let label = if show_child_count {
"counts_visible"
} else {
"counts_hidden"
};
group.bench_function(format!("collapsed_viewport_projection/{label}"), |b| {
b.iter(|| {
black_box(state.create_graphemes_in_viewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT))
});
});
}

group.finish();
}

Expand Down
Loading
Loading