Giter Site home page Giter Site logo

termdash's Introduction

Doc Status Build Status Coverage Status Go Report Card License Mentioned in Awesome Go

termdashlogo

Termdash is a cross-platform customizable terminal based dashboard.

termdashdemo

The feature set is inspired by the gizak/termui project, which in turn was inspired by yaronn/blessed-contrib.

This rewrite focuses on code readability, maintainability and testability, see the design goals. It aims to achieve the following requirements. See the high-level design for more details.

Public API and status

The public API surface is documented in the wiki.

Private packages can be identified by the presence of the /private/ directory in their import path. Stability of the private packages isn't guaranteed and changes won't be backward compatible.

There might still be breaking changes to the public API, at least until the project reaches version 1.0.0. Any breaking changes will be published in the changelog.

Current feature set

  • Full support for terminal window resizing throughout the infrastructure.
  • Customizable layout, widget placement, borders, margins, padding, colors, etc.
  • Dynamic layout changes at runtime.
  • Binary tree and Grid forms of setting up the layout.
  • Focusable containers and widgets.
  • Processing of keyboard and mouse events.
  • Periodic and event driven screen redraw.
  • A library of widgets, see below.
  • UTF-8 for all text elements.
  • Drawing primitives (Go functions) for widget development with character and sub-character resolution.

Installation

To install this library, run the following:

go get -u github.com/mum4k/termdash
cd github.com/mum4k/termdash

Usage

The usage of most of these elements is demonstrated in termdashdemo.go. To execute the demo:

go run termdashdemo/termdashdemo.go

Documentation

Please refer to the Termdash wiki for all documentation and resources.

Implemented Widgets

The Button

Allows users to interact with the application, each button press runs a callback function. Run the buttondemo.

go run widgets/button/buttondemo/buttondemo.go

buttondemo

The TextInput

Allows users to interact with the application by entering, editing and submitting text data. Run the textinputdemo.

go run widgets/textinput/textinputdemo/textinputdemo.go

textinputdemo

Can be used to create text input forms that support keyboard navigation:

go run widgets/textinput/formdemo/formdemo.go

formdemo

The Gauge

Displays the progress of an operation. Run the gaugedemo.

go run widgets/gauge/gaugedemo/gaugedemo.go

gaugedemo

The Donut

Visualizes progress of an operation as a partial or a complete donut. Run the donutdemo.

go run widgets/donut/donutdemo/donutdemo.go

donutdemo

The Text

Displays text content, supports trimming and scrolling of content. Run the textdemo.

go run widgets/text/textdemo/textdemo.go

textdemo

The SparkLine

Draws a graph showing a series of values as vertical bars. The bars can have sub-cell height. Run the sparklinedemo.

go run widgets/sparkline/sparklinedemo/sparklinedemo.go

sparklinedemo

The BarChart

Displays multiple bars showing relative ratios of values. Run the barchartdemo.

go run widgets/barchart/barchartdemo/barchartdemo.go

barchartdemo

The LineChart

Displays series of values on a line chart, supports zoom triggered by mouse events. Run the linechartdemo.

go run widgets/linechart/linechartdemo/linechartdemo.go

linechartdemo

The SegmentDisplay

Displays text by simulating a 16-segment display. Run the segmentdisplaydemo.

go run widgets/segmentdisplay/segmentdisplaydemo/segmentdisplaydemo.go

segmentdisplaydemo

Contributing

If you are willing to contribute, improve the infrastructure or develop a widget, first of all Thank You! Your help is appreciated.

Please see the CONTRIBUTING.md file for guidelines related to the Google's CLA, and code review requirements.

As stated above the primary goal of this project is to develop readable, well designed code, the functionality and efficiency come second. This is achieved through detailed code reviews, design discussions and following of the design guidelines. Please familiarize yourself with these before contributing.

If you're developing a new widget, please see the widget development section.

Termdash uses this branching model. When you fork the repository, base your changes off the devel branch and the pull request should merge it back to the devel branch. Commits to the master branch are limited to releases, major bug fixes and documentation updates.

Similar projects in Go

Projects using Termdash

  • datadash: Visualize streaming or tabular data inside the terminal.
  • grafterm: Metrics dashboards visualization on the terminal.
  • perfstat: Analyze and show tips about possible bottlenecks in Linux systems.
  • gex: Cosmos SDK explorer in-terminal.
  • ali: ALI HTTP load testing tool with realtime analysis.
  • suimon: SUI blockchain explorer and monitor.

Disclaimer

This is not an official Google product.

termdash's People

Contributors

bartosian avatar chipmunkie avatar dependabot[bot] avatar dyc3 avatar emesare avatar fenollp avatar fgksgf avatar icy-comet avatar ilmanzo avatar kvnxiao avatar lovromazgon avatar lqr471814 avatar mum4k avatar nijynot avatar nilathedragon avatar slok avatar spacez320 avatar spellarbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

