Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
f465caf2
Commit
f465caf2
authored
May 04, 2020
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow multiple highlight per plugin
parent
9bf4f721
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
6 deletions
+84
-6
SourceHighlighters.js
src/app/editor/SourceHighlighters.js
+21
-4
editor.js
src/app/editor/editor.js
+11
-1
sourceHighlighter.js
src/app/editor/sourceHighlighter.js
+2
-1
editor.test.js
test-browser/tests/editor.test.js
+50
-0
No files found.
src/app/editor/SourceHighlighters.js
View file @
f465caf2
...
@@ -12,16 +12,33 @@ class SourceHighlighters {
...
@@ -12,16 +12,33 @@ class SourceHighlighters {
highlight
(
position
,
filePath
,
hexColor
,
from
)
{
highlight
(
position
,
filePath
,
hexColor
,
from
)
{
try
{
try
{
if
(
!
this
.
highlighters
[
from
])
this
.
highlighters
[
from
]
=
new
SourceHighlighter
()
if
(
!
this
.
highlighters
[
from
])
this
.
highlighters
[
from
]
=
[]
this
.
highlighters
[
from
].
currentSourceLocation
(
null
)
const
sourceHighlight
=
new
SourceHighlighter
()
this
.
highlighters
[
from
].
currentSourceLocationFromfileName
(
position
,
filePath
,
hexColor
)
sourceHighlight
.
currentSourceLocationFromfileName
(
position
,
filePath
,
hexColor
)
this
.
highlighters
[
from
].
push
(
sourceHighlight
)
}
catch
(
e
)
{
}
catch
(
e
)
{
throw
e
throw
e
}
}
}
}
discardHighlight
(
from
)
{
discardHighlight
(
from
)
{
if
(
this
.
highlighters
[
from
])
this
.
highlighters
[
from
].
currentSourceLocation
(
null
)
if
(
this
.
highlighters
[
from
])
{
for
(
const
index
in
this
.
highlighters
[
from
])
this
.
highlighters
[
from
][
index
].
currentSourceLocation
(
null
)
}
this
.
highlighters
[
from
]
=
[]
}
discardHighlightAt
(
line
,
filePath
,
from
)
{
if
(
this
.
highlighters
[
from
])
{
for
(
const
index
in
this
.
highlighters
[
from
])
{
const
highlight
=
this
.
highlighters
[
from
][
index
]
if
(
highlight
.
source
===
filePath
&&
(
highlight
.
position
.
start
.
line
===
line
||
highlight
.
position
.
end
.
line
===
line
))
{
highlight
.
currentSourceLocation
(
null
)
this
.
highlighters
[
from
].
splice
(
index
,
1
)
}
}
}
}
}
}
}
...
...
src/app/editor/editor.js
View file @
f465caf2
...
@@ -46,7 +46,7 @@ const profile = {
...
@@ -46,7 +46,7 @@ const profile = {
name
:
'editor'
,
name
:
'editor'
,
description
:
'service - editor'
,
description
:
'service - editor'
,
version
:
packageJson
.
version
,
version
:
packageJson
.
version
,
methods
:
[
'highlight'
,
'discardHighlight'
,
'clearAnnotations'
,
'addAnnotation'
]
methods
:
[
'highlight'
,
'discardHighlight'
,
'
discardHighlightAt'
,
'
clearAnnotations'
,
'addAnnotation'
]
}
}
class
Editor
extends
Plugin
{
class
Editor
extends
Plugin
{
...
@@ -202,6 +202,16 @@ class Editor extends Plugin {
...
@@ -202,6 +202,16 @@ class Editor extends Plugin {
this
.
sourceHighlighters
.
discardHighlight
(
from
)
this
.
sourceHighlighters
.
discardHighlight
(
from
)
}
}
discardHighlightAt
(
line
,
filePath
)
{
const
{
from
}
=
this
.
currentRequest
this
.
sourceHighlighters
.
discardHighlightAt
(
line
,
filePath
,
from
)
}
currentHighlights
()
{
const
{
from
}
=
this
.
currentRequest
return
this
.
sourceHighlighters
.
currentHighlights
(
from
)
}
setTheme
(
type
)
{
setTheme
(
type
)
{
this
.
editor
.
setTheme
(
'ace/theme/'
+
this
.
_themes
[
type
])
this
.
editor
.
setTheme
(
'ace/theme/'
+
this
.
_themes
[
type
])
}
}
...
...
src/app/editor/sourceHighlighter.js
View file @
f465caf2
...
@@ -13,6 +13,7 @@ class SourceHighlighter {
...
@@ -13,6 +13,7 @@ class SourceHighlighter {
fileManager
:
this
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
fileManager
:
this
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
compilerArtefacts
:
this
.
_components
.
registry
.
get
(
'compilersartefacts'
).
api
compilerArtefacts
:
this
.
_components
.
registry
.
get
(
'compilersartefacts'
).
api
}
}
this
.
position
=
null
this
.
statementMarker
=
null
this
.
statementMarker
=
null
this
.
fullLineMarker
=
null
this
.
fullLineMarker
=
null
this
.
source
=
null
this
.
source
=
null
...
@@ -61,7 +62,7 @@ class SourceHighlighter {
...
@@ -61,7 +62,7 @@ class SourceHighlighter {
this
.
statementMarker
=
this
.
_deps
.
editor
.
addMarker
(
lineColumnPos
,
this
.
source
,
css
.
highlightcode
.
className
+
' '
+
css
.
customBackgroundColor
.
className
)
this
.
statementMarker
=
this
.
_deps
.
editor
.
addMarker
(
lineColumnPos
,
this
.
source
,
css
.
highlightcode
.
className
+
' '
+
css
.
customBackgroundColor
.
className
)
this
.
_deps
.
editor
.
scrollToLine
(
lineColumnPos
.
start
.
line
,
true
,
true
,
function
()
{})
this
.
_deps
.
editor
.
scrollToLine
(
lineColumnPos
.
start
.
line
,
true
,
true
,
function
()
{})
this
.
position
=
lineColumnPos
if
(
lineColumnPos
.
start
.
line
===
lineColumnPos
.
end
.
line
)
{
if
(
lineColumnPos
.
start
.
line
===
lineColumnPos
.
end
.
line
)
{
this
.
fullLineMarker
=
this
.
_deps
.
editor
.
addMarker
({
this
.
fullLineMarker
=
this
.
_deps
.
editor
.
addMarker
({
start
:
{
start
:
{
...
...
test-browser/tests/editor.test.js
View file @
f465caf2
...
@@ -70,6 +70,12 @@ module.exports = {
...
@@ -70,6 +70,12 @@ module.exports = {
.
checkElementStyle
(
'.ace_comment.ace_doc'
,
'color'
,
aceThemes
.
dark
.
comment
)
.
checkElementStyle
(
'.ace_comment.ace_doc'
,
'color'
,
aceThemes
.
dark
.
comment
)
.
checkElementStyle
(
'.ace_function'
,
'color'
,
aceThemes
.
dark
.
function
)
.
checkElementStyle
(
'.ace_function'
,
'color'
,
aceThemes
.
dark
.
function
)
.
checkElementStyle
(
'.ace_variable'
,
'color'
,
aceThemes
.
dark
.
variable
)
.
checkElementStyle
(
'.ace_variable'
,
'color'
,
aceThemes
.
dark
.
variable
)
},
'Should highlight source code'
:
function
(
browser
)
{
browser
.
addFile
(
'browser/sourcehighlight.js'
,
sourcehighlightScript
)
.
switchFile
(
'browser/sourcehighlight.js'
)
.
executeScript
(
'remix.exeCurrent()'
)
.
end
()
.
end
()
},
},
...
@@ -90,3 +96,47 @@ var aceThemes = {
...
@@ -90,3 +96,47 @@ var aceThemes = {
variable
:
'rgb(153, 119, 68)'
variable
:
'rgb(153, 119, 68)'
}
}
}
}
const
sourcehighlightScript
=
`
(async () => {
try {
const pos = {
start: {
line: 32,
column: 3
},
end: {
line: 32,
column: 20
}
}
await remix.call('editor', 'highlight', pos, 'browser/3_Ballot.sol')
const pos2 = {
start: {
line: 40,
column: 3
},
end: {
line: 40,
column: 20
}
}
await remix.call('editor', 'highlight', pos2, 'browser/3_Ballot.sol')
const pos3 = {
start: {
line: 50,
column: 3
},
end: {
line: 50,
column: 20
}
}
await remix.call('editor', 'highlight', pos3, 'browser/3_Ballot.sol')
} catch (e) {
console.log(e.message)
}
})()
`
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