Skip to content

Commit

Permalink
Merge pull request #56 from markruler/support-windows
Browse files Browse the repository at this point in the history
Add tcell to support Windows
  • Loading branch information
nakabonne committed Oct 13, 2020
2 parents 86bc7fb + d55656e commit 4ebe364
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions gui/gui.go
Expand Up @@ -3,12 +3,14 @@ package gui
import (
"context"
"fmt"
"runtime"
"time"

"github.com/mum4k/termdash"
"github.com/mum4k/termdash/container"
"github.com/mum4k/termdash/container/grid"
"github.com/mum4k/termdash/linestyle"
"github.com/mum4k/termdash/terminal/tcell"
"github.com/mum4k/termdash/terminal/termbox"
"github.com/mum4k/termdash/terminal/terminalapi"

Expand All @@ -24,15 +26,23 @@ const (
type runner func(ctx context.Context, t terminalapi.Terminal, c *container.Container, opts ...termdash.Option) error

func Run(targetURL string, opts *attacker.Options) error {
t, err := termbox.New(termbox.ColorMode(terminalapi.ColorMode256))
var (
t terminalapi.Terminal
err error
)
if runtime.GOOS == "windows" {
t, err = tcell.New()
} else {
t, err = termbox.New(termbox.ColorMode(terminalapi.ColorMode256))
}
if err != nil {
return fmt.Errorf("failed to generate terminal interface: %w", err)
}
defer t.Close()
return run(t, termdash.Run, targetURL, opts)
}

func run(t *termbox.Terminal, r runner, targetURL string, opts *attacker.Options) error {
func run(t terminalapi.Terminal, r runner, targetURL string, opts *attacker.Options) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down

0 comments on commit 4ebe364

Please sign in to comment.