termdash's Issues

Change of container focus using keyboard shortcuts

Currently the focus (which widget receives keyboard and mouse events) can only be moved by mouse clicks.

We could enhance the container so that widget focus is moved by configurable keyboard shortcuts. This would involve adding new container options and enhancing the container itself so that it processes events.

Design and implement a keyboard trigger library

This library would receive a stream of keyboard presses and trigger a callback on the configured key or key combination.

This would ease the development of widgets or code that uses keyboard input and wants to support multi-key shortcuts.

Widget: Text input

Implement a widget that will allow the user to provide text input. Either single or multi-line.

Remove all occurrences of utf8.RuneCountInString

While utf8.RuneCountInString counts the number of runes, it cannot be used to determine the number of cells the text takes. Full-width runes take multiple cells.

This mostly affects the text alignment code and the gauge widget.

Support variable size container splits

Currently both the vertical and the horizontal splits split the container exactly in the middle.

Allow for multiple sizes. Consider using predefined sizes (like SplitHalf, SplitQuarter, ...) instead of accepting number to avoid possibility of input errors.

Support wide unicode characters

Some unicode characters take more than one cell to be displayed.

This must be supported by the canvas.SetCell function, the draw.Text function and the text widget.

Text and ESC seq

Is it possible to use with Text widget esc seq for foreground color?
Example ESC[39;49m

Generalize mouse state machine

Design and implement a library that would ease detection of mouse button presses.

A press is when both the press and the release is within a defined area.

Look at the existing implementation in the focus tracking code of the container package.

Invalid synchronisation in termdash_test

The tests (specifically the after function) is currently synchronised by waiting for the event queue to empty. This isn't a good synchronisation, since the event processing code in termdash still races with the test code that evaluates the result.

Example traceback:
The command "go test ./..." exited with 0.
12.77s$ go test -race ./...
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5f1cc8]
goroutine 38 [running]:
testing.tRunner.func1(0xc4200c05a0)
/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/testing/testing.go:742 +0x567
panic(0x62cf60, 0x7881a0)
/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/runtime/panic.go:502 +0x24a
github.com/mum4k/termdash.TestRun.func5(0xc42009c750, 0xc42006f100)
/home/travis/gopath/src/github.com/mum4k/termdash/termdash_test.go:239 +0x68
github.com/mum4k/termdash.TestRun.func11(0xc4200c05a0)
/home/travis/gopath/src/github.com/mum4k/termdash/termdash_test.go:358 +0xa00
testing.tRunner(0xc4200c05a0, 0xc4200833e0)
/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/testing/testing.go:777 +0x16e
created by testing.(*T).Run
/home/travis/.gimme/versions/go1.10.3.linux.amd64/src/testing/testing.go:824 +0x565
FAIL github.com/mum4k/termdash 1.068s

Use fakewidget.Draw in tests that use the fake widget

All tests that use the fake widget should use fakewidget.Draw or fakewidget.MustDraw when creating the expected value.

That way changes or enhancements to fakewidget will be limited to that package.

This is an example of a test that doesn't use MustDraw and instead uses primitives directly (MustBorder, MustText):

desc: "draws widget with container border and title aligned on the left",

This is an example of a test that uses the desired helper instead of draw primitives:

fakewidget.MustDraw(

Support custom colors.

Should be configurable for:

  1. The line graphs.
  2. The axes.
  3. The values displayed next to the axes.
  4. The axes labels.

There is a potential race between Options() and Draw() calls

This affects widgets that calculate their minimum size based on what data they currently have.

The following causes a race:

  1. infra calls Options()
  2. user changes values in the widget
  3. infra calls Draw(), potentially not respecting the min size.

Widget: Table

Implement a text table widget.

Similar to: https://github.com/yaronn/blessed-contrib/blob/master/docs/images/table.gif

Targeted features:

  • Support both ASCII and Unicode text.
  • API to specify columns and rows.
  • API to specify sizes of columns (auto based on content, fixed or percentage).
  • API to merge multiple columns and rows (colspan and rowspan).
  • Support content alignment within cells.
  • Support Text trimming, character or word wrapping within cells.
  • Support scrolling of longer tables.
  • Support keyboard and mouse input to interact with the table (row by row or cell by cell).
  • Visible or invisible cell and table borders.
  • Support sorting by individual columns (ascending and descending).

Optimize redraw of terminal

Some ideas:
The canvas can track which cells were set and only apply those to the terminal.
Widgets can indicate if they need a redraw or if the content is still the same.
Container can redraw only those widgets that changed.
Thetermdash API can support user triggered redraw instead of periodic.

Unify APIs in the draw package

All functions should define their own option type instead of accepting cell options.

One of their options would be to take in a list of cell options.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.