• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Custom TESH Highlighting

JassNewGenPack Tutorial:
Custom TESH Highlighting

Table of Contents

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 any 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:
function NewTimer takes nothing returns timer
function NewTimerEx takes integer data returns timer
function ReleaseTimer takes timer t returns nothing
function GetTimerData takes timer t returns integer
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:
JASS:
// Putting comments here is fine.
// These comments don't show up in the TESH function definitions 
// though. You can put content for self-reference inside the function 
// definitions in this file though. It's quite handy. Sometimes, you 
// might forget what a function does, what form of arguments it 
// should take, and a simple type-list isn't going to help. That's 
// where these comments become quite useful.

function NewTimer takes nothing returns timer
    // Retrieves a new timer from the recycling stack.
endfunction

function NewTimerEx takes integer data returns timer
    // Retrieves a new timer from the recycling stack and sets it's data.
endfunction

function ReleaseTimer takes timer t returns nothing
    // Throws a timer into the recycling stack.
endfunction

function SetTimerData takes timer t, integer data returns nothing
    // Attaches data to a timer.
endfunction

function GetTimerData takes timer t returns integer
    // Gets the data attached to a timer.
endfunction

// The same can be said for this comment as well.
// This won't get into the function definitions module.
// If you would go down a bit, I explain a bit about this
// function definition module in the "Tip" below.

// The comment you are currently reading was only put here
// to hide the ugliness of a blank fragment in a Jass tag. :P

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
  1. Why doesn't the highlighting show up at all?
  2. My file isn't saving as .j! What should I do?
  3. 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.
  4. Why doesn't the highlighting show up for custom natives?
  5. Why can't I add struct methods?

Answers
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Because SFilip made it this way. You can't add struct methods unfortunately.
 

Attachments

  • HashtableNatives.j
    12.1 KB · Views: 251
Last edited:
Well, I don't read the documentation either =P
I knew this information ever since I started working with vJass and using Damage by Jesus4Lyf, which had a TESH file included in the resource thread at thehelper.net :p

Yesterday, I tried it out and started creating custom highlighting for UnitIndexer, TimerUtils, RegisterPlayerUnitEvent, SoundTools, and I even made the Hashtable natives because I was never able to get them to highlight like regular natives :D
 
Top