automatic reload sketches in processing - processing

I'd like to be more efficient with processing programming, is there a way to run a sketch from the command line? maybe also with a watch for file saves?
Also, is there some autocompletion for processing? the default IDE is very limited..

Windows and Linux
Pretty much the same when you want to run the sketch from the command line.
Within your processing folder there should be a processing-java file. If you cd to it's folder, you can use
./processing-java --help
Which will show you the required parameters to running, compiling and whatnot.
If you are in a hurry, this would do (replace the $parameters with the folders you want or automate it with your editor):
$PROCESSING_DIR/processing-java --sketch=$CURRENT_DOCUMENT_DIR --output=$CURRENT_DOCUMENT_DIR/run --run --force
This is my Gedit script:
/home/otto/GameDev/processing-2.1/processing-java --sketch=$GEDIT_CURRENT_DOCUMENT_DIR --output=$GEDIT_CURRENT_DOCUMENT_DIR/run --run --force
MacOSX
Haven't had a chance to test it but it shouldn't be any harder.
Source: http://wiki.processing.org/w/Command_Line

As #erisoco mentions, using the Eclipse IDE is your best bet (especially for autocomplete/etc.) and the Proclipsing plugin makes it very easy to setup Processing projects in eclipse (including integration with external libraries)
There's also a quick video tutorial on setup if necessary.
You mentioned "watch for file saves" - that sounds along the lines of "live coding".
There are multiple options. One I've used in the past is through the FluidForms library. The library also includes some handy features for (3D) design (like parameter changer, automatic arcball for 3D scenes, STL export, etc.)
You can find a few quick video tutorials on live coding Processing with Fluid Forms libs:
Fluid-Forms-Libs ~ HelloWorld
Fluid Forms Libs Parameter Changer
FluidFormsLibs-LiveCoding

This is the command I use:
> processing-java --sketch=R:\sketch_folder --force --run
I do the coding using Visual Studio Code https://code.visualstudio.com/ with the processing extension.

Related

Build chaincode(hyperledger) on Atom on Windows fail

I'm trying to build simple chaincode example in Atom editor on Windows but build fails (I'm using go-plus package) with following error:
fatal error: ltdl.h: No such file or directory #include ltdl.h
I know that using flag: -tags nopkcs11 will solve the problem, but how can i configure go-plus/Atom to use this flag?
I believe there is still an open issue for go-plus to support build tags. I have not used Atom in a while, but the only option I can think of would be to try to use a Makefile (which is not the easiest thing in the world on Windows since most of the built-in Atom commands assume GNU commands being available).
If you are open to moving to something like Visual Studio Code it does support build tags.
Perhaps we should actually reverse the build tag within Fabric and require you to enabled pkcs11 with a tag rather than disable it with a tag. I debated this when first adding the tag. Feel free to open up a JIRA item for this.

How to set up Jeash for Haxe?

