forked from limetext/lime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.go
33 lines (28 loc) · 789 Bytes
/
register.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2013 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.
package commands
import (
"github.com/limetext/lime/backend"
"github.com/limetext/lime/backend/log"
)
type namedCmd struct {
name string
cmd backend.Command
}
func registerByName(cmds []namedCmd) {
ch := backend.GetEditor().CommandHandler()
for _, cmd := range cmds {
if err := ch.Register(cmd.name, cmd.cmd); err != nil {
log.Errorf("Failed to register command %s: %s", cmd.name, err)
}
}
}
func register(cmds []backend.Command) {
ch := backend.GetEditor().CommandHandler()
for _, cmd := range cmds {
if err := ch.RegisterWithDefault(cmd); err != nil {
log.Errorf("Failed to register command: %s", err)
}
}
}