vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

Custom TESH Highlighting

Magtheridon96 · 8815

0 Members and 1 Guest are viewing this topic.

Custom TESH Highlighting
on: April 14, 2012, 11:43:56 AM

Custom TESH Highlighting

Table of Contents
  • Introduction
  • Step 1: The Declaration File
  • Step 2: Implementation
  • Wrap-Up
  • FAQ

Introduction

In this tutorial, I'm going to teach you how to get custom TESH highlighting.
This is common knowledge for a lot of people, but not for everyone.
It's actually quite simple, so I don't think anyone should have trouble with it.
What I mean by custom highlighting is highlighting for certain functions.

This can be useful for very common libraries like TimerUtils or UnitIndexer.
I even used it to provide me with highlighting for the hashtable natives.

Step 1: The Declaration File

The first thing we have to do is declare the functions that we want to highlight for TESH to highlight them. What we're going to do is open up Notepad.exe or anything other simple Text-Editor to get started.

I'm going to assume that we want highlighting for TimerUtils by Vexorian.
These are the following functions we want highlighting for:
Code: jass
  1. function NewTimer takes nothing returns timer
  2. function NewTimerEx takes integer data returns timer
  3. function ReleaseTimer takes timer t returns nothing
  4. function GetTimerData takes timer t returns integer
  5. function SetTimerData takes timer t, integer data returns nothing

As you can see, those functions don't highlight, and it's pretty annoying, especially considering the fact that a lot of us use them all the time.

Now, you're probably asking yourself: "What am I going to have to include in that file?
Come on Magtheridon96, get to the point already!"

Well, all you have to include is function declarations. You don't need to include any code at all, just the function declaration with the name, the arguments and the return-type.

For TimerUtils by Vexorian, it's going to look like this:
Code: jass
  1. // Putting comments here is fine.
  2. // These comments don't show up in the TESH function definitions
  3. // though. You can put content for self-reference inside the function
  4. // definitions in this file though. It's quite handy. Sometimes, you
  5. // might forget what a function does, what form of arguments it
  6. // should take, and a simple type-list isn't going to help. That's
  7. // where these comments become quite useful.
  8.  
  9. function NewTimer takes nothing returns timer
  10.     // Retrieves a new timer from the recycling stack.
  11. endfunction
  12.  
  13. function NewTimerEx takes integer data returns timer
  14.     // Retrieves a new timer from the recycling stack and sets it's data.
  15. endfunction
  16.  
  17. function ReleaseTimer takes timer t returns nothing
  18.     // Throws a timer into the recycling stack.
  19. endfunction
  20.  
  21. function SetTimerData takes timer t, integer data returns nothing
  22.     // Attaches data to a timer.
  23. endfunction
  24.  
  25. function GetTimerData takes timer t returns integer
  26.     // Gets the data attached to a timer.
  27. endfunction
  28.  
  29. // The same can be said about for this comment as well.
  30. // This won't get into the function definitions module.
  31. // If you would go down a bit, I explain a bit about this
  32. // function definition module in the "Tip" below.

Tip: Some people prefer to add comments within the functions.
When you're done with this tutorial, these function declarations and whatever code is in them will be available and can be referenced while you're in the editor simply by holding Ctrl (or Command for Mac Users), and clicking on the function. The comments can be useful for complex functions. They can act as a reminder to you about how a certain function is supposed to take arguments or what it does.

Now that we're done with our declaration file, we're going to save it in the .j format.
If you're using Notepad, all you have to do is Select "File > Save As", then, where it says "Text Document (.txt)", you would change it to "All Files". Now save the file with the extension .j at the end of the name.

Congratulations, you now have a TESH function declaration file!

Step 2: Implementation

We aren't done yet, we still haven't implemented our file.
This step is very easy and straightforward.

  • Open up the JNGP folder.
  • Open the folder named "tesh".
  • Open the folder named "includes".

Now move the function declaration file into the "includes" folder.

Congratulations, you're done!

Wrap-Up

I hope you liked this tutorial. I'm aware that a lot of this is common knowledge.
Still, I believe that this requires a tutorial. If you're having problems, refer to the below FAQ Section:

FAQ

Questions
  • Why doesn't the highlighting show up at all?
  • My file isn't saving as .j! What should I do?
  • I tried copying the Hashtable natives from common.j, but when I paste them and save the file, the text wraps in some very obscure way.
  • Why doesn't the highlighting show up for custom natives?
  • Why can't I add struct methods?

Answers
  • If you were doing the above steps with JNGP running, it isn't going to work.
    All you need to do is restart JNGP and the highlighting should work fine. If you're still having problems, then you either saved the .j file in the wrong directory, or you saved it as a .txt file or something. This only works for .j files.
  • Well, an obscure solution would be to find to open up the JNGP folder, go to the "jasshelper" subfolder, make a copy of common.j, rename it, and change the text.
  • Yeah, some people might face this problem. In the attachments, I've placed a Ready-To-Go Hashtable native declaration file. All you need to do is follow Step 2.
  • You can't declare them as natives. Declare them as functions. That won't tamper with anything, the highlighting has no effect on the Jass Parser.
  • Because SFilip made it a limitation. You can't add struct methods unfortunately.

Side-Note: I hope you like this tutorial.
« Last Edit: April 14, 2012, 02:17:46 PM by moyack »



Re: Custom TESH Highlighting
Reply #1 on: April 14, 2012, 12:32:40 PM

Fixed. There was a "{list}{list}" code in the post.
« Last Edit: April 14, 2012, 12:57:19 PM by moyack »



Re: Custom TESH Highlighting
Reply #2 on: April 14, 2012, 12:39:27 PM

Thanks bro :D
I found another forum bug while pasting this :P
edit
Bah, the tags are buggy :c
Basically, if I use the center tag after any of the tags instead of before, it wouldn't wrap correctly :/



Re: Re: Custom TESH Highlighting
Reply #3 on: April 14, 2012, 09:05:27 PM

Thanks bro :D
I found another forum bug while pasting this :P
edit
Bah, the tags are buggy :c
Basically, if I use the center tag after any of the tags instead of before, it wouldn't wrap correctly :/
Hmmm, it seems like you have a tag misplaced.... but I think I've fixed it...


 

Chaos Realm - The world of Game modders and wc3 addicts     WC3JASS.com - The JASS Vault   Jetcraft - A Starcraft II mod