I am trying to setup Jeash for Haxe, so I read this: http://old.haxe.org/com/libs/jeash/firststeps
Now, I found out that I cannot do that just yet:
"This is the first time you are runing haxelib. Please run haxelib setup first"
(and I love the typo in there :P )
So I decided to read this: http://haxe.org/com/haxelib/setup
I tried what is suggested. First command, I get prompted for a password, so I enter what is necessary when I install software on my comp.
Then I ran "sudo chown jansensan -R /usr/lib/haxe" (replacing "myusername" with my actual username, "jansensan") and then I get an error: "chown: -R: No such file or directory"
Is there a way to get a little bit more information? I mean, the explanation on the Haxe website makes it sound as it if will magically happen, and it is not the case.
For anyone interested (if it helps you understand my issue), my computer is a MacBook Pro running Snow Leopard and I intend to code in FDT. BTW, I can already do some Haxe stuff in FDT, why would I need to run the Haxe setup to be able to install Jeash and NME?
haxelib is a lib repositories .It adds libs to your workflow. jeash and NME are one of them.
once you have installed haxe. you just have to run in the terminal haxelib setup.Normally it goes fine.
I'm on macpro snow leopard too.Never had issues with that !.
test haxelib on terminal .. wath does it tell ?
Another alternative is to use the NME installer:
http://www.haxenme.org
It will install Haxe, Neko, HXCPP, NME and Jeash in one go. NME supports Windows, Mac, Linux, Android, iOS, webOS, Flash and HTML5 -- the HTML5 target handled using Jeash.
You're using FDT and no other Haxe installation right? This is important because FDT comes with it's own 'installation' of Haxe.
You have it two ways:
Add it to Haxelib.
Just download the source code and put the jeash library in the
project your using.
Add it to Haxelib.
For command line: you're going to need to make haxelib visible to your command line.
Get started by typing 'which haxelib'. This will tell you
1) if you have haxelib via command line.
2) Where it is.
If there is an error, then it's not visible to your command line. This is ok, you'll just need to add the whole path when calling it. Like this:
Also notice that since FDT 5 is shipped as an OSX bundle you'll have to go 'inside' of it via right click FDT -> 'Show Contents'.
When you have this path (or if you are using your own version of the haXe SDK ), you can use it to call haxelib.
Add it to source path
Download the library source code and physically add it to your source path.
All these suggestions are quite good. An alternative to dealing with all this Terminal writing is to go to http://www.haxenme.org/developers/get-started/ and use the installers provided. Afterwards, go in the prefs of FDT > Haxe SDK and add the path where the haxelib was installed, "/usr/lib/haxe" most likely.

Configuring Bison to compile an input file under Visual C 6

I'm trying to get Bison to do it's thing in VC6. I'm sure this must be a problem with my configuration. At the moment I have a Custom Build step as follows.
<Commands>
echo Start parser generation
"C:\GnuWin32\bin\bison.exe" $(InputPath)
echo Finish parser generation
<Outputs>
$(ProjDir)\$(InputName).c
$(ProjDir)\$(InputName).h
The error I get is "C:\GnuWin32\bin\bison.exe: m4: No such file or directory", which makes me think the m4.exe doesn't exist or isn't on the path, but I can run the exact same command from CMD in the same directory with no errors.
This thought process makes me think it's a problem with the output options, but I've tried various configurations with no luck.
Any help would be great, thanks in advance.
Edit: I've added some more visual studio versions to the tag list to try to get some more exposure for the question. Hopefully someone will have done this in a later version and I can work backwards.
Okay, I've managed to slove this in a very round-about way but I will try my best to document it here.
It seems that VC6 Custom build options will only look in the project directory for the m4.exe, even when you specify where the calling exe (bison) is explicitly. To solve this I did a bit of a hack and did a full cd command in the custom build window to get to the gnuwin32 directory (where both bison and m4 live) before trying to call the parser generator.
This works fine but is a bit of a hassle for trying to distribute it to other people when they may have installed GNU tools to a different location.

Xcode source automatic formatting

