I am requesting a kickstart. I wish to augment Atom’s behaviour when editing a specific file extension.
I am asking the community to point me in the right direction on what to study to make me capable of doing the work.
The first phase is to have the following “indentations” (?) -
NETWORK TITLE = Clear the TIME value A #inReset; O( ; AN #inEnable; AN #inHold; // Value not held ) ; JCN n001; // Load zero value L 0.000000e+000; // clear time value variables T #timeValue; T #outTV; n001: R #outDone; // clear done output BEC ; // return if used reset
My thought is to create a language to bind the “AWL” file extension to the behaviour.
Atom should then be able to identify that the active editor has this file type open.
I do not know how to create a new language - even if as light weight as this one.
So what you see in the code segment above is a type of assembler language.
Each segment is started with a network title (easily handled with a snippet).
The code is distributed in 4 columns.
- (optional) Jump label identified by
:. Comment by
- (required) Mneumonic or
- (optional) Tag / number / label
- (optional) Comment.
So the idea is that the indenting is worked out each time
enter is pressed.
But only if it is a AWL file.
space, will bring
A to column 2 and the cursor onto column 3.
space modifies the variable with prefix
# and postfix
; (… only if needed).
c) The cursor moved to column 4 placing the
// for the comment.
space in this area will be ignored.
enter with an empty comment, removes the comment.
enter will always go to a new line but might add
; if and when needed.
right buttons should skip white spaces when navigating through the code.
The steps (a) to (f) is just to give an idea on how Atom should handle typing.
I think I can figure out from the API and regular expressions to get the behaviour.
What I do not know: (ask study material: documentation references / documented examples)
- Creating a light weight language to link AWL extension to behaviour.
- Where is the coding done… general package or grammar linked package?
- How to handle:
- Apply changes only to the file type
- Live monitoring of user typing (
right, …) to trigger code for responses.
(future) Phase 2 will handle tag declarations…
VAR_INPUT inEnable : BOOL ; // Run timer inHold : BOOL ; // Timer type ... FALSE: TON | TRUE: Time accumulator inReset : BOOL ; // Clear time value inCycleTime : INT ; // [ms] Value of last processor cycle inTarget : REAL ; // [s] Run time duration before DONE is switched on END_VAR VAR_OUTPUT outDone : BOOL ; // Target time value reached outTV : REAL ; // Current accumulated time value END_VAR VAR timeValue : REAL ; // [s] Current time value END_VAR VAR_TEMP _done : BOOL ; //Time target reached END_VAR
(future) Phase 3 will try to make the tags available in code by autocomplete.
The idea is - when starting typing
# suggestions are made for symbol tags.
A push in the right direction for my long term project will be appreciated.
- Dan Padric