-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathviscript.go
More file actions
127 lines (99 loc) · 3.32 KB
/
viscript.go
File metadata and controls
127 lines (99 loc) · 3.32 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
------- NEXT THINGS TODO: -------
* (Red typed this) RPC cli:
add functionality to print running jobs for a given task id
that can be retrieved by lp or setting the task id as default
because that already exists
* (Red typed this) ExternalApp:
Ctrl + c - detach, delete, kill probably
Ctrl + z - detach and let it be running or pause it (https://repl.it/GeGn/1)?,
jobs - list all jobs of current terminal
fg <id> - send to foreground
* Sideways auto-scroll command line when it doesn't fit the dedicated space for it
(atm, 2 lines are reserved along the bottom of a full screen)
* block character at end to indicate continuing on next line
* make it optional (if turned off, always truncate the left)
* graphic indication of line breaks
* make graphical GUI lists of terminals, tasks, extApps, dbus subs or channels?
* scan and do/fix the most important FIXME/TODO places in the code
------- OLDER TODO: ------- (everything below was for the text editor)
* KEY-BASED NAVIGATION
* CTRL-HOME/END - PGUP/DN
* BACKSPACE/DELETE at the ends of lines
pulls us up to prev line, or pulls up next line
* when auto appending to the end of a terminal, scroll all the way down
(manual activity in the middle could increase size, so do this only when appending to body)
------- LOWER PRIORITY POLISH: -------
* if cursor movement goes past left/right of screen, auto-horizontal-scroll the page as you type
* same for when newlines/enters/returns push cursor past the bottom of visible space
* vertical scrollbars could have a smaller rendering of the first ~40 chars?
however not if we map the whole vertical space (when scrollspace is taller than screen),
because this requires scaling the text. and keeping the aspect ratio means ~40 (max)
would alter the width of the scrollbar
* when there is no scrollbar needed, should be able to see/interact with text in that area?
*/
package main
import (
"os"
"github.com/skycoin/viscript/app"
"github.com/skycoin/viscript/config"
"github.com/skycoin/viscript/headless"
"github.com/skycoin/viscript/hypervisor"
"github.com/skycoin/viscript/reds_rpc"
"github.com/skycoin/viscript/signal"
"github.com/skycoin/viscript/viewport"
)
func main() {
app.MakeHighlyVisibleLogEntry(app.Name, 13)
loadConfig()
handleAnyArguments()
inits()
go func() {
rpcInstance := reds_rpc.NewRPC()
rpcInstance.Serve()
}()
err := signal.Listen("0.0.0.0:7999")
if err != nil {
panic(err)
}
//start looping
for viewport.CloseWindow == false {
viewport.DispatchEvents() //event channel
hypervisor.TickTasks()
hypervisor.TickExternalApps()
if config.Global.Settings.RunHeadless {
headless.Tick()
} else {
viewport.PollUiInputEvents()
viewport.Tick()
viewport.UpdateDrawBuffer()
viewport.SwapDrawBuffer() //with new frame
}
}
viewport.TeardownScreen()
hypervisor.Teardown()
}
func loadConfig() {
err := config.Load("config.yaml")
if err != nil {
println(err.Error())
return
}
}
func handleAnyArguments() {
args := os.Args[1:]
if len(args) == 1 {
if args[0] == "-h" || args[0] == "-run_headless" {
config.Global.Settings.RunHeadless = true //override defalt
app.MakeHighlyVisibleLogEntry("Running in HEADLESS MODE", 9)
}
}
}
func inits() {
hypervisor.Init()
if config.Global.Settings.RunHeadless {
headless.Init()
} else {
viewport.Init() //runtime.LockOSThread()
}
}