Staredit Network > Forums > SC1 Mapping Tools > Topic: Smart triggers highlight in Vim
Smart triggers highlight in Vim
Sep 2 2010, 12:08 pm
By: Wormer  

Sep 2 2010, 12:08 pm Wormer Post #1



Smart triggers highlight!

And a little bit more...

Vim is a (very) powerful and flexible multi-platform text editor. Your humble servant spent nights trying to school it for triggers editing purposes. Let's see what came out of it:



Flashy-looking starcraft skin aside this thing has something considerable to oppose the other "advanced" text editors like Notepad++ and family. Let's look closer into it.

1.
Vim powerful syntax highlighting capabilities (in conjunction with my termendous patience) have made it possible to lexically recognize each syntactic piece of SCMD triggers scripts. You now shouldn't worry if you forget to put a semicolon or put a nasty space somewhere. The highlighting worries about it for you. It shows every single error that may make SCMD triggers fail at compilation time in red. Few examples:


Basically the following rule applies: if you see a red text SCMD wont't compile your triggers and vice versa. There are only three exceptions: 1) it still shows an opening curly brace in red if you have a line or more inbetween brace and trigger parameters, 2) it won't say anything when you exceed conditions or actions limit (16 and 64 respectively) and 3) most of numeric parameters in actions does not allow numbers which have a remainder 2^32-1 when divided on 2^32, the syntax only catches -1 and 2^32-1 as errors. The first one I am too lazy to fix :P, counting syntax constructions lexically is theoretically possible but practically undoable and finally enumerating all numbers which have a given remainer lexically is impossible.

2.
Errors aside there are things which SCMD will allow at compilation time but which are in better case either meaningless or will produce "hidden" errors or unexpected behaviour. The highlighting gives warnings for those. Few examples:


No more comments, because there are endless possibilities for these kinds of warnings. Not gonna repeat the whole list, after typing them all manually into the syntax highlighting. There may be a few faults with unit warnings though, please report any inconsistencies you can find or additions you can think. I'll write the whole list of things which are recognised later some day.

3.
A careful reader could have noticed it highlights your strings with colors *exactly* how they will look in SC. The thing hides color symbols so you can see the string without them and also recognizes escape sequences and makes use of Vim conceal mechanism to represent them as a single symbol. Weird SCMD recognition of escape sequences makes it possible to define something like \xf3cE> which is good old white. It is also recognized.

...and even more, but I'm done listing all the good sides...


Installation
Let's move to the installation part. It was probably a good idea to chew and digest the whole thing like for babies... but not at the moment. Sorry.
Alright, it actually consists of 3 independent pieces. The first peice is the color scheme for vim which can be used independently. The second piece is the syntax highlighting file which does the main job and ties reconized syntax elements with predefined highlighting groups. So you can use it independently with the other possible color schemes. The third thing is a filetype plugin which defines a few mappings (type \trg to insert a trigger for example) and which supports the string preview highlighting.

The sequence of actions is as follows:
1. Get vim from link above.
2. Put the trigger.vim file from the syntax archive in $VIM/vimfiles/syntax (for me $VIM is C:/Program Files/Vim)
3. Put the trigger.vim file from the ftplugin archive in $VIM/vimfiles/ftplugin
4. Put the sc.vim file from colorscheme archive in $VIM/vimfiles/color
5. Run vim in easy mode (because normal mode will immediately kick your ass :D ).
6. Execute the command ":colorscheme sc" to change the color scheme. To execute the command from insert mode (which is default in easy mode) press Ctrl+O : and then type the command (already without ':').
7. Open a trigger file with extension .trigger and enjoy.

As was mentioned, you can use the provided highlighting with other color schemes. The string preview thing might look ugly with light backgrounds. You can disable it by typing a command :NoTrigStrPreview and enable later by :DoTrigStrPreview.

Well, this was a minimal info. I really hope it would suffice for you to install this. If not... well, ask questions in the thread and I will try to help. There are lots of things which left behind the scene and I am very sorry for such a poor description but this thing have really weared me out. ;-) I'll probably expand more on the topic when I will feel better and have more time for doing so!

As a conclusion I am providing a few more pictures demonstrating the thing with the other color schemes:



Post has been edited 1 time(s), last time on Sep 2 2010, 4:02 pm by Wormer.



Some.

Sep 2 2010, 1:21 pm NudeRaider Post #2

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Looks very interesting, but truth to be told I think it comes a bit late.
a) Not many people are mapping anymore.
b) Those that still do already have their ways and might see it as unnecessary, because they're already contempt with their mapping tools.
Anyways, great work and I'll probably use it for those rare cases when ScmDraft just gives me an error line and I'm too lazy to find it. :P
This thing can show line numbers, right?

Quote
it won't say anything when you exceed conditions or actions limit (16 and 64 respectively)
This doesn't look hard to do but can be relevant. So since you put so much effort into pimping this program for text triggers maybe a little more won't hurt. :P




