BlitzMax TextMate Bundle

BlitzMax Forums/BlitzMax Programming/BlitzMax TextMate Bundle

N(Posted 2009) [#1]
I'm not sure how many of you all use TextMate (or the e text editor, since I use both due to their similarity and platform differences), but I figured I'd post this since there's bound to be a few Mac users here who do. Anywho, there used to be a BlitzMax tmbundle, but it's long gone since the last guy didn't pay his hosting bill or something (don't know). Result: have to write a new one.

So I did. And here it is: http://github.com/nilium/blitzmax.tmbundle/tree/master

You can either use git to clone it doing the following in your terminal (and if you use git, explaining this is probably pointless)
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/nilium/blitzmax.tmbundle.git
Or you can alternatively click the 'download' link, and extract the archive's contents into a BlitzMax.tmbundle directory under the directory in the above command.

If you think you might want to make additions to it, I would encourage you to use git so you can commit and push your changes to the remote repository, or possibly fork the project using GitHub.

This most likely will not work in E right now, as I haven't tested the recent version (what's up there) yet. It likely only requires a few changes in the build code to work, mainly due to e's dependency on Cygwin. Scratch that, works in E now.

I'm not sure if the drag commands work right now either. I can't find anything wrong with the code, but at the same time there's no output from them. Not that it matters that much, I don't think drag commands are a highly used feature in TextMate.