As a C# developer, I have become highly dependent on the automatic formatting in Visual Studio 2008. Specifically, I will use the CTRL + K , D keyboard shortcut to force things back into shape after my sloppy implementation.
I am now trying to learn Objective-C and am missing certain features in Xcode, but probably none are quite as painful as the formatting shortcut. My Google searches have yielded nothing built in, though it seems there are some hacks. Am I missing something or does this feature not exist natively in Xcode?
That's Ctrl + i.
Or for low-tech, cut and then paste. It'll reformat on paste.
Unfortunately, Xcode doesn't have anything nearly as extensive as VS or Jalopy for Eclipse available. There are SOME disparate features, such as Structure > Re-Indent as well as the auto-formatting used when you paste code into your source file. I am totally with you, though; there definitely should be something in there to help with formatting issues.
I'd like to recommend two options worth considering. Both quite new and evolving.
ClangFormat-Xcode (free) - on each cmd+s file is reformatted to specific style and saved, easy to deploy within team
An Xcode plug-in to format your code using Clang's format tools, by
#travisjeffery.
With clang-format you can use Clang to format your code to styles such
as LLVM, Google, Chromium, Mozilla, WebKit, or your own configuration.
Objective-Clean (paid, didn't try it yet) - app raising build errors if predefined style rules are violated - possibly quite hard to use within the team, so I didn't try it out.
With very minimal setup, you can get Xcode to use our App to enforce
your rules. If you are ever caught violating one of your rules, Xcode
will throw a build error and take you right to the offending line.
In xcode, you can use this shortcut to Re-indent your source code
Go to file, which has indent issues, and follow this :
Cmd + A to select all source codes
Ctrl + I to re-indent
Hope this helps.
My personal fav PrettyC wantabe is uncrustify: http://uncrustify.sourceforge.net/. It's got a few billion options however so I also suggest you download UniversalIndentGUI_macx, (also on sourceforge) a GUI someone wrote to help set the options the way you like them.
You can then add this custom user script to uncrustify the selected text:
#! /bin/sh
#
# uncrustify!
echo -n "%%%{PBXSelection}%%%"
/usr/local/bin/uncrustify -q -c /usr/local/share/uncrustify/geo_uncrustify.cfg -l oc+ <&0
echo -n "%%%{PBXSelection}%%%"
You can use Command + A to select all content and next Ctrl + I to format the selected content.
I also feel xcode should have this function.
So I made an extension to do it: Swimat
Simple install by brew cask install swimat
You can give it a try, see https://github.com/Jintin/Swimat for more information.
Cmd A + Ctrl I
Or Cmd A And then Right Click. Goto Structure -> Re-Indent
Consider buying yourself a license for AppCode, an intelligent Objective-C IDE that helps iOS/OS X developers. AppCode is fully compatible with Xcode, but goes beyond Xcode in adding powerful features.
AppCode an Objective-C variant of the Intellij IDEA IDE from JetBrains. They are also authors of popular ReSharper extension to Visual Studio, which main purpose from here seems like a desperate attempt to bring a touch of IDEA experience to a Microsoft product.
AppCode is using its own code analyser which gives close-to-perfect refactoring and code navigation support. There is an ability to re-indent and completely reformat code also (although I still keep missing a couple of formatting settings in hard cases, but mostly it works well).
You might try the trial version, of course.
Swift - https://github.com/nicklockwood/SwiftFormat
It provides Xcode Extension as well as CLI option.
CTRL + i
that's it.
(no COMMAND + i)
You can also have a look at https://github.com/octo-online/Xcode-formatter which is a formatter based on Uncrustify and integrated into Xcode. Works like a charm.
You could try that XCode plugin https://github.com/benoitsan/BBUncrustifyPlugin-Xcode
Just clone github repository, open plugin project in XCode and run it. It will be installed automatically. Restart Xode before using formatter plugin.
Don't forget to install uncrustify util before. Homebrew, for exmaple
brew install uncrustify
P.S. You can turn on "after save formatting" feature at Edit > Format Code > BBUncrustifyPlugin Preferences > Format On Save
Hope this will be useful for u ;-)
I suggest using ClangFormat. In order to install, please follow these steps:
Install Alcatraz package manager for XCode
Supports Xcode 5+ & OS X 10.9+
After installation restart XCode.
Open XCode -> Window Menu -> Package Manager
Search (find) ClangFormat and install it. After installation again restart XCode.
Now at XCode menu you can use Edit -> Clang Format submenu for formatting.
You can choose different types of formatting. Also by enabling Format On Save you can gain auto-format capability.
If your Xcode version 3.x , you should use "User Script" With Uncrustify , here this a Example:
#!/bin/sh
echo -n "%%%{PBXSelection}%%%"
$YOURPATH_TO_UNCRUSTIFY/uncrustify -q -c $YOURPATH_TO_UNCRUSTIFY_CONFIG/CodeFormatConfig.cfg -l OC+
echo -n "%%%{PBXSelection}%%%"
add above to your Xcode "User Script".
if Xcode version 4.x , I think you should read this blog : Code Formatting in Xcode 4,
In this way , used the "Apple Services" , but it's not good enough , cause too slow experience, does anyone has the same thing ?
why apple drop "user script" .... xD
First, Examine XCode Preferences "Indentation" section. You can customize things quite a bit there...
For more fine grained control, refer to the XCode User Defaults document from apple. (May require a developer login to view). For example, I was able to disable the "indent on paste" by entering the following in terminal:
defaults write com.apple.XCODE PBXIndentOnPaste No
to read back your setting:
defaults read com.apple.XCODE PBXIndentOnPaste
This only works for languages with are not whitespace delineated, but my solution is to remove all whitespace except for spaces, then add a newline after characters that usually delineate EOL (e.g. replace ';' with ';\n') then do the ubiquitous ^+i solution.
I use Python.
Example code, just replace the filenames:
python -c "import re; open(outfile,'w').write(re.sub('[\t\n\r]','',open(infile).read()).replace(';',';\n').replace('{','{\n').replace('}','}\n'))"
It 's not perfect (Example: for loops), but I like it.
We can use Xcode Formatter which uses uncrustify to easily format your source code as your team exactly wants to be!.
Installation
The recommended way is to clone GitHub project or download it from https://github.com/octo-online/Xcode-formatter and add the CodeFormatter directory in your Xcode project to get :
Xcode shortcut-based code formatting: a shortcut to format modified sources in the current workspace
automatic code formatting: add a build phase to your project to format current sources when application builds
all sources formatting: format all your code with one command line
your formatting rules shared by project: edit and use a same configuration file with your project dev team
1) How to setup the code formatter for your project
Install uncrustify
The simplest way is to use brew:
$ brew install uncrustify
To install brew:
$ ruby –e “$(curl –fsSkl raw.github.com/mxcl/homebrew/go)”
Check that uncrustify is located in /usr/local/bin
$ which uncrustify
If your uncrustify version is lower than 0.60, you might have to install it manually since modern Objective-C syntax has been added recently.
Add CodeFormatter directory beside your .xcodeproj file
Check that your Xcode application is named "Xcode" (default name)
You can see this name in the Applications/ directory (or your custom Xcode installation directory). Be carefull if you have multiple instances of Xcode on your mac: ensure that project's one is actually named "Xcode"!
(Why this ? This name is used to find currently opened Xcode files. See CodeFormatter/Uncrustify_opened_Xcode_sources.workflow appleScript).
Install the automator service Uncrustify_opened_Xcode_sources.workflow
Copy this file to your ~/Library/Services/ folder (create this folder if needed).Be careful : by double-clicking the .workflow file, you will install it but the file will be removed! Be sure to leave a copy of it for other users.
How to format opened files when building the project
Add a build phase "run script" containing the following line:
sh CodeFormatter/scripts/formatOpendSources.sh
How to format files in command line
To format currently opened files, use formatOpenedSources.sh:
$sh CodeFormatter/scripts/formatOpendSources.sh
To format all files, use formatAllSources.sh:
$sh CodeFormatter/scripts/formatAllSources.sh PATH
PATH must be replaced by your sources path.
E:g; if project name is TestApp then the command will be
$sh CodeFormatter/scripts/formatAllSources.sh TestApp
it will look for all files in the project and will format all the files as configured in uncrustify_objective_c.cfg file.
How to change formatter’s rules
Edit CodeFormatter/uncrustify_objective_c.cfg open with TextEdit
Well I was searching for an easy way. And find out on medium.
First to copy the json text and validate it on jsonlint or something similar. Then to copy from jsonlint, already the json is formatted. And paste the code on Xcode with preserving the format, shortcut shift + option + command + v

