FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
VSpaceCode/scripts/keybindings.js at master · VSpaceCode/VSpaceCode · GitHub
VSpaceCode
/
VSpaceCode
Public
Notifications
You must be signed in to change notification settings
Fork
129
Star
1.5k
Code
Issues
66
Pull requests
13
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
VSpaceCode
/
scripts
/
keybindings.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
99 lines (86 loc) · 2.5 KB
Breadcrumbs
VSpaceCode
/
scripts
/
keybindings.js
Copy path
File metadata and controls
99 lines (86 loc) · 2.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const
table
=
require
(
"markdown-table"
)
;
const
fs
=
require
(
"fs"
)
;
function
replaceChar
(
s
)
{
return
s
.
replace
(
/
/
g
,
"␣"
)
.
replace
(
/
\t
/
g
,
"↹"
)
;
}
function
createHeading
(
name
)
{
return
`#
${
name
}
`
;
}
function
createHeadingLink
(
text
,
name
)
{
const
link
=
`
${
name
}
`
.
replace
(
/
^
#
+
/
,
""
)
.
replace
(
/
[
^
a
-
z
A
-
Z
0
-
9
]
/
g
,
""
)
.
replace
(
/
/
g
,
"-"
)
.
toLowerCase
(
)
;
return
`[
${
text
}
](#
${
link
}
)`
;
}
function
createCommandText
(
binding
)
{
if
(
binding
.
command
)
{
return
`\`
${
binding
.
command
}
\``
;
}
else
if
(
binding
.
commands
)
{
return
binding
.
commands
.
map
(
(
c
)
=>
`\`
${
c
}
\``
)
.
join
(
"<br />"
)
;
}
else
{
return
"N/A"
;
}
}
function
wrapCode
(
text
)
{
if
(
text
&&
text
.
length
>
0
)
{
return
`<code>
${
text
.
replace
(
/
\`
/
g
,
"\\`"
)
}
</code>`
;
}
return
text
;
}
const
package
=
JSON
.
parse
(
fs
.
readFileSync
(
"./package.json"
)
)
;
const
defaultBindings
=
package
.
contributes
.
configuration
[
0
]
.
properties
[
"vspacecode.bindings"
]
.
default
;
const
root
=
{
key
:
replaceChar
(
" "
)
,
keys
:
[
replaceChar
(
" "
)
]
,
name
:
"VSpaceCode"
,
type
:
"bindings"
,
bindings
:
defaultBindings
,
}
;
let
strBuilder
=
[
]
;
// Breath first search
const
queue
=
[
root
]
;
while
(
queue
.
length
>
0
)
{
const
node
=
queue
.
shift
(
)
;
const
heading
=
createHeading
(
node
.
name
)
;
strBuilder
.
push
(
heading
,
"\n\n"
,
`Key Binding:
${
wrapCode
(
node
.
keys
.
join
(
" "
)
)
}
`
,
"\n\n"
,
`Type:
${
wrapCode
(
node
.
type
)
}
`
,
"\n\n"
)
;
// Process the node
const
isTransient
=
node
.
type
===
"transient"
;
const
isConditional
=
node
.
type
===
"conditional"
;
const
tableContent
=
[
[
isConditional
?
"Condition"
:
"Key Binding"
,
"Name"
,
"Type"
,
"Command(s)"
,
]
,
]
;
for
(
const
b
of
node
.
bindings
)
{
b
.
keys
=
[
...
node
.
keys
,
replaceChar
(
b
.
key
)
]
;
const
shouldJoinKeys
=
!
isTransient
&&
!
isConditional
;
const
hasBindings
=
Array
.
isArray
(
b
.
bindings
)
&&
b
.
bindings
.
length
>
0
;
tableContent
.
push
(
[
wrapCode
(
shouldJoinKeys
?
b
.
keys
.
join
(
" "
)
:
b
.
key
)
,
b
.
name
,
hasBindings
?
createHeadingLink
(
b
.
type
,
b
.
name
)
:
b
.
type
,
createCommandText
(
b
)
,
]
)
;
// Enqueue if it has binding
if
(
hasBindings
)
{
queue
.
push
(
b
)
;
}
}
// Write output of this node
strBuilder
.
push
(
table
(
tableContent
)
,
"\n\n"
)
;
}
fs
.
writeFileSync
(
"./KEYBINDINGS.md"
,
strBuilder
.
join
(
""
)
)
;
Back
|
FazBrowse Home
|
New Git URL