jkrankie(Posted 2009) [#2]
Hi,

i never got round to finishing my bundle, so this should be cool. however, having extracted the zip into a folder (BlitzMax.tmbundle), nothing appears in textmate. any chance you could give some more detailed installation instructions?

Cheers
Charlie


N(Posted 2009) [#3]
Looks like, for some reason, it's only stored the changes from my original bundle for E in the default Bundles folder, so the info.plist in the downloadable bundle is only a delta. Going to try to rebuild it, so hang on.


N(Posted 2009) [#4]
You should be able to download it now and have it work. Was not aware that TextMate only stored the delta between your local copy of a bundle and the copy you originally made. With any luck this should work now (at least it's working for me now).


jkrankie(Posted 2009) [#5]
Ok, cool it works now. I need to copy BMK etc. int /bin/bash right?

Cheers
Charlie


N(Posted 2009) [#6]
I would just add their bin to your path.

To do that, just add something like
export PATH=$PATH:/path/to/your/blitzmax/bin
to your ~/.profile (I'm not sure if this is the right place to put that, however, but it worked for me) and you should be good. Either that or I could change it so that you have to put the path to BlitzMax in a TM_BLITZMAX env. variable (Preferences -> Advanced -> Shell Variables). However, I usually just keep that sort of stuff in my path since I spend a lot of time building things from the terminal anyway.


pls(Posted 2009) [#7]
Great job!

PLS


jkrankie(Posted 2009) [#8]
I can't seem to set the environment variable right for this, i guess my unix skills are lacking somewhat. If you could have it so that you could set the path in textmate that would be cool.

Cheers
Charlie


N(Posted 2009) [#9]
Alright, I've updated the bundle. You'll have to add a TM_BLITZMAX shell variable pointing to your root BlitzMax directory (not the bin). Might use this for additional commands later, since I could use it to look up documentation and the like for functions/types/etc. Also updated the README to be a little more helpful.


jkrankie(Posted 2009) [#10]
Cool, it works now :) Nice to finally have a decent editor for OS X. I used to use the TextWrangler plugin, but that's fairly out of date now.

I guess you must constantly have a terminal window open to run apps, or is there some automated process in Textmate? Also, if i wat to add some options to the bmk build, i guess i'll need to edit one of the files in the bundle to include them?

Cheers
Charlie


N(Posted 2009) [#11]
I guess you must constantly have a terminal window open to run apps, or is there some automated process in Textmate? Also, if i wat to add some options to the bmk build, i guess i'll need to edit one of the files in the bundle to include them?
I do, but then I have it open just for finding files as well. Finder's nice, but I can get around much more easily with a terminal.

If you wanted to customize how bmk is executed, you'd have to edit the Build App command. Right now it's just calling `bmk makeapp "$TM_FILEPATH"`, so it's not terribly sophisticated. I'm thinking that I'll split it into Build GUI App and Build Console App so that you have that much choice. Not sure if there's a good way to handle other options like threading (-h) without splitting them into four commands, two for threaded and two for unthreaded. I suppose I could have it check for build flags in the file being compiled. E.g.,
'buildopt threaded
'buildopt gui
But if I did that, I would probably limit it to stop after it gets to the first non-blank/comment line so you don't have it checking the entire source file every time you build.

Would be neat if BMK had that sort of thing built in, actually. I might have to do that just for myself.

Edit: Also, for projects, I'm thinking about having a TM_BLITZMAX_MAINFILE shell variable that you can set so when you hit 'build' in a project, it'll build that file regardless of which file you've got open. Still fiddling with ideas.


jkrankie(Posted 2009) [#12]
Those are all good ideas. It would definately be useful to have GUI, console and debug modes available in Textmate. Project management as well would be a welcome addition also, especially as my current project grows in size.

Really, thank you for this :•)

Cheers
Charlie


N(Posted 2009) [#13]
I've pushed a new version that should make it a little easier to build projects, at least. I still don't have anything for switching between GUI/console, debug, etc. yet, so bear with me.

To set a specific file for your project to be built from, open the Project Information window (click the little 'i' icon at the bottom of the project drawer) and add TM_BMX_MAINFILE. This should be the path to the file relative to the project's directory. Obviously, if it's set incorrectly, it simply won't build.

Still unsure about how I'll handle build options yet.


N(Posted 2009) [#14]
Just to see if I could, I added a command to look up documentation (Quick Help) for the selected text/current word. This is equivalent to the Quick Help functionality in MaxIDE. It checks $TM_BLITZMAX/docs/html/Modules/commands.txt for the current word, and if it matches then displays that information in a tooltip.

Not terribly useful, but it might be handy for people who didn't spend tons of time messing with BMax's module source.


jkrankie(Posted 2009) [#15]
When you're working on a large project though, i tend to find the more info i can get without having to search for it the better (especially as spotlight has stopped working on my Mac)

Cheers
Charlie


z80jim(Posted 2009) [#16]
Love it!

Please keep up the good work.


N(Posted 2009) [#17]
Updated this briefly. Still messing with build option ideas, but nothing in the public repo for that yet. All I've done is added code that should make it possible to use this in E without much trouble. The only downside is that if you use E, you must have BlitzMax/bin in your PATH. This is probably a little easier for Windows users depending on how you go about things, so it doesn't concern me too much.

The reason it has to be in your path is that E won't allow you to add custom shell variables in its preferences (yet, anyway, I suppose I'll put in a request for that some time).

In the meantime, this doesn't really affect you if you use TextMate, oddly enough.


N(Posted 2009) [#18]
Alright, added build options* to the bundle. Now when using Build App, it will quickly scan the main source file for 'buildopt:option comments and pass the appropriate flags to bmk.

Currently, the only flags you can use are release, debug, gui, console, library (this probably doesn't work), and threads. For further information, refer to the README.textile on the repository, as it's more detailed than I am here.

* Bolded = the point

Edit: Next on the to-do list is letting you click on compiler errors in the build output so you can go right to the offending line/column.


Mahan(Posted 2009) [#19]
Nice work!

As a home computer agnostic that owns both PCs and a Mac I want to tell you all about E - TextEditor. http://www.e-texteditor.com/

This editor is a TextMate clone for Windows that is even compatible with TextMate bundles.


N(Posted 2009) [#20]
Pretty sure I mentioned that in the first post, but I recommend it to anyone who uses Windows. I bought both E and TextMate and use them extensively in my work, and I really can't imagine going back to using other editors when they both fit my workflow.

Out of curiosity, is the current version working under E for you? I'm doing alright with it so far, but I've not been able to have anyone else try it since I'm probably the only other BMax user with E.


N(Posted 2009) [#21]
Build errors in Build Modules/App commands are now linked so you can click on them and go to the error line.


N(Posted 2009) [#22]
I've changed the project name on github, so you'll need to update your remotes to use 'blitzmax.tmbundle' instead of 'bmax-tmbundle' for the project name. This only applies to folks using git to get the bundle though. May also apply to the GetBundles bundle, but I'm not sure since I don't think it lists this bundle.


d-bug(Posted 2009) [#23]
Very cool bundle, much better then mine is. Switching now.

Just one thing I'm missing so far is, that there is no "Build And Run" buildopt or shortcut? (bmk makeapp -x ...)
A little description on which scope to set for which element would be nice too.

One strange thing was, that when I set the buildopts to a file I've developed with MaxIDE before, they where ignored. Makeing a new file with TextMate and C&P the code from the old one solved the problem.


N(Posted 2009) [#24]
Not sure what could cause the buildopt problem switching from MaxIDE, since that really shouldn't affect anything. I suppose it may possibly be the line endings if you set TextMate to always use the same kind regardless, especially if you end up with a file with line endings being mixed, but I really couldn't say.

I'll see about adding a run option. Not entirely sure how I'll go about that, since I don't want the output piped into the results window.


N(Posted 2009) [#25]
Added an "execute" buildopt that will run the app after building. I wouldn't recommend using it since I do not check to see if bmk has successfully built the application, and so you may be running an old build of an app. What you should be doing is checking the build output, seeing if it's correct, and then using the new Run App command (⌘R).

Edit: And, just to note, the execute and Run App options may not yet work in E. I haven't had a chance to test them in it yet.


N(Posted 2009) [#26]
Ok, bundle should work with E again. Added two new commands to insert functions using the current word, similar to Ruby.

Type a word, like "foo", hit shift+enter, and it'll spit out either a function or a method named foo. If you're currently typing the word inside of a type, it'll spit out a method. This is all scope-based, so if you felt like doing so you could change the order they're processed in.

Added try/catch highlighting because I forgot it somehow. I don't use it much, so that's probably why.

Fixed highlighting on abstract methods to my knowledge. Folding is still iffy with them (same with functions/methods in extern blocks), but there's not a whole lot I can do to remedy that.

Edit: Added highlighting for brackets and quotes and such as well as automatic indentation for most blocks of code. Chances are I forgot one though.


d-bug(Posted 2009) [#27]
Thank you very much, Noel, but I will change your execute buildopt to a simple "bmk makeapp -x" since my whole game-framework throws messages into the output if anything doesn't fit.


Blueapples(Posted 2009) [#28]
Looks pretty awesome, I'll be using it. Thanks!


d-bug(Posted 2009) [#29]
I'm a bit confused now. For any reason, I can't get block commenting to work with your bundle. In normal cases, it's done by adding source.blitzmax to the scope selector of the "Insert Block Comment" Command in the Source bundle. But this is not working. It just shows a tooltip "No block comment markers found in this language". I really don't know whats going on there since you have set those markers in the Miscellaneous Preferences part of the BlitzMax bundle and the opened file is correctly highlighted as a blitzmax file.

Another thing is, that the "Documentation for Word"-Command doesn't work for me. commands.txt is in place but pressing CTRL+H has no effect.

If it's of any interest, the TextMate Version is 1.5.7 (1436).

In case that I'm getting nervy: Sorry for that! ;)


N(Posted 2009) [#30]
Regarding documentation:
1) Update to r1496 (v1.5.8): select Cutting-Edge from the updates pane. If anyone else has not updated to this version, you should do so now.

2) Did you set TM_BLITZMAX in your shell variables to point to the root of your BMax installation?

3) Does documentation for the current word exist in commands.txt? Keep in mind that this will not find documentation for your project, undocumented modules, or methods. It probably won't work on some other things like Mod and Type, since they're language keywords.

Regarding block comments, they do not work. The nature of the Insert Block Comment command is that it is set up for languages like C/C++ where you can throw a /* and */ in anywhere and it will work. With BlitzMax, that isn't the case, as you cannot simply put Rem and EndRem anywhere, least of all in the middle of keywords. I've pushed a new version of the preferences with the setting, but I would highly discourage you from trying to use Insert Block Comment with BlitzMax.

If you want, you could probably write your own Insert Block Comment command, but looking at the kinds of selections it would be used on, I can't think of any very good way to do it. Considering I encourage people to make their own changes, that's up to you now, and I would encourage people to use GitHub so their changes are made public.


d-bug(Posted 2009) [#31]
1) You've got me :/
2) Yes i did!
3) Yes it exists.

Word Documentation does it's job now. Thank you!

Block Comment used to work in my bundle. Instead of using Rem / End Rem it simply added the apostrophe at the beginning of each selected line. The preferences where the same as you have set in your bundle and I didn't modify the source.bundle. That is the part that drives me crazy.


N(Posted 2009) [#32]
Are you using Cmd-/ Or Cmd-Opt-/? Because Cmd-/ is comment selection, and Cmd-Opt-/ is block comment. You may be confusing the two, as the former will insert apostrophes and the latter will attempt (and fail) to use Rem and EndRem.


d-bug(Posted 2009) [#33]
None of them both! I've got a german keybord-layout, where / is Shift+7 wich isn't a good combination for shortcuts. What ever, after restarting Textmate und hitting my shortcut it is working now. Sorry for this. I don't know, why i had to restart Textmate. All other modifications worked without it.


N(Posted 2009) [#34]
I've pushed a bunch of changes to the language grammar, some new snippets/commands/etc., overall I'd recommend updating if you haven't.


N(Posted 2009) [#35]
Would recommend you update the bundle now if you have not been doing so somewhat regularly.

There are two important changes:

Firstly, you must set TM_BLITZMAX now. This is not optional, you will not be able to get by with putting it in your PATH. In order for the bundle to function as intended, it has to be set, and I decided I'm not going to let some things fail and others work.

Secondly, for projects is that you'll have to rename your TM_BMX_MAINFILE shell variable to TM_BLITZMAX_MAIN_FILE. This is to keep in line with the naming scheme used in other TextMate bundles, as I'm working on improving this to the point where it can be reviewed for inclusion with other 'official' (using that loosely) bundles. If you did not use this feature, it doesn't affect you.

There is now a Help command which should explain anything you need to do in order to get the bundle working.

I've added a bunch more snippets and cleaned up some others, the highlighting should be improved since I've continued to work on the language grammar. There was a case-indent branch on github for people who didn't like the Case/Default indentation options. I've decided to just outright remove those and let you figure out how you want to indent them. As such, the case-indent branch is gone.


d-bug(Posted 2009) [#36]
Interested in a better looking output like xcode bundle has?

Add the following two lines at the beginning of all Build command with html output enabled:
. "$TM_SUPPORT_PATH/lib/webpreview.sh"
html_header "BlitzMax Build" "$TM_PROJECT_DIRECTORY/$TM_BLITZMAX_MAIN_FILE"


The result:


Nothing really spectecular :)


N(Posted 2009) [#37]
That's a pretty good idea.

Edit: Pushed changes with header.


N(Posted 2009) [#38]
The bundle is now available from the textmate.org Review bundles here: http://svn.textmate.org/trunk/Review/Bundles/BlitzMax.tmbundle/

You'll have to use Subversion to get it, git-svn (this is what I'm using, but unless you want to modify the bundle, you probably don't want to use git), or the GetBundles bundle.

Also made some changes to the bundle of course- those are both available via either github or the Review bundle. I'm not sure if it'll be possible to keep the GitHub repo and subversion in sync however, so bear in mind that at least one of these repositories may have a limited lifespan.


d-bug(Posted 2009) [#39]
Your folding markers seem to be corrupted. Textmate folds correctly before saving the file. After loading it again the folding is messed up. This happend in each code, where more then one types are defined and contain methods and functions.

Changeing the markers to:
foldingStartMarker = '(?x)^(\s*+(Function|Method|Type))';
foldingStopMarker = '^(\s*+End(\ )?(Function|Method|Type))';

has fixed this issue for me.

I'm really not the king of RegExp, so if this markers above are grap ignore this post. :)


N(Posted 2009) [#40]
The only thing I could think of that would cause a problem with the folding would be If statements where the expression is on the same line as the if (e.g, If Condition (Then)? Expression) statement, but I'm having no troubles when loading files again with those.

Can you provide an example of code with messed up folding?

Also, your regular expressions are 'grap' (no offense), and you may find that you'll encounter a fair number of problems when using them- namely that the opening and closing markers are case sensitive and will open/close even if the keyword is TypeOfObject (or EndTypeOfObject, if for some reason you had that; point is, something like TypeOfObject:TTypeId = ... would create a new folding marker). (?x) specifies that whitepsace in the regex will be ignored, and your starting marker has none in the first place. You'll want the option (?i) for case insensitivity, and to have a \b at the end of each of those markers if you want them to not match unusual things (e.g., TypeOfDog). That's just my 2 cents if you want to continue using your changes.


d-bug(Posted 2009) [#41]
I didn't take it as offence. I know, that my regular expression skillz are far away from perfection.

Here is a corrupted code.

I've noticed, that when I copy it into a new file, the folding worked well again. The code was completely written with your TextMate bundle.

cheers


N(Posted 2009) [#42]
I'm not able to find any problems with the folding there. Are you using the latest version of the bundle (on textmate.org or github- I'm keeping them both in sync for now)?


d-bug(Posted 2009) [#43]
Yes, I'm using rev 11231 from textmate.org.

Here is a screen of the folding issue while folded and a screen while unfolded.

As you can see, there is a fold-marker at the comment above the methods.

Hope it helps.


N(Posted 2009) [#44]
I can't really figure why it would fold on the comments, considering neither folding marker even matches it. Are you mixing line-endings, using any foreign/non-English characters in your code, or anything else out of the ordinary?

Anyhow, try pasting this into the BlitzMax language grammar:


This is the current grammar I'm working with and is ahead of the current revision just a bit (mostly due to the change in the way numbers are included and nicer handling of attributes). Nothing has changed with the folding markers for a little while (certainly not between 11231 and the current), but if you've changed anything in the grammar you may have introduced problems, so I'd suggest copying/pasting that copy of the grammar.


d-bug(Posted 2009) [#45]
There are no non-english characters in my code. Line-endings should be all of the same type. since this code ist completly written with Textmate. This screens are made out of the same code-file I've sended you before.

Before I've made those screens, I checked out the latest repository again to be shure that there are no differences to your grammar, except the changes you've made lately.

I will check out the grammar you've postet this evening, so please stay tuned.

I'm totally confused about it now.

~edit~
Your new grammar doesn't fix the issue, as you've expected. But there is definitly something very very strange going on here. After showing "Hidden Invisibles" (ALT+CMD+I) to check linefeeds, the folding was fixed. Wich is confusing me much more then anything before. Might be a bug in a plugin, but the only one I've installed is ProjectPlus. I think my next step is to try uninstalling ProjectPlus.

I'm really sorry for searching the bug in your bundle.


N(Posted 2009) [#46]
Thought I replied and mentioned I pushed a new version of the bundle, but anyhow, the one up there is no longer current.

It's now ahead of the above grammar, anyway. I doubt it'll rectify whatever the problem is you're having, but there's an update nonetheless.


N(Posted 2009) [#47]
I pushed quite a few changes to the language grammar today. Anyone using the bundle, please make sure to update (and tell me if it doesn't work).

Also, just to note, if you're using Ruby 1.9, I cannot currently guarantee that it'll work. I believe the documentation command is broken as of 1.32 as well, but I'm not entirely sure (since I never used it).


N(Posted 2009) [#48]
Alright, fixed the Build Documentation and Documentation for Word/Selection commands. Those are both in the repositories now.


AlexO(Posted 2011) [#49]
I'm liking the bundle but It seems the 'buildopt:' comments aren't working. Anyone have any idea why they wouldn't? I've put
' buildopt: release
' buildopt: gui

as the first lines in the file and I still get a debug console app (what looks to be the default behavior).


matt!(Posted 2011) [#50]
Check your line endings in the file, it happens if they're Windows line endings I think.

I had this issue with my monkey bundle (based in part on this one) and recently fixed the issue.

https://github.com/gingerbeardman/monkey.tmbundle