-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
60 lines (46 loc) · 872 Bytes
/
interfaces.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
package smsid
import (
"syscall"
"unsafe"
)
type Status int32
const (
Failed Status = iota
Success
)
type Adapter interface {
Initialize()
IsInitialized() bool
Terminate()
Send(phone, text string) Status
SetVerbose(verb Verbose)
}
type Manager interface {
SetAdapter(tag string, adapt Adapter) Manager
Adapter(tag string) Adapter
Initialize()
IsInitialized() bool
Terminate()
Send(adaptTag, phone, message string) (stat Status)
}
// Struct for give terminal size
type winsize struct {
Row uint16
Col uint16
Xpixel uint16
YPixel uint16
}
// Getting size of terminal
func terminalSize() (int, int) {
ws := &winsize{}
ret, _, err := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(syscall.Stdin),
uintptr(syscall.TIOCGWINSZ),
uintptr(unsafe.Pointer(ws)),
)
if int(ret) == -1 {
panic(err)
}
return int(ws.Col), int(ws.Row)
}