forked from akrasuski1/akrOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_process.ks
More file actions
164 lines (141 loc) · 3.03 KB
/
lib_process.ks
File metadata and controls
164 lines (141 loc) · 3.03 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
@lazyglobal off.
// Process is a struct (list) containing process system info as its first
// element. Everything after that is process internal variables.
// System info:
// [0] - Process_finished (bool)
// [1] - os_data (list)
// [2] - Update_function (string)
// [3] - Please_redraw (bool)
// [4] - Index of process window (struct) - if non-gui, invalid index (e.g. -1)
// [5] - Proces name (string)
// [6] - Please redraw status (bool)
// [7] - Process system id
// GET:
function process_finished{
parameter process.
return process[0][0].
}
function get_process_window{
parameter process.
local wl is get_window_list(process[0][1]).
return wl[process[0][4]].
}
function get_process_window_index{
parameter process.
return process[0][4].
}
function get_process_update_function{
parameter process.
return process[0][2].
}
function process_needs_redraw{
parameter process.
return process[0][3].
}
function is_process_gui{
parameter process.
return process[0][4]>=0 and
process[0][4]<get_window_list(process[0][1]):length.
}
function get_process_name{
parameter process.
return process[0][5].
}
function process_status_needs_redraw{
parameter process.
return process[0][6].
}
function has_focus{
parameter process.
return process[0][4]=get_focused_window(process[0][1]).
}
function get_process_os_data{
parameter process.
return process[0][1].
}
function get_process_id{
parameter process.
return process[0][7].
}
// SET:
function kill_process{
parameter process.
set process[0][0] to true.
}
function invalidate_process_window{
parameter process.
set process[0][3] to true.
}
function validate_process_window{
parameter process.
set process[0][3] to false.
}
function invalidate_process_status{
parameter process.
set process[0][6] to true.
}
function validate_process_status{
parameter process.
set process[0][6] to false.
}
function change_process_window{
parameter
process,
index.
set process[0][4] to index.
invalidate_process_window(process).
}
function set_process_name{
parameter
process,
name.
set process[0][5] to name.
}
// OTHER:
function make_process_system_struct{
parameter
os_data,
update_function,
window_index,
name.
return list(
false, // not finished yet
os_data,
update_function,
true, // redraw needed
window_index,
name,
true, // status redraw needed (check if has focus though!)
get_new_pid(os_data)
).
}
function update_process{
parameter process.
global __process_state is process.
return evaluate(
get_process_update_function(process)+"(__process_state)"
).
//TODO: update above line function pointers come.
}
function update_all_processes{
parameter process_list.
local i is 0.
until i=process_list:length(){
local proc is process_list[i].
if process_finished(proc){
if is_process_gui(proc){
draw_empty_background(get_process_window(proc)).
if has_focus(proc){
draw_empty_background(get_status_window(
get_process_os_data(proc)
)).
}
}
process_list:remove(i).
}
else{
update_process(proc).
set i to i+1.
}
}
}