示例#1
0
func (hds *Heads) PrevWorkspace() *workspace.Workspace {
	if cur := hds.GlobalIndex(hds.ActiveWorkspace()); cur > -1 {
		// I f*****g hate Go's modulo operator. WTF.
		prev := misc.Mod(cur-1, len(hds.Workspaces.Wrks))
		return hds.Workspaces.Get(prev)
	}
	panic("bug")
}
示例#2
0
func (cmd HeadCycle) Run() gribble.Value {
	return syncRun(func() gribble.Value {
		cur := wm.Heads.VisibleIndex(wm.Workspace())
		next := misc.Mod(cur+1, wm.Heads.NumHeads())
		wm.Heads.WithVisibleWorkspace(next,
			func(wrk *workspace.Workspace) {
				wm.SetWorkspace(wrk, false)
			})
		wm.FocusFallback()
		return nil
	})
}
示例#3
0
文件: cycle.go 项目: pascience/foci
// Prev will highlight the previous choice in the dialog.
func (cycle *Cycle) Prev() {
	if !cycle.showing {
		return
	}

	if cycle.selected == -1 {
		cycle.selected = len(cycle.items) - 1
	} else {
		cycle.selected--
	}

	cycle.selected = misc.Mod(cycle.selected, len(cycle.items))
	cycle.highlight()
}
示例#4
0
文件: cycle.go 项目: pascience/foci
// Next will highlight the next choice in the dialog.
func (cycle *Cycle) Next() {
	if !cycle.showing {
		return
	}

	if cycle.selected == -1 {
		if len(cycle.items) > 1 {
			cycle.selected = 1
		} else {
			cycle.selected = 0
		}
	} else {
		cycle.selected++
	}

	cycle.selected = misc.Mod(cycle.selected, len(cycle.items))
	cycle.highlight()
}