forked from limetext/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
window_manual.go
112 lines (104 loc) · 2.47 KB
/
window_manual.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// 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 api
import (
"fmt"
"github.com/jxo/lime"
"github.com/jxo/lime/text"
"github.com/limetext/gopy"
)
var (
_ = lime.View{}
_ = text.Region{}
_ = fmt.Errorf
)
func (o *Window) Py_open_file(tu *py.Tuple) (py.Object, error) {
var (
arg1 string
arg2 int
)
v, err := tu.GetItem(0)
if err != nil {
return nil, err
}
if v2, ok := v.(*py.Unicode); !ok {
return nil, fmt.Errorf("Expected type *py.Unicode for lime.Window.OpenFile() arg1, not %s", v.Type())
} else {
arg1 = v2.String()
}
if tu.Size() > 1 {
v, err := tu.GetItem(1)
if err != nil {
return nil, err
}
if v2, ok := v.(*py.Long); !ok {
return nil, fmt.Errorf("Expected type *py.Long for lime.Window.OpenFile() arg2, not %s", v.Type())
} else {
arg2 = int(v2.Int64())
}
}
ret0 := o.data.OpenFile(arg1, arg2)
var pyret0 py.Object
pyret0, err = _viewClass.Alloc(1)
if err != nil {
return nil, err
} else if v2, ok := pyret0.(*View); !ok {
return nil, fmt.Errorf("Unable to convert return value to the right type?!: %s", pyret0.Type())
} else {
v2.data = ret0
}
if err != nil {
return nil, err
}
return pyret0, err
}
func (o *Window) Py_run_command(tu *py.Tuple) (py.Object, error) {
var (
arg1 string
arg2 lime.Args
)
v, err := tu.GetItem(0)
if err != nil {
return nil, err
}
if v2, ok := v.(*py.Unicode); !ok {
return nil, fmt.Errorf("Expected type *py.Unicode for lime.Window.RunCommand() arg1, not %s", v.Type())
} else {
arg1 = v2.String()
}
arg2 = make(lime.Args)
if v, err := tu.GetItem(1); err == nil {
v2, ok := v.(*py.Dict)
if !ok {
return nil, fmt.Errorf("Expected type *py.Dict for lime.Window.RunCommand() arg2, not %s", v.Type())
}
if v, err := fromPython(v2); err != nil {
return nil, err
} else {
arg2 = v.(lime.Args)
}
}
lime.GetEditor().CommandHandler().RunWindowCommand(o.data, arg1, arg2)
return toPython(nil)
}
func (o *Window) Py_focus_view(tu *py.Tuple) (py.Object, error) {
var (
arg1 *lime.View
)
if v, err := tu.GetItem(0); err != nil {
return nil, err
} else {
if v3, err2 := fromPython(v); err2 != nil {
return nil, err2
} else {
if v2, ok := v3.(*lime.View); !ok {
return nil, fmt.Errorf("Expected type *lime.View for lime.Window.SetActiveView() arg1, not %s", v.Type())
} else {
arg1 = v2
}
}
}
o.data.SetActiveView(arg1)
return toPython(nil)
}