Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matefun
Frontend
Commits
c57a071c
Commit
c57a071c
authored
Feb 20, 2019
by
Franco Pariani
Browse files
Jump to definition feature
parent
1b64d067
Changes
5
Hide whitespace changes
Inline
Side-by-side
Frontend Angular 4/src/app/layout/matefun/codemirror/functions_definition.js
View file @
c57a071c
...
...
@@ -484,4 +484,42 @@ var mac = /Mac/.test(navigator.platform);
return
{
list
:
list
,
from
:
CodeMirror
.
Pos
(
cur
.
line
,
start
),
to
:
CodeMirror
.
Pos
(
cur
.
line
,
end
)};
}
};
CodeMirror
.
defineExtension
(
"
jumpToDefinition
"
,
function
(
editor
,
options
)
{
var
word
=
options
&&
options
.
word
||
WORD
;
var
range
=
options
&&
options
.
range
||
RANGE
;
var
cur
=
editor
.
getCursor
(),
curLine
=
editor
.
getLine
(
cur
.
line
);
var
end
=
cur
.
ch
,
start
=
end
;
while
(
start
&&
word
.
test
(
curLine
.
charAt
(
start
-
1
)))
--
start
;
while
(
end
&&
word
.
test
(
curLine
.
charAt
(
end
+
1
)))
++
end
;
var
curWord
=
start
!=
end
&&
curLine
.
slice
(
start
,
end
+
1
);
if
(
curWord
.
length
>
0
){
var
list
=
[],
seen
=
{};
var
re_digits
=
new
RegExp
(
/^
\d
+$/
,
"
g
"
);
var
found
=
false
;
var
re_funs
=
new
RegExp
(
COMPLETE_FUNS
.
source
,
"
g
"
);
for
(
var
dir
=
-
1
;
dir
<=
1
;
dir
+=
2
)
{
var
line
=
cur
.
line
,
endLine
=
Math
.
min
(
Math
.
max
(
line
+
dir
*
range
,
editor
.
firstLine
()),
editor
.
lastLine
())
+
dir
;
for
(;
line
!=
endLine
&&
!
found
;
line
+=
dir
)
{
var
text
=
editor
.
getLine
(
line
),
m
;
while
(
m
=
re_funs
.
exec
(
text
))
{
if
(
!
re_digits
.
exec
(
m
[
1
])
&&
(
!
curWord
||
m
[
1
]
==
curWord
)
&&
!
Object
.
prototype
.
hasOwnProperty
.
call
(
seen
,
m
[
1
]))
{
seen
[
m
[
1
]]
=
true
;
found
=
true
;
var
newCursor
=
editor
.
getCursor
();
newCursor
.
line
=
line
;
newCursor
.
ch
=
text
.
indexOf
(
m
[
1
]);
editor
.
setCursor
(
newCursor
);
editor
.
cm
.
closeFunctionDefinition
();
}
}
}
}
}
});
});
Frontend Angular 4/src/app/layout/matefun/matefun.component.html
View file @
c57a071c
...
...
@@ -135,6 +135,7 @@
<label><b>
Ctrl+G
</b>
{{ "i18n.shortcuts.saveFile" | translate }}
</label>
<label><b>
Ctrl+{{ "i18n.shortcuts.space" | translate }}
</b>
{{ "i18n.shortcuts.autocomplete" | translate }}
</label>
<label><b>
Ctrl+Shift+K
</b>
{{ "i18n.shortcuts.comment" | translate }}
</label>
<label><b>
Alt+.
</b>
{{ "i18n.shortcuts.functionNavigation" | translate }}
</label>
</div>
</div>
</ng-template>
...
...
Frontend Angular 4/src/app/layout/matefun/matefun.component.ts
View file @
c57a071c
...
...
@@ -453,9 +453,8 @@ export class MateFunComponent {
}
else
{
this
.
modificado
=
false
;
}
}
if
(
event
.
ctrlKey
&&
event
.
shiftKey
&&
event
.
key
==
'
K
'
)
this
.
codemirror
.
instance
.
toggleComment
();
}
else
if
(
event
.
ctrlKey
&&
event
.
shiftKey
&&
event
.
key
==
'
K
'
)
this
.
codemirror
.
instance
.
toggleComment
();
else
if
(
event
.
altKey
&&
event
.
key
==
'
.
'
)
this
.
codemirror
.
instance
.
jumpToDefinition
(
this
.
codemirror
.
instance
.
doc
,
event
);
}
clickEnEditor
(
event
){
...
...
Frontend Angular 4/src/assets/i18n/en.json
View file @
c57a071c
...
...
@@ -129,7 +129,8 @@
"saveFile"
:
"Save File"
,
"autocomplete"
:
"Autocomplete"
,
"space"
:
"Space"
,
"comment"
:
"Comment/Uncomment"
"comment"
:
"Comment/Uncomment"
,
"functionNavigation"
:
"Jump to the definition"
}
}
}
Frontend Angular 4/src/assets/i18n/es.json
View file @
c57a071c
...
...
@@ -129,7 +129,8 @@
"saveFile"
:
"Guardar archivo"
,
"autocomplete"
:
"Autocompletar"
,
"space"
:
"Espacio"
,
"comment"
:
"Comentar/Descomentar"
"comment"
:
"Comentar/Descomentar"
,
"functionNavigation"
:
"Saltar a la definición"
}
}
}
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