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
1dc63cd0
Commit
1dc63cd0
authored
1 week ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Move most of the logic from postmeme.js to reusable meme_chooser.js lib
e.g. for use in automsg.js
parent
df068b60
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/load/meme_chooser.js
+92
-0
92 additions, 0 deletions
exec/load/meme_chooser.js
exec/postmeme.js
+2
-73
2 additions, 73 deletions
exec/postmeme.js
with
94 additions
and
73 deletions
exec/load/meme_chooser.js
0 → 100755
+
92
−
0
View file @
1dc63cd0
// Meme selection/chooser library
// @format.tab-size 4, @format.use-tabs true
// Supported options
// color (default: 0)
// border (default: 0)
// random (default: false)
// max_length (default: 500)
// width (default: 39)
// justify (default: center)
"
use strict
"
;
require
(
"
key_defs.js
"
,
"
KEY_LEFT
"
);
var
lib
=
load
({},
"
meme_lib.js
"
);
var
options
=
{};
function
choose
(
border
)
{
console
.
mnemonics
(
format
(
"
~Border, ~Color, ~Justify, ~@Quit@, or [Select]:
"
));
var
ch
=
console
.
getkeys
(
"
BCJ
"
+
KEY_LEFT
+
KEY_RIGHT
+
"
\r
"
+
console
.
next_key
+
console
.
prev_key
+
console
.
quit_key
,
lib
.
BORDER_COUNT
);
if
(
typeof
ch
==
"
number
"
)
return
ch
-
1
;
switch
(
ch
)
{
case
console
.
quit_key
:
return
false
;
case
'
\r
'
:
return
true
;
case
'
C
'
:
case
'
J
'
:
case
'
B
'
:
return
ch
;
case
KEY_UP
:
case
KEY_LEFT
:
case
console
.
prev_key
:
return
console
.
prev_key
;
default
:
return
console
.
next_key
;
}
}
function
main
(
text
,
options
)
{
var
attr
=
[
"
\
x01H
\
x01W
\
x011
"
,
"
\
x01H
\
x01W
\
x012
"
,
"
\
x01H
\
x01W
\
x013
"
,
"
\
x01H
\
x01W
\
x014
"
,
"
\
x01H
\
x01W
\
x015
"
,
"
\
x01H
\
x01W
\
x016
"
,
"
\
x01N
\
x01K
\
x017
"
,
];
var
justify
=
options
.
justify
||
0
;
var
border
=
options
.
border
||
0
;
var
color
=
options
.
color
||
0
;
if
(
options
.
random
)
{
border
=
random
(
lib
.
BORDER_COUNT
);
color
=
random
(
attr
.
length
);
}
var
msg
;
while
(
!
js
.
terminated
)
{
msg
=
lib
.
generate
(
options
.
width
||
39
,
attr
[
color
%
attr
.
length
],
border
%
lib
.
BORDER_COUNT
,
text
,
justify
%
lib
.
JUSTIFY_COUNT
);
console
.
clear
();
console
.
attributes
=
WHITE
|
HIGH
;
console
.
print
(
format
(
"
Meme
\
x01N
\
x01C(border
\
x01H%u
\
x01N
\
x01Cof
\
x01H%u
\
x01N
\
x01C, color
\
x01H%u
\
x01N
\
x01C of
\
x01H%u
\
x01N
\
x01C):
"
,
(
border
%
lib
.
BORDER_COUNT
)
+
1
,
lib
.
BORDER_COUNT
,
(
color
%
attr
.
length
)
+
1
,
attr
.
length
));
console
.
newline
(
2
);
print
(
msg
);
var
ch
=
choose
(
border
);
if
(
ch
===
false
)
return
false
;
if
(
ch
===
true
)
return
msg
;
if
(
typeof
ch
==
"
number
"
)
border
=
ch
;
else
if
(
ch
===
'
C
'
)
++
color
;
else
if
(
ch
===
'
J
'
)
++
justify
;
else
if
(
ch
===
'
B
'
)
++
border
;
else
if
(
ch
==
console
.
next_key
&&
border
<
lib
.
BORDER_COUNT
-
1
)
++
border
;
else
if
(
ch
==
console
.
prev_key
&&
border
>
0
)
--
border
;
else
console
.
beep
();
}
}
main
.
apply
(
null
,
argv
);
This diff is collapsed.
Click to expand it.
exec/postmeme.js
+
2
−
73
View file @
1dc63cd0
...
@@ -9,89 +9,18 @@
...
@@ -9,89 +9,18 @@
// width (default: 39)
// width (default: 39)
// justify (default: center)
// justify (default: center)
"
use strict
"
;
require
(
"
key_defs.js
"
,
"
KEY_LEFT
"
);
require
(
"
sbbsdefs.js
"
,
"
K_LINEWRAP
"
);
require
(
"
sbbsdefs.js
"
,
"
K_LINEWRAP
"
);
"
use strict
"
;
var
options
=
load
({},
"
modopts.js
"
,
"
postmeme
"
);
var
options
=
load
({},
"
modopts.js
"
,
"
postmeme
"
);
if
(
!
options
)
options
=
{};
if
(
!
options
)
options
=
{};
var
lib
=
load
({},
"
meme_lib.js
"
);
function
choose
(
border
)
{
console
.
mnemonics
(
format
(
"
~Border, ~Color, ~Justify, ~@Quit@, or [Select]:
"
));
var
ch
=
console
.
getkeys
(
"
BCJ
"
+
KEY_LEFT
+
KEY_RIGHT
+
"
\r
"
+
console
.
next_key
+
console
.
prev_key
+
console
.
quit_key
,
lib
.
BORDER_COUNT
);
if
(
typeof
ch
==
"
number
"
)
return
ch
-
1
;
switch
(
ch
)
{
case
console
.
quit_key
:
return
false
;
case
'
\r
'
:
return
true
;
case
'
C
'
:
case
'
J
'
:
case
'
B
'
:
return
ch
;
case
KEY_UP
:
case
KEY_LEFT
:
case
console
.
prev_key
:
return
console
.
prev_key
;
default
:
return
console
.
next_key
;
}
}
console
.
print
(
"
\
x01N
\
x01Y
\
x01HWhat do you want to say?
\
x01N
\r\n
"
);
console
.
print
(
"
\
x01N
\
x01Y
\
x01HWhat do you want to say?
\
x01N
\r\n
"
);
var
text
=
console
.
getstr
(
options
.
max_length
||
500
,
K_LINEWRAP
);
var
text
=
console
.
getstr
(
options
.
max_length
||
500
,
K_LINEWRAP
);
if
(
!
text
)
if
(
!
text
)
exit
(
0
);
exit
(
0
);
var
attr
=
[
"
\
x01H
\
x01W
\
x011
"
,
"
\
x01H
\
x01W
\
x012
"
,
"
\
x01H
\
x01W
\
x013
"
,
"
\
x01H
\
x01W
\
x014
"
,
"
\
x01H
\
x01W
\
x015
"
,
"
\
x01H
\
x01W
\
x016
"
,
"
\
x01N
\
x01K
\
x017
"
,
];
var
justify
=
options
.
justify
||
0
;
var
border
=
options
.
border
||
0
;
var
color
=
options
.
color
||
0
;
if
(
options
.
random
)
{
border
=
random
(
lib
.
BORDER_COUNT
);
color
=
random
(
attr
.
length
);
}
var
msg
;
while
(
!
js
.
terminated
)
{
msg
=
lib
.
generate
(
options
.
width
||
39
,
attr
[
color
%
attr
.
length
],
border
%
lib
.
BORDER_COUNT
,
text
,
justify
%
lib
.
JUSTIFY_COUNT
);
console
.
clear
();
console
.
attributes
=
WHITE
|
HIGH
;
console
.
print
(
format
(
"
Meme
\
x01N
\
x01C(border
\
x01H%u
\
x01N
\
x01Cof
\
x01H%u
\
x01N
\
x01C, color
\
x01H%u
\
x01N
\
x01C of
\
x01H%u
\
x01N
\
x01C):
"
,
(
border
%
lib
.
BORDER_COUNT
)
+
1
,
lib
.
BORDER_COUNT
,
(
color
%
attr
.
length
)
+
1
,
attr
.
length
));
console
.
newline
(
2
);
print
(
msg
);
var
ch
=
choose
(
border
);
if
(
ch
===
false
)
exit
(
1
);
if
(
ch
===
true
)
break
;
if
(
typeof
ch
==
"
number
"
)
border
=
ch
;
else
if
(
ch
===
'
C
'
)
++
color
;
else
if
(
ch
===
'
J
'
)
++
justify
;
else
if
(
ch
===
'
B
'
)
++
border
;
else
if
(
ch
==
console
.
next_key
&&
border
<
lib
.
BORDER_COUNT
-
1
)
++
border
;
else
if
(
ch
==
console
.
prev_key
&&
border
>
0
)
--
border
;
else
console
.
beep
();
}
var
msg
=
load
(
"
meme_chooser.js
"
,
text
,
options
);
if
(
!
msg
)
if
(
!
msg
)
exit
(
0
);
exit
(
0
);
...
...
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