Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: Zaubertrank on January 25, 2012, 05:04:18 am

Title: Improving Code::Blocks' Terminal to Launch Code (mac)
Post by: Zaubertrank on January 25, 2012, 05:04:18 am
I've written a short applescript that stops code::blocks from opening multiple terminals every time you want to run some code in a terminal, but I can't figure out how to use osascript (or whatever else) to convert it into a single line which can be used by code::blocks in its environment settings.  Can someone help me out here?  Here is the script:


if application "Terminal" is not running then
   
   tell application "Terminal"
      
      activate
      
      do script "$SCRIPT" in front window
      
   end tell
   
else
   
   tell application "Terminal"
      
      do script "$SCRIPT"
      
      activate
      
   end tell
   
end if
Title: Re: Improving Code::Blocks' Terminal to Launch Code (mac)
Post by: Alpha on January 25, 2012, 05:46:15 am
I have not scripted on a Mac before, so I cannot give specifics.  However, I see several solutions.

Change $SCRIPT to a variable that results in the first argument passed to your script (called as an executable).  Then bind a command consisting of the name of your script and the variable $SCRIPT to either a tool (http://wiki.codeblocks.org/index.php?title=Tools%2B_reference) or the run key.  (I am assuming the variable $SCRIPT is a Code::Blocks variable which resolves to the name of the code you are trying to run.)

A more drastic option would be to download Code::Blocks' trunk code, and create a patch to add this functionality from within.
Title: Re: Improving Code::Blocks' Terminal to Launch Code (mac)
Post by: Halan on February 10, 2012, 03:22:28 pm
Can't this be implented by default? I've got a similiar problem when using the GNOME Terminal on Linux instead of xterm..
Title: Re: Improving Code::Blocks' Terminal to Launch Code (mac)
Post by: oBFusCATed on February 10, 2012, 03:28:52 pm
Halan:
Test case? What is the exact problem?
If you want to launch a new tab inside already running instance of gnome-terminal,
this is not going to work from the usability stand point.

Zaubertrank: You can put your script in a file and then tell C::B to execute it. I don't know the exact details, but I guess it should "just work" <evil>.
Title: Re: Improving Code::Blocks' Terminal to Launch Code (mac)
Post by: Jenna on February 10, 2012, 06:10:43 pm
Can't this be implented by default? I've got a similiar problem when using the GNOME Terminal on Linux instead of xterm..
Gnome-terminal works fine with:
Code
gnome-terminal --disable-factory --hide-menubar -t $TITLE -x