Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TUI App in Rust

Avatar for Yoshihito Yoshihito
October 22, 2020

TUI App in Rust

Avatar for Yoshihito

Yoshihito

October 22, 2020
Tweet

More Decks by Yoshihito

Other Decks in Programming

Transcript

  1. About me • Ϋϥεϝιουגࣜձࣾ (Developers.IOͷͱ͜) • ෱ԬΦϑΟεॴଐ • CXࣄۀຊ෦ •

    αʔόʔαΠυΤϯδχΞ • ΍ͬͯΔ͜ͱ • AWS؀ڥʹγεςϜߏங • ϞόΠϧΞϓϦ • IoT 2
  2. TUIΞϓϦέʔγϣϯͱ͸ • Text-based user interfaces • Terminal user interfacesͱ΋ݺ͹ΕΔΈ͍ͨ •

    ࢀߟ: Text-based user interface | Wikipedia • CLI͸ίϚϯυϥΠϯͰૢ࡞͢Δ • GUI͸ΞΠίϯ΍ը૾ͱ͍ͬͨάϥϑΟΧϧͳUIͰૢ࡞͢Δ • TUI͸໊લͷ௨ΓɺςΩετϕʔεͷUIͰૢ࡞͢Δ 6
  3. Πϕϯτ੍ޚ • TickΠϕϯτ • ҰఆִؒͰൃੜ͢ΔΠϕϯτ • σʔλͷߋ৽΍ը໘ͷඳըͰར༻͢Δ • ೖྗΠϕϯτ •

    Ϛ΢εೖྗ΍ΩʔೖྗͰൃੜ͢ΔΠϕϯτ • ը໘Λ੾Γସ͑ͨΓɺԿ͔͠ΒͷػೳΛ࣮ߦ͢Δͷʹར༻͢Δ 12
  4. λʔϛφϧ੍ޚ • ৭ʑͳϥΠϒϥϦ͕༻ҙ͞Ε͍ͯΔ • termion • h*ps:/ /github.com/redox-os/termion • crossterm

    • h*ps:/ /github.com/crossterm-rs/crossterm Windows΋αϙʔτ͍ͨ͠৔߹͸crosstermΛ࢖͏͜ͱ͕ଟͦ͏ • Using cossterm for windows support. by TimonPost · Pull Request #99 · Rigellute/spo?fy- tui 16
  5. ೖྗΠϕϯτ λʔϛφϧ੍ޚͷϥΠϒϥϦΛ࢖࣮ͬͯݱ͢Δ • termion • termion::input::TermRead Λ࢖͏ • std::io::stdin().keys() ͰΩʔೖྗΛѻ͑ΔΑ͏ʹͳΔ

    • ࢀߟ: h,ps:/ /docs.rs/termion/1.5.5/termion/input/trait.TermRead.html#tymethod.keys • crossterm • crossterm::event::read ͰΩʔೖྗΛಡΈࠐΉ • featuresͰ event-stream Λ༗ޮʹ͢ΔͱΩʔೖྗΛඇಉظετϦʔϜͰѻ͑Δ • ࢀߟ: h,ps:/ /docs.rs/crossterm/0.18.0/crossterm/event/fn.read.html 23
  6. ࡞ͬͨ΋ͷ - ߏ੒ • λʔϛφϧ੍ޚ • crossterm • Πϕϯτ੍ޚ •

    TickΠϕϯτ → tokio::time::interval • ೖྗΠϕϯτ → crossterm::event::EventStream • ΞϓϦέʔγϣϯϩδοΫ • CloudWatch LogsपΓ → rusoto_logs • UIඳը • tui-rs 28
  7. ৼΓฦΓ ઌʹ΍ͬͱ͚͹/஌ͬͯΕ͹Α͔ͬͨܥͷϊ΢ϋ΢ • ඪ४ग़ྗ΁ͷϩάग़ྗ͸NG • ϑΝΠϧग़ྗ͢Δ • σόοά༻ͷ΢ΟδΣοτΛ࡞੒͢Δ (Φεεϝ) •

    CLion͔Βىಈ/σόοάͰ͖ͳ͍ • rawϞʔυʹ੾Γସ͑ΒΕͳ͍ͨΊ • λʔϛφϧͰىಈ͔ͯ͠ΒϓϩηεʹσόοΨΛΞλον͢Ε͹ྑ͍ 29
  8. ·ͱΊ • RustͩͱखܰʹTUIΞϓϦέʔγϣϯ࡞ΕΔ • ඞཁͳϥΠϒϥϦ͕ॆ࣮͍ͯ͠Δ • termion • crossterm •

    tui-rs • CLI→TUIʹ͢Δͱૢ࡞ָ͕ʹͳΔέʔε΋͋Γͦ͏ • TUIΞϓϦͳͲπʔϧ࡞੒Λ௨ͯ͠RustͷཧղΛਂΊ͍͖͍ͯͨ 30
  9. ࢀߟ • Tig • h&ps:/ /github.com/jonas/5g • tui-rs • h&ps:/

    /github.com/fdehau/tui-rs • ytop • h&ps:/ /github.com/cjbassi/ytop • bo&om • h&ps:/ /github.com/ClementTsang/bo&om • spo5fy-tui • h&ps:/ /github.com/Rigellute/spo5fy-tui 31