本文整理汇总了Golang中github.com/BurntSushi/wingo/wini.Data类的典型用法代码示例。如果您正苦于以下问题:Golang Data类的具体用法?Golang Data怎么用?Golang Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Data类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: loadOptionsConfigSection
func (conf *Configuration) loadOptionsConfigSection(
cdata *wini.Data, section string) {
for _, key := range cdata.Keys(section) {
option := key.Name()
switch option {
case "workspaces":
if workspaces, ok := getLastString(key); ok {
conf.Workspaces = strings.Split(workspaces, " ")
}
case "default_layout":
setString(key, &conf.DefaultLayout)
case "focus_follows_mouse":
setBool(key, &conf.Ffm)
case "focus_follows_mouse_focus":
setBool(key, &conf.FfmFocus)
case "focus_follows_mouse_raise":
setBool(key, &conf.FfmRaise)
case "focus_follows_mouse_startup_focus":
setBool(key, &conf.FfmStartupFocus)
case "popup_time":
setInt(key, &conf.PopupTime)
case "show_popup_fyi":
setBool(key, &conf.ShowFyi)
case "show_popup_errors":
setBool(key, &conf.ShowErrors)
case "cancel":
setString(key, &conf.CancelKey)
case "confirm":
setString(key, &conf.ConfirmKey)
case "audio_play_cmd":
setString(key, &conf.AudioProgram)
}
}
}
开发者ID:Pursuit92,项目名称:wingo,代码行数:35,代码来源:config.go
示例2: loadKeyConfigSection
func (conf *Configuration) loadKeyConfigSection(
cdata *wini.Data, section string) {
for _, key := range cdata.Keys(section) {
keyStr := key.Name()
for _, cmd := range key.Strings() {
if _, ok := conf.key[section]; !ok {
conf.key[section] = make([]keyCommand, 0)
}
if err := gribbleEnv.Check(cmd); err != nil {
logger.Warning.Printf(
"Could not parse command '%s' because: %s", cmd, err)
} else {
down, justKeyStr := isDown(keyStr)
kcmd := keyCommand{
cmdStr: cmd,
cmdName: gribbleEnv.CommandName(cmd),
down: down,
keyStr: justKeyStr,
}
conf.key[section] = append(conf.key[section], kcmd)
}
}
}
}
开发者ID:flying99999,项目名称:wingo,代码行数:26,代码来源:config.go
示例3: loadKeyConfigSection
func (conf *conf) loadKeyConfigSection(cdata *wini.Data, section string) {
for _, key := range cdata.Keys(section) {
keyStr := key.Name()
for _, cmd := range key.Strings() {
if _, ok := conf.key[section]; !ok {
conf.key[section] = make([]keyCommand, 0)
}
// "keyStr" is actually made up of a key string
// and a toggle of "down" or "up" corresponding to a key press
// or a key release, respectively. Look for that.
// If it isn't there, assume 'down'
spacei := strings.Index(keyStr, " ")
down := true
if spacei > -1 {
if keyStr[spacei+1:] == "up" {
down = false
}
keyStr = keyStr[:spacei]
}
// 'cmd' might have space separated parameters
cmdName, args := commandParse(cmd)
kcmd := keyCommand{
cmd: cmdName,
args: args,
down: down,
keyStr: keyStr,
}
conf.key[section] = append(conf.key[section], kcmd)
}
}
}
开发者ID:dlintw,项目名称:wingo,代码行数:34,代码来源:config.go
示例4: loadMouseConfigSection
// loadMouseConfigSection does two things:
// 1) Inspects the section name to infer the identifier. In general, the
// "mouse" prefix is removed, and whatever remains is the identifier. There
// are two special cases: "MouseBorders*" turns into "borders_*" and
// "MouseFull*" turns into "full_*".
// 2) Constructs a "mouseCommand" for *every* value.
func (conf *conf) loadMouseConfigSection(cdata *wini.Data, section string) {
ident := ""
switch {
case len(section) > 7 && section[:7] == "borders":
ident = "borders_" + section[7:]
case len(section) > 4 && section[:4] == "full":
ident = "full_" + section[4:]
default:
ident = section
}
for _, key := range cdata.Keys(section) {
mouseStr := key.Name()
for _, cmd := range key.Strings() {
if _, ok := conf.mouse[ident]; !ok {
conf.mouse[ident] = make([]mouseCommand, 0)
}
// "mouseStr" is actually made up of a button string
// and a toggle of "down" or "up" corresponding to a button press
// or a button release, respectively. Look for that.
// If it isn't there, assume 'down'
spacei := strings.Index(mouseStr, " ")
down := true
buttonStr := mouseStr
if spacei > -1 {
buttonStr = mouseStr[:spacei]
if mouseStr[spacei+1:] == "up" {
down = false
}
}
// 'cmd' can sometimes take parameters. For mouse commands,
// only one such command does so: Resize. Check for that.
// (The parameter is which way to resize. If it's absent, default
// to "Infer".)
var direction uint32 = ewmh.Infer
if len(cmd) > 6 && strings.ToLower(cmd[:6]) == "resize" {
spacei := strings.Index(cmd, " ")
if spacei > -1 {
direction = strToDirection(cmd[spacei+1:])
cmd = cmd[:spacei]
}
}
mcmd := mouseCommand{
cmd: cmd,
down: down,
buttonStr: buttonStr,
direction: direction,
}
conf.mouse[ident] = append(conf.mouse[ident], mcmd)
}
}
}
开发者ID:dlintw,项目名称:wingo,代码行数:61,代码来源:config.go
示例5: loadFloat
func loadFloat(dat *wini.Data, name, key string, target *float64) {
k := dat.GetKey(name, key)
if k == nil {
utils.Fail("Missing key " + key + " in section " + name)
}
tmp, err := k.Floats()
utils.FailMeMaybe(err)
if len(tmp) > 0 {
*target = tmp[0]
} else {
utils.Fail("Missing key " + key + " in section " + name)
}
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:15,代码来源:config.go
示例6: loadOptionsConfigSection
func (conf *conf) loadOptionsConfigSection(cdata *wini.Data, section string) {
for _, key := range cdata.Keys(section) {
option := key.Name()
switch option {
case "workspaces":
if workspaces, ok := getLastString(key); ok {
conf.workspaces = strings.Split(workspaces, " ")
}
case "always_floating":
if alwaysFloating, ok := getLastString(key); ok {
conf.alwaysFloating = strings.Split(alwaysFloating, " ")
}
case "focus_follows_mouse":
setBool(key, &conf.ffm)
case "cancel":
setString(key, &conf.cancelKey)
case "confirm":
setString(key, &conf.confirmKey)
}
}
}
开发者ID:dlintw,项目名称:wingo,代码行数:21,代码来源:config.go
示例7: loadString
func loadString(dat *wini.Data, name, key, def string, target *string) {
k := dat.GetKey(name, key)
if k == nil {
if def == "" {
utils.Fail("Missing key " + key + " in section " + name)
} else {
*target = def
return
}
}
tmp := k.Strings()
if len(tmp) > 0 {
*target = tmp[0]
} else {
if def == "" {
utils.Fail("Missing key " + key + " in section " + name)
} else {
*target = def
return
}
}
}
开发者ID:AmandaCameron,项目名称:gobar,代码行数:24,代码来源:config.go
示例8: loadMouseConfigSection
// loadMouseConfigSection does two things:
// 1) Inspects the section name to infer the identifier. In general, the
// "mouse" prefix is removed, and whatever remains is the identifier. There
// are two special cases: "MouseBorders*" turns into "borders_*" and
// "MouseFull*" turns into "full_*".
// 2) Constructs a "mouseCommand" for *every* value.
//
// The idents are used for attaching mouse commands to the corresponding
// frames. (See the mouseCommand methods.)
func (conf *Configuration) loadMouseConfigSection(
cdata *wini.Data, section string) {
ident := ""
switch {
case len(section) > 7 && section[:7] == "borders":
ident = "borders_" + section[7:]
case len(section) > 4 && section[:4] == "full":
ident = "full_" + section[4:]
default:
ident = section
}
for _, key := range cdata.Keys(section) {
mouseStr := key.Name()
for _, cmd := range key.Strings() {
if _, ok := conf.mouse[ident]; !ok {
conf.mouse[ident] = make([]mouseCommand, 0)
}
if err := gribbleEnv.Check(cmd); err != nil {
logger.Warning.Printf(
"Could not parse command '%s' because: %s", cmd, err)
} else {
down, justMouseStr := isDown(mouseStr)
mcmd := mouseCommand{
cmdStr: cmd,
cmdName: gribbleEnv.CommandName(cmd),
down: down,
buttonStr: justMouseStr,
}
conf.mouse[ident] = append(conf.mouse[ident], mcmd)
}
}
}
}
开发者ID:flying99999,项目名称:wingo,代码行数:45,代码来源:config.go
示例9: readSection
// readSection loads a particular section from the configuration file into
// the hook groups. One section may result in the same hook being added to
// multiple groups.
func readSection(cdata *wini.Data, section string) error {
// First lets roll up the match conditions.
match := cdata.GetKey(section, "match")
if match == nil {
return fmt.Errorf("Could not find 'match' in the '%s' hook.", section)
}
satisfies := make([]string, len(match.Strings()))
copy(satisfies, match.Strings())
// Check each satisfies command to make sure it's a valid Gribble command.
if cmd, err := checkCommands(satisfies); err != nil {
return fmt.Errorf("The match command '%s' in the '%s' hook could "+
"not be parsed: %s", cmd, section, err)
}
// Now try to find whether it's a conjunction or not.
conjunction := true
conjunctionKey := cdata.GetKey(section, "conjunction")
if conjunctionKey != nil {
if vals, err := conjunctionKey.Bools(); err != nil {
logger.Warning.Println(err)
} else {
conjunction = vals[0]
}
}
// Now traverse all of the keys in the section. We'll skip "match" since
// we've already grabbed the data. Any other key should correspond to
// a hook group name.
addedOne := false
for _, key := range cdata.Keys(section) {
groupName := Type(key.Name())
if groupName == "match" || groupName == "conjunction" {
continue
}
if _, ok := groups[groupName]; !ok {
return fmt.Errorf("Unrecognized hook group '%s' in the '%s' hook.",
groupName, section)
}
consequences := make([]string, len(key.Strings()))
copy(consequences, key.Strings())
// Check each consequent command to make sure it's valid.
if cmd, err := checkCommands(consequences); err != nil {
return fmt.Errorf("The '%s' command '%s' in the '%s' hook could "+
"not be parsed: %s", groupName, cmd, section, err)
}
hook := hook{
name: section,
satisfies: satisfies,
conjunction: conjunction,
consequences: consequences,
}
groups[groupName] = append(groups[groupName], hook)
addedOne = true
}
if !addedOne {
return fmt.Errorf(
"No hook groups were detected in the '%s' hook.", section)
}
return nil
}
开发者ID:flying99999,项目名称:wingo,代码行数:67,代码来源:hook.go
注:本文中的github.com/BurntSushi/wingo/wini.Data类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论