Go Help

Go Build V2

Introduction

The Go Build Chapter showed a basic External Tool for Compile and Link.   This is a much more complete script that does the following.

  1. Handles file and directory names with spaces (not a recommended practice).
  2. Allows the Compile and Link Messages  to display to the Bottom Pane, a New Tab, a Pop up Terminal or a Pop up Window.
  3. NOTE:  With gEdit 2.30.4, you can now go to the error line in your code.  Set OUTPUT=1 and Display in Bottom Pane.  Just click on the error in the botton pane.

Install

  1. Make sure that you have Zenity installed.  See the end of the Plugins Chapter.
  2. If you have a general ‘temp’ directory, set it as described in the introductory chapter.
  3. Open Gedit and Go to Tools>Manage External Tools.
  4. Choose Go Build, or create a new tool.
  5. Copy and Paste the script below into the code panel, overwriting the existing code.
  6. Make the other settings as documented in ‘Tool Settings’ in the script below.
  7. Set the OUTPUT switch below ‘Tool Settings’ in the script below.
  8. Use MakeGo from the Go Build Chapter or roll your own.
#!/bin/bash

# Go Build - Calls your make file Shell Script
#            Creates executable of '$DOCPATH.out'
#   Manual - www.gohelp.wordpress.com - 'Gedit - An IDE for Go'
#-------------------------------------------------------------------------
#   *Tool Settings: Save = Current Document, Input = nothing,
#                   OutPut = see below
#
#           Set Tool Output to:
#
#OUTPUT=1  Bottom Pane or Create New Document - save to file, Display
#OUTPUT=2  Bottom Pane - for script error     - save to file, Popup Terminal
#OUTPUT=3  Bottom Pane - for script error     - save to file, Popup Window
#--------------------------------------------------------------------------
OUTPUT=3    # Set OUTPUT Switch

DIR="${GEDIT_CURRENT_DOCUMENT_DIR}"
DOCPATH="${GEDIT_CURRENT_DOCUMENT_PATH//%20/ }" # ex tool puts %20 for spaces

if  ! ( test -z "$MyTemp" ) # if MyTemp exists in environment
then
    TMPDIR="${MyTemp}"
else
    TMPDIR="${DIR}"  # else set TMPDIR to current document directory
fi

"${DIR}"/MakeGo "${DOCPATH}" > "${TMPDIR}"/GoBuild.tmp

case $OUTPUT in
    1) cat "${TMPDIR}"/GoBuild.tmp
       ;;
    2) TermCmd="less \"${TMPDIR}\""/"GoBuild.tmp"
       gnome-terminal --command "${TermCmd}" -t "Go Build" &  # Note & at end
       ;;
    3) nLines=`wc -l "${TMPDIR}"/GoBuild.tmp|awk '{print $1}'`
       if [ "${nLines}" -gt 28 ]
       then
           nLines=28
       fi
       zHeight=$(( nLines * 25 ))

       longLine=`wc -L "${TMPDIR}"/GoBuild.tmp|awk '{print $1}'`
       if [ "${longLine}" -gt 80 ]
       then
           longLine=80
       fi
       zWidth=$(( longLine * 9 ))

       zenity --text-info \
           --height=${zHeight} \
           --width=${zWidth} \
           --title="Go Build" \
           --filename="${TMPDIR}"/GoBuild.tmp \ &
       ;;

    *) echo "Please Set Go Build OUTPUT option"
esac

sleep 1   # make sure new shells have displayed, then exit
rm "${TMPDIR}"/GoBuild.tmp

Create a free website or blog at WordPress.com.

%d bloggers like this: