HAWC2 VSCode extension
Extension for interacting and inspecting files related to HAWC2 (e.g. .htc
, .ae
, .pc
, .st
).
It adds the following features:
Features
Syntax highlighting
HTC-file
- Highlights blocks (statements with
begin
and end
) and colors the block name depending on if it can be repeated or not.
- Highlights keywords, also depending of if they can be repeated within the block or not.
- Different colors for numbers and strings as well as comments
- Supports tag identifiers (default to square-bracket tags (
[tag]
) but identifiers can be changed from the extension settings, search for hawc2. See more here or below)
AE-, PC- and ST-files
- Highlights the tabular data
- Highlights data headers such as: # sets, # subsets/profiles, # rows and relative profile thickness
Figures with syntax highlighting for PC- and ST-files and GIF showing how to change tag identifier
PC-file
ST-file
Changing Tags
Code folding
The extension provides code folding for the AE-, PC-, ST- and HTC-files.
HTC-file
The folding for the HTC file is folding based on blocks and the blocks begin XXX
and end XXX
statements are still visible af the fold to make it clear that it is only folding the text in the block.
AE-, PC- and ST-files
All the tabular data files are folder on either set or sub-set/airfoils
AE-files
GIF's with code folding for PC- and ST-files
PC-file
ST-file
Hover documentation
HTC-file
Hovering above a line with a keyword/block that has documentation displays the documentation information for that keyword/block.
AE-, PC- and ST-files
- Hover information for each column including additional information such as set #, subset/profile #, column #, row #
- For ST-files in shows which format the data has (classic or FPM)
- Shows documentation for data header # sets, # subsets/profiles, # rows and relative profile thickness
ST-file
GIFs showing hover documentation for AE- and PC-files
AE-file
PC-file
Auto completion
Note: Only implemented for the HTC-file.
With the cursor at an empty line within any known block (currently the output
block is not supported) and pressing Ctrl
+Space
gives a list of possible keywords/blocks within the current block. The doc string can also be shown by pressing Ctrl
+Space
again. Items are selected by pressing Enter
.
File-view
File-view allows to render the file content using HTML/CSS/JavaScript.
File-view is currently implemented for AE-, PC-, ST- and HTC-files
❗Be aware ❗ The view of the HTC-file is only a helper tool and it not using the same parser as in HAWC2 and hence there is not guarantee that it is representing the exact input for HAWC2. But please report of any discrepancy is observed. |
How to open file-view
- Open a file in editor mode
- Right click to open the file-menu
- Click the Open XX-file View at the bottom of the menu
Note: For HTC-files with continue_in_file
it will try HAWC2 execution path as the same as the HTC-file or the parent folder (e.g. path_htc_file/../
) if they are not execution paths it will prompt an input box where the path should be given relative to the HTC-file.
It will write an error if it fails to load any of the files.
The current HTC-webview can show the
- Beam Topology: View of the
main_body
beam nodes where orientation
has been applied to construct the 3D beam topology. Each main_body
is given a unique color.
- Beam Constraints: Using the same data as Beam Topology, but each type of constraint between bodies are added with different markers.
- Local Coordinate System: Using the same data as Beam Topology, but shows the local coordinate system at the first node of each of the bodies
Notice: The legend is interactive. A single click will hide the line/trace/legend-group element(s) from the plot. A double click will only show the line/trace/legend-group that is double clicked.
From the menu it is also possible to save the HTC-file as an HTML-file instead of just showing it in a webview tab in VSCode.
GIFs showing file-view for AE- PC- and ST-files
AE-file
PC-file
ST-file
Diagnostics
The HTC-file is being checked for end of line character on each line before a line that starts with an exit
statement.
Terminal profiles
The extension provides terminal profiles for Powershell (Windows) and bash (linux) making it straight forward to run HAWC2 simulations directly from the built-in terminal. If HAWC2 is installed on Windows using the msi installer, the terminal profile should work straight out of the box, initializing HAWC2, CheckVersion and license_manager as aliases to use in the open session. If HAWC2 is not installed using the msi installer, or the user would rather specify a different version to the one installed, the user should instead specify the path where HAWC2 is installed in the extension settings. On Linux the session is initialized with an extended PATH variable including the path from the settings.
FAQ
- My file is not recognized as a HAWC2 file. How can I have VSCode see it as a HAWC2 file?
The extension will recognize files of the form:
*_XXX*.dat
or *.XXX
(e.g. *_htc.dat
, *_htc_new.dat
, htc_file_name.htc
).
If VSCode do not recognize your file or it is not following the pattern as above, the file format for a given file can either be set manually or if you want to associate a pattern it can be done with the Change Language Mode (Ctrl+K M
). All the file types can be search with the HAWC2 keyword. It is also possible to change in the lower right corner of the editor.
Contributing/Developing the extension
Development instruction with code overview is discussed here.