Exemple #1
0
func (c *column) CreateViews(g *gocui.Gui, colv *gocui.View) error {
	if c.isActive {
		colv.FgColor = gocui.ColorCyan | gocui.AttrBold
	} else {
		colv.FgColor = gocui.ColorDefault
	}
	x, y, maxX, maxY, err := g.ViewPosition(colv.Name())
	y = y + 2
	if err != nil {
		return err
	}
	maxIssues := maxY / LinesPerEntry
	c.maxIssues = maxIssues
	for i := 0; i < maxIssues; i++ {
		v, err := g.SetView(fmt.Sprintf("col-%s-%d", c.name, i),
			x, y+(i*LinesPerEntry), maxX, y+((i+1)*LinesPerEntry))
		if err != nil {
			if err != gocui.ErrorUnkView {
				return err
			}
		}
		v.SelBgColor = gocui.ColorRed
		v.Frame = false
		v.Wrap = true
	}
	return c.redraw(g)
}
func nextView(g *gocui.Gui, v *gocui.View) error {

	if v == nil {
		return g.SetCurrentView(vPlatforms)
	}
	getLine(g, v)

	switch v.Name() {
	case vPlatforms:
		return g.SetCurrentView(vTranscripts)
	case vTranscripts:
		return g.SetCurrentView(vDestinations)
	case vDestinations:
		if x, err := g.View(vTop); err == nil {
			x.Clear()
			fmt.Fprintf(x, "Hit enter to submit selections")
		}
		return g.SetCurrentView(vSubmit)
	case vSubmit:
		return g.SetCurrentView(vText)
	case vText:
		return g.SetCurrentView(vPlatforms)
	}
	return g.SetCurrentView(vPlatforms)
}
Exemple #3
0
func removeTrackCommand(g *gocui.Gui, v *gocui.View) error {
	switch v.Name() {
	case VIEW_PLAYLISTS:
		if playlist := gui.getSelectedPlaylist(); playlist != nil {
			playlists.Remove(playlist.Name())
			gui.updatePlaylistsView()
			gui.updateTracksView()
		}
	case VIEW_TRACKS:
		if playlist, index := gui.getSelectedPlaylistAndTrack(); index > -1 {
			for i := 1; i <= getOffsetFromTypedNumbers(); i++ {
				playlist.RemoveTrack(index)
			}
			gui.updateTracksView()
			goTo(g, v, index+1)
		}
	case VIEW_QUEUE:
		if index := gui.getQueueSelectedTrackIndex(); index > -1 {
			for i := 1; i <= getOffsetFromTypedNumbers(); i++ {
				if queue.Remove(index) != nil {
					continue
				}
			}
			gui.updateQueueView()
		}
	}
	return nil
}
Exemple #4
0
func (runner *appRunner) confirmStringDetail(gui *gocui.Gui, view *gocui.View) error {
	text := strings.TrimSpace(view.Buffer())

	runner.activeStringDetailController.Confirm(text)
	runner.restoreMainView()
	runner.gui.DeleteView(view.Name())
	return nil
}
Exemple #5
0
func toggleButton(g *gocui.Gui, v *gocui.View) error {
	nextview := "butdown"
	if v != nil && v.Name() == "butdown" {
		nextview = "butup"
	}
	_, err := g.SetCurrentView(nextview)
	return err
}
Exemple #6
0
func nextView(g *gocui.Gui, v *gocui.View) error {
	if v == nil || v.Name() == "side" {
		_, err := g.SetCurrentView("main")
		return err
	}
	_, err := g.SetCurrentView("side")
	return err
}
Exemple #7
0
func (runner *appRunner) confirmListDetail(gui *gocui.Gui, view *gocui.View) error {
	_, originY := view.Origin()
	_, cursorY := view.Cursor()
	runner.activeListDetailController.Confirm(originY + cursorY)
	runner.restoreMainView()
	runner.gui.DeleteView(view.Name())
	return nil
}
Exemple #8
0
func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error {
	name := v.Name()
	x0, y0, x1, y1, err := g.ViewPosition(name)
	if err != nil {
		return err
	}
	if _, err := g.SetView(name, x0+dx, y0+dy, x1+dx, y1+dy); err != nil {
		return err
	}
	return nil
}
Exemple #9
0
func pageUpDownJumpCount(v *gocui.View) int {
	var jump int
	switch v.Name() {
	case "side", "summary":
		jump = 8
	case "detail":
		jump = 30
	default:
		jump = 8
	}
	return jump
}
Exemple #10
0
// redraw views
func onMovingCursorRedrawView(g *gocui.Gui, v *gocui.View) error {
	switch v.Name() {
	case "summary":
		if err := redrawDetail(g); err != nil {
			return err
		}
	case "side":
		if err := changeHost(g, v); err != nil {
			return err
		}
	}
	return nil
}
Exemple #11
0
func previousView(g *gocui.Gui, v *gocui.View) error {
	if v == nil {
		return g.SetCurrentView("side")
	}
	switch v.Name() {
	case "side":
		return g.SetCurrentView("side")
	case "summary":
		return g.SetCurrentView("side")
	case "detail":
		return g.SetCurrentView("summary")
	default:
		return g.SetCurrentView("side")
	}
}
Exemple #12
0
func removeAllTracksCommand(g *gocui.Gui, v *gocui.View) error {
	switch v.Name() {
	case VIEW_PLAYLISTS:
	case VIEW_TRACKS:
		if playlist, index := gui.getSelectedPlaylistAndTrack(); index > -1 {
			playlist.RemoveAllTracks()
			gui.updateTracksView()
			return gui.enableSideView()
		}
	case VIEW_QUEUE:
		queue.RemoveAll()
		gui.updateQueueView()
		return gui.enableTracksView()
	}
	return nil
}
Exemple #13
0
func nextView(g *gocui.Gui, v *gocui.View) error {
	g.Cursor = false
	v.Highlight = false
	log.Println("nextView: " + v.Name())
	var err error
	switch v.Name() {
	case "channels":
		err = g.SetCurrentView("input")
		g.Cursor = true
	case "input":
		err = g.SetCurrentView("channels")
		g.CurrentView().Highlight = true
	}
	//	g.Flush()
	return err
}
Exemple #14
0
func keyPressed(key rune, g *gocui.Gui, v *gocui.View) error {
	multipleKeysBuffer.WriteRune(key)
	keyCombination := multipleKeysBuffer.String()

	if handler := keyboard.SequentialKeys[v.Name()+" "+keyCombination]; handler != nil {
		multipleKeysBuffer.Reset()
		err := handler(g, v)
		multipleKeysNumber = 0
		return err
	}

	if len(keyCombination) >= 2 {
		multipleKeysBuffer.Reset()
		return keyPressed(rune(keyCombination[1]), g, v)
	}
	return nil
}
Exemple #15
0
func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error {

	name := v.Name()

	// x0, y0, x1, y1, err := g.ViewPosition(name)
	// if err != nil {
	// return err
	// }

	// logger.Logger.Printf("RESIZE %d %d %d %d\n", x0+dx, y0+dy, x1+dx, y1+dy)

	if _, err := g.SetView(name, 0, 0, 0, 0); err != nil {
		return err
	}

	return nil
}
Exemple #16
0
func previousView(g *gocui.Gui, v *gocui.View) error {
	var err error

	if v == nil {
		_, err = g.SetCurrentView("side")
	}
	switch v.Name() {
	case "side":
		_, err = g.SetCurrentView("side")
	case "summary":
		_, err = g.SetCurrentView("side")
	case "detail":
		_, err = g.SetCurrentView("summary")
	default:
		_, err = g.SetCurrentView("side")
	}
	return err
}
func getLine(g *gocui.Gui, v *gocui.View) error {
	var line string
	var err error

	_, cy := v.Cursor()
	if line, err = v.Line(cy); err != nil {
		line = ""
	}
	switch v.Name() {
	case vPlatforms:
		opt.platform = line
	case vTranscripts:
		opt.transcript = line
	case vDestinations:
		opt.destination = line
	}
	return err
}
Exemple #18
0
func showMsg(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	if _, err := g.SetCurrentView(v.Name()); err != nil {
		return err
	}

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	maxX, maxY := g.Size()
	if v, err := g.SetView("msg", maxX/2-10, maxY/2, maxX/2+10, maxY/2+2); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, l)
	}
	return nil
}
Exemple #19
0
func movable(v *gocui.View, nextY int) (ok bool, yLimit int) {
	switch v.Name() {
	case "side":
		yLimit = len(scanHistory.ScanResults) - 1
		if yLimit < nextY {
			return false, yLimit
		}
		return true, yLimit
	case "summary":
		yLimit = len(currentScanResult.KnownCves) - 1
		if yLimit < nextY {
			return false, yLimit
		}
		return true, yLimit
	case "detail":
		if currentDetailLimitY < nextY {
			return false, currentDetailLimitY
		}
		return true, currentDetailLimitY
	default:
		return true, 0
	}
}
Exemple #20
0
func nextView(g *gocui.Gui, v *gocui.View) error {
	nextIndex := (active + 1) % len(viewArr)
	name := viewArr[nextIndex]

	out, err := g.View("v2")
	if err != nil {
		return err
	}
	fmt.Fprintln(out, "Going from view "+v.Name()+" to "+name)

	if _, err := setCurrentViewOnTop(g, name); err != nil {
		return err
	}

	if nextIndex == 0 || nextIndex == 3 {
		g.Cursor = true
	} else {
		g.Cursor = false
	}

	active = nextIndex
	return nil
}
Exemple #21
0
func keyPressed(key rune, g *gocui.Gui, v *gocui.View) error {
	multipleKeysBuffer = append(multipleKeysBuffer, key)
	var keyCombination string
	if len(multipleKeysBuffer) == 1 {
		keyCombination = string(multipleKeysBuffer[0])
	} else {
		keyCombination = string(multipleKeysBuffer[0]) + string(multipleKeysBuffer[1])
	}

	if handler := keyboard.SequentialKeys[v.Name()+" "+keyCombination]; handler != nil {
		multipleKeysBuffer = make([]rune, 0, 0)
		err := handler(g, v)
		multipleKeysNumber = 0
		return err
	}

	if len(multipleKeysBuffer) >= 2 {
		key1 := multipleKeysBuffer[1]
		multipleKeysBuffer = make([]rune, 0, 0)
		return keyPressed(rune(key1), g, v)
	}
	return nil
}
Exemple #22
0
func nextView(g *gocui.Gui, v *gocui.View) error {
	if v == nil || v.Name() == "side" {
		return g.SetCurrentView("main")
	}
	return g.SetCurrentView("side")
}
Exemple #23
0
func (runner *appRunner) cancelStringDetail(gui *gocui.Gui, view *gocui.View) error {
	runner.activeStringDetailController.Cancel()
	runner.restoreMainView()
	runner.gui.DeleteView(view.Name())
	return nil
}