Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
active-shell
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
echicken
active-shell
Commits
24e68345
Commit
24e68345
authored
11 months ago
by
echicken
Browse files
Options
Downloads
Patches
Plain Diff
Reorg
parent
36bd5ea0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/active-shell.ts
+7
-96
7 additions, 96 deletions
src/active-shell.ts
src/lib/UI.ts
+116
-0
116 additions, 0 deletions
src/lib/UI.ts
with
123 additions
and
96 deletions
src/active-shell.ts
+
7
−
96
View file @
24e68345
import
type
{
ICgaDefs
,
IKeyDefs
,
ISbbsDefs
}
from
'
@swag/ts4s
'
;
import
type
{
ICgaDefs
,
ISbbsDefs
}
from
'
@swag/ts4s
'
;
import
{
load
}
from
'
@swag/ts4s
'
;
import
{
load
}
from
'
@swag/ts4s
'
;
import
*
as
swindows
from
'
swindows
'
;
import
*
as
swindows
from
'
swindows
'
;
import
{
IShellWindow
}
from
'
./lib/types
'
;
import
UI
from
'
./lib/UI
'
;
import
ActivityWindow
from
'
./lib/ActivityWindow
'
;
import
MenuWindow
from
'
./lib/MenuWindow
'
;
const
sbbsdefs
:
ISbbsDefs
=
load
(
'
sbbsdefs.js
'
);
const
sbbsdefs
:
ISbbsDefs
=
load
(
'
sbbsdefs.js
'
);
const
cgadefs
:
ICgaDefs
=
load
(
'
cga_defs.js
'
);
const
cgadefs
:
ICgaDefs
=
load
(
'
cga_defs.js
'
);
const
keydefs
:
IKeyDefs
=
load
(
'
key_defs.js
'
);
const
{
bbs
,
console
,
mswait
}
=
js
.
global
;
const
{
bbs
,
console
,
mswait
}
=
js
.
global
;
const
windowManager
=
new
swindows
.
WindowManager
();
const
windowManager
=
new
swindows
.
WindowManager
();
const
windows
:
IShellWindow
[]
=
[
const
ui
=
new
UI
(
windowManager
);
new
ActivityWindow
(
'
Activity
'
,
windowManager
,
{
x
:
0
,
y
:
0
},
{
width
:
windowManager
.
size
.
width
,
height
:
Math
.
ceil
(
windowManager
.
size
.
height
/
2
)
},
),
new
MenuWindow
(
'
Main
'
,
`
${
js
.
exec_dir
}
main.ini`
,
windowManager
,
{
x
:
0
,
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
},
{
width
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
}
),
new
MenuWindow
(
'
Messages
'
,
`
${
js
.
exec_dir
}
messages.ini`
,
windowManager
,
{
x
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
},
{
width
:
windowManager
.
size
.
width
-
(
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
*
2
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
}
),
new
MenuWindow
(
'
Games
'
,
`
${
js
.
exec_dir
}
games.ini`
,
windowManager
,
{
x
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
+
(
windowManager
.
size
.
width
-
(
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
*
2
)),
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
},
{
width
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
}
),
];
let
activeWindow
:
number
=
1
;
function
cycleWindows
():
void
{
for
(
const
window
of
windows
)
{
window
.
cycle
();
}
}
function
focusWindow
(
idx
:
number
):
void
{
if
(
idx
<
0
)
idx
=
windows
.
length
-
1
;
idx
=
idx
%
windows
.
length
;
windows
[
activeWindow
].
window
.
title
=
{
text
:
windows
[
activeWindow
].
window
.
title
?.
text
??
''
,
attr
:
(
cgadefs
.
BG_BLACK
|
cgadefs
.
WHITE
)
as
swindows
.
types
.
attr
,
alignment
:
swindows
.
defs
.
ALIGNMENT
.
LEFT
,
};
windows
[
idx
].
window
.
title
=
{
text
:
windows
[
idx
].
window
.
title
?.
text
??
''
,
attr
:
(
cgadefs
.
BG_CYAN
|
cgadefs
.
LIGHTCYAN
)
as
swindows
.
types
.
attr
,
alignment
:
swindows
.
defs
.
ALIGNMENT
.
LEFT
,
};
activeWindow
=
idx
;
}
function
getInput
():
void
{
let
input
=
console
.
inkey
(
sbbsdefs
.
K_NONE
);
if
(
input
===
''
)
return
;
if
(
input
===
'
q
'
)
js
.
global
.
exit
(
0
);
switch
(
input
)
{
case
'
\t
'
:
case
keydefs
.
KEY_RIGHT
:
focusWindow
(
activeWindow
+
1
);
break
;
case
keydefs
.
KEY_LEFT
:
focusWindow
(
activeWindow
-
1
);
break
;
default
:
windows
[
activeWindow
].
getCmd
(
input
);
break
;
}
}
function
init
():
void
{
function
init
():
void
{
js
.
on_exit
(
`bbs.sys_status =
${
bbs
.
sys_status
}
;`
);
js
.
on_exit
(
`bbs.sys_status =
${
bbs
.
sys_status
}
;`
);
js
.
on_exit
(
`console.attributes =
${
console
.
attributes
}
;`
);
js
.
on_exit
(
`console.attributes =
${
console
.
attributes
}
;`
);
js
.
on_exit
(
`console.ctrlkey_passthru =
${
console
.
ctrlkey_passthru
}
;`
);
js
.
on_exit
(
`console.ctrlkey_passthru =
${
console
.
ctrlkey_passthru
}
;`
);
js
.
on_exit
(
`windowManager.showCursor();`
);
js
.
on_exit
(
`windowManager.showCursor();`
);
js
.
on_exit
(
`console.clear();`
);
js
.
on_exit
(
'
console.home();
'
);
js
.
on_exit
(
'
console.write("
\
x1B[0;37;40m")
'
);
js
.
on_exit
(
'
console.write("
\
x1B[2J")
'
);
js
.
time_limit
=
0
;
js
.
time_limit
=
0
;
bbs
.
sys_status
|=
sbbsdefs
.
SS_MOFF
;
bbs
.
sys_status
|=
sbbsdefs
.
SS_MOFF
;
console
.
ctrlkey_passthru
=
"
+UPKTG
"
;
console
.
ctrlkey_passthru
=
"
+UPKTG
"
;
console
.
clear
(
cgadefs
.
BG_BLACK
|
cgadefs
.
LIGHTGRAY
);
console
.
clear
(
cgadefs
.
BG_BLACK
|
cgadefs
.
LIGHTGRAY
);
windowManager
.
hideCursor
();
windowManager
.
hideCursor
();
focusWindow
(
1
);
}
}
function
main
():
void
{
function
main
():
void
{
while
(
!
js
.
terminated
)
{
while
(
!
js
.
terminated
)
{
getInput
();
ui
.
cycle
();
cycleWindows
();
windowManager
.
refresh
();
windowManager
.
refresh
();
bbs
.
nodesync
();
bbs
.
nodesync
();
mswait
(
5
);
mswait
(
5
);
...
...
This diff is collapsed.
Click to expand it.
src/lib/UI.ts
0 → 100644
+
116
−
0
View file @
24e68345
import
type
{
ICgaDefs
,
IKeyDefs
,
ISbbsDefs
}
from
'
@swag/ts4s
'
;
import
{
load
}
from
'
@swag/ts4s
'
;
import
*
as
swindows
from
'
swindows
'
;
import
{
IShellWindow
}
from
'
./types
'
;
import
ActivityWindow
from
'
./ActivityWindow
'
;
import
MenuWindow
from
'
./MenuWindow
'
;
const
sbbsdefs
:
ISbbsDefs
=
load
(
'
sbbsdefs.js
'
);
const
keydefs
:
IKeyDefs
=
load
(
'
key_defs.js
'
);
const
cgadefs
:
ICgaDefs
=
load
(
'
cga_defs.js
'
);
const
{
console
}
=
js
.
global
;
function
getWindows
(
windowManager
:
swindows
.
WindowManager
):
IShellWindow
[]
{
const
windows
:
IShellWindow
[]
=
[
new
ActivityWindow
(
'
Activity
'
,
windowManager
,
{
x
:
0
,
y
:
0
},
{
width
:
windowManager
.
size
.
width
,
height
:
Math
.
ceil
(
windowManager
.
size
.
height
/
2
)
},
),
new
MenuWindow
(
'
Main
'
,
`
${
js
.
exec_dir
}
main.ini`
,
windowManager
,
{
x
:
0
,
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
},
{
width
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
}
),
new
MenuWindow
(
'
Messages
'
,
`
${
js
.
exec_dir
}
messages.ini`
,
windowManager
,
{
x
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
},
{
width
:
windowManager
.
size
.
width
-
(
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
*
2
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
}
),
new
MenuWindow
(
'
Games
'
,
`
${
js
.
exec_dir
}
games.ini`
,
windowManager
,
{
x
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
+
(
windowManager
.
size
.
width
-
(
Math
.
floor
(
windowManager
.
size
.
width
/
3
)
*
2
)),
y
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
)
},
{
width
:
Math
.
floor
(
windowManager
.
size
.
width
/
3
),
height
:
Math
.
floor
(
windowManager
.
size
.
height
/
2
),
}
),
];
return
windows
;
}
export
default
class
UI
{
activeWindow
:
number
=
0
;
windows
:
IShellWindow
[]
=
[];
constructor
(
windowManager
:
swindows
.
WindowManager
)
{
this
.
windows
=
getWindows
(
windowManager
);
this
.
focusWindow
(
1
);
}
cycle
():
void
{
for
(
const
window
of
this
.
windows
)
{
window
.
cycle
();
}
this
.
getInput
();
}
focusWindow
(
n
:
number
):
void
{
let
idx
=
this
.
activeWindow
+
n
;
if
(
idx
<
0
)
{
idx
=
this
.
windows
.
length
-
1
;
}
else
if
(
idx
>=
this
.
windows
.
length
)
{
idx
=
0
;
}
this
.
windows
[
this
.
activeWindow
].
window
.
title
=
{
text
:
this
.
windows
[
this
.
activeWindow
].
window
.
title
?.
text
??
''
,
attr
:
(
cgadefs
.
BG_BLACK
|
cgadefs
.
WHITE
)
as
swindows
.
types
.
attr
,
alignment
:
swindows
.
defs
.
ALIGNMENT
.
LEFT
,
};
this
.
windows
[
idx
].
window
.
title
=
{
text
:
this
.
windows
[
idx
].
window
.
title
?.
text
??
''
,
attr
:
(
cgadefs
.
BG_CYAN
|
cgadefs
.
LIGHTCYAN
)
as
swindows
.
types
.
attr
,
alignment
:
swindows
.
defs
.
ALIGNMENT
.
LEFT
,
};
this
.
activeWindow
=
idx
;
}
getInput
():
void
{
let
input
=
console
.
inkey
(
sbbsdefs
.
K_NONE
);
if
(
input
===
''
)
return
;
if
(
input
===
'
q
'
)
js
.
global
.
exit
(
0
);
switch
(
input
)
{
case
'
\t
'
:
case
keydefs
.
KEY_RIGHT
:
this
.
focusWindow
(
1
);
break
;
case
keydefs
.
KEY_LEFT
:
this
.
focusWindow
(
-
1
);
break
;
default
:
this
.
windows
[
this
.
activeWindow
].
getCmd
(
input
);
break
;
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment