Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
d1b1b197
Commit
d1b1b197
authored
12 years ago
by
Jan Keromnes
Committed by
Marijn Haverbeke
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[shell] lookup keywords in hashmap not in arrays
parent
333855ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mode/shell/shell.js
+22
-7
22 additions, 7 deletions
mode/shell/shell.js
with
22 additions
and
7 deletions
mode/shell/shell.js
+
22
−
7
View file @
d1b1b197
CodeMirror
.
defineMode
(
'
shell
'
,
function
(
config
)
{
var
atoms
=
[
'
true
'
,
'
false
'
],
keywords
=
[
'
if
'
,
'
then
'
,
'
do
'
,
'
else
'
,
'
elif
'
,
'
while
'
,
'
until
'
,
'
for
'
,
'
in
'
,
'
esac
'
,
'
fi
'
,
'
fin
'
,
'
fil
'
,
'
done
'
,
'
exit
'
,
'
set
'
,
'
unset
'
,
'
export
'
,
'
function
'
],
commands
=
[
'
ab
'
,
'
awk
'
,
'
bash
'
,
'
beep
'
,
'
cat
'
,
'
cc
'
,
'
cd
'
,
'
chown
'
,
'
chmod
'
,
'
chroot
'
,
'
clear
'
,
'
cp
'
,
'
curl
'
,
'
cut
'
,
'
diff
'
,
'
echo
'
,
'
find
'
,
'
gawk
'
,
'
gcc
'
,
'
get
'
,
'
git
'
,
'
grep
'
,
'
kill
'
,
'
killall
'
,
'
ls
'
,
'
make
'
,
'
mkdir
'
,
'
openssl
'
,
'
mv
'
,
'
nc
'
,
'
node
'
,
'
npm
'
,
'
ping
'
,
'
ps
'
,
'
restart
'
,
'
rm
'
,
'
rmdir
'
,
'
sed
'
,
'
service
'
,
'
sh
'
,
'
shopt
'
,
'
shred
'
,
'
source
'
,
'
sort
'
,
'
sleep
'
,
'
ssh
'
,
'
start
'
,
'
stop
'
,
'
su
'
,
'
sudo
'
,
'
tee
'
,
'
telnet
'
,
'
top
'
,
'
touch
'
,
'
vi
'
,
'
vim
'
,
'
wall
'
,
'
wc
'
,
'
wget
'
,
'
who
'
,
'
write
'
,
'
yes
'
,
'
zsh
'
];
var
words
=
{};
function
define
(
style
,
string
)
{
var
split
=
string
.
split
(
'
'
);
for
(
var
i
=
0
;
i
<
split
.
length
;
i
++
)
{
words
[
split
[
i
]]
=
style
;
}
};
// Atoms
define
(
'
atom
'
,
'
true false
'
);
// Keywords
define
(
'
keyword
'
,
'
if then do else elif while until for in esac fi fin
'
+
'
fil done exit set unset export function
'
);
// Commands
define
(
'
builtin
'
,
'
ab awk bash beep cat cc cd chown chmod chroot clear cp
'
+
'
curl cut diff echo find gawk gcc get git grep kill killall ln ls make
'
+
'
mkdir openssl mv nc node npm ping ps restart rm rmdir sed service sh
'
+
'
shopt shred source sort sleep ssh start stop su sudo tee telnet top
'
+
'
touch vi vim wall wc wget who write yes zsh
'
);
function
tokenBase
(
stream
,
state
)
{
...
...
@@ -42,10 +60,7 @@ CodeMirror.defineMode('shell', function(config) {
stream
.
eatWhile
(
/
\w
/
);
var
cur
=
stream
.
current
();
if
(
stream
.
peek
()
===
'
=
'
&&
/
\w
+/
.
test
(
cur
))
return
'
def
'
;
if
(
atoms
.
indexOf
(
cur
)
!==
-
1
)
return
'
atom
'
;
if
(
commands
.
indexOf
(
cur
)
!==
-
1
)
return
'
builtin
'
;
if
(
keywords
.
indexOf
(
cur
)
!==
-
1
)
return
'
keyword
'
;
return
null
;
return
words
[
cur
]
||
null
;
}
function
tokenString
(
quote
)
{
...
...
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