-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
94 lines (82 loc) · 2.22 KB
/
main.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
// Acme & vi crossover editor, created with duit.
package main
import (
"flag"
"image"
"log"
"os"
"9fans.net/go/draw"
"github.com/mjl-/duit"
)
var (
dui *duit.DUI
topUI *mainUI
squareDirtyColor, squareBorderColor, squareCleanColor *draw.Image
tagColors, textColors *duit.EditColors
)
const (
control = 0x1f
)
func main() {
log.SetFlags(0)
flag.Usage = func() {
log.Printf("usage: acvi [flags] [file ...]\n")
flag.PrintDefaults()
}
flag.Parse()
args := flag.Args()
var err error
dui, err = duit.NewDUI("acvi", &duit.DUIOpts{FontName: os.Getenv("font")})
if err != nil {
log.Fatalf("new dui: %s\n", err)
}
allocColor := func(v draw.Color) *draw.Image {
c, err := dui.Display.AllocImage(image.Rect(0, 0, 1, 1), draw.ARGB32, true, v)
if err != nil {
log.Fatalf("alloccolor: %s\n", err)
}
return c
}
tagColors = &duit.EditColors{
Fg: allocColor(0x111111ff),
Bg: allocColor(0xeaffffff),
SelFg: dui.Regular.Normal.Text,
SelBg: allocColor(0x9eefeeff),
ScrollVis: allocColor(0xeaffffff),
ScrollBg: allocColor(0x4b9999ff), // same s,v offset as for textColor
HoverScrollVis: allocColor(0xeaffffff),
HoverScrollBg: allocColor(0x3e8080ff), // -10 v
CommandBorder: dui.CommandMode,
VisualBorder: dui.VisualMode,
}
textColors = &duit.EditColors{
Fg: allocColor(0x111111ff),
Bg: allocColor(0xfffeeaff),
SelFg: dui.Regular.Normal.Text,
SelBg: allocColor(0xeeef9fff),
ScrollVis: allocColor(0xfffeeaff),
ScrollBg: allocColor(0x9a984bff),
HoverScrollVis: allocColor(0xfffeeaff),
HoverScrollBg: allocColor(0x807e3eff), // -10 v
CommandBorder: dui.CommandMode,
VisualBorder: dui.VisualMode,
}
squareDirtyColor = allocColor(0x0e0098ff)
squareBorderColor = allocColor(0x8888ccff)
squareCleanColor = tagColors.Bg
topUI = newMainUI(args)
dui.Top.UI = topUI
dui.Top.ID = "columns"
dui.Render()
for {
select {
case e := <-dui.Inputs:
dui.Input(e)
case err, ok := <-dui.Error:
if !ok {
return
}
log.Printf("duit: %s\n", err)
}
}
}