; Copyright 1996,1997,1998,1999 by Salvador E. Tropea [SET],
; see copyrigh file for details
;
;;;
;;; Here are 3 macros converted from TEML to sLisp
;;;
;******************************************************************
;
; MACRO:   MakeFuncText: Sample macro to comment a function
;
; USE:     Put the cursor immediately after a function name which is
;          at the left of the screen, then press Alt-T. Do not include
;          the return type or parameters before using this macro.
;
;******************************************************************

(defmacro 'Make Function Text'
 (eval
  ; add white space
  (InsertText '\n\n')
  ; go before beginning of intended function name
  (SendCommands cmcLineUp cmcLineUp cmcLineStart
  ; mark function name
                cmcSelectOn cmcWordRight cmcSelectOff)
  ; copy for prototyping
  (SendCommands cmcLineStart cmcLineDown cmcCopyBlock cmcLineUp cmcLineStart)
  ; add "Function" to comment area
  (InsertText '\nFunction: ')
  ; put in comment lines before and after
  (SendCommands cmcLineEnd cmcLineUp cmcLineStart)
  (InsertText '/*****************************************************')
  (SendCommands cmcLineStart cmcLineDown cmcLineEnd)
  (InsertText '\n\n')
  (SendCommands cmcLineStart)
  (InsertText 'Description:\n')
  (SendCommands cmcLineStart)
  (InsertText '*****************************************************/\n')
  ; go back to end of name
  (SendCommands cmcLineDown cmcLineEnd)
  )
)

;*******************************************************************
;
; MACRO:       MakeStub
;
; DESCRIPTION: Creates a stub, based on a user-entered function name.
;   It assumes the cursor is positioned immediately after the name,
;   and the name is at the left of the screen.
;
;*******************************************************************

(defmacro 'Make Stub'
 (eval
  ; go before beginning of intended function name
  (SendCommands cmcLineStart)
  ; void return type
  (InsertText "void ")
  (SendCommands cmcLineEnd)
  ; void parameter
  (InsertText "( void )\n{\n")
  (InsertText "printf(\"This is ")
  (SendCommands cmcLineUp cmcLineUp cmcLineStart cmcWordRight)
  (SendCommands cmcSelectOn cmcWordRight cmcCharLeft cmcCharLeft cmcSelectOff)
  (SendCommands cmcLineDown cmcLineDown cmcLineEnd)
  (InsertText " ")
  (SendCommands cmcCopyBlock cmcHideSelect cmcLineEnd)
  (InsertText "\\n\");")
  (InsertText "\n}")
 )
)

;*******************************************************************
;
; MACRO:       MainCIO
;
; DESCRIPTION: Inserts outline of main program for C that uses STDIO.H
;
;*******************************************************************/

(defmacro 'Main C STDIO'
 (eval
  (InsertText "#include <stdio.h>\n\n")
  (InsertText "int main(void)\n{\n\n  return 0;\n")
  (SendCommands cmcLineStart)
  (InsertText "}")
  (SendCommands cmcLineUp cmcLineUp cmcCharRight)
 )
)

;*******************************************************************
;
; MACRO:   Test RunProgam
;
; DESCRIPTION: Example of how to call an external program, in this
; example the editor will call ls and put the directory list in the
; Message Window.
;
;*******************************************************************/

(defmacro 'Test RunProgram'
 (eval
  (InsertText
   (RunProgramRedir
    (AskString "The output of the program will be inserted" "External program")
   )
  )
 )
)

;*******************************************************************
;
; These macro were created by Rolf Campbell (Endlisnis)
; email: s257m@unb.ca Endlisnis@hotmail.com
; and uses an external program provided by him.
;
; MACRO:   Prototype
;
; DESCRIPTION: Look ups the function under the cursor to report the
; prototype, even when partially typed.
;
; http://www.geocities.com/CollegePark/Quad/1974/LEMUR02.ZIP
;
;*******************************************************************/

(defmacro 'List Members'
 (eval
  (RunProgram (+ "lemur " (WhichEditor) " -s " (WordUnderCursor 256 1)))
  (SendCommands cmcGoEndOfWord)
 )
)

(defmacro 'Prototype'
 (eval
  (ShowInStatusLine
   (RunProgramRedir
    (+ "lemur " (WhichEditor) " " (WordUnderCursor 256 1))
   )
  )
 )
)

(defmacro 'Prototype Complete'
 (eval
  (setv "proto"
   (RunProgramRedir
    (+ "lemur " (WhichEditor) " -c " (WordUnderCursor 256 1))
   )
  )
  (SendCommands cmcGoEndOfWord)
  (InsertText (+ proto "(") 1)
  (ShowInStatusLine (+ "Added: " proto))
 )
)

