Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Main
Synchronet
Commits
d08254ee
Commit
d08254ee
authored
7 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Many more methods for setting/clear ext. modes and sending sequences
parent
a39c5c55
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/ansiterm_lib.js
+96
-2
96 additions, 2 deletions
exec/load/ansiterm_lib.js
with
96 additions
and
2 deletions
exec/load/ansiterm_lib.js
+
96
−
2
View file @
d08254ee
// $Id$
// vi: tabstop=4
/* Example usage:
var ansi = load({}, 'ansiterm_lib.js');
ansi.send('ext_mode', 'set', 'bg_bright_intensity');
ansi.send('attributes', 'set', ansi.BG_RED|ansi.BLINK);
ansi.send('screen', 'clear');
*/
load
(
"
sbbsdefs.js
"
);
const
defs
=
{
// SyncTerm extended modes
ext_mode
:
{
origin
:
6
,
autowrap
:
7
,
cursor
:
25
,
brght_alt_charset
:
31
,
no_bright_intensity
:
32
,
bg_bright_intensity
:
33
,
blink_alt_charset
:
34
,
no_blink
:
35
,
},
// SyncTerm emulation speed map
speed_map
:
{
unlimited
:
0
,
300
:
1
,
600
:
2
,
1200
:
3
,
2400
:
4
,
4800
:
5
,
9600
:
6
,
19200
:
7
,
38400
:
8
,
57600
:
9
,
76800
:
10
,
115200
:
11
,
},
// standard
cursor_move
:
{
up
:
'
A
'
,
down
:
'
B
'
,
right
:
'
C
'
,
left
:
'
D
'
,
},
scroll_dir
:
{
up
:
'
S
'
,
down
:
'
T
'
,
},
};
function
attr
(
atr
,
curatr
,
color
)
{
var
str
=
""
;
...
...
@@ -34,7 +84,7 @@ function attr(atr, curatr, color)
}
if
(
atr
&
HIGH
)
{
if
(
!
(
curatr
&
HIGH
))
str
+=
"
1;
"
;
str
+=
"
1;
"
;
}
if
((
atr
&
0x07
)
!=
(
curatr
&
0x07
))
{
switch
(
atr
&
0x07
)
{
...
...
@@ -67,7 +117,7 @@ function attr(atr, curatr, color)
if
((
atr
&
0x70
)
!=
(
curatr
&
0x70
))
{
switch
(
atr
&
0x70
)
{
/* The BG_BLACK macro is 0x200, so isn't in the mask */
case
0
/* BG_BLACK */
:
case
0
/* BG_BLACK */
:
str
+=
"
40;
"
;
break
;
case
BG_RED
:
...
...
@@ -98,5 +148,49 @@ function attr(atr, curatr, color)
return
str
.
substring
(
0
,
str
.
length
-
1
)
+
'
m
'
;
}
var
ext_mode
=
{
set
:
function
(
mode
)
{
return
format
(
"
\
x1b[?%uh
"
,
defs
.
ext_mode
[
mode
]);
},
clear
:
function
(
mode
)
{
return
format
(
"
\
x1b[?%ul
"
,
defs
.
ext_mode
[
mode
]);
},
save
:
function
(
mode
)
{
return
format
(
"
\
x1b[?%us
"
,
defs
.
ext_mode
[
mode
]);
},
restore
:
function
(
mode
)
{
return
format
(
"
\
x1b[?%uu
"
,
defs
.
ext_mode
[
mode
]);
}
}
var
speed
=
{
set
:
function
(
rate
)
{
return
format
(
"
\
x1b[;%u*r
"
,
rate
<
300
?
rate
:
defs
.
speed_map
[
rate
]);
},
clear
:
function
()
{
return
"
\
x1b[*r
"
;
}
}
var
cursor_position
=
{
move
:
function
(
dir
,
n
)
{
return
format
(
"
\
x1b[%s%s
"
,
n
?
n
:
""
,
defs
.
cursor_move
[
dir
]);
},
set
:
function
(
x
,
y
)
{
return
format
(
"
\
x1b[%u;%uH
"
,
y
,
x
);
},
home
:
function
()
{
return
"
\
x1b[H
"
;
},
save
:
function
()
{
return
"
\
x1b[s
"
;
},
restore
:
function
()
{
return
"
\
x1b[u
"
;
}
}
var
screen
=
{
scroll
:
function
(
dir
,
n
)
{
return
format
(
"
\
x1b[%s%s
"
,
n
?
n
:
""
,
defs
.
scroll_dir
[
dir
]);
},
clear
:
function
()
{
return
"
\
x1b[2J
"
;
}
}
var
attributes
=
{
current
:
0
,
set
:
function
(
a
)
{
return
set_attributes
(
a
);
}
}
var
color
=
true
;
function
set_attributes
(
a
)
{
var
str
=
attr
(
a
,
this
.
attributes
.
current
,
this
.
color
);
this
.
attributes
.
current
=
a
;
return
str
;
}
function
send
(
a
,
b
,
c
,
d
)
{
console
.
write
(
this
[
a
][
b
](
c
,
d
));
}
/* Leave as last line for convenient load() usage: */
this
;
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