         return
 
     insertLine: (text, currentRow) ->
-        insertField = $('#lineToInsert')
-        toInsert = insertField.val()
-        insertField.val('')
+        command = $('#commandToInsert').find(':selected').text()
+        numberOfInputs = @commands[command]
+        inputs = []
+        inputsDiv = $('#insertInputs')
+        for i in [1..numberOfInputs] by 1
+            inputs[i - 1] = inputsDiv.find("##{1}").val()
+
+        # Possibly do some input sanitizing here.
+
+        toInsert = "#{command}(#{inputs.join()});"
         text.insertLines currentRow, [toInsert]
         return
 

    setUpInsertCommands: ->
        selector = $('#commandToInsert')
        for command of @commands
            selector.append($("<option/>", {
                value: command,
                text: command
                }))
        return

    displaySelectInputFields: (event) ->

        inputsDiv = $('#insertInputs')
        inputsDiv.empty()
        for i in [1..numberOfInputs] by 1
            inputsDiv.append("<input id='#{i}' type='text' size='5'>")
        return

    button: (func) ->
