Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d8d59fd8
Commit
d8d59fd8
authored
Aug 10, 2017
by
Alexander Zobnin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ace: add custom behaviour for prometheus
parent
b260a642
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
3 deletions
+75
-3
public/app/core/components/code_editor/mode-prometheus.js
+75
-3
No files found.
public/app/core/components/code_editor/mode-prometheus.js
View file @
d8d59fd8
...
...
@@ -49,10 +49,10 @@ var PrometheusHighlightRules = function() {
regex
:
"
\\
+|
\\
-|
\\
*|
\\
/|%|
\\
^|=|==|!=|<=|>=|<|>|=
\\
~|!
\\
~"
},
{
token
:
"paren.lparen"
,
regex
:
"[
\\
(
]"
regex
:
"[
[({
]"
},
{
token
:
"paren.rparen"
,
regex
:
"[
\\
)
]"
regex
:
"[
\\
])}
]"
},
{
token
:
"text"
,
regex
:
"
\\
s+"
...
...
@@ -65,16 +65,88 @@ oop.inherits(PrometheusHighlightRules, TextHighlightRules);
exports
.
PrometheusHighlightRules
=
PrometheusHighlightRules
;
});
ace
.
define
(
"ace/mode/behaviour/prometheus"
,[
"require"
,
"exports"
,
"module"
,
"ace/lib/oop"
,
"ace/mode/behaviour"
,
"ace/mode/behaviour/cstyle"
,
"ace/token_iterator"
],
function
(
require
,
exports
,
module
)
{
"use strict"
;
var
oop
=
require
(
"../../lib/oop"
);
var
Behaviour
=
require
(
"../behaviour"
).
Behaviour
;
var
CstyleBehaviour
=
require
(
"./cstyle"
).
CstyleBehaviour
;
var
TokenIterator
=
require
(
"../../token_iterator"
).
TokenIterator
;
function
getWrapped
(
selection
,
selected
,
opening
,
closing
)
{
var
rowDiff
=
selection
.
end
.
row
-
selection
.
start
.
row
;
return
{
text
:
opening
+
selected
+
closing
,
selection
:
[
0
,
selection
.
start
.
column
+
1
,
rowDiff
,
selection
.
end
.
column
+
(
rowDiff
?
0
:
1
)
]
};
};
var
PrometheusBehaviour
=
function
()
{
this
.
inherit
(
CstyleBehaviour
);
// Rewrite default CstyleBehaviour for {} braces
this
.
add
(
"braces"
,
"insertion"
,
function
(
state
,
action
,
editor
,
session
,
text
)
{
if
(
text
==
'{'
)
{
var
selection
=
editor
.
getSelectionRange
();
var
selected
=
session
.
doc
.
getTextRange
(
selection
);
if
(
selected
!==
""
&&
editor
.
getWrapBehavioursEnabled
())
{
return
getWrapped
(
selection
,
selected
,
'{'
,
'}'
);
}
else
if
(
CstyleBehaviour
.
isSaneInsertion
(
editor
,
session
))
{
return
{
text
:
'{}'
,
selection
:
[
1
,
1
]
};
}
}
else
if
(
text
==
'}'
)
{
var
cursor
=
editor
.
getCursorPosition
();
var
line
=
session
.
doc
.
getLine
(
cursor
.
row
);
var
rightChar
=
line
.
substring
(
cursor
.
column
,
cursor
.
column
+
1
);
if
(
rightChar
==
'}'
)
{
var
matching
=
session
.
$findOpeningBracket
(
'}'
,
{
column
:
cursor
.
column
+
1
,
row
:
cursor
.
row
});
if
(
matching
!==
null
&&
CstyleBehaviour
.
isAutoInsertedClosing
(
cursor
,
line
,
text
))
{
return
{
text
:
''
,
selection
:
[
1
,
1
]
};
}
}
}
});
this
.
add
(
"braces"
,
"deletion"
,
function
(
state
,
action
,
editor
,
session
,
range
)
{
var
selected
=
session
.
doc
.
getTextRange
(
range
);
if
(
!
range
.
isMultiLine
()
&&
selected
==
'{'
)
{
var
line
=
session
.
doc
.
getLine
(
range
.
start
.
row
);
var
rightChar
=
line
.
substring
(
range
.
start
.
column
+
1
,
range
.
start
.
column
+
2
);
if
(
rightChar
==
'}'
)
{
range
.
end
.
column
++
;
return
range
;
}
}
});
}
oop
.
inherits
(
PrometheusBehaviour
,
CstyleBehaviour
);
exports
.
PrometheusBehaviour
=
PrometheusBehaviour
;
});
ace
.
define
(
"ace/mode/prometheus"
,[
"require"
,
"exports"
,
"module"
,
"ace/lib/oop"
,
"ace/mode/text"
,
"ace/mode/prometheus_highlight_rules"
],
function
(
require
,
exports
,
module
)
{
"use strict"
;
var
oop
=
require
(
"../lib/oop"
);
var
TextMode
=
require
(
"./text"
).
Mode
;
var
PrometheusHighlightRules
=
require
(
"./prometheus_highlight_rules"
).
PrometheusHighlightRules
;
var
PrometheusBehaviour
=
require
(
"./behaviour/prometheus"
).
PrometheusBehaviour
;
var
Mode
=
function
()
{
this
.
HighlightRules
=
PrometheusHighlightRules
;
this
.
$behaviour
=
this
.
$defaultBehaviour
;
this
.
$behaviour
=
new
PrometheusBehaviour
()
;
};
oop
.
inherits
(
Mode
,
TextMode
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment