Giter Site home page Giter Site logo

tvxwidgets's Introduction

tvxwidgets

PkgGoDev Go codecov Go Report

tvxwidgets provides extra widgets for tview.

Screenshot

Widgets

Example

package main

import (
	"time"

	"github.com/gdamore/tcell/v2"
	"github.com/navidys/tvxwidgets"
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	gauge := tvxwidgets.NewActivityModeGauge()
	gauge.SetTitle("activity mode gauge")
	gauge.SetPgBgColor(tcell.ColorOrange)
	gauge.SetRect(10, 4, 50, 3)
	gauge.SetBorder(true)

	update := func() {
		tick := time.NewTicker(500 * time.Millisecond)
		for {
			select {
			case <-tick.C:
				gauge.Pulse()
				app.Draw()
			}
		}
	}
	go update()

	if err := app.SetRoot(gauge, false).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}

tvxwidgets's People

Contributors

akrennmair avatar dependabot[bot] avatar fyb3roptik avatar hidayathamir avatar navidys avatar stdr-sumon 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

tvxwidgets's Issues

Checksum for release v0.3.0 changed ⚠️

It seems like the checksum for release v0.3.0 changed, but no new releases happened recently

➜ go mod download
verifying github.com/navidys/[email protected]: checksum mismatch
        downloaded: h1:KreOFWGTmaTF4YaL3bHA5tdLRELp+2y6JIq65ILpsOk=
        go.sum:     h1:n04eW19PyUpnEochKGn15ZvCmKkcpzA188vH6XBnOMA=

SECURITY ERROR
This download does NOT match an earlier download recorded in go.sum.
The bits may have been replaced on the origin server, or an attacker may
have intercepted the download attempt.

Both MinIO and podman-tui have the original checksum recorded, so this happened somewhere, just want to make sure the dependency has not been compromised

Need to change empty field color of UtilModeGauge object

Is your feature request related to a problem? Please describe.
I would like to change empty portion color of a object when it is created via tvxwidgets.NewUtilModeGauge()

Describe the solution you'd like
I thought such as, perhaps we may a global function function for that as we have for setting the label. e.g.:

func (g *UtilModeGauge) SetEmptyColor (color tcell.Color) {
g.emptyColor = color
}

gauge default maxValue causes panic

Describe the bug
gauge maxValue can be zero, causing panic with divide by zero

To Reproduce
Initialize gauge without setting maxValue
Draw

Expected behavior
The initialization should never allow zero value for gauge max value.

Desktop:

  • OS Ubuntu 22.04.1 LTS, Linux 5.15.39-051539-generic #202205120747 SMP Thu May 12 12:51:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • go version go1.19.2 linux/amd64
  • tview version github.com/rivo/tview v0.0.0-20220916081518-2e69b7385a37

Line charts

It would be useful if line charts and/or sparkline charts are implemented in this library, to better represent a dataset or multiple datasets. Do look at termui for reference.

Many people have requested support to render line charts in the tview repo, but the author is planning it for v2 (here). Since you already support custom widgets, perhaps you could add support for this too?

The source for the relevant widgets are here:

Braille Mode line charts don't display in the correct Y value range

Describe the bug
Braille Mode line charts don't draw the dots in the correct y-axis location. For example, I created a chart with data values between 1 and 2 stepping by .1 (1, 1.1, 1.2 ... 2.0). The PlotMarkerDot mode accurately displays the dots in the 1 - 2 range on the Y axis. However, when using PlotMarkerBraille mode, the dots appear between the range of 0 and 1. The gap is much larger if the the data values are bigger (for example, 100 to 101 stepping by .1)

To Reproduce
Steps to reproduce the behavior:
Run this code:

import (
      "github.com/gdamore/tcell/v2"
      "github.com/navidys/tvxwidgets"
      "github.com/rivo/tview"
  )

  func getChart(title string, marker tvxwidgets.Marker, data []float64, color tcell.Color) tview.Primitive {
      chart := tvxwidgets.NewPlot()
      chart.SetBorder(true)
      chart.SetTitle(title)
      chart.SetLineColor([]tcell.Color{
          tcell.ColorGreen,
      })
      chart.SetAxesColor(color)
      chart.SetAxesLabelColor(color)
      chart.SetMarker(marker)
      chart.SetData([][]float64{data})
      return chart
  }

  func main() {
      app := tview.NewApplication()
      sampleData := []float64{}
      for i := 0; i <= 10; i++ {
          sampleData = append(sampleData, 1+0.1*float64(i))
      }

      bmLineChart := getChart("line chart (braille mode)", tvxwidgets.PlotMarkerBraille, sampleData, tcell.ColorRed)
      dmLineChart := getChart("line chart (dot mode)", tvxwidgets.PlotMarkerDot, sampleData, tcell.ColorGold)

      layout := tview.NewFlex().SetDirection(tview.FlexColumn)
      layout.AddItem(bmLineChart, 0, 1, false)
      layout.AddItem(dmLineChart, 0, 1, false)
      layout.SetRect(0, 0, 100, 30)

      if err := app.SetRoot(layout, false).Run(); err != nil {
          panic(err)
      }
  }

Expected behavior
I expect the Braille Mode to use the correct range for the values.

Screenshots
Notice, the "dot mode" correctly displays in the range of 1 to 2, while the "braille mode" displays in the range of 0 to 1.
image

Desktop (please complete the following information):

  • OS Ubuntu 22.04.2
  • tview version
  • github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf

Additional context

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.