A TUI for exploring crates.io using Ratatui

Overview

crates-tui

crates-tui is a simple terminal user interface explorer for crates.io based on Ratatui.

crates-tui.mov

It supports features like:

  • copy cargo add command to clipboard
  • open the docs page in the browser
  • open crates.io page in the brower
image image image image

Install

cargo install crates-tui

Arch Linux

crates-tui can be installed with an AUR helper:

paru -S crates-tui

Screenshots

Open in browser

open-in-browser.mov

Logging

crates-tui-logging.mov

Base16 Theme

Dracula

image

Rose Pine

image

GitHub

image

You can find example color configurations here.

Help

help.mov

Key to Action configurations per mode

You can find the default configuration here.

Background

This repository contains an opinionated way of organizing a small to medium sized Ratatui TUI applications.

It has several features, notably:

  • Uses async to fetch crate information without blocking the UI
  • Multiple custom widgets
    • Selection tab
    • Input prompt
    • Search results table
    • Summary view
  • Has configurable key chords that map to actions

This repository is meant to serve as a reference for some patterns you may follow when developing Ratatui applications. The code will function as a reference for the tutorial material on https://ratatui.rs as well.

Comments
  • feat: refactor app.rs

    feat: refactor app.rs

    The purpose of this PR is to gradually refactor the app module to split the search and summary functionality better. Right now app is a module that has a bit of everything.

    Don't merge this, I'll update this as I'm working through the refactor.


    This PR refactors app.rs and adds a permanent statusbar.

    opened by joshka 4
  • Version flag emits idempotent output

    Version flag emits idempotent output

    For crates-tui -V I get the following output:

    crates-tui 0.1.5-VERGEN_IDEMPOTENT_OUTPUT (2024-02-10)
    

    This is probably due to missing commits (.git folder) during build process.

    Any idea how to make the output better? I'm interested in submitting a PR.

    opened by orhun 2
  • chore(deps): bump webbrowser from 0.8.12 to 0.8.13

    chore(deps): bump webbrowser from 0.8.12 to 0.8.13

    Bumps webbrowser from 0.8.12 to 0.8.13.

    Release notes

    Sourced from webbrowser's releases.

    v0.8.13

    Releasing v0.8.13 with the following changes

    Added

    • AIX: experimental support. See PR #79
    Changelog

    Sourced from webbrowser's changelog.

    [0.8.13] - 2024-03-05

    Added

    • AIX: experimental support. See PR #79
    Commits
    • ec9359d Release v0.8.13 [skip ci]
    • 0e8ea84 android: move target api level of tests to 33 #build-android
    • b88c138 android: fix android build #build-android
    • b7b7462 android: create avd before compiling tests #build-android
    • c53c4d7 unix: fix lint #build-linux
    • 98172a0 Merge branch 'ecnelises-aix' - see PR #79
    • 2007762 Initial AIX enablement
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump clap from 4.5.1 to 4.5.2

    chore(deps): bump clap from 4.5.1 to 4.5.2

    Bumps clap from 4.5.1 to 4.5.2.

    Release notes

    Sourced from clap's releases.

    v4.5.2

    [4.5.2] - 2024-03-06

    Fixes

    • (macros) Silence a warning
    Changelog

    Sourced from clap's changelog.

    [4.5.2] - 2024-03-06

    Fixes

    • (macros) Silence a warning
    Commits
    • f65d421 chore: Release
    • 886b272 docs: Update changelog
    • 3ba4297 Merge pull request #5386 from amaanq/static-var-name
    • 2aea950 fix: Use SCREAMING_SNAKE_CASE for static variable authors
    • 690f555 Merge pull request #5382 from clap-rs/renovate/pre-commit-action-3.x
    • a2aa644 chore(deps): update compatible (dev) (#5381)
    • c233de5 chore(deps): update pre-commit/action action to v3.0.1
    • d0028d7 Merge pull request #5371 from BenWiederhake/dev-fix-link-command-trailing_var...
    • 0076cac fix(builder): Don't doc-link to undocumented item
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump chrono from 0.4.34 to 0.4.35

    chore(deps): bump chrono from 0.4.34 to 0.4.35

    Bumps chrono from 0.4.34 to 0.4.35.

    Release notes

    Sourced from chrono's releases.

    v0.4.35

    Most of our efforts have shifted to improving the API for a 0.5 release, for which cleanups and refactorings are landing on the 0.4.x branch.

    The most significant changes in this release are two sets of deprecations.

    • We deprecated all timestamp-related methods on NaiveDateTime. The reason is that a timestamp is defined to be in UTC. The NaiveDateTime type doesn't know the offset from UTC, so it was technically wrong to have these methods. The alternative is to use the similar methods on the DateTime<Utc> type, or from the TimeZone trait.

      Converting from NaiveDateTime to DateTime<Utc> is simple with .and_utc(), and in the other direction with .naive_utc().

    • The panicking constructors of TimeDelta (the new name of the Duration type) are deprecated. This was the last part of chrono that defaulted to panicking on error, dating from before rust 1.0.

    • A nice change is that NaiveDate now includes a niche. So now Option<NaiveDate>, Option<NaiveDateTime> and Option<DateTime<Tz>> are the same size as their base types.

    • format::Numeric and format::Fixed are marked as non_exhaustive. This will allow us to improve our formatting and parsing support, and we have reason to believe this breaking change will have little to no impact on users.

    Additions

    • Add DateTime::{from_timestamp_micros, from_timestamp_nanos} (#1234)
    • Add getters to Parsed (#1465)

    Deprecations

    • Deprecate timestamp methods on NaiveDateTime (#1473)
    • Deprecate panicking constructors of TimeDelta (#1450)

    Changes/fixes

    • Use NonZeroI32 inside NaiveDate (#1207)
    • Mark format::Numeric and format::Fixed as non_exhaustive (#1430)
    • Parsed fixes to error values (#1439)
    • Use overflowing_naive_local in DateTime::checked_add* (#1333)
    • Do complete range checks in Parsed::set_* (#1465)

    Documentation

    • Rustfmt doctests (#1452)
    • Improve docs for crate features (#1455, thanks @​edmorley)
    • Add more documentation and examples to Parsed (#1439)

    Internal

    • Refactor internals module (#1428, #1429, #1431, #1432, #1433, #1438)
    • CI: test cross-compiling to x86_64-unknown-illumos instead of Solaris (#1437)
    • CI: lint Windows target, fix clippy warning (#1441)
    • CI: only run cargo hack check on Linux (#1442)
    • Update windows-bindgen to 0.54 (#1462, #1483)
    • Simplify error value of parse_internal (#1459)
    • Simplify SerdeError (#1458)
    • Simplify NaiveDate::from_isoywd a bit (#1464)

    ... (truncated)

    Commits
    • 9fdb596 Prepare 0.4.35
    • 9e667b6 Deprecate panicking TimeDelta constructors
    • 2c1b0be Tests: replace TimeDelta::milliseconds with try_milliseconds
    • 2bf3302 Tests: replace TimeDelta::seconds with try_seconds
    • f93508f Tests: replace TimeDelta::minutes with try_minutes
    • 9fc931a Tests: replace TimeDelta::hours with try_hours
    • 9f23c08 Tests: replace TimeDelta::days with try_days
    • e8f9b5e Tests: replace TimeDelta::weeks with try_weeks
    • 51a1aa2 Tests: use Days type when it is more appropriate than TimeDelta
    • 4251bd1 Replace TimeDelta::seconds with try_seconds
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump strum from 0.26.1 to 0.26.2

    chore(deps): bump strum from 0.26.1 to 0.26.2

    Bumps strum from 0.26.1 to 0.26.2.

    Changelog

    Sourced from strum's changelog.

    0.26.2

    • #337: Fix missing generic impls for EnumTryAs
    • #334: Support prefix in AsRefStr. Technically a breaking change, but prefix was just added in 0.26.0 so it's a newer feature and it makes the feature more consisent in general.
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump serde from 1.0.196 to 1.0.197

    chore(deps): bump serde from 1.0.196 to 1.0.197

    Bumps serde from 1.0.196 to 1.0.197.

    Release notes

    Sourced from serde's releases.

    v1.0.197

    • Fix unused_imports warnings when compiled by rustc 1.78
    • Optimize code size of some Display impls (#2697, thanks @​nyurik)
    Commits
    • 5fa711d Release 1.0.197
    • f5d8ae4 Resolve prelude redundant import warnings
    • 1d54973 Merge pull request #2697 from nyurik/format-str
    • b8fafef A few minor write_str optimizations and inlining
    • c42ebb8 Update ui test suite to nightly-2024-02-12
    • 9e68062 Ignore incompatible_msrv clippy lint for conditionally compiled code
    • 846f865 Ignore dead_code warnings in test
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump textwrap from 0.16.0 to 0.16.1

    chore(deps): bump textwrap from 0.16.0 to 0.16.1

    Bumps textwrap from 0.16.0 to 0.16.1.

    Release notes

    Sourced from textwrap's releases.

    textwrap-0.16.1

    Version 0.16.1 (2024-02-17)

    This release fixes display_width to ignore inline-hyperlinks. The minimum supported version of Rust is now documented to be 1.56.

    • #526: Ignore ANSI hyperlinks in display_width: calculations.
    • #521: Add Options::width setter method.
    • #520: Clarify that WordSeparator is an enum rather than a trait.
    • #518: Test with latest stable and nightly Rust, but check that we can build with Rust 1.56.
    Changelog

    Sourced from textwrap's changelog.

    Version 0.16.1 (2024-02-17)

    This release fixes display_width to ignore inline-hyperlinks. The minimum supported version of Rust is now documented to be 1.56.

    • #526: Ignore ANSI hyperlinks in display_width: calculations.
    • #521: Add Options::width setter method.
    • #520: Clarify that WordSeparator is an enum rather than a trait.
    • #518: Test with latest stable and nightly Rust, but check that we can build with Rust 1.56.
    Commits
    • 39914e0 Merge pull request #533 from mgeisler/release-0.16.1
    • 8f84d66 Bump version to 0.16.1
    • a87c395 Update changelog for version 0.16.1
    • 3dd0774 Add dependency graph for version 0.16.1
    • b656c07 Merge pull request #532 from mgeisler/skip-ansi-escape-sequence-early-return
    • 599b78a Early return in skip_ansi_escape_sequence
    • e7a20ef Merge pull request #526 from tertsdiepraam/ansi-hyperlink
    • 5d28004 display_width: support BEL as a separator in hyperlinks
    • aa09798 Merge pull request #529 from mgeisler/dependabot/npm_and_yarn/examples/wasm/w...
    • 12feb68 Bump follow-redirects from 1.15.2 to 1.15.4 in /examples/wasm/www
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore(deps): bump clap from 4.5.0 to 4.5.1

    chore(deps): bump clap from 4.5.0 to 4.5.1

    Bumps clap from 4.5.0 to 4.5.1.

    Release notes

    Sourced from clap's releases.

    v4.5.1

    [4.5.1] - 2024-02-16

    Fixes

    • (error) Include suggestion to add -- even if there is a "did you mean" so long as last or trailing_var_arg is used
    Changelog

    Sourced from clap's changelog.

    [4.5.1] - 2024-02-16

    Fixes

    • (error) Include suggestion to add -- even if there is a "did you mean" so long as last or trailing_var_arg is used
    Commits
    • 0c01b55 chore: Release
    • 08e0b5b docs: Update changelog
    • f2c4e6e Merge pull request #5359 from poliorcetics/ab/push-szymvyzpmnqx
    • e782775 fix(complete): Handle newlines in command/arg descriptions
    • fba7c85 test(complete): Show newline issue
    • 8a7a13a chore: Release
    • 7b3a3e1 docs: Update changelog
    • 7b624ca Merge pull request #5356 from epage/escape
    • 446328a fix(error): Include -- in more cases
    • 7de6df8 test(error): Show existing last behavior
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • jm/refactor tui

    jm/refactor tui

    • refactor: remove unnecessary Tui struct
    • refactor: simplify tui::init/restore
    • refactor: remove tui from handle_action
    • refactor: simplify action handling
    opened by joshka 0
  • chore(deps): bump ratatui from 0.26.1-alpha.1 to 0.26.1

    chore(deps): bump ratatui from 0.26.1-alpha.1 to 0.26.1

    Bumps ratatui from 0.26.1-alpha.1 to 0.26.1.

    Release notes

    Sourced from ratatui's releases.

    v0.26.1

    0.26.1 - 2024-02-12

    This is a patch release that fixes bugs and adds enhancements, including new iterators, title options for blocks, and various rendering improvements. ✨

    Features

    • 74a0511 (rect) Add Rect::positions iterator (#928)

      Useful for performing some action on all the cells in a particular area.
      E.g.,
      
      fn render(area: Rect, buf: &amp;mut Buffer) {
         for position in area.positions() {
              buf.get_mut(position.x, position.y).set_symbol(&quot;x&quot;);
          }
      }
      

    • 9182f47 (uncategorized) Add Block::title_top and Block::title_top_bottom (#940)

      This adds the ability to add titles to the top and bottom of a block
      without having to use the `Title` struct (which will be removed in a
      future release - likely v0.28.0).
      

      Fixes a subtle bug if the title was created from a right aligned Line and was also right aligned. The title would be rendered one cell too far to the right.

      Block::bordered()
          .title_top(Line::raw(&quot;A&quot;).left_aligned())
          .title_top(Line::raw(&quot;B&quot;).centered())
          .title_top(Line::raw(&quot;C&quot;).right_aligned())
          .title_bottom(Line::raw(&quot;D&quot;).left_aligned())
          .title_bottom(Line::raw(&quot;E&quot;).centered())
          .title_bottom(Line::raw(&quot;F&quot;).right_aligned())
          .render(buffer.area, &amp;mut buffer);
      // renders
      &quot;┌A─────B─────C┐&quot;,
      &quot;│             │&quot;,
      &quot;└D─────E─────F┘&quot;,
      </code></pre>
      </li>
      </ul>
      <!-- raw HTML omitted -->
      </blockquote>
      <p>... (truncated)</p>
      </details>
      <details>
      <summary>Changelog</summary>
      

      <p><em>Sourced from <a href="https://github.com/ratatui-org/ratatui/blob/main/CHANGELOG.md">ratatui's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/ratatui-org/ratatui/releases/tag/0.26.1">0.26.1</a> - 2024-02-12</h2> <p>This is a patch release that fixes bugs and adds enhancements, including new iterators, title options for blocks, and various rendering improvements. ✨</p> <h3>Features</h3> <ul> <li> <p><a href="https://github.com/ratatui-org/ratatui/commit/74a051147a4059990c31e08d96a8469d8220537b">74a0511</a> <em>(rect)</em> Add Rect::positions iterator (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/928">#928</a>)</p> <pre lang="text"><code>Useful for performing some action on all the cells in a particular area. E.g.,

      fn render(area: Rect, buf: &amp;amp;mut Buffer) {
         for position in area.positions() {
              buf.get_mut(position.x, position.y).set_symbol(&amp;quot;x&amp;quot;);
          }
      }
      </code></pre>
      <p></code></pre></p>
      </li>
      <li>
      <p><a href="https://github.com/ratatui-org/ratatui/commit/9182f47026d1630cb749163b6f8b8987474312ae">9182f47</a>
      <em>(uncategorized)</em> Add Block::title_top and Block::title_top_bottom (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/940">#940</a>)</p>
      <pre lang="text"><code>This adds the ability to add titles to the top and bottom of a block
      without having to use the `Title` struct (which will be removed in a
      future release - likely v0.28.0).
      <p>Fixes a subtle bug if the title was created from a right aligned Line
      and was also right aligned. The title would be rendered one cell too far
      to the right.</p>
      <pre lang="rust"><code>Block::bordered()
          .title_top(Line::raw(&amp;quot;A&amp;quot;).left_aligned())
          .title_top(Line::raw(&amp;quot;B&amp;quot;).centered())
          .title_top(Line::raw(&amp;quot;C&amp;quot;).right_aligned())
          .title_bottom(Line::raw(&amp;quot;D&amp;quot;).left_aligned())
          .title_bottom(Line::raw(&amp;quot;E&amp;quot;).centered())
          .title_bottom(Line::raw(&amp;quot;F&amp;quot;).right_aligned())
          .render(buffer.area, &amp;amp;mut buffer);
      // renders
      &amp;quot;┌A─────B─────C┐&amp;quot;,
      &amp;quot;│             │&amp;quot;,
      &amp;quot;└D─────E─────F┘&amp;quot;,
      </code></pre>
      <p>Addresses part of <a href="https://redirect.github.com/ratatui-org/ratatui/issues/738">ratatui-org/ratatui#738</a>
      </code></pre></p>
      </li>
      </ul>
      <!-- raw HTML omitted -->
      </blockquote>
      <p>... (truncated)</p>
      </details>
      <details>
      <summary>Commits</summary>
      <ul>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/efd1e476425477b0bce15e3dd96d5cdeb0e1174b"><code>efd1e47</code></a> chore(release): prepare for 0.26.1 (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/945">#945</a>)</li>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/410d08b2b5812d7e29302adc0e8ddf18eb7d1d26"><code>410d08b</code></a> docs: add link to FOSDEM 2024 talk (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/944">#944</a>)</li>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/a4892ad444739d7a760bc45bbd954e728c66b2d2"><code>a4892ad</code></a> chore: fix typo in docsrs example (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/946">#946</a>)</li>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/18870ce99063a492674de061441b2cce5dc54c60"><code>18870ce</code></a> chore: fix the method name for setting the Line style (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/947">#947</a>)</li>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/1f208ffd0368b4d269854dc0c550686dcd2d1de0"><code>1f208ff</code></a> docs: add GitHub Sponsors badge (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/943">#943</a>)</li>
      <li><a href="https://github.com/ratatui-org/ratatui/commit/e51ca6e0d2705e6e0a96aeee78f1e80fcaaf34fc"><code>e51ca6e</code></a> refactor: finish tidying up table (<a href="https://redirect.github.com/ratatui-org/ratatui/issues/942">#942</a>)</li>
      <li>See full diff in <a href="https://github.com/ratatui-org/ratatui/compare/v0.26.1-alpha.1...v0.26.1">compare view</a></li>
      </ul>
      </details>
      <br />
      
      
      [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=ratatui&package-manager=cargo&previous-version=0.26.1-alpha.1&new-version=0.26.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
      
      Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
      
      [//]: # (dependabot-automerge-start)
      [//]: # (dependabot-automerge-end)
      
      ---
      
      <details>
      <summary>Dependabot commands and options</summary>
      <br />
      
      You can trigger Dependabot actions by commenting on this PR:
      - `@dependabot rebase` will rebase this PR
      - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
      - `@dependabot merge` will merge this PR after your CI passes on it
      - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
      - `@dependabot cancel merge` will cancel a previously requested merge and block automerging
      - `@dependabot reopen` will reopen this PR if it is closed
      - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
      - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency
      - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
      - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
      - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
      
      
      </details>
      dependencies rust 
    opened by dependabot[bot] 0
  • chore: release v0.1.8

    chore: release v0.1.8

    🤖 New release

    • crates-tui: 0.1.7 -> 0.1.8
    Changelog

    0.1.8 - 2024-03-11

    Fixed

    • restore bracketed paste in tui::restore (#37)

    Other

    • (deps) bump clap from 4.5.1 to 4.5.2 (#41)
    • (deps) bump webbrowser from 0.8.12 to 0.8.13 (#42)
    • (deps) bump chrono from 0.4.34 to 0.4.35 (#40)
    • (deps) bump strum from 0.26.1 to 0.26.2 (#39)
    • (deps) bump serde from 1.0.196 to 1.0.197 (#38)
    • (deps) bump textwrap from 0.16.0 to 0.16.1 (#36)
    • (deps) bump clap from 4.5.0 to 4.5.1 (#35)
    • jm/refactor tui (#33)


    This PR was generated with release-plz.

    release 
    opened by kdheepak 0
  • Some other simplications

    Some other simplications

    • [ ] Status bar basically has an if statement that does something different for each mode that it's presented in, but the shared common functionality isn't enough to make it worth doing that way. Instead just handle that in the specific widget E.g. take code that is kinda like:
    impl Widget for A { fn render(...) { StatusBar.mode(A).render(...) }
    impl Widget for B { fn render(...) { StatusBar.mode(B).render(...) }
    impl Widget for StatusBar {
      fn render(...) {
        match mode {
          A => render_A_status_bar(),
          B => render_B_status_bar(),
        }
      }
    }
    

    and simplify it

    impl Widget for A { fn render(...) { render_A_status_bar() }
    impl Widget for B { fn render(...) { render_B_status_bar() }
    
    • [x] Help widget render method has a long iterator chain which calls get command a bunch of times. The command list is constant data. Write it as an constant array and then map that instead of the repeated code.

    • [x] consider just having an Event::Crossterm(CrosstermEvent) variant instead of mapping each variant to Event variants.

    opened by joshka 2
  • continued refactoring of app.rs for simplicity

    continued refactoring of app.rs for simplicity

    kd: do you have more simplifications in mind for crates-tui?

    joshka: I think app is still doing too many things. Try reading it top to bottom and writing them out.

    • [ ] Split mode into keybinding focused selector (not sure the right name for this) and tab selection. Rationale: The App has a 9 modes, but the app really just has 3 tabs of note (summary, search, and almost there crate info), these need to have a more prominent role in how they control the app. Showing help and popup are things that can happen on any mode and which overlay the mode. Common is there not because it's an actual mode, but to add a global keybinding profile

    • [ ] Push the methods on Mode and the methods that call them down into the search page. Rationale: impl Mode: contains stuff which is used in app to select which part of the search page to render. The search page should handle how to render itself, and these checks should be moved there instead

    • [ ] Remove the excess help and popup modes. Make the rendering of these a stack where the main mode is rendered and the help or popup are rendered over the top without having to track these as a mode Rationale: Last mode is only a thing because there's help and popup modes rather than there being some sort more useful stack of what's rendered (i.e. render the help popup over the summary / search mode )

    • [ ] Store which page is currently focused in a way that makes it easier to push the keys to the right place in the one method Rationale: Handle key event should not know about Search or filter - it shoud just forward the event to the search page and let it handle it if the search page is the one currently shown.

    • [ ] Make the code to handle events / commands to actions a method call on some keybindings type (may need to refactor the config types to make that work?) Rationale: in handle_key_events_from_config: the code that gets the command from the key binding is overly complex and belongs in some keybindings type instead of the app and elsewhere

    • [ ] Split the actions into actions for each page and global actions (perhaps Action::SearchAction(SearchAction) or similar) Rationale: in handle_action: There's still a mismash of things which are search responsibilities and app responsibilities stemming from the action type being a global enum that has everything that can happen in the app. This means to understans the search page, you have to understand how the application as a whole interacts with it. The enum should only have actions related to the app (quit, tick, resize, show/hide help/popup, switch tabs, open urls (maybe), copy clipboard (maybe))

    • [ ] Simplify the event -> command -> action approach Rationale: The event -> command -> action conversion is overly complex. My guess is that Command might be better off as a set of constants in a module rather than an enum? Not enitrely sure about how to fix this one. Perhaps there's just one too many concepts, or they fit badly for the usage?

    • [ ] create a type / module for handling keyboard chords properly Rationale: Key refresh tick handling should be done outside of the app with a more clearly defined and testable mechanism for holding key events that turn into chords (or can be bypassed when the user is in a place where they expect to just be able to type normally)

    • [ ] Simplify Quit Rationale: Looking at how it ends up interacting with the entire app, I think quit makes more sense as exit: bool than as a mode. It does't have any behavior / keys that make sense, so it's really just a simple flag

    • [ ] Move scroll related methods into the various widgets and handle pushing the events or actions to the widgets instead of handling calling individual methods Rationale: the scroll methods are there because the events / actions are not handled by the visible / focused widget properly. Push the logic down

    • [ ] Simplify the switch mode method Rationale: Switch mode has some recent modifications to support pushing the search mode down into the pages, but that was step 1, step 2 is making it so the search page is responsible for handling search / filter mode and the main app doesn't care about it

    • [ ] Fix how crate info showing is handled - move the loading parts of that into a crate info module instead of search module Rationale: update_current_selection_crate_info / show_full_crate_details should be pulled out and converted to something that allows a tab for the crate info to be shown. This would allow pressing enter on the summary screen and pressing enter on the search results to do the same thing. If you don't want this as a tab, at least make it a high level concept which the app pushes to the selected tab to render (but a tab is better)

    • [ ] Move crate counting down to search Rationale: store_total_number_of_crates belongs in search, not the app

    • [ ] Make the open url / clipboard copy a parameterized action Rationale: Open url / clipyboard should accept a url and be something any page can trigger (push don't pull)

    • [ ] Move the part of cursor setting that calls search out, and replace with something more generic Rationale: update_cursor knows too much about search - it should perhaps just be shared mutable state for whichever view / page is visible to set (or a call to send a SetCursor action, whichever makes sense)

    • [ ] move the events widget into its own type / module Rationale: This is mostly self contained behavior / related to the key chord handling mentioned above (perhaps they belong together?)

    Currently App is ~600 LoC in a 650 LoC file. I'm guessing a once all the things that are separate responsibilities are extracted it would be closer to half that.

    With a more general perspective on this once these tasks are done, look at the two most unrelated methods in each type and try to explain the relationship between them. The language that you use to describe how this works is a good source of missing concepts that might help model the application in a way that aligns the code with how we talk about the code.

    opened by joshka 1
Releases(v0.1.7)
Owner
Ratatui
Rust library that's all about cooking up terminal user interfaces (TUIs). Successor of tui-rs.
Ratatui
A rust crate for rendering large text to the terminal using font8x8 and ratatui.

tui-big-text tui-big-text is a rust crate that renders large pixel text as a ratatui widget using the glyphs from the font8x8 crate. Installation carg

Josh McKinney 7 Sep 7, 2023
A simple library fot creating file explorer for the ratatui crate.

ratatui-explorer ratatui-explorer is a simple library for creating file explorers for ratatui. Features: File explorer functionality. Input handling (

null 5 Feb 29, 2024
A simple and efficient terminal UI implementation with ratatui.rs for getting quick insights from csv files right on the terminal

CSV-GREP csv-grep is an intuitive TUI application writting with ratatui.rs for reading, viewing and quickly analysing csv files right on the terminal.

Anthony Ezeabasili 16 Mar 10, 2024
A gui tool written in Dioxus to make it easy to release a workspace of crates to crates.io

Easy-Release: a visual tool for releasing workspaces of libraries A work-in-progress GUI for releasing a large workspace of crates manually, but easil

Jon Kelley 13 Jan 18, 2023
A template for bootstrapping a Rust TUI application with tui-rs & crossterm

rust-tui-template A template for bootstrapping a Rust TUI application with tui-rs & crossterm. tui-rs The library is based on the principle of immedia

Orhun Parmaksız 72 Dec 31, 2022
An interactive shell environment for exploring the p2panda protocol

An interactive shell environment for exploring the p2panda protocol. Uses a mock node and clients to simulate network logic.

null 4 Dec 12, 2021
Remote-Archive is a utility for exploring remote archive files without downloading the entire contents of the archive.

[WIP] REMOTE-ARCHIVE Remote-Archive is a utility for exploring remote archive files without downloading the entire contents of the archive. The idea b

null 4 Nov 7, 2022
✨ A simple and cute tool for exploring Wikipedia from the terminal ✨

Wikipe ✨ Wikipe ✨ is a tool to search Wikipedia from the command-line. Given a search query, it returns a list of matching Wikipedia articles, which c

Harvey 4 Dec 20, 2022
A complete imgui-rs example using dependencies only from crates.io.

Dear imgui-rs, hello. This is a fairly basic, but complete and standalone example application for the Rust version of dear imgui (https://github.com/o

null 0 Nov 30, 2022
Simple file manager to practice using tui-rs

simple-tui-file-manager Simple file manager to practice using tui-rs Keymap Key description j, up move up k, down move down h, Left move parent dir l,

Slug 3 Nov 12, 2022
1 library and 2 binary crates to run SSH/SCP commands on a "mass" of hosts in parallel

massh 1 library and 2 binary crates to run SSH/SCP commands on a "mass" of hosts in parallel. The binary crates are CLI and GUI "frontends" for the li

null 2 Oct 16, 2022
A list of crates with snippets used by me to learn more about Rust.

my-rust-examples This is a list of crates used by me to learn Rust. How to execute You can use a dependency called cargo-play: cargo install cargo-pla

Ronald 0 Jan 3, 2022
List public items (public API) of library crates. Enables diffing public API between releases.

cargo-public-items List public items (the public API) of a Rust library crate by analyzing the rustdoc JSON of the crate. Automatically builds the rus

Martin Nordholts 203 Dec 31, 2022
This repo contains crates that are used to create the micro services and keep shared code in a common place.

MyEmma Helper Crates This repo contains crates that can are reused over different services. These crate are used in projects at MyEmma. But these crat

MyEmma 1 Jan 14, 2022
Use raw-window-handle 0.5 with crates that depend on 0.4.

OldHasRawWindowHandleWrapper Wrap any type that implements HasRawWindowHandle and HasRawDisplayHandle from raw-window-handle 0.5 in OldHasRawWindowHan

null 1 Nov 25, 2022
A series of crates that I made to compile images/video into asciinema & play them.

Bad Apple A series of crates that I made to compile images/video into asciinema & play them. The end goal is to make a kernel & legacy bootloader that

S0ra 10 Nov 29, 2022
Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

consumet-rs 5 Aug 13, 2023
Fix broken crates instantly 🏃🏽‍♀️💨

Patch-Crate patch-crate lets rust app developer instantly make and keep fixes to rust crate dependencies. It's a vital band-aid for those of us living

YiiSh 9 Nov 23, 2023
A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.

xplr A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf. [Quickstart] [Features] [Plugins] [Documentation] [Upgrade Guide] [

Arijit Basu 2.6k Jan 1, 2023