Syntax highlighting

For all talk about quests. Creating, testing, bugs, and development progress.
Post Reply
User avatar
TheLacus
Posts: 625
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Syntax highlighting

Post by TheLacus » Fri Jun 15, 2018 6:36 pm

A WIP integration of Template script language with Visual Studio Code. Syntax highlighting and a few other features are also available for Notepad++.

VS Code
Visual Studio Code is a powerful open source and cross-platform text editor.
A preview of features of this extension can be seen on this gallery, while the downloads are found on Github.

Image

Installation
  1. Download the latest version (.vsix) from Releases on github (you can find the changelog here).
  2. Click on Extensions button, open the dropdown menu and choose Install from VSIX.
  3. Restart vs code.
Setup
Daggerfall quest files use .txt extension so we need to choose how to associate a file with the Template language instead of default raw text.
  • Individual Files
    1. Open a quest file.
    2. Select dftemplate from the language indicator on the bottom right corner.
  • Folder
    1. Open the folder with all quest files. Tipically this is StreamingAssets/QuestPacks/Author (/PackName for a single pack).
    2. Open File>Preferences>Settings>Workspace Settings
    3. Add a file association for the workspace. This associate all txt files in the folder.

      Code: Select all

      "files.associations": {
      	"*.txt": "dftemplate"
       }
      
      If you prefer, this is a ready to use settings file.
      dftemplate_settings.7z
      (635 Bytes) Downloaded 4 times
    4. File -> Open folder
  • Workspace (suggested)
    A workspace is a group of folder; this is useful if we want to open both Quests and QuestPacks at the same time.
    1. Extract and place quests.code-workspace inside StreamingAssets/QuestPacks.
      quests.code-workspace.zip
      (284 Bytes) Downloaded 5 times
      You can also create it manually or from the editor UI. This is the content of the file above:

      Code: Select all

      {
      	"folders": [
      		{
      			"path": "../Quests"
      		},
      		{
      			"path": "."
      		}
      	],
      	"settings": {
      		"files.associations": {
      			"*.txt": "dftemplate"
      		}
      	}
      }
      
    2. File -> Open workspace
  • Global
    1. Open File>Preferences>Settings>User Settings
    2. Add a global file association. This associate all txt files for all folders called Quests.

      Code: Select all

      "files.associations": {
              "**/Quests/*.txt": "dftemplate"
      },
      
Settings
Change settings from Open File>Preferences>Settings>Workspace Settings or User settings. Workspace settings consist of a file added to local folder which overrides user settings.
  • Centered Messages
    dftemplate.format.centeredMessages: Messages with <ce> tag are horizontally centered, otherwise they are aligned to the left.
  • Diagnostics
    Diagnostics are enabled by default but they are still quite crude so if you want you can disable them with dftemplate.diagnostics.enabled. When enabled, they can run only when a file is opened or saved, or being refreshed as you type (dftemplate.diagnostics.live). If you reduce dftemplate.diagnostics.delay they will run more often so there is also more going on in background.
  • Modules
    There is no reason to change this settings at this time, but if a mod adds new actions to the quest engine, quest writers can import signatures for autocomplete and diagnostics adding a json file path to dftemplate.modules.
Contribution
I appreciate all issue reports and feedback.
If you want to contribuite to development, open cloned folder in editor and run npm install (with no args) to automatically install dependencies.

Notepad++
Notepad++ is a powerful but light text editor available in 32 and 64 bit versions. All the tools here work for both. Unfortunately is only available for Windows, but it works fine with Wine.

The following installation instructions refers to two paths: %AppData% and %InstallationPath%. By default the latter is \Program Files\Notepad++ for 64 bit or \Program Files (x86)\Notepad++ for 32 bit. If you use the portable version (shipped without installer) AppData is not used; instead, you'll find all the files inside the extracted folder.

All files for can be found here.

Syntax Highlighting
Recognizes and highlights known keywords, comments and vars with different color

Image

Installation:
  1. Move the file userDefineLang.xml inside %AppData%\Roaming\Notepad++\. If you had already installed a custom language in the past, you'll need to merge the content with the existing file (just put one <UserLang> after the other).
  2. Quests file have .txt extension so we can't make an automatic association. When you open a quest file with notepad++, you have to manually select Language > DfTemplate.
  3. I tested colors on Default (light theme), Obsidian and Bespin (dark themes). If you use a different theme and want to change colors, you can use the UI offered by Notepad++ at Language > Define your language. Right click on background color to set it transparent.
