Exemple #1
0
func changeHost(g *gocui.Gui, v *gocui.View) error {

	if err := g.DeleteView("summary"); err != nil {
		return err
	}
	if err := g.DeleteView("detail"); err != nil {
		return err
	}

	_, cy := v.Cursor()
	l, err := v.Line(cy)
	if err != nil {
		return err
	}
	serverName := strings.TrimSpace(l)

	for _, r := range scanHistory.ScanResults {
		if serverName == strings.TrimSpace(r.ServerInfoTui()) {
			currentScanResult = r
			break
		}
	}

	if err := setSummaryLayout(g); err != nil {
		return err
	}
	if err := setDetailLayout(g); err != nil {
		return err
	}
	return nil
}
Exemple #2
0
func codeComplete(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()

		x, y := ox+cx, oy+cy

		f := proj.GetFile("test.go")
		off := f.GetOffset(x, y)
		cands := codecomplete.Complete(proj, f, off)

		maxX, maxY := g.Size()
		maxY = maxY/2 - (len(cands) / 2)
		if v, err := g.SetView("msg", maxX/2-30, maxY, maxX/2+30, maxY+len(cands)+2); err != nil {
			if err != gocui.ErrorUnkView {
				return err
			}
			fmt.Fprintln(v, x, y, off)
			for _, c := range cands {
				fmt.Fprintln(v, c.Name, c.Perc)
			}

			if err := g.SetCurrentView("msg"); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemple #3
0
func getLine(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	g.ShowCursor = false

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

	maxX, maxY := g.Size()
	length := 10 + len(current_name)
	if l != "" {
		current_name = l
		if v, err := g.SetView("msg", maxX/2-length/2, maxY/2-3, maxX/2+length/2, maxY/2+3); err != nil {
			v.BgColor = gocui.ColorGreen
			v.FgColor = gocui.ColorBlack
			if err != gocui.ErrorUnkView {
				return err
			}
			current_proj = projects[current_name]
			current_proj.start()
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", (length-15)/2), "Active Project")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", 5), current_name)
			fmt.Fprintln(v, "")
			setView(g, "msg")
		}
	}
	return nil
}
Exemple #4
0
func cursorPageDown(g *gocui.Gui, v *gocui.View) error {
	jump := pageUpDownJumpCount(v)

	if v != nil {
		cx, cy := v.Cursor()
		ox, oy := v.Origin()
		ok, yLimit := movable(v, oy+cy+jump)
		_, maxY := v.Size()

		if !ok {
			if yLimit < maxY {
				v.SetCursor(cx, yLimit)
			} else {
				v.SetCursor(cx, maxY-1)
				v.SetOrigin(ox, yLimit-maxY+1)
			}
		} else if yLimit < oy+jump+maxY {
			if yLimit < maxY {
				v.SetCursor(cx, yLimit)
			} else {
				v.SetOrigin(ox, yLimit-maxY+1)
				v.SetCursor(cx, maxY-1)
			}
		} else {
			v.SetCursor(cx, cy)
			v.SetOrigin(ox, oy+jump)
		}
		onMovingCursorRedrawView(g, v)
	}
	return nil
}
Exemple #5
0
func getLine(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

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

	maxX, maxY := g.Size()
	if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		fmt.Fprintln(v, l)
		if err := g.SetCurrentView("msg"); err != nil {
			return err
		}
	}

	if v, err := g.View("main"); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		f := proj.GetFile(l)
		if f != nil {
			v.Clear()
			fmt.Fprintf(v, "%s", f.GetBody())
		}
		v.Editable = true
		v.Wrap = true
	}
	return nil
}
Exemple #6
0
func removeProject(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	g.ShowCursor = false

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

	maxX, maxY := g.Size()
	length := 20
	if l != "" {
		if v, err := g.SetView("del_proj", maxX/2-length/2, maxY/2, maxX/2+length/2, maxY/2+2); err != nil {
			v.BgColor = gocui.ColorRed
			if err != gocui.ErrorUnkView {
				return err
			}
			fmt.Fprintln(v, "Press 'd' to delete")
			setView(g, "del_proj")
		}
	}
	return nil
}
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 cursorMoveTop(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, _ := v.Cursor()
		v.SetCursor(cx, 0)
	}
	onMovingCursorRedrawView(g, v)
	return nil
}
Exemple #9
0
func cursorMoveMiddle(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		_, maxY := v.Size()
		cx, _ := v.Cursor()
		v.SetCursor(cx, maxY/2)
	}
	onMovingCursorRedrawView(g, v)
	return nil
}
func destinationsMenuDown(g *gocui.Gui, v *gocui.View) error {
	length := 9
	_, cy := v.Cursor()
	_, oy := v.Origin()
	if cy+oy < length-1 {
		return menuDown(g, v)
	}
	return nil
}
func platformsMenuDown(g *gocui.Gui, v *gocui.View) error {
	length := 3
	_, cy := v.Cursor()
	_, oy := v.Origin()
	if cy+oy < length-1 {
		return menuDown(g, v)
	}
	return nil
}
func cursorHome(g *gocui.Gui, v *gocui.View) error {
	ox, _ := v.Origin()
	cx, _ := v.Cursor()
	v.SetCursor(cx, 0)
	v.SetOrigin(ox, 0)

	updateTracksView(g, v)
	return nil
}
func transcriptsMenuDown(g *gocui.Gui, v *gocui.View) error {
	length := 5
	_, cy := v.Cursor()
	_, oy := v.Origin()
	if cy+oy < length-1 {
		return menuDown(g, v)
	}
	return nil
}
Exemple #14
0
func setContact(g *gocui.Gui, v *gocui.View) error {
	_, cy := v.Cursor()
	jid := viewJids[cy]

	g.View("main").Clear()
	io.Copy(g.View("main"), bytes.NewReader(jidBuffs[jid]))

	g.SetCurrentView("input")
	return nil
}
Exemple #15
0
func prev(g *ui.Gui, v *ui.View) error {
	cx, cy := v.Cursor()
	if cy-1 < 0 {
		return nil
	}
	err := v.SetCursor(cx, cy-1)
	printNodes()
	printNode(g)
	return err
}
Exemple #16
0
func next(g *ui.Gui, v *ui.View) error {
	cx, cy := v.Cursor()
	if cy+1 >= len(cli.Nodes) {
		return nil
	}
	err := v.SetCursor(cx, cy+1)
	printNodes()
	printNode(g)
	return err
}
Exemple #17
0
func (gui *Gui) getSelected(v *gocui.View) (string, error) {
	var l string
	var err error

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

	return l, err
}
Exemple #18
0
func moveRight(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx+1, cy); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox+1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemple #19
0
func cursorLeft(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx-1, cy); err != nil && ox > 0 {
			if err := v.SetOrigin(ox-1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemple #20
0
func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemple #21
0
func cursorDown(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
Exemple #22
0
func (runner *appRunner) cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
		runner.layout(g)
	}
	return nil
}
Exemple #23
0
func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && 0 < oy {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	onMovingCursorRedrawView(g, v)
	return nil
}
Exemple #24
0
func cursorPageUp(g *gocui.Gui, v *gocui.View) error {
	jump := pageUpDownJumpCount(v)
	if v != nil {
		cx, _ := v.Cursor()
		ox, oy := v.Origin()
		if err := v.SetOrigin(ox, oy-jump); err != nil {
			v.SetOrigin(ox, 0)
			v.SetCursor(cx, 0)

		}
		onMovingCursorRedrawView(g, v)
	}
	return nil
}
Exemple #25
0
func moveDown(g *gocui.Gui, v *gocui.View) error {
	fmt.Println("yo")
	if v != nil {
		fmt.Println("hey")
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
func cursorUp(g *gocui.Gui, v *gocui.View) error {
	offset := getOffsetFromTypedNumbers()
	ox, oy := v.Origin()
	cx, cy := v.Cursor()
	if err := v.SetCursor(cx, cy-offset); err != nil && oy > 0 {
		if err := v.SetOrigin(ox, oy-offset); err != nil {
			return err
		}
	}
	if v == gui.playlistsView {
		gui.updateTracksView()
	}
	return nil
}
Exemple #27
0
func cmd(g *ui.Gui, v *ui.View) error {
	_, cur := v.Cursor()
	current = "node"
	cmdTokens = []rune{}
	var err error
	nv, err := g.View("node")
	if err != nil {
		return err
	}
	cmdMode = true
	if err := cli.Connect(cur, update); err != nil {
		return err
	}
	return nv.SetCursor(0, 0)
}
Exemple #28
0
func cmdEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) {
	switch {
	case ch != 0 && mod == 0:
		v.EditWrite(ch)
	case key == gocui.KeySpace:
		v.EditWrite(' ')
	case key == gocui.KeyBackspace || key == gocui.KeyBackspace2:
		cx, _ := v.Cursor()
		if cx > len(fmt.Sprintf(cmdPrefix, cTubes.Selected)) {
			v.EditDelete(true)
		}
	case key == gocui.KeyDelete:
		v.EditDelete(false)
	}
}
Exemple #29
0
func selectChannel(g *gocui.Gui, v *gocui.View, token string, getChannelIdChan chan<- ChannelIdRequest, getUserNameChan chan<- UserNameRequest, getMessagesChan chan<- MessageRequest) error {
	log.Println("selectChannel called")
	_, cy := v.Cursor()
	channel, err := v.Line(cy)
	if err != nil {
		log.Println("selectChannel returning err")
		return err
	}
	log.Println("selectChannel calling getChannelId with " + channel)
	channelId := GetChannelId(channel, getChannelIdChan)
	log.Println("selectChannel calling populateMessages")
	err = populateMessages(g, token, channelId, getUserNameChan, getMessagesChan)
	log.Println("selectChannel returning")
	return err
}
func cursorDown(g *gocui.Gui, v *gocui.View) error {
	offset := getOffsetFromTypedNumbers()
	if cx, cy := v.Cursor(); canGoToNewPosition(cy + offset) {
		if err := v.SetCursor(cx, cy+offset); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+offset); err != nil {
				return err
			}
		}
		if v == gui.playlistsView {
			gui.updateTracksView()
		}
	}
	return nil
}