VIM to CodeClap

With the release of version 0.6 I took advantage of the additional command line arguments and added a few shortcuts to VIM. Now with a single key press from within VIM I can start debugging. F4 will start CodeClap and run to the same cursor position in VIM and F5 will break at main().

Pressing F4 from within VIM


Instantly launches CodeClap and breaks at the same place


There are a million ways to do this with VIM/Bash but wanted to share in case it is useful for anyone.

Add to existing vimrc file
1
2
3
4
5
6
7
8
9
nnoremap <F4> :call CodeClapRunToCursor()<CR>
function! CodeClapRunToCursor()
   :call system('./codeClapDebug.bash ' . expand('%:t') . ' ' . line("."))
endfunction

nnoremap <F5> :call CodeClapRunToMain()<CR>
function! CodeClapRunToMain()
   :call system('./codeClapDebug.bash')
endfunction


codeClapDebug.bash file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#!/bin/bash

fileName=$1
lineNum=$2

#configuration
executable=~/dev/projects/engine2d/build/a.out
workingDir=~/dev/projects/engine2d/build
codeClap=~/dev/codeclap/codeclap

if [ $# == 2 ];
then
    $codeClap --chdir $workingDir $executable $fileName:$lineNum
else
    $codeClap --chdir $workingDir $executable
fi


Edited by joe513 on Reason: Initial post
Very very nice :D
Thanks for sharing !

This is really cool, well done!

I probably have to make the argument parsing part of the soon-to-be customization layer as well so that people can get even more creative with different startup behavior.
Here is the compulsory emacsian equivalent :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(defun codeClapRunToCursor ()
  (interactive)
  (compile (format "./codeClapDebug.sh %s %s" (file-name-nondirectory buffer-file-name) (line-number-at-pos)))
  )
(global-set-key [f8] 'codeClapRunToCursor)

(defun codeClapRunToMain ()
  (interactive)
  (compile "./codeClapDebug.sh")
  )
(global-set-key [C-f8] 'codeClapRunToMain)
Nice, thanks for adding it! Its getting harder to justify my printf() debugging now :)
After two weeks of usage, I have to say can't do without. And run to cursor is really awesome. Can't wait for even more possibilities :D

It already replaced gdb and printf for most tasks.
albatros
After two weeks of usage, I have to say can't do without. And run to cursor is really awesome. Can't wait for even more possibilities :D

It already replaced gdb and printf for most tasks.

That is something I really like to hear :). The next update is right around the corner but it took/will take me a few additional days because of time constraints. I will then also write a bit about my immediate plans for 0.8-1.0.
I tried to do this on 0.6.0 on windows 7, just calling the codeClap.exe but I can only get the program to start with an empty configuration.
I tried to pass it the arguments by hand but got same result.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@echo off

SET fileName=%1
SET lineNum=%2

SET executable="%~dp0..\build\win32_game.exe"
SET workingDir="%~dp0..\build\"
SET codeclap="w:\misc\lib\codeclap\codeclap.exe"

if "%~1" == "" (
    %codeclap% --chdir %workingDir% %executable% %fileName%:%lineNum%
) else (
    %codeclap% --chdir %workingDir% %executable%
)


Is it just a bug or am I missing something obvious?

Also, if this is not the place for this kind of post please tell me and I'll send an e-mail instead ^_^
bjeeeern
I tried to do this on 0.6.0 on windows 7, just calling the codeClap.exe but I can only get the program to start with an empty configuration.
I tried to pass it the arguments by hand but got same result.


Is there a space anywhere in the file path for the build directory? If so I think there is an issue with spaces on Windows that is supposed to be fixed in the next release.

Can you share the full command that you are using in the terminal?

Edit: Might also try using the full path names instead of relative paths, seems like I had issues with that in the past but I have not tried in the latest release.


Edited by joe513 on
bjeeeern
I tried to do this on 0.6.0 on windows 7, just calling the codeClap.exe but I can only get the program to start with an empty configuration.
I tried to pass it the arguments by hand but got same result.

Is it just a bug or am I missing something obvious?

Also, if this is not the place for this kind of post please tell me and I'll send an e-mail instead ^_^


I think the forums are quite good for communicating and exchanging information because everyone can profit from this. But if you value private communication you can also mail me using [email protected]

Best you try it with the now available 0.7.2. I tried it with that build and everything should work just fine. Just make sure to wrap the parameters in "" if they contain any spaces.
I am on 0.7.2 now but still does not seem to work.

I'll post some variations of the command I put in the terminal and the resulting program screen I get.

1
2
3
4
5
6
7
"W:\misc\lib\codeclap\codeclap.exe" --chdir "W:\handmade\build\" "W:\handmade\build\handmade.exe" handmade.cpp:1227
"W:\misc\lib\codeclap\codeclap.exe" --chdir "W:\handmade\build\" "W:\handmade\build\handmade.exe" W:\handmade\code\handmade.cpp:1227
"W:\misc\lib\codeclap\codeclap.exe" --chdir "W:\handmade\build\" "W:\handmade\build\handmade.exe" "W:\handmade\code\handmade.cpp":1227

"C:\Users\kuma\Desktop\enviroment\misc\lib\codeclap\codeclap.exe" --chdir "C:\Users\kuma\Desktop\enviroment\handmade\build\""C:\Users\kuma\Desktop\enviroment\handmade\build\handmade.exe" handmade.cpp:1227 
"C:\Users\kuma\Desktop\enviroment\misc\lib\codeclap\codeclap.exe" --chdir "C:\Users\kuma\Desktop\enviroment\handmade\build\" "C:\Users\kuma\Desktop\enviroment\handmade\build\handmade.exe" C:\Users\kuma\Desktop\enviroment\handmade\handmade.cpp:1227
"C:\Users\kuma\Desktop\enviroment\misc\lib\codeclap\codeclap.exe" --chdir "C:\Users\kuma\Desktop\enviroment\handmade\build\" "C:\Users\kuma\Desktop\enviroment\handmade\build\handmade.exe" "C:\Users\kuma\Desktop\enviroment\handmade\handmade.cpp":1227


All gives the same default screen:


bjeeeern
I am on 0.7.2 now but still does not seem to work.
I'll post some variations of the command I put in the terminal and the resulting program screen I get.


That's still a bit of a puzzler. At this point I suspect that it may not be caused by the argument parsing but maybe some problem during startup. If for example the .exe does not exist the behavior is as described and the normal window opens. I will add a few hints and more output capabilities to analyze this behavior further.

Have you tried just dragging the same exe on the configuration window and starting it from there?