Trying to compile and debug C++ from Vim

I've been learning C++ and Allegro using Code::Blocks on Windows XP, and recently felt like learning Vim. However, I have no idea how to compile a program "manually" (i.e., without using an IDE).
For compiling from within Vim, I have gotten as far as setting the makeprg to gcc, but I understand I also need a makefile. What is that and how do I write one? Is it with the makefile that I can use libraries such as Allegro?
Also, I've gotten quite fond of the CB debugger (I'm using gdb). Is it possible to do something similar with Vim?
Thank you.
Look at MinGW. I would avoid Cygwin if you only need gcc and make. You'll want both MinGW and MSYS. MSYS has a windows port of make.
If you're interested in more unix utlities for the windows command line I recommend CoreUtils.
For learning make see the manual
You don't necessarily need a Makefile, but it's the preferred (and possibly sanest) way of compiling code on UNIX-like systems.
I don't know if GNU Make has a Windows port, but you can probably run it under Cygwin.
To learn more about GNU Make and Makefiles:
make (Wikipedia)
GNU Make
GNU Make Manual
Also, see this question: compile directly from vim
Mandatory edit: I don't use Windows or Cygwin. You might want to take epochwolf's advice on that department.
I'm not in expert in makefiles and debugging but I know that Vim lets you do many things.
For example if you want to compile a file with gcc, it's not very different from the usual way. In normal mode type:
:!gcc file.c -o file
In fact you can use (almost) every system command just by adding "!" in front of your command.
gdb also works with Vim
:!gdb
I hope it will help you.
To integrate vim with devenv, you can use devenv from Visual Studio to complie the project in vim. The command as follows:
Devenv SolutionName /build SolnConfigName [/project ProjName [/projectconfig ProjConfigName]]
Typicatlly, the devenv should located in C:\Program Files\Microsoft Visual Studio 8\Common7\IDE. Set it to the path of environment to make it callable from vim. We also need to make vim recognize the error messages thrown by the commandline build tool devenv. Just put the following lines in your vimrc:
" Quickfix mode: command line devenv error format
au FileType cpp set makeprg=devenv.com\ /Build\ Debug\ *[SolutionName]*
au FileType cpp set errorformat=\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m
Then You can use :make to compile and build the program from vim.
EDIT1: A few bookmarks you might find useful:
GNU make tutorial (this one uses gcc and make, so it should be right up your alley)
Another one
Win port of some of GNU utils Can was mentioning; I personally use these and haven't had any problems with them on Windows platform.
Yes, you can compile without the makefile. If your program is simple (for example, one file only) you can compile by calling the compiler and including the name of the program in the same line (don't remember how it goes with gcc). Of course, to make things easier this can be mapped to a key within vim, so you don't have to jump to command prompt and back.
If you are working on a bigger project, which consists of several files and such, than a makefile is useful. It will "search" through the files, determine dependencies, include them in the build, maybe put the source files in one directory and the resulting exe file in the other and such. So it is more of a linking and building system than just compiling.
Although the GNU make mentioned in Can Berk Guder's answer is a popular one, there are quite a number of other tooks for "building makefiles" ("makefile" has become a type of synonym for that kind of operation) - here, you can see some other options on this link. Due to its part in history vim has good support for :make, but others can be easily used as well (there are a lot of texts on this subject on VimWikia.
Well, that's it. Just my 0,2 euros :)
As long as you have GNU-make installed (with cygwin or mingw under windows), you don't need to write a makefile for single-file projects. Just run :make from vim, and that's enough.
If your project is made of several files, then you will have to write a makefile (or any equivalent for scons, aap, (b)jam, ant, ...), tune your &makeprg in consequence, and finally call :make from vim. See the relevant category in vimtips. You can of course run the compiler as you would have ran any other external tool, but you would loose the possibility to jump to the line(s) of the error(s).
NB: if you are using the win32 version of vim, and gcc-cygwin, you'll need to translate the error messages obtained. I used to maintain a perl script for this purpose, it is now part of a bigger suite (still in beta stage)
Regarding your question about debugging, it can't be done from vim under windows for the moment. The only debugger that can be integrated so far is gdb, but under linux only ; see the pyclewn (.sf.net) project.
I'm not sure about debugging, but I know an easy way to compile and run the current program as I wrote a small vim plugin to do so.
http://pastebin.com/qc5Zp2P7
It assumes you are using the g++ compiler. If not, just change the name to the compiler you're using. Save this file to whereveryouinstalledvim/ftplugin/cpp.vim
In order to compile and run the currently open program, just type shift-e while in non-editing mode.

Resources