Sep 2 2010, 3:42 pm Wormer Post #3



It's never too late :)

I even don't know why I've done this, because I was not really deceiving myself with dreams people will use it. I wasn't either making this for my own use, because I'm triggering on Macro Triggers and don't really need this. Once it seemed to me there could be nothing better than Notepad++, the only thing that always annoyed me in it was that it wasn't able to distinguish the truth "Trigger" from "Trigger" in "Preserve Trigger". That how I found Vim. When I first installed it I was like :wtfage: "Eh? Woooot???". After a few days of learning I've surrendered and returned to my lovely Notepad++. And now several years after that I was able to force my way through a steep learning curve of Vim. Yes, Vim is a very powerful tool, but you need to learn it. Nothing can describe it better than the picture. I've done this highlighting thing to understand Vim better, I've been learning Vim on it. It's no trifle, the highlighting altogether with learning basics of Vim took me full 18 days (as of now) of hard work with trials, falls and errors. Now looking behind I do realize how weak Notepad++ and similar editors are. Vim is power. It makes even a bigger advantage if you touch-type with all 10 fingers. Of course Vim is not only useful for starcraft triggers. If someone wants to personally develop I strongly suggest learning Vim. Vim allows you to do all kinds of typing work really fast and efficient. This is my try to bring Vim into the people, to show all it's possibilities and convince someone to my side. Will you use it or not is up to you, but I tell that with Notepad++ and Co you're staying in the stone age of text editing.


Quote from NudeRaider
Anyways, great work and I'll probably use it for those rare cases when ScmDraft just gives me an error line and I'm too lazy to find it. :P
Sure, at least in that role :) I'm a human too and of course there are errors. Please report any deviations from SCMD you will encounter. I don't promise the fast fix for that, but I'll do that when I got free time.

Quote from NudeRaider
This thing can show line numbers, right?
Yes, it can.

Quote from NudeRaider
Quote
it won't say anything when you exceed conditions or actions limit (16 and 64 respectively)
This doesn't look hard to do but can be relevant. So since you put so much effort into pimping this program for text triggers maybe a little more won't hurt. :P
It only looks like easy thing to do. The truth is that Vim highlighting isn't really very well suitable for these kind of things. It's not a compiler, but simply a lexical analyser. What I made had become possible only due to my mulish obstinacy and devilish patience. Now this thing counts pure 5000 lines of (in many cases copy pasted) text with many of them over 1000 characters and some even going up to 3000. If I wanted to count actions and conditions I should have made the decision in the early stages. Anyways, even if I would want to make it I can't see an easy way to implement this kind of thing lexically. And I can't even think about all the hard ways of doing so, because they are so hard that verges with impossibility.

As a side note. You see... I am to explain, why I've popped up this question once more. If SCMD (or any other program) could import/export triggers in a text form it would have been possible to make a Vim plugin which sets the program on the starcraft map, receives the text from the program and afterwards automatically packs it all back in the map by a single keypress (let's say F6)! Moreover it will read all errors reported and automatically highlight erroneous lines and move the cursor to the first one! That sounds like magic, but it's actually possible and not that hard to do!

Post has been edited 3 time(s), last time on Sep 2 2010, 3:50 pm by Wormer.



Some.

Sep 2 2010, 10:23 pm Cinolt Post #4



Quote from Wormer
As a side note. You see... I am to explain, why I've popped up this question once more. If SCMD (or any other program) could import/export triggers in a text form it would have been possible to make a Vim plugin which sets the program on the starcraft map, receives the text from the program and afterwards automatically packs it all back in the map by a single keypress (let's say F6)! Moreover it will read all errors reported and automatically highlight erroneous lines and move the cursor to the first one! That sounds like magic, but it's actually possible and not that hard to do!

I wrote a program a while back that imported .trg files into a map, making it possible to compile text triggers in one step with ProTRG. But it turns out that ProTRG is still really bugged, as sometimes with more complicated triggers it wouldn't even produce a .trg file when it worked fine with text triggers, and the CUWP handling was broken as well. I unfortunately don't know enough Python to fix these bugs myself in the source, but if a working text trigger editor with .trg support came out then the one-step process would definitely be possible.

As for this program it seems like the effort would have been much better spent with ProTRG or MacroTriggers, as they're both much more efficient than SCMD's text trigedit.



None.

Sep 2 2010, 11:29 pm Wormer Post #5



Quote from name:yoonkwun
As for this program it seems like the effort would have been much better spent with ProTRG or MacroTriggers, as they're both much more efficient than SCMD's text trigedit.
Yea, I have a feeling I spent too much time on wrong things in this life. :bye3



Some.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[2024-4-27. : 6:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[2024-4-27. : 3:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
Please log in to shout.


Members Online: UndeadStar, Excalibur