User forums > Using Code::Blocks

setting auto save file in "Tools" ?

(1/3) > >>

edison:
The source formatter of CB is based on Astyle, It works great in most case but still have some bug(for example, it can not handle the noexcept of C++11 correctly sometimes).

So I decided try to set Clang-format as a item in the Tools menu. But I found there is a problem here:
The clang-format may change the content that was last version file I saved but not the current version file I edited. This behaviour would cause lost the the current content.

So, is there any CB macro or script can be used to save file and allow set before the called .exe in Tools's Executable input field ?
Or, if possible, add a auto save file option and a auto re-load file after .exe ran option would be much simple for using the "Tools" ...

ollydbg:
My suggest:
Use C::B build-in Scripting commands - CodeBlocks, there is a Save function in EditorManager.

EDIT: also, read Variable expansion - CodeBlocks

edison:
I have try put these in the Executable input field:

SaveActive(); & $(CODEBLOCKS)\sdk\LLVM\bin\clang-format.exe
or
[[SaveActive();]] & $(CODEBLOCKS)\sdk\LLVM\bin\clang-format.exe
or
'SaveActive();' & $(CODEBLOCKS)\sdk\LLVM\bin\clang-format.exe

it does not works...

ollydbg:
Please read the two wiki pages carefully in my first replies.

Here is a minimal sample, you save all the files, and then run cmd.exe


--- Code: ---[[GetEditorManager().SaveAll();]] & cmd.exe

--- End code ---

Jenna:
You might want to use SaveActive() instead of SaveAll(), so only the active editor gets saved.
I had to put a (sleep 1)before the exe-command, because sometimes the check for externally modified files does not kick in.
I think this happens because the saving might happen in the same second as the change by the external tool happens.
I don't know if there is such an easy command on windows or you need windows-scripting for it.
On linux I put
--- Code: ---[[ GetEditorManager().SaveActive(); ]] sleep 1 &&
--- End code ---
before the executables name.

Navigation

[0] Message Index

[#] Next page

Go to full version