Go Help

Go Run

Introduction

The next logical step is to run your program from within Gedit with one keystroke.

Setup

  1. If you have not done so already, go back to the Chapter Plugins and install External Tools.
  2. In Gedit go to Tools>Manage External Tools.

You should see a screen similar to below. If you have followed the previous Chapters, this is old hat.

  1. Go to the bottom left of the window and click on the icon just above the help button.  This will create a new tool waiting for input of a name.  Give it a name, I used ‘Go Run’.
  2. Go to the right hand panel and enter the code on the screen shot.  Or copy and paste from here.

#!/bin/bash

# Runs Go program in current Gedit tab
# Output in bottom pane

DOC=$GEDIT_CURRENT_DOCUMENT_NAME

# Strip ‘.go’ and append “.out” to source file name
RunFile=${DOC%%.go}.out

./$RunFile

Below the code panel you can set:

Shortcut Key

Just press the key combination you want to use to for Go Run.  Also, if there is conflict with another tool, click on that tool name, more to the shortcut key field and change it, or press backspace to erase the shortcut.

Save

Set this to nothing or current document if you wish to save your file before it is run.  It was already saved when you compiled.

Input

Set this to nothing.  $GEDIT_CURRENT_DOCUMENT_NAME is used to get the document name.

Output

Set this to display in bottom pane.

Applicability

Choose for your situation.

Languages

Above the Close Button, you can make your tool language specific.  If you installed the syntax highlighter previously, Go will come up as one of your language choices.  This creates a new language category or adds your tool to an existing one in the left pane.  You can set your new Tool to Go.  If you set it to ‘all languages’, then it will always come up on the Tools>External Tools drop down box.  I changed the built in Tools ‘Build’ and the ‘Remove Trailing Spaces’ to C.  Now they don’t come up on the Tools>External Tools when I am editing Go.

Close Window


TEST

Open Gedit.  Enter some source code.  Compile and Link, then Press your Go Run shortcut key, or go to the menu and go to Tools>External Tools>Go Run.  You should see the output of your program in the bottom panel.

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: