(in-package "KPML-I")

;;; File: extra-command-tables.lisp
;;; John: June 97

;;; Adds extra combinations of commands for use with the extended
;;; development frame, particularly but not exclusively for PC
;;; single thread Lisp.

;;; ----------------------------------------------------------------------
;;; Oct 98, Edinburgh; added user level to filter complexity for
;;;    new users. User level is controlled by placing the required
;;;    levels on the *features* list thus:
;;;
;;; :KPML-LEVEL>= :KPML-L0 : novice level, for users new to computers.
;;;                           Resources can be loaded not saved, no
;;;                           choosers, inquiries, implementations, etc.
;;;                           are assumed. Simple generation is available
;;;                           with inspection of structure.
;;;               :KPML-L1 : beginners, can save modified resources,
;;;                           but no patching and resource versioning.
;;;               :KPML-L2 : Modes can be changed, patching and resource
;;;                           versioning available.
;;;               :KPML-L3 : Creation of resources and other advanced options
;;;                           available.
;;; ----------------------------------------------------------------------


(clim:define-command-table 
 FILE-MENU-COMMAND-TABLE
 :menu (
	#+(and :kpml-level>= :kpml-l0)
          ("Load Resources" :command com-LOAD-LINGUISTIC-RESOURCE)
	#+(and :kpml-level>= :kpml-l1)
	  ("Save Resources" :command com-STORE-GRAMMAR-RESOURCE)
	#+(and :kpml-level>= :kpml-l3)
          ("Create Resources" :command com-CREATE-NEW-LANGUAGE)
        ("Divider1" :divider :line)

	#+(and :kpml-level>= :kpml-l1)
          ("Load lexicons" :command com-LOAD-LEXICON-FILES)
	#+(and :kpml-level>= :kpml-l2)    ;; 2.0.55
	  ("Reload last loaded lexicon file" :command com-RELOAD-LEXICON-FILE)
	#+(and :kpml-level>= :kpml-l2)
  	  ("Write lexicons" :menu LEXICON-WRITING-COMMAND-TABLE)
        #+(and :kpml-level>= :kpml-l2)
          ("Divider3" :divider :line)

        ;; 2.1 these added back to the explicit development menu options...
	#+(and :kpml-level>= :kpml-l1)
          ("Load examples" :command com-load-example-files)
	#+(and :kpml-level>= :kpml-l2)    ;; 2.0.55
	  ("Reload last loaded example file" :command com-reload-last-example-file-main)
	#+(and :kpml-level>= :kpml-l2)
          ("Write examples" :command com-WRITE-EXAMPLE-FILES)
        #+(and :kpml-level>= :kpml-l2)
	  ("Divider2" :divider :line)

        #+(and :kpml-level>= :kpml-l0)
	  ("Set default language" :command com-SET-DEFAULT-LANGUAGE)
        ("Divider3" :divider :line)
	#+(and :kpml-level>= :kpml-l2)
   	  ("Environment Directories" :command com-ENVIRONMENT-DIRECTORIES)
        ("Toggle local/nonlocal resources" 
         :command com-TOGGLE-LOCAL-NONLOCAL-RESOURCES)
	("Reload KPML configuration file" :command com-LOAD-KPML-CONFIG-MENU)
	#+(and acl3.0 :kpml-level>= :kpml-full)
	  ("Load compiled Lisp file" :command com-LOAD-FSL)
        #+(and :kpml-level>= :kpml-l2)
	("KPML Tools" :command com-KPML-TOOLS)
	("Quit" :command com-Quit)))

(clim:define-command-table 
 LEXICON-WRITING-COMMAND-TABLE
    :menu (("Write all lexicons under current multilingual modes" 
	    :command com-WRITE-LEXICON-FILES)
	   ("Write newly acquired lexical items"
	    :command com-WRITE-NEW-LEXICAL-ITEMS)))

(clim:define-command-table
 INSPECT-MENU-COMMAND-TABLE
 :menu (
	#+(and :kpml-level>= :kpml-l0)
	  ("Print System" :command com-print-system-solo)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print Chooser" :command com-print-chooser-solo)
	#+(and :kpml-level>= :kpml-l2)
  	  ("Print Inquiry" :command com-print-inquiry-solo)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print Implementation" :command com-print-implementation-solo)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print lexical item" :command com-print-lexical-item-solo)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print sentence plan" :command com-print-sentence-plan)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print expanded sentence plan" :command com-print-expanded-plan)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print SPL term" :command com-print-spl-term-solo)
	#+(and :kpml-level>= :kpml-l2)
	  ("Print concept" :command com-print-concept-solo)
	#+(and :kpml-level>= :kpml-l0)	
	  ("Print feature" :command com-print-feature-solo)
        #+(and :kpml-level>= :kpml-l0)
          ("Divider1" :divider nil)
	#+(and :kpml-level>= :kpml-l0)	
	  ("Who can ..." :command |COM-WHO-CAN-...|)
	#+(and :kpml-level>= :kpml-l2)
	  ("Show disabled systems" :command com-show-disabled-systems)           ;; 4.0
	#+(and :kpml-level>= :kpml-l1)	
	  ("Examples using features" :command com-examples-using-features)
	;; 4.0
	#+(and :kpml-level>= :kpml-l1)	
	  ("Examples with substring" :command com-examples-with-substring)
  	#+(and :kpml-level>= :kpml-l1)	
	  ("Mark examples with substring" :command com-mark-examples-with-substring)
	("Divider2" :divider :line)
	("Graph Grammar" :command com-graph-grammar-solo)
	("Graph Region" :command com-graph-region)
	#+(and :kpml-level>= :kpml-l2)	
	  ("Graph Collection" :command com-graph-collection)
	))


(clim:define-command-table
 EDIT-MENU-COMMAND-TABLE
 :menu (("Make new system" :command com-make-new-system)
	("------" :divider :line)
	("Edit new system" :command com-make-new-system)
	#+(and :kpml-level>= :kpml-l2)	
	  ("Edit new chooser" :command com-make-new-chooser)
	#+(and :kpml-level>= :kpml-l2)	
	  ("Edit new inquiry" :command com-make-new-inquiry)
	#+(and :kpml-level>= :kpml-l2)	
	  ("Edit new lexical item" :command com-make-new-lexeme)
	#+(and :kpml-level>= :kpml-l2)	
	  ("------" :divider :line)
	#+(and :kpml-level>= :kpml-l2)	
	  ("Set editing methods" :command com-editing-methods)
	))

(defun com-stubb ()
  (let ((message-frame 
	 (clim:get-frame-pane 
	  kpml-i::*resource-development-frame* 'kpml-i::inspector)))
    (format message-frame 
	    "~%Implementation not yet in place for this version.")
    (format *trace-output* 
	    "~%Implementation not yet in place for this version.")))


  ;;
  ;; 4.0 restructured slightly and added some internal clearances
  ;;     on demand...
  ;;
(clim:define-command-table
 CLEAR-MENU-COMMAND-TABLE
 :menu (("Networks" :command com-CLEAR-SYSTEMIC-NETWORKS)
	("Lexicon" :command com-CLEAR-LEXICON)
	("Examples" :command com-CLEAR-EXAMPLES)
	("Language varieties" :command com-CLEAR-LANGUAGE-VARIETIES)
	("Redo all initializations" :command com-INITIALIZE-ALL)
	("Divider1" :divider :line)
	("Windows" :command com-CLEAR-Windows)
	("Divider2" :divider :line)
        ("Indirect load file" :command com-CLEAR-INDIRECTION)
	("Warnings" :command com-CLEAR-WARNINGS)                        ;; 4.0
        ("Tracing options" :command com-DEVELOPMENT-BS-OPTIONS)
	("Divider3" :divider :line)
	("Generation history" :command com-CLEAR-GENHISTORY-2)
	("Clear plan graphs" :command com-CLEAR-PLAN-GRAPHS)
	("Clear coreference table" :command com-CLEAR-COREFS)
	))


(clim:define-command-table
 FLAG-MENU-COMMAND-TABLE
 :menu (("KPML Flags" :command com-FLAGS)
	("Environment Directories" :command com-ENVIRONMENT-DIRECTORIES)
	("KPML Options" :command com-KPML-OPTIONS)
	("Grapher Display Modes" :command com-grapher-display-modes)
	("------" :divider)
	("Toggle Resource Versioning" :command com-TOGGLE-VERSIONING)
	("Toggle showing SPL on generation" :command com-TOGGLE-SPL-SHOWING)
	("KPML version" :command com-GIVE-KPML-VERSION)))

(clim:define-command-table 
 WINDOW-LAUNCHER-TABLE
 :menu (("Example manager" :command com-EXAMPLE-MANAGER)
        ("Traversal Graph" :command com-TRAVERSAL-GRAPH)
        #+(and :kpml-level>= :kpml-l2)
	("Cumulative History Display" :command com-SHOW-CUMULATIVE-HISTORY)
        #+(and :kpml-level>= :kpml-l2)
        ("Region Overview" :command com-REGION-OVERVIEW)
        ("divider1" :divider nil)
        ("Activate and reset selection expression tool"
         :command com-ACTIVATE-SELEXPR-TOOL)
	))

;;; ----------------------------------------------------------------------
;;; Following two differ mostly in which command table they draw
;;; their commands from...

(clim:define-command-table
    GENERATION-OPTIONS-TABLE
    :menu (("Generate fresh example" :command com-generate-example)
	   ("Generate again" :command com-generate-again-2)
	   ("------" :divider)
	   ("Change generation modes" :command com-GENERATION-DISPLAY-MODES-2)
	   ("Reset generation modes" :command com-RESET-GENERATION-MODES-2)))

(clim:define-command-table
    GENERATION-OPTIONS-TABLE-2
    :menu (("Generate fresh example" :command com-generate-sentence)
	   ("Generate again" :command com-generate-again)
	   ("Generate next" :command com-generate-next)))

;;; ----------------------------------------------------------------------


(clim:define-command-table
 GENERATION-STEPPER-TABLE
 :menu (("Toggle single Step" :command com-toggle-single-step)
	("Pause on inquiry" :command com-get-inquiry-to-pause)
	("Trace clearing options" :command com-CLEARING-OPTIONS)
	))

;;; ----------------------------------------------------------------------
;;; Resource grapher menu items...

(clim:define-command-table
 RESOURCE-GRAPHER-FLAGS-COMMAND-TABLE
 :menu (("Toggle Generation Path" :command com-toggle-generation-path)
	;; 1.1 can preserve cut systems in graph if wanted...
	("Toggle system stubb visibility" 
	 :command com-toggle-system-stubbs-visibility)
	("Toggle gate visibility" :command com-toggle-gates-visibility)
        ("Toggle showing last used feature in a system"
	 :command com-toggle-last-used-feature)
	("Toggle region external links visibility"
	 :command com-toggle-region-external-links-visibility)
        ;; 2.1
        ("Toggle showing disabled systems" :command com-toggle-disabled-visibility)
	;; 1.1 new options...
	("Toggle system name visibility" 
	 :command com-toggle-system-name-visibility)
	("------" :divider :line)
        ("Toggle region restriction" :command com-toggle-region-restriction)
        ("Toggle systemic notation" :command com-toggle-systemic-notation)
        ("Toggle display of generated example strings"
	 :command com-toggle-show-example-strings)
	;; 4.0
	("Divider2" :divider nil)
	("Toggle concept definitions as popups" :command com-toggle-show-concept-as-popups)
	))

(clim:define-command-table
    COLLECTED-FEATURE-COMMAND-TABLE
 :menu (("Clear collected features" :command com-clear-collected-features)
	("Show examples" :command com-show-examples-with-collected-features)
	("Show collected" :menu show-collected-options)
	("Graph from collected features" :command com-graph-from-collecteds)
	("Toggle showing collected features highlighted"
	 :command com-toggle-highlight-collecteds)
	))

(clim:define-command-table
    SHOW-COLLECTED-OPTIONS
 :menu (("Always show collected pane" :command com-show-collected-always)
	("Show collected pane when present" 
	 :command com-show-collected-conditional)
	("Never show collected pane" :command com-show-collected-never)))


