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
07a6c7e1
Commit
07a6c7e1
authored
1 month ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Make the 'opt' object predefinition optional (not required)
Defaults to CP437/ANSI output in this case
parent
5ef56d97
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/tdfonts_lib.js
+12
-12
12 additions, 12 deletions
exec/load/tdfonts_lib.js
with
12 additions
and
12 deletions
exec/load/tdfonts_lib.js
+
12
−
12
View file @
07a6c7e1
...
@@ -66,7 +66,7 @@ function loadfont(fn_arg) {
...
@@ -66,7 +66,7 @@ function loadfont(fn_arg) {
exit
(
1
);
exit
(
1
);
}
}
if
(
opt
.
info
)
{
if
(
this
.
opt
&&
opt
.
info
)
{
writeln
(
"
file:
"
+
fn
);
writeln
(
"
file:
"
+
fn
);
}
}
...
@@ -96,12 +96,12 @@ function loadfont(fn_arg) {
...
@@ -96,12 +96,12 @@ function loadfont(fn_arg) {
try
{
try
{
const
sequence
=
"
\
x55
\
xaa
\
x00
\
xff
"
;
const
sequence
=
"
\
x55
\
xaa
\
x00
\
xff
"
;
if
(
opt
.
random
)
if
(
this
.
opt
&&
opt
.
random
)
opt
.
index
=
(
map
.
match
(
new
RegExp
(
sequence
,
'
g
'
))
-
1
);
opt
.
index
=
(
map
.
match
(
new
RegExp
(
sequence
,
'
g
'
))
-
1
);
var
index
=
-
1
;
var
index
=
-
1
;
var
n
=
0
;
var
n
=
0
;
if
(
opt
.
index
>
0
)
{
if
(
this
.
opt
&&
opt
.
index
>
0
)
{
while
(
n
<
opt
.
index
)
{
while
(
n
<
opt
.
index
)
{
index
=
map
.
indexOf
(
sequence
,
index
+
1
);
index
=
map
.
indexOf
(
sequence
,
index
+
1
);
if
(
index
===
-
1
)
if
(
index
===
-
1
)
...
@@ -139,7 +139,7 @@ function loadfont(fn_arg) {
...
@@ -139,7 +139,7 @@ function loadfont(fn_arg) {
exit
(
1
);
exit
(
1
);
}
}
if
(
opt
.
info
)
{
if
(
this
.
opt
&&
opt
.
info
)
{
write
(
"
font:
"
+
font
.
name
+
"
\n
char list:
"
);
write
(
"
font:
"
+
font
.
name
+
"
\n
char list:
"
);
}
}
...
@@ -154,7 +154,7 @@ function loadfont(fn_arg) {
...
@@ -154,7 +154,7 @@ function loadfont(fn_arg) {
// Check if the character exists in the font (not 0xffff)
// Check if the character exists in the font (not 0xffff)
if
(
glyph_data_offset
!==
0xffff
)
{
if
(
glyph_data_offset
!==
0xffff
)
{
if
(
opt
.
info
)
if
(
this
.
opt
&&
opt
.
info
)
write
(
charlist
[
i
]);
write
(
charlist
[
i
]);
// Read glyph width and height from font.data
// Read glyph width and height from font.data
...
@@ -173,7 +173,7 @@ function loadfont(fn_arg) {
...
@@ -173,7 +173,7 @@ function loadfont(fn_arg) {
}
}
}
}
if
(
opt
.
info
)
if
(
this
.
opt
&&
opt
.
info
)
writeln
(
""
);
writeln
(
""
);
// Read and store glyph data
// Read and store glyph data
...
@@ -248,7 +248,7 @@ function readchar(i, font) { // glyph argument is no longer needed, we return th
...
@@ -248,7 +248,7 @@ function readchar(i, font) { // glyph argument is no longer needed, we return th
var
cell_idx
=
row
*
width
+
col
;
var
cell_idx
=
row
*
width
+
col
;
if
(
cell_idx
<
glyph
.
cell
.
length
)
{
if
(
cell_idx
<
glyph
.
cell
.
length
)
{
if
(
opt
.
encoding
===
ENC_UNICODE
)
{
if
(
this
.
opt
&&
opt
.
encoding
===
ENC_UNICODE
)
{
// ibmtoutf8 needs to be implemented or replaced with a lookup
// ibmtoutf8 needs to be implemented or replaced with a lookup
// For now, a basic mapping or assume Synchronet handles CP437 bytes in strings
// For now, a basic mapping or assume Synchronet handles CP437 bytes in strings
// Let's try a basic lookup for common chars, or assume direct charCodeAt gives the CP437 value.
// Let's try a basic lookup for common chars, or assume direct charCodeAt gives the CP437 value.
...
@@ -319,7 +319,7 @@ function printcolor(color) {
...
@@ -319,7 +319,7 @@ function printcolor(color) {
var
fgmcolors
=
[
1
,
2
,
3
,
10
,
5
,
6
,
7
,
15
,
14
,
12
,
9
,
11
,
4
,
13
,
8
,
0
];
// MIRC colors
var
fgmcolors
=
[
1
,
2
,
3
,
10
,
5
,
6
,
7
,
15
,
14
,
12
,
9
,
11
,
4
,
13
,
8
,
0
];
// MIRC colors
var
bgmcolors
=
[
1
,
2
,
3
,
10
,
5
,
6
,
7
,
15
,
14
,
12
,
9
,
11
,
4
,
13
,
8
,
0
];
// MIRC backgrounds
var
bgmcolors
=
[
1
,
2
,
3
,
10
,
5
,
6
,
7
,
15
,
14
,
12
,
9
,
11
,
4
,
13
,
8
,
0
];
// MIRC backgrounds
if
(
opt
.
color
===
COLOR_ANSI
)
{
if
(
this
.
opt
==
undefined
||
opt
.
color
===
COLOR_ANSI
)
{
out
+=
"
\
x1b[
"
;
out
+=
"
\
x1b[
"
;
out
+=
(
fgacolors
[
fg
]
+
"
;
"
);
out
+=
(
fgacolors
[
fg
]
+
"
;
"
);
out
+=
(
bgacolors
[
bg
]
+
"
m
"
);
out
+=
(
bgacolors
[
bg
]
+
"
m
"
);
...
@@ -356,7 +356,7 @@ function printrow(glyph, row) {
...
@@ -356,7 +356,7 @@ function printrow(glyph, row) {
}
}
// Reset color at the end of the row
// Reset color at the end of the row
if
(
opt
.
color
===
COLOR_ANSI
)
{
if
(
this
.
opt
==
undefined
||
opt
.
color
===
COLOR_ANSI
)
{
out
+=
"
\
x1b[0m
"
;
out
+=
"
\
x1b[0m
"
;
}
else
{
}
else
{
out
+=
"
\
x03
"
;
out
+=
"
\
x03
"
;
...
@@ -392,9 +392,9 @@ function output(str, font) {
...
@@ -392,9 +392,9 @@ function output(str, font) {
}
}
// Calculate padding for justification
// Calculate padding for justification
if
(
opt
.
justify
===
CENTER_JUSTIFY
)
{
if
(
this
.
top
&&
opt
.
justify
===
CENTER_JUSTIFY
)
{
padding
=
Math
.
floor
((
opt
.
width
-
linewidth
)
/
2
);
padding
=
Math
.
floor
((
opt
.
width
-
linewidth
)
/
2
);
}
else
if
(
opt
.
justify
===
RIGHT_JUSTIFY
)
{
}
else
if
(
this
.
opt
&&
opt
.
justify
===
RIGHT_JUSTIFY
)
{
padding
=
opt
.
width
-
linewidth
;
padding
=
opt
.
width
-
linewidth
;
}
}
...
@@ -437,7 +437,7 @@ function output(str, font) {
...
@@ -437,7 +437,7 @@ function output(str, font) {
}
}
// End the line and reset color
// End the line and reset color
if
(
opt
.
color
===
COLOR_ANSI
)
{
if
(
this
.
opt
==
undefined
||
opt
.
color
===
COLOR_ANSI
)
{
out
+=
"
\
x1b[0m
"
;
// Reset color and print newline
out
+=
"
\
x1b[0m
"
;
// Reset color and print newline
}
else
{
}
else
{
out
+=
"
\
x03
"
;
// Reset MIRC color and print newline
out
+=
"
\
x03
"
;
// Reset MIRC color and print newline
...
...
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