// BindKeyboard sets the vertical and horizontal axes used by the KeyboardScroller.
490963
func (c *KeyboardScroller) BindKeyboard(hori, vert string) {
	c.keysMu.Lock()

	c.verticalAxis = vert
	c.horizontalAxis = hori

	defer c.keysMu.Unlock()
}
692521
func (g *Gui) DeleteKeybindings(viewname string) {
	var s []*keybinding
	for _, kb := range g.keybindings {
		if kb.viewName != viewname {
			s = append(s, kb)
		}
	}
	g.keybindings = s
}
864736
func (c *Context) EditInlineKeyboard(om *OutgoingMessage, fromState string, kb InlineKeyboard) error {

	bot := c.Bot()
	if om.MsgID != 0 {
		log.WithField("msgID", om.MsgID).Debug("EditMessageTextAndInlineKeyboard")
	} else {
		om.ChatID = 0
		log.WithField("inlineMsgID", om.InlineMsgID).Debug("EditMessageTextAndInlineKeyboard")
	}
	var msg OutgoingMessage

	_, err := c.db.C("messages").Find(bson.M{"_id": om.ID, "$or": []bson.M{{"inlinekeyboardmarkup.state": fromState}, {"inlinekeyboardmarkup": bson.M{"$exists": false}}}}).Apply(mgo.Change{Update: bson.M{"$set": bson.M{"inlinekeyboardmarkup": kb}}}, &msg)

	if msg.BotID == 0 {
		return fmt.Errorf("EditInlineKeyboard – message (botid=%v id=%v state %s) not found", bot.ID, om.MsgID, fromState)
	}

	tgKeyboard := kb.tg()
	prevTGKeyboard := om.InlineKeyboardMarkup.tg()
	if whetherTGInlineKeyboardsAreEqual(prevTGKeyboard, tgKeyboard) {
		c.Log().Debugf("EditMessageTextAndInlineKeyboard – message (_id=%s botid=%v id=%v state %s) not updated both text and kb have not changed", om.ID, bot.ID, om.MsgID, fromState)
		return nil
	}

	_, err = bot.API.Send(tg.EditMessageReplyMarkupConfig{
		BaseEdit: tg.BaseEdit{
			ChatID:          om.ChatID,
			MessageID:       om.MsgID,
			InlineMessageID: om.InlineMsgID,
			ReplyMarkup:     &tg.InlineKeyboardMarkup{InlineKeyboard: tgKeyboard},
		},
	})

	if err != nil {
		if err.(tg.Error).IsCantAccessChat() || err.(tg.Error).ChatMigrated() {
			if c.Callback != nil {
				c.AnswerCallbackQuery("Message can be outdated. Bot can't edit messages created before converting to the Super Group", false)
			}
		} else if err.(tg.Error).IsAntiFlood() {
			c.Log().WithError(err).Warn("TG Anti flood activated")
		}
		// Oops. error is occurred – revert the original keyboard
		err := c.db.C("messages").Update(bson.M{"_id": msg.ID}, bson.M{"$set": bson.M{"inlinekeyboardmarkup": msg.InlineKeyboardMarkup}})
		return err
	}

	return nil

}
149140
func (s *DefaultSubscriber) QueueBind(name, key string) error {
	err := s.channel.QueueBind(name, key, s.exchange, false, nil)
	if err != nil {
		return fmt.Errorf("Failed to bind queue %s with key %s on exchange '%s' (%s)", name, key, s.exchange, err)
	}
	return nil
}
106947
func (c *GraphClause) BindingsMap() map[string]int {
	bm := make(map[string]int)

	addToBindings(bm, c.SBinding)
	addToBindings(bm, c.SAlias)
	addToBindings(bm, c.STypeAlias)
	addToBindings(bm, c.SIDAlias)
	addToBindings(bm, c.PAlias)
	addToBindings(bm, c.PAnchorBinding)
	addToBindings(bm, c.PBinding)
	addToBindings(bm, c.PLowerBoundAlias)
	addToBindings(bm, c.PUpperBoundAlias)
	addToBindings(bm, c.PIDAlias)
	addToBindings(bm, c.PAnchorAlias)
	addToBindings(bm, c.OBinding)
	addToBindings(bm, c.OAlias)
	addToBindings(bm, c.OTypeAlias)
	addToBindings(bm, c.OIDAlias)
	addToBindings(bm, c.OAnchorAlias)
	addToBindings(bm, c.OAnchorBinding)
	addToBindings(bm, c.OLowerBoundAlias)
	addToBindings(bm, c.OUpperBoundAlias)

	return bm
}
502545
func (c *Context) EditMessageTextAndInlineKeyboard(om *OutgoingMessage, fromState string, text string, kb InlineKeyboard) error {
	bot := c.Bot()
	if om.MsgID != 0 {
		log.WithField("msgID", om.MsgID).Debug("EditMessageTextAndInlineKeyboard")
	} else {
		om.ChatID = 0
		log.WithField("inlineMsgID", om.InlineMsgID).Debug("EditMessageTextAndInlineKeyboard")
	}

	var msg OutgoingMessage

	var err error

	if om.ParseMode == "HTML" {
		textCleared, err := sanitize.HTMLAllowing(text, []string{"a", "b", "strong", "i", "em", "a", "code", "pre"}, []string{"href"})

		if err == nil && textCleared != "" {
			text = textCleared
		}
	}

	om.Text = text
	prevTextHash := om.TextHash
	om.TextHash = om.GetTextHash()

	if fromState != "" {
		_, err = c.db.C("messages").Find(bson.M{"_id": om.ID, "$or": []bson.M{{"inlinekeyboardmarkup.state": fromState}, {"inlinekeyboardmarkup": bson.M{"$exists": false}}}}).Apply(mgo.Change{Update: bson.M{"$set": bson.M{"inlinekeyboardmarkup": kb, "texthash": om.TextHash}}}, &msg)
	} else {
		_, err = c.db.C("messages").Find(bson.M{"_id": om.ID}).Apply(mgo.Change{Update: bson.M{"$set": bson.M{"inlinekeyboardmarkup": kb, "texthash": om.TextHash}}}, &msg)
	}

	if err != nil {
		c.Log().WithError(err).Error("EditMessageTextAndInlineKeyboard messages update error")
	}

	if msg.BotID == 0 {
		c.Log().Warn(fmt.Sprintf("EditMessageTextAndInlineKeyboard – message (_id=%s botid=%v id=%v state %s) not found", om.ID.Hex(), bot.ID, om.MsgID, fromState))
		return nil

	}

	tgKeyboard := kb.tg()

	if prevTextHash == om.TextHash {
		prevTGKeyboard := om.InlineKeyboardMarkup.tg()
		if whetherTGInlineKeyboardsAreEqual(prevTGKeyboard, tgKeyboard) {
			c.Log().Debugf("EditMessageTextAndInlineKeyboard – message (_id=%s botid=%v id=%v state %s) not updated both text and kb have not changed", om.ID.Hex(), bot.ID, om.MsgID, fromState)
			return nil
		}
	}


	_, err = bot.API.Send(tg.EditMessageTextConfig{
		BaseEdit: tg.BaseEdit{
			ChatID:          om.ChatID,
			InlineMessageID: om.InlineMsgID,
			MessageID:       om.MsgID,
			ReplyMarkup:     &tg.InlineKeyboardMarkup{InlineKeyboard: tgKeyboard},
		},
		ParseMode: om.ParseMode,
		Text:      text,
		DisableWebPagePreview: !om.WebPreview,
	})

	if err != nil {
		if err.(tg.Error).IsCantAccessChat() || err.(tg.Error).ChatMigrated() {
			if c.Callback != nil {
				c.AnswerCallbackQuery("Message can be outdated. Bot can't edit messages created before converting to the Super Group", false)
			}
		} else if err.(tg.Error).IsAntiFlood() {
			c.Log().WithError(err).Warn("TG Anti flood activated")
		}
		// Oops. error is occurred – revert the original keyboard
		c.db.C("messages").Update(bson.M{"_id": msg.ID}, bson.M{"$set": bson.M{"texthash": prevTextHash, "inlinekeyboardmarkup": msg.InlineKeyboardMarkup}})
		return err
	}

	return nil
}
1187024
func keyKeys(xu *xgbutil.XUtil) []xgbutil.KeyKey {
	xu.KeybindsLck.RLock()
	defer xu.KeybindsLck.RUnlock()

	keys := make([]xgbutil.KeyKey, len(xu.Keybinds))
	i := 0
	for key, _ := range xu.Keybinds {
		keys[i] = key
		i++
	}
	return keys
}
810128
func (buttons *Buttons) Markup(columns int) Keyboard {
	keyboard := Keyboard{}

	col := 0

	row := Buttons{}
	len := len(*buttons)
	for i, button := range *buttons {
		row.Append(button.Data, button.Text)
		col++
		if col == columns || i == (len-1) {
			col = 0
			keyboard.AddRows(row)
			row = Buttons{}
		}
	}

	return keyboard
}
1202412
func bindValues(keyvals []interface{}) {
	for i := 1; i < len(keyvals); i += 2 {
		if v, ok := keyvals[i].(Valuer); ok {
			keyvals[i] = v()
		}
	}
}
840855
func Buttons(buttons [][]string) *ReplyKeyboardMarkup {
	keyboard := make([][]KeyboardButton, len(buttons))
	for i := range buttons {
		keyboard[i] = make([]KeyboardButton, len(buttons[i]))
		for j := range buttons[i] {
			keyboard[i][j] = KeyboardButton{Text: buttons[i][j]}
		}
	}
	return &ReplyKeyboardMarkup{Keyboard: keyboard}
}
1310958
func (ctrl *GameController) BindForButton(btn GameControllerButton) GameControllerButtonBind {
	return GameControllerButtonBind(C.SDL_GameControllerGetBindForButton(ctrl.cptr(), btn.c()))
}
908334
func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge {
	return func(user, instruction string, questions []string, echos []bool) ([]string, error) {
		log.Printf("Keyboard interactive challenge: ")
		log.Printf("-- User: %s", user)
		log.Printf("-- Instructions: %s", instruction)
		for i, question := range questions {
			log.Printf("-- Question %d: %s", i+1, question)
		}

		// Just send the password back for all questions
		answers := make([]string, len(questions))
		for i := range answers {
			answers[i] = string(password)
		}

		return answers, nil
	}
}
1014898
func (g *Grid) OnKeyEvent(ev KeyEvent) {
	for _, w := range g.cells {
		w.OnKeyEvent(ev)
	}
}
1272363
func (h *Handle) KeyPrefix() []string {
	h.Lock()
	defer h.Unlock()
	return []string{h.app}
}
953736
func (kf *KeyFormat) KeyBytes(segments ...[]byte) ([]byte, error) {
	key := make([]byte, kf.length)
	n := copy(key, kf.prefix)
	var offset int
	for i, l := range kf.layout {
		si := i + offset
		if len(segments) <= si {
			break
		}
		s := segments[si]
		switch l {
		case VariadicSegmentLength:
			// Must be a final variadic element
			key = append(key, s...)
			n += len(s)
		case DelimiterSegmentLength:
			// ignore
			offset--
		default:
			if len(s) != l {
				return nil, fmt.Errorf("the segment '0x%X' provided to KeyFormat.KeyBytes() does not have required "+
					"%d bytes required by layout for segment %d", s, l, i)
			}
			n += l
			// Big endian so pad on left if not given the full width for this segment
			copy(key[n-len(s):n], s)
		}
	}
	return key[:n], nil
}
742291
func (s *StaticKeyProvider) SetKeyFormat(v string) *StaticKeyProvider {
	s.KeyFormat = &v
	return s
}
185831
func addKeyString(xu *xgbutil.XUtil, callback xgbutil.CallbackKey,
	evtype int, win xproto.Window, keyStr string, grab bool) {

	xu.KeybindsLck.Lock()
	defer xu.KeybindsLck.Unlock()

	k := xgbutil.KeyString{
		Str:      keyStr,
		Callback: callback,
		Evtype:   evtype,
		Win:      win,
		Grab:     grab,
	}
	xu.Keystrings = append(xu.Keystrings, k)
}