Known issues:
  • Punctuation following a keyword is seen as part of the keyword itself. (ex. [...] __foo_, [...]).
Regions
This is a feature offered with highlighting which is not part of official language syntax. It allows to fold a group of code lines and focus on the parts of code you're working on without scrolling.

Code: Select all

--- @region Name

--- @end
Image


Auto-Complete
Suggest completion from a list of known words.

Image

Installation:
Move the file DfTemplate.xml inside %InstallationPath%\plugins\APIs\.

Task list
List all tasks in a quest file.

Image

Installation:
  1. Open %AppData%\Roaming\Notepad++\functionList.xml.
  2. Open dfTemplate_functionList.xml from the downloaded files.
  3. Copy xml code from this file to functionList.xml following instructions provided in the file itself.
  4. Use the Function List button to toggle tasks panel.
Last edited by TheLacus on Tue Aug 07, 2018 3:20 pm, edited 14 times in total.

User avatar
Deepfighter
Posts: 55
Joined: Sun Mar 22, 2015 10:24 am
Location: Iliac-Bay
Contact:

Re: Syntax highlighting

Post by Deepfighter » Fri Jun 15, 2018 7:08 pm

Personally, I think that this change is very helpful and would be probably highly appreciated. At least for translating reasons it's helping a lot. The current quest editor for translating quests has the same and can't imagine it without.

+1 from me :)
Head of the German Daggerfall translation - www.daggerfalldeutsch.de
and German translator for The Elder Scrolls V: Skyrim and Lore-Expert for The Elder Scrolls: Online

User avatar
Jay_H
Posts: 1430
Joined: Tue Aug 25, 2015 1:54 am

Re: Syntax highlighting

Post by Jay_H » Fri Jun 15, 2018 10:05 pm

As a quest writer I am very interested in this.
Check out the Daggerfall Unity mod page on ModDB.

I rarely read instructions well the first time. Tell me to re-read them. I'll do it.

User avatar
Interkarma
Posts: 3174
Joined: Sun Mar 22, 2015 1:51 am

Re: Syntax highlighting

Post by Interkarma » Fri Jun 15, 2018 10:47 pm

This is a smart idea!

User avatar
TheLacus
Posts: 625
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Syntax highlighting

Post by TheLacus » Sat Jun 16, 2018 11:52 am

Thank you for feedback! I've update first post with installation instructions.

@Deepfighter
I'll give a look at translation editor, thank you for pointing that out.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
TheLacus
Posts: 625
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Syntax highlighting

Post by TheLacus » Mon Jun 18, 2018 7:35 pm

Added highlighting and snippets for Visual Studio Code.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
Jay_H
Posts: 1430
Joined: Tue Aug 25, 2015 1:54 am

Re: Syntax highlighting

Post by Jay_H » Wed Jun 20, 2018 2:27 am

I installed it, but I don't have any highlighting on my end (except where I highlight some word with the mouse and it repeats the highlighting elsewhere). Is there some missing step?

Image
Check out the Daggerfall Unity mod page on ModDB.

I rarely read instructions well the first time. Tell me to re-read them. I'll do it.

User avatar
TheLacus
Posts: 625
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Syntax highlighting

Post by TheLacus » Wed Jun 20, 2018 9:59 am

You can change language from the language indicator on the bottom-right corner. Select 'dftemplate'. Extension is .txt so this can't be done automatically (unless you want it for all text files). :)
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

User avatar
Hazelnut
Posts: 637
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Syntax highlighting

Post by Hazelnut » Wed Jun 20, 2018 11:30 am

line 35 of dftemplate.tmLanguage has a typo:

Code: Select all

					<key>1</ley>
This is duplicated a few times. Is this correct for the VS code file? Anyway, found it while messing with trying to get an Atom grammar definition by converting yours. They seem to both be TextMate based so the info is same, but Atom wants a json/cson file instead.

I found a converter that turns .tmLanguage into .cson but it doesn't recognise the 'match' key annoyingly, that would be a real easy way to auto generate atom highlighting.

User avatar
Jay_H
Posts: 1430
Joined: Tue Aug 25, 2015 1:54 am

Re: Syntax highlighting

Post by Jay_H » Wed Jun 20, 2018 11:51 am

It's working now, and magnificently. Thank you TheLacus!
Check out the Daggerfall Unity mod page on ModDB.

I rarely read instructions well the first time. Tell me to re-read them. I'll do it.

Post Reply